Rev 1 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | magnus | 1 | /************************************************* |
2 | * Exim - an Internet mail transport agent * |
||
3 | *************************************************/ |
||
4 | |||
5 | /* Copyright (c) University of Cambridge 1995 - 2003 */ |
||
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 | |||
16 | |||
17 | #define FALSE 0 |
||
18 | #define TRUE 1 |
||
19 | #define TRUE_UNSET 2 |
||
20 | |||
21 | |||
22 | /* If gcc is being used to compile Exim, we can use its facility for checking |
||
23 | the arguments of printf-like functions. This is done by a macro. */ |
||
24 | |||
25 | #ifdef __GNUC__ |
||
26 | #define PRINTF_FUNCTION __attribute__((format(printf,1,2))) |
||
27 | #else |
||
28 | #define PRINTF_FUNCTION |
||
29 | #endif |
||
30 | |||
31 | |||
32 | /* Some operating systems (naughtily, imo) include a definition for "uchar" in |
||
33 | the standard header files, so we use "uschar". Solaris has u_char in |
||
34 | sys/types.h. This is just a typing convenience, of course. */ |
||
35 | |||
36 | typedef int BOOL; |
||
37 | typedef unsigned char uschar; |
||
38 | |||
39 | |||
40 | /* These macros save typing for the casting that is needed to cope with the |
||
41 | mess that is "char" in ISO/ANSI C. Having now been bitten enough times by |
||
42 | systems where "char" is actually signed, I've converted Exim to use entirely |
||
43 | unsigned chars, except in a few special places such as arguments that are |
||
44 | almost always literal strings. */ |
||
45 | |||
46 | #define CS (char *) |
||
47 | #define CSS (char **) |
||
48 | #define US (unsigned char *) |
||
49 | #define USS (unsigned char **) |
||
50 | |||
51 | /* The C library string functions expect "char *" arguments. Use macros to |
||
52 | avoid having to write a cast each time. We do this for string and file |
||
53 | functions; for other calls to external libraries (which are on the whole |
||
54 | special-purpose) we just use casts. */ |
||
55 | |||
56 | |||
57 | #define Uatoi(s) atoi(CS(s)) |
||
58 | #define Uatol(s) atol(CS(s)) |
||
59 | #define Uchdir(s) chdir(CS(s)) |
||
60 | #define Uchmod(s,n) chmod(CS(s),n) |
||
61 | #define Uchown(s,n,m) chown(CS(s),n,m) |
||
62 | #define Ufgets(b,n,f) fgets(CS(b),n,f) |
||
63 | #define Ufopen(s,t) fopen(CS(s),CS(t)) |
||
64 | #define Ulink(s,t) link(CS(s),CS(t)) |
||
65 | #define Ulstat(s,t) lstat(CS(s),t) |
||
66 | #ifdef O_BINARY /* This is for Cygwin, */ |
||
67 | #define Uopen(s,n,m) open(CS(s),(n)|O_BINARY,m) /* where all files must */ |
||
68 | #else /* be opened as binary */ |
||
69 | #define Uopen(s,n,m) open(CS(s),n,m) /* to avoid problems */ |
||
70 | #endif /* with CRLF endings. */ |
||
71 | #define Uread(f,b,l) read(f,CS(b),l) |
||
72 | #define Urename(s,t) rename(CS(s),CS(t)) |
||
73 | #define Ustat(s,t) stat(CS(s),t) |
||
74 | #define Ustrcat(s,t) strcat(CS(s),CS(t)) |
||
75 | #define Ustrchr(s,n) US strchr(CS(s),n) |
||
76 | #define Ustrcmp(s,t) strcmp(CS(s),CS(t)) |
||
77 | #define Ustrcpy(s,t) strcpy(CS(s),CS(t)) |
||
78 | #define Ustrcspn(s,t) strcspn(CS(s),CS(t)) |
||
79 | #define Ustrftime(s,m,f,t) strftime(CS(s),m,f,t) |
||
80 | #define Ustrlen(s) (int)strlen(CS(s)) |
||
81 | #define Ustrncat(s,t,n) strncat(CS(s),CS(t),n) |
||
82 | #define Ustrncmp(s,t,n) strncmp(CS(s),CS(t),n) |
||
83 | #define Ustrncpy(s,t,n) strncpy(CS(s),CS(t),n) |
||
84 | #define Ustrpbrk(s,t) strpbrk(CS(s),CS(t)) |
||
85 | #define Ustrrchr(s,n) US strrchr(CS(s),n) |
||
86 | #define Ustrspn(s,t) strspn(CS(s),CS(t)) |
||
87 | #define Ustrstr(s,t) US strstr(CS(s),CS(t)) |
||
88 | #define Ustrtod(s,t) strtod(CS(s),CSS(t)) |
||
89 | #define Ustrtol(s,t,b) strtol(CS(s),CSS(t),b) |
||
90 | #define Ustrtoul(s,t,b) strtoul(CS(s),CSS(t),b) |
||
91 | #define Uunlink(s) unlink(CS(s)) |
||
92 | |||
93 | #endif |
||
94 | |||
95 | /* End of mytypes.h */ |