1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) The Exim Maintainers 2020 - 2024 */
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");
122 #ifdef RADIUS_CONFIG_FILE
123 builtin_macro_create(US"_HAVE_RADIUS");
125 #ifdef CYRUS_PWCHECK_SOCKET
126 builtin_macro_create(US"_HAVE_PWCHECK");
129 builtin_macro_create(US"_HAVE_PERL");
132 builtin_macro_create(US"_HAVE_DLFUNC");
134 #ifdef USE_TCP_WRAPPERS
135 builtin_macro_create(US"_HAVE_TCPWRAPPERS");
138 builtin_macro_create(US"_HAVE_TLS");
140 builtin_macro_create(US"_HAVE_GNUTLS");
142 builtin_macro_create(US"_HAVE_OPENSSL");
145 #ifdef SUPPORT_TRANSLATE_IP_ADDRESS
146 builtin_macro_create(US"_HAVE_TRANSLATE_IP_ADDRESS");
148 #ifdef SUPPORT_MOVE_FROZEN_MESSAGES
149 builtin_macro_create(US"_HAVE_MOVE_FROZEN_MESSAGES");
151 #ifdef WITH_CONTENT_SCAN
152 builtin_macro_create(US"_HAVE_CONTENT_SCANNING");
155 builtin_macro_create(US"_HAVE_DKIM");
158 builtin_macro_create(US"_HAVE_DMARC");
160 #ifndef DISABLE_DNSSEC
161 builtin_macro_create(US"_HAVE_DNSSEC");
163 #ifndef DISABLE_ESMTP_LIMITS
164 builtin_macro_create(US"_HAVE_ESMTP_LIMITS");
166 #ifndef DISABLE_EVENT
167 builtin_macro_create(US"_HAVE_EVENT");
170 builtin_macro_create(US"_HAVE_I18N");
173 builtin_macro_create(US"_HAVE_OCSP");
175 #ifndef DISABLE_PIPE_CONNECT
176 builtin_macro_create(US"_HAVE_PIPE_CONNECT");
179 builtin_macro_create(US"_HAVE_PRDR");
182 builtin_macro_create(US"_HAVE_PROXY");
185 builtin_macro_create(US"_HAVE_SOCKS");
187 #if defined(SUPPORT_SRS)
188 builtin_macro_create(US"_HAVE_NATIVE_SRS"); /* beware clash with _HAVE_SRS */
191 builtin_macro_create(US"_HAVE_TCP_FASTOPEN");
194 builtin_macro_create(US"_HAVE_SPF");
197 builtin_macro_create(US"_HAVE_SRS");
199 #ifdef EXPERIMENTAL_ARC
200 builtin_macro_create(US"_HAVE_ARC");
202 #ifdef EXPERIMENTAL_BRIGHTMAIL
203 builtin_macro_create(US"_HAVE_BRIGHTMAIL");
206 builtin_macro_create(US"_HAVE_DANE");
208 #ifdef EXPERIMENTAL_DCC
209 builtin_macro_create(US"_HAVE_DCC");
211 #ifdef EXPERIMENTAL_DSN_INFO
212 builtin_macro_create(US"_HAVE_DSN_INFO");
214 #ifndef DISABLE_TLS_RESUME
215 builtin_macro_create(US"_HAVE_TLS_RESUME");
217 #ifndef DISABLE_WELLKNOWN
218 builtin_macro_create(US"_HAVE_WELLKNOWN");
220 #ifdef EXPERIMENTAL_XCLIENT
221 builtin_macro_create(US"_HAVE_XCLIENT");
224 #ifdef LOOKUP_LSEARCH
225 builtin_macro_create(US"_HAVE_LOOKUP_LSEARCH");
228 builtin_macro_create(US"_HAVE_LOOKUP_CDB");
231 builtin_macro_create(US"_HAVE_LOOKUP_DBM");
234 builtin_macro_create(US"_HAVE_LOOKUP_DNSDB");
236 #ifdef LOOKUP_DSEARCH
237 builtin_macro_create(US"_HAVE_LOOKUP_DSEARCH");
240 builtin_macro_create(US"_HAVE_LOOKUP_IBASE");
243 builtin_macro_create(US"_HAVE_LMDB");
244 builtin_macro_create(US"_HAVE_LOOKUP_LMDB");
247 builtin_macro_create(US"_HAVE_LOOKUP_JSON");
250 builtin_macro_create(US"_HAVE_LOOKUP_LDAP");
253 builtin_macro_create(US"_HAVE_LOOKUP_MYSQL");
256 builtin_macro_create(US"_HAVE_LOOKUP_NIS");
258 #ifdef LOOKUP_NISPLUS
259 builtin_macro_create(US"_HAVE_LOOKUP_NISPLUS");
262 builtin_macro_create(US"_HAVE_LOOKUP_ORACLE");
265 builtin_macro_create(US"_HAVE_LOOKUP_PASSWD");
268 builtin_macro_create(US"_HAVE_LOOKUP_PGSQL");
271 builtin_macro_create(US"_HAVE_LOOKUP_REDIS");
274 builtin_macro_create(US"_HAVE_LOOKUP_SQLITE");
277 builtin_macro_create(US"_HAVE_LOOKUP_TESTDB");
280 builtin_macro_create(US"_HAVE_LOOKUP_WHOSON");
283 #ifdef TRANSPORT_APPENDFILE
284 # ifdef SUPPORT_MAILDIR
285 builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILDIR");
287 # ifdef SUPPORT_MAILSTORE
288 builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILSTORE");
291 builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MBX");
298 #ifdef WITH_CONTENT_SCAN
306 #ifdef EXPERIMENTAL_ARC
307 builtin_macro_create(US"_EXP_ARC");
309 #ifdef EXPERIMENTAL_BRIGHTMAIL
310 builtin_macro_create(US"_EXP_BMI");
312 #ifdef EXPERIMENTAL_DCC
313 builtin_macro_create(US"_EXP_DCC");
315 #ifdef EXPERIMENTAL_DSN_INFO
316 builtin_macro_create(US"_EXP_DSNI");
318 #ifdef EXPERIMENTAL_QUEUEFILE
319 builtin_macro_create(US"_EXP_QUEUEFILE");
329 options_transports();
349 printf("#include \"exim.h\"\n");
356 printf("macro_item * macros = &p%d;\n", mp_index-1);
357 printf("macro_item * mlast = &p0;\n");