LDFLAGS -> LDLIBS
[gnokii.git] / include / misc.h
1 /*
2
3   $Id$
4
5   G N O K I I
6
7   A Linux/Unix toolset and driver for Nokia mobile phones.
8
9   Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml.
10
11   Released under the terms of the GNU GPL, see file COPYING for more details.
12
13   Header file for miscellaneous defines, typedefs etc.
14
15   $Log$
16   Revision 1.1.1.1  2001/11/25 21:59:21  short
17   :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
18
19   Revision 1.26  2001/11/14 10:46:12  pkot
20   Small cleanup with __unices__
21
22   Revision 1.25  2001/07/03 15:27:14  pkot
23   AT commands for SMS handling support (Tamas Bondar)
24   Small at-emulator code cleanup (me)
25
26   Revision 1.24  2001/06/28 00:28:46  pkot
27   Small docs updates (Pawel Kot)
28
29
30 */
31
32 #ifndef __misc_h
33 #define __misc_h    
34
35 #include "config.h"
36
37 /* Some general defines. */
38
39 #ifndef false
40   #define false (0)
41 #endif
42
43 #ifndef true
44   #define true (!false)
45 #endif
46
47 #ifndef bool    
48   #define bool int
49 #endif
50
51 /* A define to make debug printfs neat */
52 #ifndef DEBUG
53 #define dprintf(a...) do { } while (0)
54 #else
55 #define dprintf(a...) do { fprintf(stderr, a); fflush(stderr); } while (0) 
56 #endif
57
58 /* Use gsprintf instead of sprintf and sprintf */
59 #ifdef HAVE_SNPRINTF
60 # define gsprintf(a, b, c...) snprintf(a, b, c)
61 #else
62 # define gsprintf(a, b, c...) sprintf(a, c)
63 #endif
64
65 /* Get rid of long defines. Use #if __unices__ */
66 #define __unices__ defined(__svr4__) || defined(__FreeBSD__) || defined(__bsdi__)
67 #if __unices__
68 # include <strings.h>
69 # include <sys/file.h>
70 #endif
71
72 /* This one is for NLS. */
73 #ifdef USE_NLS
74   #include <libintl.h>
75   #define _(x) gettext(x)
76 #else
77   #define _(x) (x)
78 #endif /* USE_NLS */
79
80 /* Definitions for u8, u16, u32 and u64, borrowed from
81    /usr/src/linux/include/asm-i38/types.h */
82
83 #ifndef u8
84   typedef unsigned char u8;
85 #endif
86
87 #ifndef u16
88   typedef unsigned short u16;
89 #endif
90
91 #ifndef u32
92   typedef unsigned int u32;
93 #endif
94
95 #ifndef s32
96   typedef int s32;
97 #endif
98
99 #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
100   #ifndef u64
101     typedef unsigned long long u64;
102   #endif
103
104   #ifndef s64
105     typedef signed long long s64;
106   #endif
107 #endif 
108
109 /* This one is for FreeBSD and similar systems without __ptr_t_ */
110 /* FIXME: autoconf should take care of this. */
111
112 #ifndef __ptr_t
113   typedef void * __ptr_t;
114 #endif /* __ptr_t */
115
116
117 /* Add here any timer operations which are not supported by libc5 */
118
119 #ifndef HAVE_TIMEOPS
120 #ifdef WIN32
121
122 #include <windows.h>
123 #include <sys/timeb.h>
124 #define timersub(a, b, result)
125   do {
126     (result)->tv_sec = (a)->time - (b)->time;
127     (result)->tv_usec = ((a)->millitm - (b)->millitm) * 1000;
128     if ((result)->tv_usec < 0) {
129       --(result)->tv_sec;
130       (result)->tv_usec += 1000000;
131     }
132   } while (0)
133 #define gettimeofday(a, b) _ftime(a)
134
135 #else
136 #include <sys/time.h>
137
138 #ifndef timersub
139 #define timersub(a, b, result)                                                \
140   do {                                                                        \
141     (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;                             \
142     (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;                          \
143     if ((result)->tv_usec < 0) {                                              \
144       --(result)->tv_sec;                                                     \
145       (result)->tv_usec += 1000000;                                           \
146     }                                                                         \
147   } while (0)
148 #endif
149
150 #endif /* WIN32 */
151 #endif /* HAVE_TIMEOPS */
152
153
154 #include <stdio.h>
155 extern int GetLine(FILE *File, char *Line, int count);
156
157 /* For models table */
158 typedef struct {
159   char *model;
160   char *number;
161   int flags;
162 } PhoneModel;
163
164 #define PM_CALLERGROUP    0x0001
165 #define PM_NETMONITOR     0x0002
166 #define PM_KEYBOARD       0x0004
167 #define PM_SMS            0x0008
168 #define PM_CALENDAR       0x0010
169 #define PM_DTMF           0x0020
170 #define PM_DATA           0x0040
171 #define PM_SPEEDDIAL      0x0080
172 #define PM_EXTPBK         0x0100
173 #define PM_AUTHENTICATION 0x0200
174
175 extern char *GetModel (const char *);
176 extern PhoneModel *GetPhoneModel (const char *);
177
178 #endif /* __misc_h */
179