1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) The Exim Maintainers 2020 - 2022 */
6 /* Copyright (c) Jeremy Harris 1995 - 2018 */
7 /* See the file NOTICE for conditions of use and distribution. */
8 /* SPDX-License-Identifier: GPL-2.0-or-later */
10 /* Create a static data structure with the predefined macros, to be
11 included in the main Exim build */
14 #include "macro_predef.h"
16 unsigned mp_index = 0;
18 /* Global dummy variables */
20 void fn_smtp_receive_timeout(const uschar * name, const uschar * str) {}
21 uschar * syslog_facility_str;
23 /******************************************************************************/
26 builtin_macro_create_var(const uschar * name, const uschar * val)
28 printf ("static macro_item p%d = { ", mp_index);
30 printf(".next=NULL,");
32 printf(".next=&p%d,", mp_index-1);
34 printf(" .command_line=FALSE, .namelen=%d, .replen=%d,"
35 " .name=US\"%s\", .replacement=US\"%s\" };\n",
36 Ustrlen(name), Ustrlen(val), CS name, CS val);
42 builtin_macro_create(const uschar * name)
44 builtin_macro_create_var(name, US"y");
48 /* restricted snprintf */
50 spf(uschar * buf, int len, const uschar * fmt, ...)
55 while (*fmt && len > 1)
56 if (*fmt == '%' && fmt[1] == 'T')
58 uschar * s = va_arg(ap, uschar *);
59 while (*s && len-- > 1)
60 *buf++ = toupper(*s++);
65 *buf++ = *fmt++; len--;
72 options_from_list(optionlist * opts, unsigned nopt,
73 const uschar * section, uschar * group)
76 uschar buf[EXIM_DRIVERNAME_MAX];
78 /* The 'previously-defined-substring' rule for macros in config file
79 lines is done thus for these builtin macros: we know that the table
80 we source from is in strict alpha order, hence the builtins portion
81 of the macros list is in reverse-alpha (we prepend them) - so longer
82 macros that have substrings are always discovered first during
85 for (int i = 0; i < nopt; i++) if (*(s = US opts[i].name) && *s != '*')
88 spf(buf, sizeof(buf), CUS"_OPT_%T_%T_%T", section, group, s);
90 spf(buf, sizeof(buf), CUS"_OPT_%T_%T", section, s);
91 builtin_macro_create(buf);
96 /******************************************************************************/
99 /* Create compile-time feature macros */
103 /* Probably we could work out a static initialiser for wherever
104 macros are stored, but this will do for now. Some names are awkward
105 due to conflicts with other common macros. */
107 #ifdef SUPPORT_CRYPTEQ
108 builtin_macro_create(US"_HAVE_CRYPTEQ");
111 builtin_macro_create(US"_HAVE_ICONV");
114 builtin_macro_create(US"_HAVE_IPV6");
116 #ifdef HAVE_SETCLASSRESOURCES
117 builtin_macro_create(US"_HAVE_SETCLASSRESOURCES");
120 builtin_macro_create(US"_HAVE_PAM");
123 builtin_macro_create(US"_HAVE_PERL");
126 builtin_macro_create(US"_HAVE_DLFUNC");
128 #ifdef USE_TCP_WRAPPERS
129 builtin_macro_create(US"_HAVE_TCPWRAPPERS");
132 builtin_macro_create(US"_HAVE_TLS");
134 builtin_macro_create(US"_HAVE_GNUTLS");
136 builtin_macro_create(US"_HAVE_OPENSSL");
139 #ifdef SUPPORT_TRANSLATE_IP_ADDRESS
140 builtin_macro_create(US"_HAVE_TRANSLATE_IP_ADDRESS");
142 #ifdef SUPPORT_MOVE_FROZEN_MESSAGES
143 builtin_macro_create(US"_HAVE_MOVE_FROZEN_MESSAGES");
145 #ifdef WITH_CONTENT_SCAN
146 builtin_macro_create(US"_HAVE_CONTENT_SCANNING");
149 builtin_macro_create(US"_HAVE_DKIM");
152 builtin_macro_create(US"_HAVE_DMARC");
154 #ifndef DISABLE_DNSSEC
155 builtin_macro_create(US"_HAVE_DNSSEC");
157 #ifndef DISABLE_EVENT
158 builtin_macro_create(US"_HAVE_EVENT");
161 builtin_macro_create(US"_HAVE_I18N");
164 builtin_macro_create(US"_HAVE_OCSP");
166 #ifndef DISABLE_PIPE_CONNECT
167 builtin_macro_create(US"_HAVE_PIPE_CONNECT");
170 builtin_macro_create(US"_HAVE_PRDR");
173 builtin_macro_create(US"_HAVE_PROXY");
176 builtin_macro_create(US"_HAVE_SOCKS");
178 #if defined(SUPPORT_SRS)
179 builtin_macro_create(US"_HAVE_NATIVE_SRS"); /* beware clash with _HAVE_SRS */
182 builtin_macro_create(US"_HAVE_TCP_FASTOPEN");
185 builtin_macro_create(US"_HAVE_SPF");
188 builtin_macro_create(US"_HAVE_SRS");
190 #ifdef EXPERIMENTAL_ARC
191 builtin_macro_create(US"_HAVE_ARC");
193 #ifdef EXPERIMENTAL_BRIGHTMAIL
194 builtin_macro_create(US"_HAVE_BRIGHTMAIL");
197 builtin_macro_create(US"_HAVE_DANE");
199 #ifdef EXPERIMENTAL_DCC
200 builtin_macro_create(US"_HAVE_DCC");
202 #ifdef EXPERIMENTAL_DSN_INFO
203 builtin_macro_create(US"_HAVE_DSN_INFO");
205 #ifndef DISABLE_TLS_RESUME
206 builtin_macro_create(US"_HAVE_TLS_RESUME");
209 #ifdef LOOKUP_LSEARCH
210 builtin_macro_create(US"_HAVE_LOOKUP_LSEARCH");
213 builtin_macro_create(US"_HAVE_LOOKUP_CDB");
216 builtin_macro_create(US"_HAVE_LOOKUP_DBM");
219 builtin_macro_create(US"_HAVE_LOOKUP_DNSDB");
221 #ifdef LOOKUP_DSEARCH
222 builtin_macro_create(US"_HAVE_LOOKUP_DSEARCH");
225 builtin_macro_create(US"_HAVE_LOOKUP_IBASE");
228 builtin_macro_create(US"_HAVE_LMDB");
229 builtin_macro_create(US"_HAVE_LOOKUP_LMDB");
232 builtin_macro_create(US"_HAVE_LOOKUP_JSON");
235 builtin_macro_create(US"_HAVE_LOOKUP_LDAP");
238 builtin_macro_create(US"_HAVE_LOOKUP_MYSQL");
241 builtin_macro_create(US"_HAVE_LOOKUP_NIS");
243 #ifdef LOOKUP_NISPLUS
244 builtin_macro_create(US"_HAVE_LOOKUP_NISPLUS");
247 builtin_macro_create(US"_HAVE_LOOKUP_ORACLE");
250 builtin_macro_create(US"_HAVE_LOOKUP_PASSWD");
253 builtin_macro_create(US"_HAVE_LOOKUP_PGSQL");
256 builtin_macro_create(US"_HAVE_LOOKUP_REDIS");
259 builtin_macro_create(US"_HAVE_LOOKUP_SQLITE");
262 builtin_macro_create(US"_HAVE_LOOKUP_TESTDB");
265 builtin_macro_create(US"_HAVE_LOOKUP_WHOSON");
268 #ifdef TRANSPORT_APPENDFILE
269 # ifdef SUPPORT_MAILDIR
270 builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILDIR");
272 # ifdef SUPPORT_MAILSTORE
273 builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILSTORE");
276 builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MBX");
283 #ifdef WITH_CONTENT_SCAN
291 #ifdef EXPERIMENTAL_ARC
292 builtin_macro_create(US"_EXP_ARC");
294 #ifdef EXPERIMENTAL_BRIGHTMAIL
295 builtin_macro_create(US"_EXP_BMI");
297 #ifdef EXPERIMENTAL_DCC
298 builtin_macro_create(US"_EXP_DCC");
300 #ifdef EXPERIMENTAL_DSN_INFO
301 builtin_macro_create(US"_EXP_DSNI");
303 #ifdef EXPERIMENTAL_ESMTP_LIMITS
304 builtin_macro_create(US"_EXP_LIMITS");
306 #ifdef EXPERIMENTAL_QUEUEFILE
307 builtin_macro_create(US"_EXP_QUEUEFILE");
317 options_transports();
337 printf("#include \"exim.h\"\n");
344 printf("macro_item * macros = &p%d;\n", mp_index-1);
345 printf("macro_item * mlast = &p0;\n");