7 A Linux/Unix toolset and driver for Nokia mobile phones.
9 Copyright (C) 1999, 2000 Hugh Blemings & Pavel JanÃk ml.
11 Released under the terms of the GNU GPL, see file COPYING for more details.
13 Header file for miscellaneous defines, typedefs etc.
16 Revision 1.1.1.1.6.1 2001/11/25 23:04:51 short
18 * g{,v}asprintf() - "asprintf()" compatibility emulation
19 * ARRAY_LEN() - sizeof(x)/sizeof(*x)
20 * SAFE_STRNCPY{,_SIZEOF}() - strncpy with variable-size autodetection
21 * G_GNUC_PRINTF - GCC attribute from glib
22 * N_(x) - missing in localization macros
24 Revision 1.1.1.1 2001/11/25 21:59:21 short
25 :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
27 Revision 1.26 2001/11/14 10:46:12 pkot
28 Small cleanup with __unices__
30 Revision 1.25 2001/07/03 15:27:14 pkot
31 AT commands for SMS handling support (Tamas Bondar)
32 Small at-emulator code cleanup (me)
34 Revision 1.24 2001/06/28 00:28:46 pkot
35 Small docs updates (Pawel Kot)
45 /* Some general defines. */
59 #define ARRAY_LEN(x) (sizeof((x))/sizeof((x)[0]))
61 #define SAFE_STRNCPY(dest,src,n) do { \
62 strncpy((dest),(src),(n)); \
67 #define SAFE_STRNCPY_SIZEOF(dest,src) \
68 SAFE_STRNCPY((dest),(src),sizeof((dest)))
70 /* Stolen from <glib.h>: */
71 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
72 #define G_GNUC_PRINTF( format_idx, arg_idx ) \
73 __attribute__((format (printf, format_idx, arg_idx)))
75 #define G_GNUC_PRINTF( format_idx, arg_idx )
76 #endif /* !__GNUC__ */
78 #define GNOKII_MAX(a, b) (((a) > (b)) ? (a) : (b))
79 #define GNOKII_MIN(a, b) (((a) < (b)) ? (a) : (b))
81 /* A define to make debug printfs neat */
83 #define dprintf(a...) do { } while (0)
85 #define dprintf(a...) do { fprintf(stderr, a); fflush(stderr); } while (0)
88 /* Use gsprintf instead of sprintf and sprintf */
90 # define gsprintf(a, b, c...) snprintf(a, b, c)
92 # define gsprintf(a, b, c...) sprintf(a, c)
95 # define gvsprintf(a, b, c...) vsnprintf(a, b, c)
97 # define gvsprintf(a, b, c...) vsprintf(a, c)
100 # define gasprintf(a...) asprintf(a)
103 extern int gasprintf(char **destp,const char *fmt,...);
105 #ifdef HAVE_VASPRINTF
106 # define gvasprintf(a...) vasprintf(a)
109 extern int gvasprintf(char **destp,const char *fmt,va_list ap);
112 /* Get rid of long defines. Use #if __unices__ */
113 #define __unices__ defined(__svr4__) || defined(__FreeBSD__) || defined(__bsdi__)
115 # include <strings.h>
116 # include <sys/file.h>
119 /* This one is for NLS. */
122 #define _(x) gettext(x)
128 /* Definitions for u8, u16, u32 and u64, borrowed from
129 /usr/src/linux/include/asm-i38/types.h */
132 typedef unsigned char u8;
136 typedef unsigned short u16;
140 typedef unsigned int u32;
147 #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
149 typedef unsigned long long u64;
153 typedef signed long long s64;
157 /* This one is for FreeBSD and similar systems without __ptr_t_ */
158 /* FIXME: autoconf should take care of this. */
161 typedef void * __ptr_t;
165 /* Add here any timer operations which are not supported by libc5 */
171 #include <sys/timeb.h>
172 #define timersub(a, b, result)
174 (result)->tv_sec = (a)->time - (b)->time;
175 (result)->tv_usec = ((a)->millitm - (b)->millitm) * 1000;
176 if ((result)->tv_usec < 0) {
178 (result)->tv_usec += 1000000;
181 #define gettimeofday(a, b) _ftime(a)
184 #include <sys/time.h>
187 #define timersub(a, b, result) \
189 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
190 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
191 if ((result)->tv_usec < 0) { \
192 --(result)->tv_sec; \
193 (result)->tv_usec += 1000000; \
199 #endif /* HAVE_TIMEOPS */
203 extern int GetLine(FILE *File, char *Line, int count);
205 /* For models table */
212 #define PM_CALLERGROUP 0x0001
213 #define PM_NETMONITOR 0x0002
214 #define PM_KEYBOARD 0x0004
215 #define PM_SMS 0x0008
216 #define PM_CALENDAR 0x0010
217 #define PM_DTMF 0x0020
218 #define PM_DATA 0x0040
219 #define PM_SPEEDDIAL 0x0080
220 #define PM_EXTPBK 0x0100
221 #define PM_AUTHENTICATION 0x0200
223 extern char *GetModel (const char *);
224 extern PhoneModel *GetPhoneModel (const char *);
226 #endif /* __misc_h */