Get TLS SNI server-switching working with GnuTLS.
[exim.git] / src / src / mytypes.h
CommitLineData
059ec3d9
PH
1/*************************************************
2* Exim - an Internet mail transport agent *
3*************************************************/
4
0a49a7a4 5/* Copyright (c) University of Cambridge 1995 - 2009 */
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
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
d1406d48 16#ifndef FALSE
059ec3d9 17#define FALSE 0
d1406d48
NM
18#endif
19
20#ifndef TRUE
059ec3d9 21#define TRUE 1
d1406d48
NM
22#endif
23
24#ifndef TRUE_UNSET
059ec3d9 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
30the arguments of printf-like functions. This is done by a macro. */
31
b3c261f7 32#if defined(__GNUC__) || defined(__clang__)
ce552449 33#define PRINTF_FUNCTION(A,B) __attribute__((format(printf,A,B)))
7be682ca 34#define ARG_UNUSED __attribute__((__unused__))
059ec3d9 35#else
ce552449 36#define PRINTF_FUNCTION(A,B)
7be682ca 37#define ARG_UNUSED /**/
059ec3d9
PH
38#endif
39
40
41/* Some operating systems (naughtily, imo) include a definition for "uchar" in
42the standard header files, so we use "uschar". Solaris has u_char in
43sys/types.h. This is just a typing convenience, of course. */
44
059ec3d9 45typedef unsigned char uschar;
cd59ab18
PP
46typedef int BOOL;
47/* We also have SIGNAL_BOOL, which requires signal.h be included, so is defined
48elsewhere */
059ec3d9
PH
49
50
51/* These macros save typing for the casting that is needed to cope with the
52mess that is "char" in ISO/ANSI C. Having now been bitten enough times by
53systems where "char" is actually signed, I've converted Exim to use entirely
54unsigned chars, except in a few special places such as arguments that are
55almost always literal strings. */
56
57#define CS (char *)
58#define CCS (const char *)
59#define CSS (char **)
60#define US (unsigned char *)
61#define CUS (const unsigned char *)
62#define USS (unsigned char **)
63
64/* The C library string functions expect "char *" arguments. Use macros to
65avoid having to write a cast each time. We do this for string and file
66functions that are called quite often; for other calls to external libraries
67(which are on the whole special-purpose) we just use individual casts. */
68
69#define Uatoi(s) atoi(CCS(s))
70#define Uatol(s) atol(CCS(s))
71#define Uchdir(s) chdir(CCS(s))
72#define Uchmod(s,n) chmod(CCS(s),n)
73#define Uchown(s,n,m) chown(CCS(s),n,m)
74#define Ufgets(b,n,f) fgets(CS(b),n,f)
75#define Ufopen(s,t) fopen(CCS(s),CCS(t))
76#define Ulink(s,t) link(CCS(s),CCS(t))
77#define Ulstat(s,t) lstat(CCS(s),t)
78
79#ifdef O_BINARY /* This is for Cygwin, */
80#define Uopen(s,n,m) open(CCS(s),(n)|O_BINARY,m) /* where all files must */
81#else /* be opened as binary */
82#define Uopen(s,n,m) open(CCS(s),n,m) /* to avoid problems */
83#endif /* with CRLF endings. */
84#define Uread(f,b,l) read(f,CS(b),l)
85#define Urename(s,t) rename(CCS(s),CCS(t))
86#define Ustat(s,t) stat(CCS(s),t)
87#define Ustrcat(s,t) strcat(CS(s),CCS(t))
88#define Ustrchr(s,n) US strchr(CCS(s),n)
89#define CUstrchr(s,n) CUS strchr(CCS(s),n)
90#define CUstrerror(n) CUS strerror(n)
91#define Ustrcmp(s,t) strcmp(CCS(s),CCS(t))
92#define Ustrcpy(s,t) strcpy(CS(s),CCS(t))
93#define Ustrcspn(s,t) strcspn(CCS(s),CCS(t))
94#define Ustrftime(s,m,f,t) strftime(CS(s),m,f,t)
95#define Ustrlen(s) (int)strlen(CCS(s))
96#define Ustrncat(s,t,n) strncat(CS(s),CCS(t),n)
97#define Ustrncmp(s,t,n) strncmp(CCS(s),CCS(t),n)
98#define Ustrncpy(s,t,n) strncpy(CS(s),CCS(t),n)
99#define Ustrpbrk(s,t) strpbrk(CCS(s),CCS(t))
100#define Ustrrchr(s,n) US strrchr(CCS(s),n)
101#define CUstrrchr(s,n) CUS strrchr(CCS(s),n)
102#define Ustrspn(s,t) strspn(CCS(s),CCS(t))
103#define Ustrstr(s,t) US strstr(CCS(s),CCS(t))
104#define CUstrstr(s,t) CUS strstr(CCS(s),CCS(t))
105#define Ustrtod(s,t) strtod(CCS(s),CSS(t))
106#define Ustrtol(s,t,b) strtol(CCS(s),CSS(t),b)
107#define Ustrtoul(s,t,b) strtoul(CCS(s),CSS(t),b)
108#define Uunlink(s) unlink(CCS(s))
109#endif
110
111/* End of mytypes.h */