1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) Jeremy Harris 2017 */
6 /* See the file NOTICE for conditions of use and distribution. */
8 /* Create a static data structure with the predefined macros, to be
9 included in the main Exim build */
12 #include "macro_predef.h"
14 unsigned mp_index = 0;
16 /* Global dummy variables */
18 void fn_smtp_receive_timeout(const uschar * name, const uschar * str) {}
19 uschar * syslog_facility_str;
21 /******************************************************************************/
24 builtin_macro_create_var(const uschar * name, const uschar * val)
26 printf ("static macro_item p%d = { ", mp_index);
28 printf(".next=NULL,");
30 printf(".next=&p%d,", mp_index-1);
32 printf(" .command_line=FALSE, .namelen=%d, .replen=%d,"
33 " .name=US\"%s\", .replacement=US\"%s\" };\n",
34 Ustrlen(name), Ustrlen(val), CS name, CS val);
40 builtin_macro_create(const uschar * name)
42 builtin_macro_create_var(name, US"y");
46 /* restricted snprintf */
48 spf(uschar * buf, int len, const uschar * fmt, ...)
53 while (*fmt && len > 1)
54 if (*fmt == '%' && fmt[1] == 'T')
56 uschar * s = va_arg(ap, uschar *);
57 while (*s && len-- > 1)
58 *buf++ = toupper(*s++);
63 *buf++ = *fmt++; len--;
70 options_from_list(optionlist * opts, unsigned nopt,
71 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 (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");
150 #ifndef DISABLE_DNSSEC
151 builtin_macro_create(US"_HAVE_DNSSEC");
153 #ifndef DISABLE_EVENT
154 builtin_macro_create(US"_HAVE_EVENT");
157 builtin_macro_create(US"_HAVE_I18N");
160 builtin_macro_create(US"_HAVE_OCSP");
163 builtin_macro_create(US"_HAVE_PRDR");
166 builtin_macro_create(US"_HAVE_PROXY");
169 builtin_macro_create(US"_HAVE_SOCKS");
172 builtin_macro_create(US"_HAVE_TCP_FASTOPEN");
174 #ifdef EXPERIMENTAL_LMDB
175 builtin_macro_create(US"_HAVE_LMDB");
178 builtin_macro_create(US"_HAVE_SPF");
180 #ifdef EXPERIMENTAL_SRS
181 builtin_macro_create(US"_HAVE_SRS");
183 #ifdef EXPERIMENTAL_BRIGHTMAIL
184 builtin_macro_create(US"_HAVE_BRIGHTMAIL");
186 #ifdef EXPERIMENTAL_DANE
187 builtin_macro_create(US"_HAVE_DANE");
189 #ifdef EXPERIMENTAL_DCC
190 builtin_macro_create(US"_HAVE_DCC");
192 #ifdef EXPERIMENTAL_DMARC
193 builtin_macro_create(US"_HAVE_DMARC");
195 #ifdef EXPERIMENTAL_DSN_INFO
196 builtin_macro_create(US"_HAVE_DSN_INFO");
199 #ifdef LOOKUP_LSEARCH
200 builtin_macro_create(US"_HAVE_LOOKUP_LSEARCH");
203 builtin_macro_create(US"_HAVE_LOOKUP_CDB");
206 builtin_macro_create(US"_HAVE_LOOKUP_DBM");
209 builtin_macro_create(US"_HAVE_LOOKUP_DNSDB");
211 #ifdef LOOKUP_DSEARCH
212 builtin_macro_create(US"_HAVE_LOOKUP_DSEARCH");
215 builtin_macro_create(US"_HAVE_LOOKUP_IBASE");
218 builtin_macro_create(US"_HAVE_LOOKUP_LDAP");
220 #ifdef EXPERIMENTAL_LMDB
221 builtin_macro_create(US"_HAVE_LOOKUP_LMDB");
224 builtin_macro_create(US"_HAVE_LOOKUP_MYSQL");
227 builtin_macro_create(US"_HAVE_LOOKUP_NIS");
229 #ifdef LOOKUP_NISPLUS
230 builtin_macro_create(US"_HAVE_LOOKUP_NISPLUS");
233 builtin_macro_create(US"_HAVE_LOOKUP_ORACLE");
236 builtin_macro_create(US"_HAVE_LOOKUP_PASSWD");
239 builtin_macro_create(US"_HAVE_LOOKUP_PGSQL");
242 builtin_macro_create(US"_HAVE_LOOKUP_REDIS");
245 builtin_macro_create(US"_HAVE_LOOKUP_SQLITE");
248 builtin_macro_create(US"_HAVE_LOOKUP_TESTDB");
251 builtin_macro_create(US"_HAVE_LOOKUP_WHOSON");
254 #ifdef TRANSPORT_APPENDFILE
255 # ifdef SUPPORT_MAILDIR
256 builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILDIR");
258 # ifdef SUPPORT_MAILSTORE
259 builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILSTORE");
262 builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MBX");
266 #ifdef WITH_CONTENT_SCAN
277 options_transports();
293 printf("#include \"exim.h\"\n");
298 printf("macro_item * macros = &p%d;\n", mp_index-1);
299 printf("macro_item * mlast = &p0;\n");