X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/e5a9dba621b4301bfbe2bc05576ddc5ec752b1b5..c0ad8edfe5615780184f88bfc8fa306b76db6bbc:/src/src/exim.h diff --git a/src/src/exim.h b/src/src/exim.h index 9bc15cecb..d03b48c66 100644 --- a/src/src/exim.h +++ b/src/src/exim.h @@ -1,10 +1,8 @@ -/* $Cambridge: exim/src/src/exim.h,v 1.12 2005/05/10 10:19:11 ph10 Exp $ */ - /************************************************* * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2005 */ +/* Copyright (c) University of Cambridge 1995 - 2016 */ /* See the file NOTICE for conditions of use and distribution. */ @@ -13,10 +11,25 @@ that is needed. They don't all need everything, of course, but it's far too messy to have each one importing its own list, and anyway, most of them need most of these includes. */ +#ifndef EXIM_H +#define EXIM_H + /* Assume most systems have statfs() unless os.h undefines this macro */ #define HAVE_STATFS +/* Similarly, assume most systems have srandom() unless os.h undefines it. +This call dates back at least as far as SUSv2. */ + +#define HAVE_SRANDOM + +/* This is primarily for the Gnu C library; we define it before os.h so that +os.h has a chance to hurriedly undef it, Just In Case. We need C99 for some +64-bit math support, and defining _ISOC99_SOURCE breaks and friends. +*/ + +#define _GNU_SOURCE 1 + /* First of all include the os-specific header, which might set things that are needed by any of the other headers, including system headers. */ @@ -25,7 +38,7 @@ are needed by any of the other headers, including system headers. */ /* If it didn't define os_find_running_interfaces, use the common function. */ #ifndef os_find_running_interfaces -#define os_find_running_interfaces os_common_find_running_interfaces +# define os_find_running_interfaces os_common_find_running_interfaces #endif /* If it didn't define the base for "base 62" numbers, we really do use 62. @@ -34,21 +47,27 @@ Darwin, with their case-insensitive file systems, that can't use base 62 for making unique names. */ #ifndef BASE_62 -#define BASE_62 62 +# define BASE_62 62 #endif /* The maximum value of localhost_number depends on the base being used */ #if BASE_62 == 62 -#define LOCALHOST_MAX 16 +# define LOCALHOST_MAX 16 #else -#define LOCALHOST_MAX 10 +# define LOCALHOST_MAX 10 +#endif + +/* If not overridden by os.h, dynamic libraries have filenames ending .so */ +#ifndef DYNLIB_FN_EXT +# define DYNLIB_FN_EXT "so" #endif /* ANSI C standard includes */ #include #include +#include #include #include #include @@ -61,38 +80,61 @@ making unique names. */ #include #if defined(__svr4__) && defined(__sparc) && ! defined(__EXTENSIONS__) -#define __EXTENSIONS__ /* so that SunOS 5 gets NGROUPS_MAX */ -#include -#undef __EXTENSIONS__ +# define __EXTENSIONS__ /* so that SunOS 5 gets NGROUPS_MAX */ +# include +# undef __EXTENSIONS__ #else -#include +# include #endif +/* C99 integer types, figure out how to undo this if needed for older systems */ + +#include + /* Just in case some aged system doesn't define them... */ #ifndef INT_MAX -#define INT_MAX 2147483647 +# define INT_MAX 2147483647 +#endif + +#ifndef INT_MIN +# define INT_MIN (-INT_MAX - 1) +#endif + +#ifndef SHRT_MAX +# define SHRT_MAX 32767 #endif #ifndef UCHAR_MAX -#define UCHAR_MAX 255 +# define UCHAR_MAX 255 +#endif + + +/* To match int_eximarith_t. Define in OS/os.h- to override. */ +#ifndef EXIM_ARITH_MAX +# define EXIM_ARITH_MAX ((int_eximarith_t)9223372036854775807LL) +#endif +#ifndef EXIM_ARITH_MIN +# define EXIM_ARITH_MIN (-EXIM_ARITH_MAX - 1) #endif /* Some systems have PATH_MAX and some have MAX_PATH_LEN. */ #ifndef PATH_MAX -#ifdef MAX_PATH_LEN -#define PATH_MAX MAX_PATH_LEN -#else -#define PATH_MAX 1024 -#endif +# ifdef MAX_PATH_LEN +# define PATH_MAX MAX_PATH_LEN +# else +# define PATH_MAX 1024 +# endif #endif #include #include #include #include -#include +#ifndef NO_POLL_H +# include +#endif #include #include #include @@ -101,11 +143,11 @@ making unique names. */ in sys/file.h. */ #ifndef LOCK_SH -#define NO_FLOCK +# define NO_FLOCK #endif #ifndef NO_SYSEXITS /* some OS don't have this */ -#include +# include #endif /* A few OS don't have socklen_t; their os.h files define EXIM_SOCKLEN_T to @@ -113,22 +155,22 @@ be size_t or whatever. We used to use SOCKLEN_T, but then it was discovered that this is used by the AIX include files. */ #ifndef EXIM_SOCKLEN_T -#define EXIM_SOCKLEN_T socklen_t +# define EXIM_SOCKLEN_T socklen_t #endif /* Ensure that the sysexits we reference are defined */ #ifndef EX_UNAVAILABLE -#define EX_UNAVAILABLE 69 /* service unavailable; used for execv fail */ +# define EX_UNAVAILABLE 69 /* service unavailable; used for execv fail */ #endif #ifndef EX_CANTCREAT -#define EX_CANTCREAT 73 /* can't create file: treat as temporary */ +# define EX_CANTCREAT 73 /* can't create file: treat as temporary */ #endif #ifndef EX_TEMPFAIL -#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */ +# define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */ #endif #ifndef EX_CONFIG -#define EX_CONFIG 78 /* configuration error */ +# define EX_CONFIG 78 /* configuration error */ #endif /* This one is not in any sysexits file that I've come across */ @@ -140,7 +182,7 @@ that this is used by the AIX include files. */ #include #ifndef NO_SYS_RESOURCE_H /* QNX doesn't have this */ -#include +# include #endif #include @@ -151,7 +193,7 @@ so that it can appear in the code, even if it is never actually used when the code is run. It saves some #ifdef occurrences. */ #ifndef AF_INET6 -#define AF_INET6 24 +# define AF_INET6 24 #endif #include @@ -192,24 +234,24 @@ or a macro with entries f_frsize and f_bsize. */ f_free. */ #ifndef F_BAVAIL - #define F_BAVAIL f_bavail + # define F_BAVAIL f_bavail #endif #ifndef F_FAVAIL - #define F_FAVAIL f_ffree + # define F_FAVAIL f_ffree #endif /* All the systems I've been able to look at seem to have F_FILES */ #ifndef F_FILES - #define F_FILES f_files + # define F_FILES f_files #endif #endif #ifndef SIOCGIFCONF /* HACK for SunOS 5 */ -#include +# include #endif #include @@ -218,26 +260,22 @@ or a macro with entries f_frsize and f_bsize. */ #include /* There's a shambles in IRIX6 - it defines EX_OK in unistd.h which conflicts -with the definition in sysexits.h. Arrange to preserve it, even though at -present Exim doesn't actually use it. */ +with the definition in sysexits.h. Exim does not actually use this macro, so we +just undefine it. It would be nice to be able to re-instate the definition from +sysexits.h if there is no definition in unistd.h, but I do not think there is a +way to do this in C because macro definitions are not scanned for other macros +at definition time. [The code here used to assume they were, until I was +disabused of the notion. Luckily, since EX_OK is not used, it didn't matter.] */ #ifdef EX_OK -#define SAVE_EX_OK EX_OK -#undef EX_OK +# undef EX_OK #endif #include -#ifdef SAVE_EX_OK -#ifdef EX_OK -#undef EX_OK -#endif -#define EX_OK SAVE_EX_OK -#endif - #include #ifndef NO_NET_IF_H -#include +# include #endif #include #include @@ -273,13 +311,54 @@ included in arpa/nameser.h. Fudge them here. */ header files. I don't suppose they have T_SRV either. */ #ifndef T_TXT -#define T_TXT 16 +# define T_TXT 16 #endif #ifndef T_SRV -#define T_SRV 33 +# define T_SRV 33 +#endif + +/* Many systems do not have T_SPF. */ + +#ifndef T_SPF +# define T_SPF 99 +#endif + +/* New TLSA record for DANE */ +#ifndef T_TLSA +# define T_TLSA 52 +#endif +#define MAX_TLSA_EXPANDED_SIZE 8192 + +/* It seems that some versions of arpa/nameser.h don't define *any* of the +T_xxx macros, which seem to be non-standard nowadays. Just to be on the safe +side, put in definitions for all the ones that Exim uses. */ + +#ifndef T_A +# define T_A 1 +#endif + +#ifndef T_CNAME +# define T_CNAME 5 +#endif + +#ifndef T_SOA +# define T_SOA 6 +#endif + +#ifndef T_MX +# define T_MX 15 #endif +#ifndef T_NS +# define T_NS 2 +#endif + +#ifndef T_PTR +# define T_PTR 12 +#endif + + /* We define a few private types for special DNS lookups: . T_ZNS gets the nameservers of the enclosing zone of a domain @@ -288,11 +367,17 @@ header files. I don't suppose they have T_SRV either. */ . T_CSA gets the domain's Client SMTP Authorization SRV record + . T_ADDRESSES looks up both AAAA (or A6) and A records + +If any of these names appear in the RRtype list at: + +then we should rename Exim's private type away from the conflict. */ #define T_ZNS (-1) #define T_MXH (-2) #define T_CSA (-3) +#define T_ADDRESSES (-4) /* The resolv.h header defines __P(x) on some Solaris 2.5.1 systems (without checking that it is already defined, in fact). This conflicts with other @@ -300,13 +385,24 @@ headers that behave likewise (see below), leading to compiler warnings. Arrange to undefine it if resolv.h defines it. */ #if defined(__P) -#define __P_WAS_DEFINED_BEFORE_RESOLV +# define __P_WAS_DEFINED_BEFORE_RESOLV #endif #include #if defined(__P) && ! defined (__P_WAS_DEFINED_BEFORE_RESOLV) -#undef __P +# undef __P +#endif + +/* If not defined by os.h, we do nothing special to push DNS resolver state +back to be available by the classic resolver routines. Also, provide +prototype for our get routine, unless defined away. */ + +#ifndef os_put_dns_resolver_res +# define os_put_dns_resolver_res(R) do {/**/} while(0) +#endif +#ifndef os_get_dns_resolver_res +res_state os_get_dns_resolver_res(void); #endif /* These three are to support the IP option logging code. Linux is @@ -317,7 +413,7 @@ have netinet/ip_var.h, so there's a general macro to control its inclusion. */ #include #ifndef NO_IP_VAR_H -#include +# include #endif /* Linux (and some others) uses a different type for the 2nd argument of @@ -325,20 +421,20 @@ iconv(). It's os.h file defines ICONV_ARG2_TYPE. For the rest, define a default here. */ #ifndef ICONV_ARG2_TYPE -#define ICONV_ARG2_TYPE const char ** +# define ICONV_ARG2_TYPE char ** #endif /* One OS uses a different type for the 5th argument of getsockopt */ #ifndef GETSOCKOPT_ARG5_TYPE -#define GETSOCKOPT_ARG5_TYPE socklen_t * +# define GETSOCKOPT_ARG5_TYPE socklen_t * #endif /* One operating system uses a different type for the 2nd argument of select(). Its os.h file defines SELECT_ARG2_TYPE. For the rest, define a default here. */ #ifndef SELECT_ARG2_TYPE -#define SELECT_ARG2_TYPE fd_set +# define SELECT_ARG2_TYPE fd_set #endif /* One operating system uses a different type for the 4th argument of @@ -346,7 +442,7 @@ dn_expand(). Its os.h file defines DN_EXPAND_ARG4_TYPE. For the rest, define a default here. */ #ifndef DN_EXPAND_ARG4_TYPE -#define DN_EXPAND_ARG4_TYPE char * +# define DN_EXPAND_ARG4_TYPE char * #endif /* One operating system defines a different type for the yield of inet_addr(). @@ -357,7 +453,7 @@ changed, use a macro for the type, and define it here so that it is possible to use different values for specific OS if ever necessary. */ #ifndef S_ADDR_TYPE -#define S_ADDR_TYPE u_long +# define S_ADDR_TYPE u_long #endif /* (At least) one operating system (Solaris) defines a different type for the @@ -366,7 +462,7 @@ Its os.h file defines PAM_CONVERSE_ARG2_TYPE. For the rest, define a default here. */ #ifndef PAM_CONVERSE_ARG2_TYPE -#define PAM_CONVERSE_ARG2_TYPE const struct pam_message +# define PAM_CONVERSE_ARG2_TYPE const struct pam_message #endif /* One operating system (SunOS4) defines getc, ungetc, feof, and ferror as @@ -374,79 +470,97 @@ macros and not as functions. Exim needs them to be assignable functions. This flag gets set to cause this to be sorted out here. */ #ifdef FUDGE_GETC_AND_FRIENDS -#undef getc +# undef getc extern int getc(FILE *); -#undef ungetc +# undef ungetc extern int ungetc(int, FILE *); -#undef feof +# undef feof extern int feof(FILE *); -#undef ferror +# undef ferror extern int ferror(FILE *); #endif /* The header from the PCRE regex package */ -#include "pcre/pcre.h" +#include /* Exim includes are in several files. Note that local_scan.h #includes -mytypes.h and store.h, so we don't need to mention them explicitly. */ - -#include "config.h" +config.h, mytypes.h, and store.h, so we don't need to mention them explicitly. +*/ #include "local_scan.h" #include "macros.h" #include "dbstuff.h" #include "structs.h" #include "globals.h" +#include "hash.h" #include "functions.h" #include "dbfunctions.h" #include "osfunctions.h" #ifdef EXPERIMENTAL_BRIGHTMAIL -#include "bmi_spam.h" +# include "bmi_spam.h" #endif #ifdef EXPERIMENTAL_SPF -#include "spf.h" +# include "spf.h" #endif #ifdef EXPERIMENTAL_SRS -#include "srs.h" +# include "srs.h" #endif -#ifdef EXPERIMENTAL_DOMAINKEYS -#include "dk.h" +#ifndef DISABLE_DKIM +# include "dkim.h" +#endif +#ifdef EXPERIMENTAL_DMARC +# include "dmarc.h" +# include #endif /* The following stuff must follow the inclusion of config.h because it requires various things that are set therein. */ #if HAVE_ICONV /* Not all OS have this */ -#include +# include +#endif + +#if defined(USE_READLINE) || defined(EXPAND_DLFUNC) || defined (LOOKUP_MODULE_DIR) +# include #endif -#if defined(USE_READLINE) || defined(EXPAND_DLFUNC) -#include +#ifdef ENABLE_DISABLE_FSYNC +# define EXIMfsync(f) (disable_fsync? 0 : fsync(f)) +#else +# define EXIMfsync(f) fsync(f) #endif /* Backward compatibility; LOOKUP_LSEARCH now includes all three */ #if (!defined LOOKUP_LSEARCH) && (defined LOOKUP_WILDLSEARCH || defined LOOKUP_NWILDLSEARCH) -#define LOOKUP_LSEARCH yes +# define LOOKUP_LSEARCH yes #endif /* Define a union to hold either an IPv4 or an IPv6 sockaddr structure; this -simplifies some of the coding. */ +simplifies some of the coding. We include the sockaddr to reduce type-punning +issues in C99. */ union sockaddr_46 { struct sockaddr_in v4; #if HAVE_IPV6 struct sockaddr_in6 v6; #endif + struct sockaddr v0; }; /* If SUPPORT_TLS is not defined, ensure that USE_GNUTLS is also not defined -so that if USE_GNUTLS *is* set, we can assume SUPPORT_TLS is also set. */ +so that if USE_GNUTLS *is* set, we can assume SUPPORT_TLS is also set. +Likewise, OSCP, AUTH_TLS and CERTNAMES cannot be supported. */ #ifndef SUPPORT_TLS -#undef USE_GNUTLS +# undef USE_GNUTLS +# ifndef DISABLE_OCSP +# define DISABLE_OCSP +# endif +# undef EXPERIMENTAL_CERTNAMES +# undef AUTH_TLS #endif /* If SPOOL_DIRECTORY, LOG_FILE_PATH or PID_FILE_PATH have not been defined, @@ -470,22 +584,17 @@ which will end up in config.h if supplied in OS/Makefile-xxx. If it is not set, default to EDQUOT if it exists, otherwise ENOSPC. */ #ifndef ERRNO_QUOTA -#ifdef EDQUOT -#define ERRNO_QUOTA EDQUOT -#else -#define ERRNO_QUOTA ENOSPC -#endif +# ifdef EDQUOT +# define ERRNO_QUOTA EDQUOT +# else +# define ERRNO_QUOTA ENOSPC +# endif #endif -/* Ensure PATH_MAX is defined */ - -#ifndef PATH_MAX - #ifdef MAXPATHLEN - #define PATH_MAX MAXPATHLEN - #else - #define PATH_MAX 1024 - #endif +/* DANE w/o DNSSEC is useless */ +#if defined(EXPERIMENTAL_DANE) && defined(DISABLE_DNSSEC) +# undef DISABLE_DNSSEC #endif - +#endif /* End of exim.h */