Commit | Line | Data |
---|---|---|
d185889f JH |
1 | /************************************************* |
2 | * Exim - an Internet mail transport agent * | |
3 | *************************************************/ | |
4 | ||
f9ba5e22 | 5 | /* Copyright (c) Jeremy Harris 1995 - 2018 */ |
d185889f JH |
6 | /* See the file NOTICE for conditions of use and distribution. */ |
7 | ||
8 | /* Create a static data structure with the predefined macros, to be | |
9 | included in the main Exim build */ | |
10 | ||
11 | #include "exim.h" | |
5f69a529 | 12 | #include "macro_predef.h" |
d185889f | 13 | |
1a7c9a48 | 14 | unsigned mp_index = 0; |
d185889f JH |
15 | |
16 | /* Global dummy variables */ | |
17 | ||
18 | void fn_smtp_receive_timeout(const uschar * name, const uschar * str) {} | |
19 | uschar * syslog_facility_str; | |
20 | ||
21 | /******************************************************************************/ | |
22 | ||
23 | void | |
970424a5 | 24 | builtin_macro_create_var(const uschar * name, const uschar * val) |
d185889f | 25 | { |
1a7c9a48 JH |
26 | printf ("static macro_item p%d = { ", mp_index); |
27 | if (mp_index == 0) | |
28 | printf(".next=NULL,"); | |
29 | else | |
30 | printf(".next=&p%d,", mp_index-1); | |
31 | ||
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); | |
35 | mp_index++; | |
d185889f JH |
36 | } |
37 | ||
970424a5 JH |
38 | |
39 | void | |
40 | builtin_macro_create(const uschar * name) | |
41 | { | |
42 | builtin_macro_create_var(name, US"y"); | |
43 | } | |
44 | ||
45 | ||
c11d665d | 46 | /* restricted snprintf */ |
f1f7d0cd | 47 | void |
d185889f JH |
48 | spf(uschar * buf, int len, const uschar * fmt, ...) |
49 | { | |
50 | va_list ap; | |
51 | va_start(ap, fmt); | |
52 | ||
53 | while (*fmt && len > 1) | |
54 | if (*fmt == '%' && fmt[1] == 'T') | |
55 | { | |
56 | uschar * s = va_arg(ap, uschar *); | |
57 | while (*s && len-- > 1) | |
58 | *buf++ = toupper(*s++); | |
59 | fmt += 2; | |
60 | } | |
61 | else | |
62 | { | |
63 | *buf++ = *fmt++; len--; | |
64 | } | |
65 | *buf = '\0'; | |
66 | va_end(ap); | |
67 | } | |
68 | ||
69 | void | |
70 | options_from_list(optionlist * opts, unsigned nopt, | |
71 | const uschar * section, uschar * group) | |
72 | { | |
d185889f JH |
73 | const uschar * s; |
74 | uschar buf[64]; | |
75 | ||
76 | /* The 'previously-defined-substring' rule for macros in config file | |
77 | lines is done thus for these builtin macros: we know that the table | |
78 | we source from is in strict alpha order, hence the builtins portion | |
79 | of the macros list is in reverse-alpha (we prepend them) - so longer | |
80 | macros that have substrings are always discovered first during | |
81 | expansion. */ | |
82 | ||
db3f7b69 | 83 | for (int i = 0; i < nopt; i++) if (*(s = US opts[i].name) && *s != '*') |
d185889f JH |
84 | { |
85 | if (group) | |
f1f7d0cd | 86 | spf(buf, sizeof(buf), CUS"_OPT_%T_%T_%T", section, group, s); |
d185889f | 87 | else |
f1f7d0cd | 88 | spf(buf, sizeof(buf), CUS"_OPT_%T_%T", section, s); |
d185889f JH |
89 | builtin_macro_create(buf); |
90 | } | |
91 | } | |
92 | ||
93 | ||
94 | /******************************************************************************/ | |
95 | ||
96 | ||
97 | /* Create compile-time feature macros */ | |
98 | static void | |
99 | features(void) | |
100 | { | |
101 | /* Probably we could work out a static initialiser for wherever | |
102 | macros are stored, but this will do for now. Some names are awkward | |
103 | due to conflicts with other common macros. */ | |
104 | ||
105 | #ifdef SUPPORT_CRYPTEQ | |
106 | builtin_macro_create(US"_HAVE_CRYPTEQ"); | |
107 | #endif | |
108 | #if HAVE_ICONV | |
109 | builtin_macro_create(US"_HAVE_ICONV"); | |
110 | #endif | |
111 | #if HAVE_IPV6 | |
112 | builtin_macro_create(US"_HAVE_IPV6"); | |
113 | #endif | |
114 | #ifdef HAVE_SETCLASSRESOURCES | |
115 | builtin_macro_create(US"_HAVE_SETCLASSRESOURCES"); | |
116 | #endif | |
117 | #ifdef SUPPORT_PAM | |
118 | builtin_macro_create(US"_HAVE_PAM"); | |
119 | #endif | |
120 | #ifdef EXIM_PERL | |
121 | builtin_macro_create(US"_HAVE_PERL"); | |
122 | #endif | |
123 | #ifdef EXPAND_DLFUNC | |
124 | builtin_macro_create(US"_HAVE_DLFUNC"); | |
125 | #endif | |
126 | #ifdef USE_TCP_WRAPPERS | |
127 | builtin_macro_create(US"_HAVE_TCPWRAPPERS"); | |
128 | #endif | |
129 | #ifdef SUPPORT_TLS | |
130 | builtin_macro_create(US"_HAVE_TLS"); | |
131 | # ifdef USE_GNUTLS | |
132 | builtin_macro_create(US"_HAVE_GNUTLS"); | |
133 | # else | |
134 | builtin_macro_create(US"_HAVE_OPENSSL"); | |
135 | # endif | |
136 | #endif | |
137 | #ifdef SUPPORT_TRANSLATE_IP_ADDRESS | |
138 | builtin_macro_create(US"_HAVE_TRANSLATE_IP_ADDRESS"); | |
139 | #endif | |
140 | #ifdef SUPPORT_MOVE_FROZEN_MESSAGES | |
141 | builtin_macro_create(US"_HAVE_MOVE_FROZEN_MESSAGES"); | |
142 | #endif | |
143 | #ifdef WITH_CONTENT_SCAN | |
144 | builtin_macro_create(US"_HAVE_CONTENT_SCANNING"); | |
145 | #endif | |
146 | #ifndef DISABLE_DKIM | |
147 | builtin_macro_create(US"_HAVE_DKIM"); | |
148 | #endif | |
149 | #ifndef DISABLE_DNSSEC | |
150 | builtin_macro_create(US"_HAVE_DNSSEC"); | |
151 | #endif | |
152 | #ifndef DISABLE_EVENT | |
153 | builtin_macro_create(US"_HAVE_EVENT"); | |
154 | #endif | |
155 | #ifdef SUPPORT_I18N | |
156 | builtin_macro_create(US"_HAVE_I18N"); | |
157 | #endif | |
158 | #ifndef DISABLE_OCSP | |
159 | builtin_macro_create(US"_HAVE_OCSP"); | |
160 | #endif | |
161 | #ifndef DISABLE_PRDR | |
162 | builtin_macro_create(US"_HAVE_PRDR"); | |
163 | #endif | |
164 | #ifdef SUPPORT_PROXY | |
165 | builtin_macro_create(US"_HAVE_PROXY"); | |
166 | #endif | |
167 | #ifdef SUPPORT_SOCKS | |
168 | builtin_macro_create(US"_HAVE_SOCKS"); | |
169 | #endif | |
170 | #ifdef TCP_FASTOPEN | |
171 | builtin_macro_create(US"_HAVE_TCP_FASTOPEN"); | |
172 | #endif | |
173 | #ifdef EXPERIMENTAL_LMDB | |
174 | builtin_macro_create(US"_HAVE_LMDB"); | |
175 | #endif | |
7952eef9 | 176 | #ifdef SUPPORT_SPF |
d185889f JH |
177 | builtin_macro_create(US"_HAVE_SPF"); |
178 | #endif | |
179 | #ifdef EXPERIMENTAL_SRS | |
180 | builtin_macro_create(US"_HAVE_SRS"); | |
181 | #endif | |
617d3932 JH |
182 | #ifdef EXPERIMENTAL_ARC |
183 | builtin_macro_create(US"_HAVE_ARC"); | |
184 | #endif | |
d185889f JH |
185 | #ifdef EXPERIMENTAL_BRIGHTMAIL |
186 | builtin_macro_create(US"_HAVE_BRIGHTMAIL"); | |
187 | #endif | |
c0635b6d | 188 | #ifdef SUPPORT_DANE |
d185889f JH |
189 | builtin_macro_create(US"_HAVE_DANE"); |
190 | #endif | |
191 | #ifdef EXPERIMENTAL_DCC | |
192 | builtin_macro_create(US"_HAVE_DCC"); | |
193 | #endif | |
194 | #ifdef EXPERIMENTAL_DMARC | |
195 | builtin_macro_create(US"_HAVE_DMARC"); | |
196 | #endif | |
197 | #ifdef EXPERIMENTAL_DSN_INFO | |
198 | builtin_macro_create(US"_HAVE_DSN_INFO"); | |
199 | #endif | |
8ac90765 JH |
200 | #ifdef EXPERIMENTAL_REQUIRETLS |
201 | builtin_macro_create(US"_HAVE_REQTLS"); | |
202 | #endif | |
ee8b8090 JH |
203 | #ifdef EXPERIMENTAL_PIPE_CONNECT |
204 | builtin_macro_create(US"_HAVE_PIPE_CONNECT"); | |
205 | #endif | |
d185889f JH |
206 | |
207 | #ifdef LOOKUP_LSEARCH | |
208 | builtin_macro_create(US"_HAVE_LOOKUP_LSEARCH"); | |
209 | #endif | |
210 | #ifdef LOOKUP_CDB | |
211 | builtin_macro_create(US"_HAVE_LOOKUP_CDB"); | |
212 | #endif | |
213 | #ifdef LOOKUP_DBM | |
214 | builtin_macro_create(US"_HAVE_LOOKUP_DBM"); | |
215 | #endif | |
216 | #ifdef LOOKUP_DNSDB | |
217 | builtin_macro_create(US"_HAVE_LOOKUP_DNSDB"); | |
218 | #endif | |
219 | #ifdef LOOKUP_DSEARCH | |
220 | builtin_macro_create(US"_HAVE_LOOKUP_DSEARCH"); | |
221 | #endif | |
222 | #ifdef LOOKUP_IBASE | |
223 | builtin_macro_create(US"_HAVE_LOOKUP_IBASE"); | |
224 | #endif | |
225 | #ifdef LOOKUP_LDAP | |
226 | builtin_macro_create(US"_HAVE_LOOKUP_LDAP"); | |
227 | #endif | |
228 | #ifdef EXPERIMENTAL_LMDB | |
229 | builtin_macro_create(US"_HAVE_LOOKUP_LMDB"); | |
230 | #endif | |
231 | #ifdef LOOKUP_MYSQL | |
232 | builtin_macro_create(US"_HAVE_LOOKUP_MYSQL"); | |
233 | #endif | |
234 | #ifdef LOOKUP_NIS | |
235 | builtin_macro_create(US"_HAVE_LOOKUP_NIS"); | |
236 | #endif | |
237 | #ifdef LOOKUP_NISPLUS | |
238 | builtin_macro_create(US"_HAVE_LOOKUP_NISPLUS"); | |
239 | #endif | |
240 | #ifdef LOOKUP_ORACLE | |
241 | builtin_macro_create(US"_HAVE_LOOKUP_ORACLE"); | |
242 | #endif | |
243 | #ifdef LOOKUP_PASSWD | |
244 | builtin_macro_create(US"_HAVE_LOOKUP_PASSWD"); | |
245 | #endif | |
246 | #ifdef LOOKUP_PGSQL | |
247 | builtin_macro_create(US"_HAVE_LOOKUP_PGSQL"); | |
248 | #endif | |
249 | #ifdef LOOKUP_REDIS | |
250 | builtin_macro_create(US"_HAVE_LOOKUP_REDIS"); | |
251 | #endif | |
252 | #ifdef LOOKUP_SQLITE | |
253 | builtin_macro_create(US"_HAVE_LOOKUP_SQLITE"); | |
254 | #endif | |
255 | #ifdef LOOKUP_TESTDB | |
256 | builtin_macro_create(US"_HAVE_LOOKUP_TESTDB"); | |
257 | #endif | |
258 | #ifdef LOOKUP_WHOSON | |
259 | builtin_macro_create(US"_HAVE_LOOKUP_WHOSON"); | |
260 | #endif | |
261 | ||
262 | #ifdef TRANSPORT_APPENDFILE | |
263 | # ifdef SUPPORT_MAILDIR | |
264 | builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILDIR"); | |
265 | # endif | |
266 | # ifdef SUPPORT_MAILSTORE | |
267 | builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILSTORE"); | |
268 | # endif | |
269 | # ifdef SUPPORT_MBX | |
270 | builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MBX"); | |
271 | # endif | |
272 | #endif | |
c11d665d JH |
273 | |
274 | #ifdef WITH_CONTENT_SCAN | |
275 | features_malware(); | |
276 | #endif | |
260958d6 JH |
277 | |
278 | features_crypto(); | |
d185889f JH |
279 | } |
280 | ||
281 | ||
282 | static void | |
283 | options(void) | |
284 | { | |
285 | options_main(); | |
286 | options_routers(); | |
287 | options_transports(); | |
288 | options_auths(); | |
12263aa8 | 289 | options_logging(); |
8442641e JH |
290 | #if defined(SUPPORT_TLS) && !defined(USE_GNUTLS) |
291 | options_tls(); | |
292 | #endif | |
d185889f JH |
293 | } |
294 | ||
970424a5 JH |
295 | static void |
296 | params(void) | |
297 | { | |
215e8e5f | 298 | #ifndef DISABLE_DKIM |
a2701501 | 299 | params_dkim(); |
215e8e5f | 300 | #endif |
970424a5 JH |
301 | } |
302 | ||
d185889f JH |
303 | |
304 | int | |
305 | main(void) | |
306 | { | |
307 | printf("#include \"exim.h\"\n"); | |
308 | features(); | |
309 | options(); | |
970424a5 | 310 | params(); |
d185889f | 311 | |
1a7c9a48 JH |
312 | printf("macro_item * macros = &p%d;\n", mp_index-1); |
313 | printf("macro_item * mlast = &p0;\n"); | |
f1f7d0cd | 314 | exit(0); |
d185889f | 315 | } |