]> git.lyx.org Git - features.git/blob - src/lyxlib.h
last updates from 1.0.4, no more updates expected from that branch now
[features.git] / src / lyxlib.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4
5 *           LyX, The Document Processor
6 *        
7 *           Copyright (C) 1995 Matthias Ettrich
8 *           Copyright (C) 1995-1998 The LyX Team.
9 *
10 *======================================================*/
11
12 #ifndef _LYX_LIB_H
13 #define _LYX_LIB_H
14
15 #include <stdlib.h>
16 #include <time.h>
17 #include "LString.h"
18 #include "gettext.h"
19
20 /// generates an checksum
21 unsigned long lyxsum(char const *file);
22
23 /// returns a date string
24 inline char* date() 
25 {
26         time_t tid;
27         if ((tid=time(NULL)) == (time_t)-1)
28                 return (char*)NULL;
29         else
30                 return (ctime(&tid));
31 }
32
33
34 // Where can I put this?  I found the occurence of the same code
35 // three/four times. Don't you think it better to use a macro definition
36 // (an inlined member of some class)?
37 ///
38 inline LString getUserName()
39 {
40         LString userName ;
41         userName = getenv("LOGNAME");
42         if (userName.empty())
43                 userName = getenv("USER");
44         if (userName.empty())
45                 userName = _("unknown");
46         return userName;
47 }
48
49
50 /// Returns the maximum of two integers.
51 inline
52 int Maximum(int a, int b)
53 {
54         return ((a>b) ? a : b);
55 }
56
57
58 /// Returns the minimum of two integers.
59 inline
60 int Minimum(int a, int b)
61 {
62         return ((a<b) ? a : b);
63 }
64
65 #endif