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