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(const uschar
* name
)
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=1,"
33 " .name=US\"%s\", .replacement=US\"y\" };\n",
34 Ustrlen(name
), CS name
);
39 spf(uschar
* buf
, int len
, const uschar
* fmt
, ...)
44 while (*fmt
&& len
> 1)
45 if (*fmt
== '%' && fmt
[1] == 'T')
47 uschar
* s
= va_arg(ap
, uschar
*);
48 while (*s
&& len
-- > 1)
49 *buf
++ = toupper(*s
++);
54 *buf
++ = *fmt
++; len
--;
61 options_from_list(optionlist
* opts
, unsigned nopt
,
62 const uschar
* section
, uschar
* group
)
68 /* The 'previously-defined-substring' rule for macros in config file
69 lines is done thus for these builtin macros: we know that the table
70 we source from is in strict alpha order, hence the builtins portion
71 of the macros list is in reverse-alpha (we prepend them) - so longer
72 macros that have substrings are always discovered first during
75 for (i
= 0; i
< nopt
; i
++) if (*(s
= US opts
[i
].name
) && *s
!= '*')
78 spf(buf
, sizeof(buf
), CUS
"_OPT_%T_%T_%T", section
, group
, s
);
80 spf(buf
, sizeof(buf
), CUS
"_OPT_%T_%T", section
, s
);
81 builtin_macro_create(buf
);
86 /******************************************************************************/
89 /* Create compile-time feature macros */
93 /* Probably we could work out a static initialiser for wherever
94 macros are stored, but this will do for now. Some names are awkward
95 due to conflicts with other common macros. */
97 #ifdef SUPPORT_CRYPTEQ
98 builtin_macro_create(US
"_HAVE_CRYPTEQ");
101 builtin_macro_create(US
"_HAVE_ICONV");
104 builtin_macro_create(US
"_HAVE_IPV6");
106 #ifdef HAVE_SETCLASSRESOURCES
107 builtin_macro_create(US
"_HAVE_SETCLASSRESOURCES");
110 builtin_macro_create(US
"_HAVE_PAM");
113 builtin_macro_create(US
"_HAVE_PERL");
116 builtin_macro_create(US
"_HAVE_DLFUNC");
118 #ifdef USE_TCP_WRAPPERS
119 builtin_macro_create(US
"_HAVE_TCPWRAPPERS");
122 builtin_macro_create(US
"_HAVE_TLS");
124 builtin_macro_create(US
"_HAVE_GNUTLS");
126 builtin_macro_create(US
"_HAVE_OPENSSL");
129 #ifdef SUPPORT_TRANSLATE_IP_ADDRESS
130 builtin_macro_create(US
"_HAVE_TRANSLATE_IP_ADDRESS");
132 #ifdef SUPPORT_MOVE_FROZEN_MESSAGES
133 builtin_macro_create(US
"_HAVE_MOVE_FROZEN_MESSAGES");
135 #ifdef WITH_CONTENT_SCAN
136 builtin_macro_create(US
"_HAVE_CONTENT_SCANNING");
139 builtin_macro_create(US
"_HAVE_DKIM");
141 #ifndef DISABLE_DNSSEC
142 builtin_macro_create(US
"_HAVE_DNSSEC");
144 #ifndef DISABLE_EVENT
145 builtin_macro_create(US
"_HAVE_EVENT");
148 builtin_macro_create(US
"_HAVE_I18N");
151 builtin_macro_create(US
"_HAVE_OCSP");
154 builtin_macro_create(US
"_HAVE_PRDR");
157 builtin_macro_create(US
"_HAVE_PROXY");
160 builtin_macro_create(US
"_HAVE_SOCKS");
163 builtin_macro_create(US
"_HAVE_TCP_FASTOPEN");
165 #ifdef EXPERIMENTAL_LMDB
166 builtin_macro_create(US
"_HAVE_LMDB");
168 #ifdef EXPERIMENTAL_SPF
169 builtin_macro_create(US
"_HAVE_SPF");
171 #ifdef EXPERIMENTAL_SRS
172 builtin_macro_create(US
"_HAVE_SRS");
174 #ifdef EXPERIMENTAL_BRIGHTMAIL
175 builtin_macro_create(US
"_HAVE_BRIGHTMAIL");
177 #ifdef EXPERIMENTAL_DANE
178 builtin_macro_create(US
"_HAVE_DANE");
180 #ifdef EXPERIMENTAL_DCC
181 builtin_macro_create(US
"_HAVE_DCC");
183 #ifdef EXPERIMENTAL_DMARC
184 builtin_macro_create(US
"_HAVE_DMARC");
186 #ifdef EXPERIMENTAL_DSN_INFO
187 builtin_macro_create(US
"_HAVE_DSN_INFO");
190 #ifdef LOOKUP_LSEARCH
191 builtin_macro_create(US
"_HAVE_LOOKUP_LSEARCH");
194 builtin_macro_create(US
"_HAVE_LOOKUP_CDB");
197 builtin_macro_create(US
"_HAVE_LOOKUP_DBM");
200 builtin_macro_create(US
"_HAVE_LOOKUP_DNSDB");
202 #ifdef LOOKUP_DSEARCH
203 builtin_macro_create(US
"_HAVE_LOOKUP_DSEARCH");
206 builtin_macro_create(US
"_HAVE_LOOKUP_IBASE");
209 builtin_macro_create(US
"_HAVE_LOOKUP_LDAP");
211 #ifdef EXPERIMENTAL_LMDB
212 builtin_macro_create(US
"_HAVE_LOOKUP_LMDB");
215 builtin_macro_create(US
"_HAVE_LOOKUP_MYSQL");
218 builtin_macro_create(US
"_HAVE_LOOKUP_NIS");
220 #ifdef LOOKUP_NISPLUS
221 builtin_macro_create(US
"_HAVE_LOOKUP_NISPLUS");
224 builtin_macro_create(US
"_HAVE_LOOKUP_ORACLE");
227 builtin_macro_create(US
"_HAVE_LOOKUP_PASSWD");
230 builtin_macro_create(US
"_HAVE_LOOKUP_PGSQL");
233 builtin_macro_create(US
"_HAVE_LOOKUP_REDIS");
236 builtin_macro_create(US
"_HAVE_LOOKUP_SQLITE");
239 builtin_macro_create(US
"_HAVE_LOOKUP_TESTDB");
242 builtin_macro_create(US
"_HAVE_LOOKUP_WHOSON");
245 #ifdef TRANSPORT_APPENDFILE
246 # ifdef SUPPORT_MAILDIR
247 builtin_macro_create(US
"_HAVE_TRANSPORT_APPEND_MAILDIR");
249 # ifdef SUPPORT_MAILSTORE
250 builtin_macro_create(US
"_HAVE_TRANSPORT_APPEND_MAILSTORE");
253 builtin_macro_create(US
"_HAVE_TRANSPORT_APPEND_MBX");
264 options_transports();
272 printf("#include \"exim.h\"\n");
276 printf("macro_item * macros = &p%d;\n", mp_index
-1);
277 printf("macro_item * mlast = &p0;\n");