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)
75 uschar buf[EXIM_DRIVERNAME_MAX];
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");
177 #if defined(SUPPORT_SRS)
178 builtin_macro_create(US"_HAVE_NATIVE_SRS"); /* beware clash with _HAVE_SRS */
181 builtin_macro_create(US"_HAVE_TCP_FASTOPEN");
184 builtin_macro_create(US"_HAVE_SPF");
186 #if defined(EXPERIMENTAL_SRS_ALT) || defined(SUPPORT_SRS)
187 builtin_macro_create(US"_HAVE_SRS");
189 #ifdef EXPERIMENTAL_ARC
190 builtin_macro_create(US"_HAVE_ARC");
192 #ifdef EXPERIMENTAL_BRIGHTMAIL
193 builtin_macro_create(US"_HAVE_BRIGHTMAIL");
196 builtin_macro_create(US"_HAVE_DANE");
198 #ifdef EXPERIMENTAL_DCC
199 builtin_macro_create(US"_HAVE_DCC");
201 #ifdef EXPERIMENTAL_DSN_INFO
202 builtin_macro_create(US"_HAVE_DSN_INFO");
204 #ifndef DISABLE_TLS_RESUME
205 builtin_macro_create(US"_HAVE_TLS_RESUME");
208 #ifdef LOOKUP_LSEARCH
209 builtin_macro_create(US"_HAVE_LOOKUP_LSEARCH");
212 builtin_macro_create(US"_HAVE_LOOKUP_CDB");
215 builtin_macro_create(US"_HAVE_LOOKUP_DBM");
218 builtin_macro_create(US"_HAVE_LOOKUP_DNSDB");
220 #ifdef LOOKUP_DSEARCH
221 builtin_macro_create(US"_HAVE_LOOKUP_DSEARCH");
224 builtin_macro_create(US"_HAVE_LOOKUP_IBASE");
227 builtin_macro_create(US"_HAVE_LMDB");
228 builtin_macro_create(US"_HAVE_LOOKUP_LMDB");
231 builtin_macro_create(US"_HAVE_LOOKUP_JSON");
234 builtin_macro_create(US"_HAVE_LOOKUP_LDAP");
236 #ifdef EXPERIMENTAL_LMDB
237 builtin_macro_create(US"_HAVE_LOOKUP_LMDB");
240 builtin_macro_create(US"_HAVE_LOOKUP_MYSQL");
243 builtin_macro_create(US"_HAVE_LOOKUP_NIS");
245 #ifdef LOOKUP_NISPLUS
246 builtin_macro_create(US"_HAVE_LOOKUP_NISPLUS");
249 builtin_macro_create(US"_HAVE_LOOKUP_ORACLE");
252 builtin_macro_create(US"_HAVE_LOOKUP_PASSWD");
255 builtin_macro_create(US"_HAVE_LOOKUP_PGSQL");
258 builtin_macro_create(US"_HAVE_LOOKUP_REDIS");
261 builtin_macro_create(US"_HAVE_LOOKUP_SQLITE");
264 builtin_macro_create(US"_HAVE_LOOKUP_TESTDB");
267 builtin_macro_create(US"_HAVE_LOOKUP_WHOSON");
270 #ifdef TRANSPORT_APPENDFILE
271 # ifdef SUPPORT_MAILDIR
272 builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILDIR");
274 # ifdef SUPPORT_MAILSTORE
275 builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILSTORE");
278 builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MBX");
285 #ifdef WITH_CONTENT_SCAN
293 #ifdef EXPERIMENTAL_ARC
294 builtin_macro_create(US"_EXP_ARC");
296 #ifdef EXPERIMENTAL_BRIGHTMAIL
297 builtin_macro_create(US"_EXP_BMI");
299 #ifdef EXPERIMENTAL_DCC
300 builtin_macro_create(US"_EXP_DCC");
302 #ifdef EXPERIMENTAL_DSN_INFO
303 builtin_macro_create(US"_EXP_DSNI");
305 #ifdef EXPERIMENTAL_ESMTP_LIMITS
306 builtin_macro_create(US"_EXP_LIMITS");
308 #ifdef EXPERIMENTAL_QUEUEFILE
309 builtin_macro_create(US"_EXP_QUEUEFILE");
311 #if defined(EXPERIMENTAL_SRS_ALT)
312 builtin_macro_create(US"_EXP_SRS");
322 options_transports();
342 printf("#include \"exim.h\"\n");
348 printf("macro_item * macros = &p%d;\n", mp_index-1);
349 printf("macro_item * mlast = &p0;\n");