Import Debian changes 4.92-8+deb10u3
[hcoop/debian/exim4.git] / src / mytypes.h
CommitLineData
420a0d19
CE
1/*************************************************
2* Exim - an Internet mail transport agent *
3*************************************************/
4
2ea97746 5/* Copyright (c) University of Cambridge 1995 - 2018 */
420a0d19
CE
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
11local_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#ifndef FALSE
2ea97746 17# define FALSE 0
420a0d19
CE
18#endif
19
20#ifndef TRUE
2ea97746 21# define TRUE 1
420a0d19
CE
22#endif
23
24#ifndef TRUE_UNSET
2ea97746 25# define TRUE_UNSET 2
420a0d19
CE
26#endif
27
28
29/* If gcc is being used to compile Exim, we can use its facility for checking
30the arguments of printf-like functions. This is done by a macro. */
31
32#if defined(__GNUC__) || defined(__clang__)
2ea97746
CE
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__))
420a0d19 36#else
2ea97746
CE
37# define PRINTF_FUNCTION(A,B)
38# define ARG_UNUSED /**/
39# define WARN_UNUSED_RESULT /**/
420a0d19
CE
40#endif
41
42#ifdef WANT_DEEPER_PRINTF_CHECKS
2ea97746 43# define ALMOST_PRINTF(A, B) PRINTF_FUNCTION(A, B)
420a0d19 44#else
2ea97746 45# define ALMOST_PRINTF(A, B)
420a0d19
CE
46#endif
47
48
49/* Some operating systems (naughtily, imo) include a definition for "uchar" in
50the standard header files, so we use "uschar". Solaris has u_char in
51sys/types.h. This is just a typing convenience, of course. */
52
53typedef unsigned char uschar;
2ea97746 54typedef unsigned BOOL;
420a0d19
CE
55/* We also have SIGNAL_BOOL, which requires signal.h be included, so is defined
56elsewhere */
57
58
59/* These macros save typing for the casting that is needed to cope with the
60mess that is "char" in ISO/ANSI C. Having now been bitten enough times by
61systems where "char" is actually signed, I've converted Exim to use entirely
62unsigned chars, except in a few special places such as arguments that are
63almost 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 **)
188b6fee 71#define CUSS (const unsigned char **)
420a0d19
CE
72
73/* The C library string functions expect "char *" arguments. Use macros to
74avoid having to write a cast each time. We do this for string and file
75functions 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)
82#define Uchown(s,n,m) chown(CCS(s),n,m)
83#define Ufgets(b,n,f) fgets(CS(b),n,f)
84#define Ufopen(s,t) fopen(CCS(s),CCS(t))
85#define Ulink(s,t) link(CCS(s),CCS(t))
86#define Ulstat(s,t) lstat(CCS(s),t)
87
88#ifdef O_BINARY /* This is for Cygwin, */
89#define Uopen(s,n,m) open(CCS(s),(n)|O_BINARY,m) /* where all files must */
90#else /* be opened as binary */
91#define Uopen(s,n,m) open(CCS(s),n,m) /* to avoid problems */
92#endif /* with CRLF endings. */
93#define Uread(f,b,l) read(f,CS(b),l)
94#define Urename(s,t) rename(CCS(s),CCS(t))
95#define Ustat(s,t) stat(CCS(s),t)
96#define Ustrcat(s,t) strcat(CS(s),CCS(t))
97#define Ustrchr(s,n) US strchr(CCS(s),n)
98#define CUstrchr(s,n) CUS strchr(CCS(s),n)
99#define CUstrerror(n) CUS strerror(n)
100#define Ustrcmp(s,t) strcmp(CCS(s),CCS(t))
101#define Ustrcpy(s,t) strcpy(CS(s),CCS(t))
102#define Ustrcspn(s,t) strcspn(CCS(s),CCS(t))
103#define Ustrftime(s,m,f,t) strftime(CS(s),m,f,t)
104#define Ustrlen(s) (int)strlen(CCS(s))
105#define Ustrncat(s,t,n) strncat(CS(s),CCS(t),n)
106#define Ustrncmp(s,t,n) strncmp(CCS(s),CCS(t),n)
107#define Ustrncpy(s,t,n) strncpy(CS(s),CCS(t),n)
108#define Ustrpbrk(s,t) strpbrk(CCS(s),CCS(t))
109#define Ustrrchr(s,n) US strrchr(CCS(s),n)
110#define CUstrrchr(s,n) CUS strrchr(CCS(s),n)
111#define Ustrspn(s,t) strspn(CCS(s),CCS(t))
112#define Ustrstr(s,t) US strstr(CCS(s),CCS(t))
113#define CUstrstr(s,t) CUS strstr(CCS(s),CCS(t))
114#define Ustrtod(s,t) strtod(CCS(s),CSS(t))
115#define Ustrtol(s,t,b) strtol(CCS(s),CSS(t),b)
116#define Ustrtoul(s,t,b) strtoul(CCS(s),CSS(t),b)
117#define Uunlink(s) unlink(CCS(s))
118#endif
119
120/* End of mytypes.h */