Commit | Line | Data |
---|---|---|
059ec3d9 PH |
1 | /************************************************* |
2 | * Exim - an Internet mail transport agent * | |
3 | *************************************************/ | |
4 | ||
f9ba5e22 | 5 | /* Copyright (c) University of Cambridge 1995 - 2018 */ |
059ec3d9 PH |
6 | /* See the file NOTICE for conditions of use and distribution. */ |
7 | ||
8 | ||
9 | /* This header file contains type definitions and macros that I use as | |
10 | "standard" in the code of Exim and its utilities. Make it idempotent because | |
11 | local_scan.h includes it and exim.h includes them both (to get this earlier). */ | |
12 | ||
13 | #ifndef MYTYPES_H | |
14 | #define MYTYPES_H | |
15 | ||
d1406d48 | 16 | #ifndef FALSE |
2f4df477 | 17 | # define FALSE 0 |
d1406d48 NM |
18 | #endif |
19 | ||
20 | #ifndef TRUE | |
2f4df477 | 21 | # define TRUE 1 |
d1406d48 NM |
22 | #endif |
23 | ||
24 | #ifndef TRUE_UNSET | |
2f4df477 | 25 | # define TRUE_UNSET 2 |
d1406d48 | 26 | #endif |
059ec3d9 PH |
27 | |
28 | ||
29 | /* If gcc is being used to compile Exim, we can use its facility for checking | |
30 | the arguments of printf-like functions. This is done by a macro. */ | |
31 | ||
b3c261f7 | 32 | #if defined(__GNUC__) || defined(__clang__) |
268d00ff JH |
33 | # define PRINTF_FUNCTION(A,B) __attribute__((format(printf,A,B))) |
34 | # define ARG_UNUSED __attribute__((__unused__)) | |
35 | # define WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) | |
059ec3d9 | 36 | #else |
2f4df477 JH |
37 | # define PRINTF_FUNCTION(A,B) |
38 | # define ARG_UNUSED /**/ | |
268d00ff | 39 | # define WARN_UNUSED_RESULT /**/ |
059ec3d9 PH |
40 | #endif |
41 | ||
81f91683 | 42 | #ifdef WANT_DEEPER_PRINTF_CHECKS |
2f4df477 | 43 | # define ALMOST_PRINTF(A, B) PRINTF_FUNCTION(A, B) |
81f91683 | 44 | #else |
2f4df477 | 45 | # define ALMOST_PRINTF(A, B) |
81f91683 PP |
46 | #endif |
47 | ||
059ec3d9 PH |
48 | |
49 | /* Some operating systems (naughtily, imo) include a definition for "uchar" in | |
50 | the standard header files, so we use "uschar". Solaris has u_char in | |
51 | sys/types.h. This is just a typing convenience, of course. */ | |
52 | ||
059ec3d9 | 53 | typedef unsigned char uschar; |
a207d5dd | 54 | typedef unsigned BOOL; |
cd59ab18 PP |
55 | /* We also have SIGNAL_BOOL, which requires signal.h be included, so is defined |
56 | elsewhere */ | |
059ec3d9 PH |
57 | |
58 | ||
59 | /* These macros save typing for the casting that is needed to cope with the | |
60 | mess that is "char" in ISO/ANSI C. Having now been bitten enough times by | |
61 | systems where "char" is actually signed, I've converted Exim to use entirely | |
62 | unsigned chars, except in a few special places such as arguments that are | |
63 | almost always literal strings. */ | |
64 | ||
65 | #define CS (char *) | |
66 | #define CCS (const char *) | |
67 | #define CSS (char **) | |
68 | #define US (unsigned char *) | |
69 | #define CUS (const unsigned char *) | |
70 | #define USS (unsigned char **) | |
55414b25 | 71 | #define CUSS (const unsigned char **) |
059ec3d9 PH |
72 | |
73 | /* The C library string functions expect "char *" arguments. Use macros to | |
74 | avoid having to write a cast each time. We do this for string and file | |
75 | functions that are called quite often; for other calls to external libraries | |
76 | (which are on the whole special-purpose) we just use individual casts. */ | |
77 | ||
78 | #define Uatoi(s) atoi(CCS(s)) | |
79 | #define Uatol(s) atol(CCS(s)) | |
80 | #define Uchdir(s) chdir(CCS(s)) | |
81 | #define Uchmod(s,n) chmod(CCS(s),n) | |
059ec3d9 PH |
82 | #define Ufgets(b,n,f) fgets(CS(b),n,f) |
83 | #define Ufopen(s,t) fopen(CCS(s),CCS(t)) | |
84 | #define Ulink(s,t) link(CCS(s),CCS(t)) | |
85 | #define Ulstat(s,t) lstat(CCS(s),t) | |
86 | ||
87 | #ifdef O_BINARY /* This is for Cygwin, */ | |
88 | #define Uopen(s,n,m) open(CCS(s),(n)|O_BINARY,m) /* where all files must */ | |
89 | #else /* be opened as binary */ | |
90 | #define Uopen(s,n,m) open(CCS(s),n,m) /* to avoid problems */ | |
91 | #endif /* with CRLF endings. */ | |
92 | #define Uread(f,b,l) read(f,CS(b),l) | |
93 | #define Urename(s,t) rename(CCS(s),CCS(t)) | |
94 | #define Ustat(s,t) stat(CCS(s),t) | |
95 | #define Ustrcat(s,t) strcat(CS(s),CCS(t)) | |
96 | #define Ustrchr(s,n) US strchr(CCS(s),n) | |
97 | #define CUstrchr(s,n) CUS strchr(CCS(s),n) | |
98 | #define CUstrerror(n) CUS strerror(n) | |
99 | #define Ustrcmp(s,t) strcmp(CCS(s),CCS(t)) | |
100 | #define Ustrcpy(s,t) strcpy(CS(s),CCS(t)) | |
101 | #define Ustrcspn(s,t) strcspn(CCS(s),CCS(t)) | |
102 | #define Ustrftime(s,m,f,t) strftime(CS(s),m,f,t) | |
103 | #define Ustrlen(s) (int)strlen(CCS(s)) | |
104 | #define Ustrncat(s,t,n) strncat(CS(s),CCS(t),n) | |
105 | #define Ustrncmp(s,t,n) strncmp(CCS(s),CCS(t),n) | |
106 | #define Ustrncpy(s,t,n) strncpy(CS(s),CCS(t),n) | |
107 | #define Ustrpbrk(s,t) strpbrk(CCS(s),CCS(t)) | |
108 | #define Ustrrchr(s,n) US strrchr(CCS(s),n) | |
109 | #define CUstrrchr(s,n) CUS strrchr(CCS(s),n) | |
110 | #define Ustrspn(s,t) strspn(CCS(s),CCS(t)) | |
111 | #define Ustrstr(s,t) US strstr(CCS(s),CCS(t)) | |
112 | #define CUstrstr(s,t) CUS strstr(CCS(s),CCS(t)) | |
113 | #define Ustrtod(s,t) strtod(CCS(s),CSS(t)) | |
114 | #define Ustrtol(s,t,b) strtol(CCS(s),CSS(t),b) | |
115 | #define Ustrtoul(s,t,b) strtoul(CCS(s),CSS(t),b) | |
116 | #define Uunlink(s) unlink(CCS(s)) | |
117 | #endif | |
118 | ||
119 | /* End of mytypes.h */ |