Fixed broken calling of stackcheck()
[gnokii.git] / include / misc.h
1 /*
2
3   G N O K I I
4
5   A Linux/Unix toolset and driver for Nokia mobile phones.
6
7   Released under the terms of the GNU GPL, see file COPYING for more details.
8
9   Header file for miscellaneous defines, typedefs etc.
10
11 */
12
13 #ifndef __misc_h
14 #define __misc_h    
15
16 #include <stdio.h>
17 #include <stdlib.h>
18
19 #ifndef VC6
20   #include "config.h"
21
22   /* Use gsprintf instead of sprintf and sprintf */
23   #ifdef HAVE_SNPRINTF
24   # define gsprintf(a, b, c...) snprintf(a, b, c)
25   #else
26   # define gsprintf(a, b, c...) sprintf(a, c)
27   #endif
28
29 #endif
30
31 /* Some general defines. */
32
33 #ifndef false
34   #define false (0)
35 #endif
36
37 #ifndef true
38   #define true (!false)
39 #endif
40
41 #ifndef bool    
42   #define bool int
43 #endif
44
45 /* This one is for NLS. */
46
47 #ifdef USE_NLS
48
49   #ifndef VC6
50     #include <libintl.h>
51     #define _(x) gettext(x)
52   #else
53     #define _(x) (x)
54   #endif
55
56 #else
57   #define _(x) (x)
58 #endif /* USE_NLS */
59
60 /* Definitions for u8, u16, u32 and u64, borrowed from
61    /usr/src/linux/include/asm-i38/types.h */
62
63 #ifndef u8
64   typedef unsigned char u8;
65 #endif
66
67 #ifndef u16
68   typedef unsigned short u16;
69 #endif
70
71 #ifndef u32
72   typedef unsigned int u32;
73 #endif
74
75 #ifndef s32
76   typedef int s32;
77 #endif
78
79 #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
80   #ifndef u64
81     typedef unsigned long long u64;
82   #endif
83
84   #ifndef s64
85     typedef signed long long s64;
86   #endif
87 #endif 
88
89 /* This one is for FreeBSD and similar systems without __ptr_t_ */
90 /* FIXME: autoconf should take care of this. */
91
92 #ifndef __ptr_t
93   typedef void * __ptr_t;
94 #endif /* __ptr_t */
95
96
97 /* Add here any timer operations which are not supported by libc5 */
98
99 #ifndef HAVE_TIMEOPS
100 #include <sys/time.h>
101
102 #ifndef timersub
103 #define timersub(a, b, result)                                                \
104   do {                                                                        \
105     (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;                             \
106     (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;                          \
107     if ((result)->tv_usec < 0) {                                              \
108       --(result)->tv_sec;                                                     \
109       (result)->tv_usec += 1000000;                                           \
110     }                                                                         \
111   } while (0)
112 #endif
113
114 #endif /* HAVE_TIMEOPS */
115
116 #include <stdio.h>
117
118 extern int GetLine(FILE *File, char *Line, int count);
119
120 int mem_to_int(const char str[], int len);
121
122 void hexdump(u16 MessageLength, u8 *MessageBuffer);
123 void txhexdump(u16 MessageLength, u8 *MessageBuffer);
124
125 #endif /* __misc_h */