build: use pkg-config for i18n
[exim.git] / src / src / mytypes.h
index 6d2f169b7fc342f9a68679cb87277322bb9e7cc5..598569d00462512eeb9f13022073a3a708b974e0 100644 (file)
@@ -2,8 +2,10 @@
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
+/* Copyright (c) The Exim Maintainers 2020 - 2023 */
 /* Copyright (c) University of Cambridge 1995 - 2018 */
 /* See the file NOTICE for conditions of use and distribution. */
 /* Copyright (c) University of Cambridge 1995 - 2018 */
 /* See the file NOTICE for conditions of use and distribution. */
+/* SPDX-License-Identifier: GPL-2.0-or-later */
 
 
 /* This header file contains type definitions and macros that I use as
 
 
 /* This header file contains type definitions and macros that I use as
@@ -28,29 +30,40 @@ local_scan.h includes it and exim.h includes them both (to get this earlier). */
 #endif
 
 
 #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. */
+/* We gave up on trying to get compilers to check on printf-like functions
+because they are both whiney about value sizes where they cannot do decent
+static analysis, and incapable of handling extensions to printf formats.
+The annotation on functions is still in place but does nothing. */
 
 #if defined(__GNUC__) || defined(__clang__)
 
 #if defined(__GNUC__) || defined(__clang__)
-# define PRINTF_FUNCTION(A,B)  __attribute__((format(printf,A,B)))
+/* #  define PRINTF_FUNCTION(A,B)      __attribute__((format(printf,A,B))) */
 # define ARG_UNUSED            __attribute__((__unused__))
 # define ARG_UNUSED            __attribute__((__unused__))
+# define FUNC_MAYBE_UNUSED     __attribute__((__unused__))
 # define WARN_UNUSED_RESULT    __attribute__((__warn_unused_result__))
 # define ALLOC                 __attribute__((malloc))
 # define WARN_UNUSED_RESULT    __attribute__((__warn_unused_result__))
 # define ALLOC                 __attribute__((malloc))
-# define ALLOC_SIZE(A)         __attribute__((alloc_size(A)))
 # define NORETURN              __attribute__((noreturn))
 # define NORETURN              __attribute__((noreturn))
+# ifndef __clang__
+#  define ALLOC_SIZE(A)                __attribute__((alloc_size(A)))
+# else
+#  define ALLOC_SIZE(A)                /**/
+# endif
 #else
 #else
-# define PRINTF_FUNCTION(A,B)
 # define ARG_UNUSED            /**/
 # define ARG_UNUSED            /**/
+# define FUNC_MAYBE_UNUSED     /**/
 # define WARN_UNUSED_RESULT    /**/
 # define ALLOC                 /**/
 # define ALLOC_SIZE(A)         /**/
 # define NORETURN              /**/
 #endif
 
 # define WARN_UNUSED_RESULT    /**/
 # define ALLOC                 /**/
 # define ALLOC_SIZE(A)         /**/
 # define NORETURN              /**/
 #endif
 
+#ifndef PRINTF_FUNCTION
+# define PRINTF_FUNCTION(A,B)  /**/
+#endif
+
 #ifdef WANT_DEEPER_PRINTF_CHECKS
 # define ALMOST_PRINTF(A, B) PRINTF_FUNCTION(A, B)
 #else
 #ifdef WANT_DEEPER_PRINTF_CHECKS
 # define ALMOST_PRINTF(A, B) PRINTF_FUNCTION(A, B)
 #else
-# define ALMOST_PRINTF(A, B)
+# define ALMOST_PRINTF(A, B)   /**/
 #endif
 
 
 #endif
 
 
@@ -104,7 +117,7 @@ functions that are called quite often; for other calls to external libraries
 #define Urename(s,t)       rename(CCS(s),CCS(t))
 #define Ustat(s,t)         stat(CCS(s),t)
 #define Ustrchr(s,n)       US strchr(CCS(s),n)
 #define Urename(s,t)       rename(CCS(s),CCS(t))
 #define Ustat(s,t)         stat(CCS(s),t)
 #define Ustrchr(s,n)       US strchr(CCS(s),n)
-#define CUstrchr(s,n)      CUS strchr(CCS(s),n)
+#define Ustrchrnul(s,n)    US strchrnul(CCS(s),n)
 #define CUstrerror(n)      CUS strerror(n)
 #define Ustrcmp(s,t)       strcmp(CCS(s),CCS(t))
 #define Ustrcpy_nt(s,t)    strcpy(CS s, CCS t)         /* no taint check */
 #define CUstrerror(n)      CUS strerror(n)
 #define Ustrcmp(s,t)       strcmp(CCS(s),CCS(t))
 #define Ustrcpy_nt(s,t)    strcpy(CS s, CCS t)         /* no taint check */
@@ -124,7 +137,7 @@ functions that are called quite often; for other calls to external libraries
 #define Ustrtoul(s,t,b)    strtoul(CCS(s),CSS(t),b)
 #define Uunlink(s)         unlink(CCS(s))
 
 #define Ustrtoul(s,t,b)    strtoul(CCS(s),CSS(t),b)
 #define Uunlink(s)         unlink(CCS(s))
 
-#ifdef EM_VERSION_C
+#if defined(EM_VERSION_C) || defined(LOCAL_SCAN) || defined(DLFUNC_IMPL)
 # define Ustrcat(s,t)       strcat(CS(s), CCS(t))
 # define Ustrcpy(s,t)       strcpy(CS(s), CCS(t))
 # define Ustrncat(s,t,n)    strncat(CS(s), CCS(t), n)
 # define Ustrcat(s,t)       strcat(CS(s), CCS(t))
 # define Ustrcpy(s,t)       strcpy(CS(s), CCS(t))
 # define Ustrncat(s,t,n)    strncat(CS(s), CCS(t), n)