Define _ISOC99_SOURCE in exim.h
[exim.git] / src / src / exim.h
index 53b70d9d4f894c2b00f1c1df58baf92aa7b55fd7..987aebf838d354da59a6753468f13dbea9361e80 100644 (file)
@@ -1,10 +1,8 @@
-/* $Cambridge: exim/src/src/exim.h,v 1.6 2004/12/29 16:24:03 ph10 Exp $ */
-
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2004 */
+/* Copyright (c) University of Cambridge 1995 - 2012 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 
@@ -17,6 +15,16 @@ most of these includes. */
 
 #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. */
+
+#define _ISOC99_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. */
 
@@ -45,10 +53,16 @@ making unique names. */
 #define LOCALHOST_MAX  10
 #endif
 
+/* If not overriden by os.h, dynamic libraries have filenames ending .so */
+#ifndef DYNLIB_FN_EXT
+# define DYNLIB_FN_EXT "so"
+#endif
+
 /* ANSI C standard includes */
 
 #include <ctype.h>
 #include <locale.h>
+#include <math.h>
 #include <signal.h>
 #include <stdarg.h>
 #include <stddef.h>
@@ -60,7 +74,7 @@ making unique names. */
 /* Unix includes */
 
 #include <errno.h>
-#if    defined(__svr4__) && defined(__sparc) && ! defined(__EXTENSIONS__)
+#if defined(__svr4__) && defined(__sparc) && ! defined(__EXTENSIONS__)
 #define __EXTENSIONS__  /* so that SunOS 5 gets NGROUPS_MAX */
 #include <limits.h>
 #undef  __EXTENSIONS__
@@ -68,12 +82,24 @@ making unique names. */
 #include <limits.h>
 #endif
 
+/* C99 integer types, figure out how to undo this if needed for older systems */
+
+#include <inttypes.h>
+
 /* Just in case some aged system doesn't define them... */
 
 #ifndef INT_MAX
 #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
 #endif
@@ -92,6 +118,9 @@ making unique names. */
 #include <sys/file.h>
 #include <dirent.h>
 #include <netdb.h>
+#ifndef NO_POLL_H
+#include <poll.h>
+#endif
 #include <pwd.h>
 #include <grp.h>
 #include <syslog.h>
@@ -107,11 +136,12 @@ in sys/file.h. */
 #include <sysexits.h>
 #endif
 
-/* A few OS don't have socklen_t; their os.h files define SOCKLEN_T to
-be size_t or whatever. */
+/* A few OS don't have socklen_t; their os.h files define EXIM_SOCKLEN_T to
+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 SOCKLEN_T
-#define SOCKLEN_T socklen_t
+#ifndef EXIM_SOCKLEN_T
+#define EXIM_SOCKLEN_T socklen_t
 #endif
 
 /* Ensure that the sysexits we reference are defined */
@@ -206,7 +236,7 @@ or a macro with entries f_frsize and f_bsize. */
 #endif
 
 
-#ifndef  SIOCGIFCONF    /* HACK for SunOS 5 */
+#ifndef  SIOCGIFCONF   /* HACK for SunOS 5 */
 #include <sys/sockio.h>
 #endif
 
@@ -216,23 +246,19 @@ or a macro with entries f_frsize and f_bsize. */
 #include <fcntl.h>
 
 /* 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
 #endif
 
 #include <unistd.h>
 
-#ifdef SAVE_EX_OK
-#ifdef EX_OK
-#undef EX_OK
-#endif
-#define EX_OK SAVE_EX_OK
-#endif
-
 #include <utime.h>
 #ifndef NO_NET_IF_H
 #include <net/if.h>
@@ -278,12 +304,54 @@ header files. I don't suppose they have T_SRV either. */
 #define T_SRV 33
 #endif
 
-/* We use the private type T_ZNS for retrieving the nameservers for the
-enclosing zone of a domain, and the private type T_MXH for retrieving
-the MX hostnames only (without their priorities). */
+/* Many systems do not have T_SPF. */
+
+#ifndef T_SPF
+#define T_SPF 99
+#endif
+
+/* 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
+
+ . T_MXH gets the MX hostnames only (without their priorities)
+
+ . T_CSA gets the domain's Client SMTP Authorization SRV record
+
+*/
 
 #define T_ZNS (-1)
 #define T_MXH (-2)
+#define T_CSA (-3)
 
 /* 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,6 +368,17 @@ to undefine it if resolv.h defines it. */
 #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
 different to everyone else and there are also other systems which don't
 have netinet/ip_var.h, so there's a general macro to control its inclusion. */
@@ -377,12 +456,11 @@ extern int ferror(FILE *);
 
 /* The header from the PCRE regex package */
 
-#include "pcre/pcre.h"
+#include <pcre.h>
 
 /* 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"
@@ -402,6 +480,9 @@ mytypes.h and store.h, so we don't need to mention them explicitly. */
 #ifdef EXPERIMENTAL_SRS
 #include "srs.h"
 #endif
+#ifndef DISABLE_DKIM
+#include "dkim.h"
+#endif
 
 /* The following stuff must follow the inclusion of config.h because it
 requires various things that are set therein. */
@@ -410,10 +491,16 @@ requires various things that are set therein. */
 #include <iconv.h>
 #endif
 
-#ifdef USE_READLINE
+#if defined(USE_READLINE) || defined(EXPAND_DLFUNC) || defined (LOOKUP_MODULE_DIR)
 #include <dlfcn.h>
 #endif
 
+#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)
@@ -421,13 +508,15 @@ requires various things that are set therein. */
 #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
@@ -475,5 +564,4 @@ default to EDQUOT if it exists, otherwise ENOSPC. */
   #endif
 #endif
 
-
 /* End of exim.h */