Make BOOL unsigned; fix resulting latent bugs
[exim.git] / src / src / mytypes.h
index 18d5e8046c0d08bb587a2b957cecb6fa7b3da153..b288a32cbcb8e47c6cb54489a3b52a153f5c022d 100644 (file)
@@ -1,10 +1,8 @@
-/* $Cambridge: exim/src/src/mytypes.h,v 1.1 2004/10/07 10:39:01 ph10 Exp $ */
-
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2004 */
+/* Copyright (c) University of Cambridge 1995 - 2015 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 
@@ -15,19 +13,34 @@ local_scan.h includes it and exim.h includes them both (to get this earlier). */
 #ifndef MYTYPES_H
 #define MYTYPES_H
 
+#ifndef FALSE
+# define FALSE         0
+#endif
+
+#ifndef TRUE
+# define TRUE          1
+#endif
 
-#define FALSE         0
-#define TRUE          1
-#define TRUE_UNSET    2
+#ifndef TRUE_UNSET
+# define TRUE_UNSET    2
+#endif
 
 
 /* If gcc is being used to compile Exim, we can use its facility for checking
 the arguments of printf-like functions. This is done by a macro. */
 
-#ifdef __GNUC__
-#define PRINTF_FUNCTION  __attribute__((format(printf,1,2)))
+#if defined(__GNUC__) || defined(__clang__)
+# define PRINTF_FUNCTION(A,B)  __attribute__((format(printf,A,B)))
+# define ARG_UNUSED  __attribute__((__unused__))
+#else
+# define PRINTF_FUNCTION(A,B)
+# define ARG_UNUSED  /**/
+#endif
+
+#ifdef WANT_DEEPER_PRINTF_CHECKS
+# define ALMOST_PRINTF(A, B) PRINTF_FUNCTION(A, B)
 #else
-#define PRINTF_FUNCTION
+# define ALMOST_PRINTF(A, B)
 #endif
 
 
@@ -35,8 +48,10 @@ the arguments of printf-like functions. This is done by a macro. */
 the standard header files, so we use "uschar". Solaris has u_char in
 sys/types.h. This is just a typing convenience, of course. */
 
-typedef int BOOL;
 typedef unsigned char uschar;
+typedef unsigned BOOL;
+/* We also have SIGNAL_BOOL, which requires signal.h be included, so is defined
+elsewhere */
 
 
 /* These macros save typing for the casting that is needed to cope with the
@@ -51,6 +66,7 @@ almost always literal strings. */
 #define US   (unsigned char *)
 #define CUS  (const unsigned char *)
 #define USS  (unsigned char **)
+#define CUSS (const unsigned char **)
 
 /* The C library string functions expect "char *" arguments. Use macros to
 avoid having to write a cast each time. We do this for string and file