1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) Jeremy Harris 1995 - 2018 */
6 /* Copyright (c) The Exim Maintainers 2020 */
7 /* See the file NOTICE for conditions of use and distribution. */
9 /* Create a static data structure with the predefined macros, to be
10 included in the main Exim build */
13 #include "macro_predef.h"
15 unsigned mp_index = 0;
17 /* Global dummy variables */
19 void fn_smtp_receive_timeout(const uschar * name, const uschar * str) {}
20 uschar * syslog_facility_str;
22 /******************************************************************************/
25 builtin_macro_create_var(const uschar * name, const uschar * val)
27 printf ("static macro_item p%d = { ", mp_index);
29 printf(".next=NULL,");
31 printf(".next=&p%d,", mp_index-1);
33 printf(" .command_line=FALSE, .namelen=%d, .replen=%d,"
34 " .name=US\"%s\", .replacement=US\"%s\" };\n",
35 Ustrlen(name), Ustrlen(val), CS name, CS val);
41 builtin_macro_create(const uschar * name)
43 builtin_macro_create_var(name, US"y");
47 /* restricted snprintf */
49 spf(uschar * buf, int len, const uschar * fmt, ...)
54 while (*fmt && len > 1)
55 if (*fmt == '%' && fmt[1] == 'T')
57 uschar * s = va_arg(ap, uschar *);
58 while (*s && len-- > 1)
59 *buf++ = toupper(*s++);
64 *buf++ = *fmt++; len--;
71 options_from_list(optionlist * opts, unsigned nopt,
72 const uschar * section, uschar * group)
77 /* The 'previously-defined-substring' rule for macros in config file
78 lines is done thus for these builtin macros: we know that the table
79 we source from is in strict alpha order, hence the builtins portion
80 of the macros list is in reverse-alpha (we prepend them) - so longer
81 macros that have substrings are always discovered first during
84 for (int i = 0; i < nopt; i++) if (*(s = US opts[i].name) && *s != '*')
87 spf(buf, sizeof(buf), CUS"_OPT_%T_%T_%T", section, group, s);
89 spf(buf, sizeof(buf), CUS"_OPT_%T_%T", section, s);
90 builtin_macro_create(buf);
95 /******************************************************************************/
98 /* Create compile-time feature macros */
102 /* Probably we could work out a static initialiser for wherever
103 macros are stored, but this will do for now. Some names are awkward
104 due to conflicts with other common macros. */
106 #ifdef SUPPORT_CRYPTEQ
107 builtin_macro_create(US"_HAVE_CRYPTEQ");
110 builtin_macro_create(US"_HAVE_ICONV");
113 builtin_macro_create(US"_HAVE_IPV6");
115 #ifdef HAVE_SETCLASSRESOURCES
116 builtin_macro_create(US"_HAVE_SETCLASSRESOURCES");
119 builtin_macro_create(US"_HAVE_PAM");
122 builtin_macro_create(US"_HAVE_PERL");
125 builtin_macro_create(US"_HAVE_DLFUNC");
127 #ifdef USE_TCP_WRAPPERS
128 builtin_macro_create(US"_HAVE_TCPWRAPPERS");
131 builtin_macro_create(US"_HAVE_TLS");
133 builtin_macro_create(US"_HAVE_GNUTLS");
135 builtin_macro_create(US"_HAVE_OPENSSL");
138 #ifdef SUPPORT_TRANSLATE_IP_ADDRESS
139 builtin_macro_create(US"_HAVE_TRANSLATE_IP_ADDRESS");
141 #ifdef SUPPORT_MOVE_FROZEN_MESSAGES
142 builtin_macro_create(US"_HAVE_MOVE_FROZEN_MESSAGES");
144 #ifdef WITH_CONTENT_SCAN
145 builtin_macro_create(US"_HAVE_CONTENT_SCANNING");
148 builtin_macro_create(US"_HAVE_DKIM");
151 builtin_macro_create(US"_HAVE_DMARC");
153 #ifndef DISABLE_DNSSEC
154 builtin_macro_create(US"_HAVE_DNSSEC");
156 #ifndef DISABLE_EVENT
157 builtin_macro_create(US"_HAVE_EVENT");
160 builtin_macro_create(US"_HAVE_I18N");
163 builtin_macro_create(US"_HAVE_OCSP");
165 #ifndef DISABLE_PIPE_CONNECT
166 builtin_macro_create(US"_HAVE_PIPE_CONNECT");
169 builtin_macro_create(US"_HAVE_PRDR");
172 builtin_macro_create(US"_HAVE_PROXY");
175 builtin_macro_create(US"_HAVE_SOCKS");
178 builtin_macro_create(US"_HAVE_TCP_FASTOPEN");
180 #ifdef EXPERIMENTAL_LMDB
181 builtin_macro_create(US"_HAVE_LMDB");
184 builtin_macro_create(US"_HAVE_SPF");
186 #if defined(EXPERIMENTAL_SRS_ALT) || defined(EXPERIMENTAL_SRS_NATIVE)
187 builtin_macro_create(US"_HAVE_SRS");
189 #if defined(EXPERIMENTAL_SRS_NATIVE)
190 builtin_macro_create(US"_HAVE_NATIVE_SRS"); /* beware clash with _HAVE_SRS */
192 #ifdef EXPERIMENTAL_ARC
193 builtin_macro_create(US"_HAVE_ARC");
195 #ifdef EXPERIMENTAL_BRIGHTMAIL
196 builtin_macro_create(US"_HAVE_BRIGHTMAIL");
199 builtin_macro_create(US"_HAVE_DANE");
201 #ifdef EXPERIMENTAL_DCC
202 builtin_macro_create(US"_HAVE_DCC");
204 #ifdef EXPERIMENTAL_DSN_INFO
205 builtin_macro_create(US"_HAVE_DSN_INFO");
207 #ifdef EXPERIMENTAL_TLS_RESUME
208 builtin_macro_create(US"_HAVE_TLS_RESUME");
211 #ifdef LOOKUP_LSEARCH
212 builtin_macro_create(US"_HAVE_LOOKUP_LSEARCH");
215 builtin_macro_create(US"_HAVE_LOOKUP_CDB");
218 builtin_macro_create(US"_HAVE_LOOKUP_DBM");
221 builtin_macro_create(US"_HAVE_LOOKUP_DNSDB");
223 #ifdef LOOKUP_DSEARCH
224 builtin_macro_create(US"_HAVE_LOOKUP_DSEARCH");
227 builtin_macro_create(US"_HAVE_LOOKUP_IBASE");
230 builtin_macro_create(US"_HAVE_LOOKUP_JSON");
233 builtin_macro_create(US"_HAVE_LOOKUP_LDAP");
235 #ifdef EXPERIMENTAL_LMDB
236 builtin_macro_create(US"_HAVE_LOOKUP_LMDB");
239 builtin_macro_create(US"_HAVE_LOOKUP_MYSQL");
242 builtin_macro_create(US"_HAVE_LOOKUP_NIS");
244 #ifdef LOOKUP_NISPLUS
245 builtin_macro_create(US"_HAVE_LOOKUP_NISPLUS");
248 builtin_macro_create(US"_HAVE_LOOKUP_ORACLE");
251 builtin_macro_create(US"_HAVE_LOOKUP_PASSWD");
254 builtin_macro_create(US"_HAVE_LOOKUP_PGSQL");
257 builtin_macro_create(US"_HAVE_LOOKUP_REDIS");
260 builtin_macro_create(US"_HAVE_LOOKUP_SQLITE");
263 builtin_macro_create(US"_HAVE_LOOKUP_TESTDB");
266 builtin_macro_create(US"_HAVE_LOOKUP_WHOSON");
269 #ifdef TRANSPORT_APPENDFILE
270 # ifdef SUPPORT_MAILDIR
271 builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILDIR");
273 # ifdef SUPPORT_MAILSTORE
274 builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILSTORE");
277 builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MBX");
281 #ifdef WITH_CONTENT_SCAN
294 options_transports();
314 printf("#include \"exim.h\"\n");
319 printf("macro_item * macros = &p%d;\n", mp_index-1);
320 printf("macro_item * mlast = &p0;\n");