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 | { | |
73 | int i; | |
74 | const uschar * s; | |
75 | uschar buf[64]; | |
76 | ||
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 | |
82 | expansion. */ | |
83 | ||
84 | for (i = 0; i < nopt; i++) if (*(s = US opts[i].name) && *s != '*') | |
85 | { | |
86 | if (group) | |
f1f7d0cd | 87 | spf(buf, sizeof(buf), CUS"_OPT_%T_%T_%T", section, group, s); |
d185889f | 88 | else |
f1f7d0cd | 89 | spf(buf, sizeof(buf), CUS"_OPT_%T_%T", section, s); |
d185889f JH |
90 | builtin_macro_create(buf); |
91 | } | |
92 | } | |
93 | ||
94 | ||
95 | /******************************************************************************/ | |
96 | ||
97 | ||
98 | /* Create compile-time feature macros */ | |
99 | static void | |
100 | features(void) | |
101 | { | |
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. */ | |
105 | ||
106 | #ifdef SUPPORT_CRYPTEQ | |
107 | builtin_macro_create(US"_HAVE_CRYPTEQ"); | |
108 | #endif | |
109 | #if HAVE_ICONV | |
110 | builtin_macro_create(US"_HAVE_ICONV"); | |
111 | #endif | |
112 | #if HAVE_IPV6 | |
113 | builtin_macro_create(US"_HAVE_IPV6"); | |
114 | #endif | |
115 | #ifdef HAVE_SETCLASSRESOURCES | |
116 | builtin_macro_create(US"_HAVE_SETCLASSRESOURCES"); | |
117 | #endif | |
118 | #ifdef SUPPORT_PAM | |
119 | builtin_macro_create(US"_HAVE_PAM"); | |
120 | #endif | |
121 | #ifdef EXIM_PERL | |
122 | builtin_macro_create(US"_HAVE_PERL"); | |
123 | #endif | |
124 | #ifdef EXPAND_DLFUNC | |
125 | builtin_macro_create(US"_HAVE_DLFUNC"); | |
126 | #endif | |
127 | #ifdef USE_TCP_WRAPPERS | |
128 | builtin_macro_create(US"_HAVE_TCPWRAPPERS"); | |
129 | #endif | |
130 | #ifdef SUPPORT_TLS | |
131 | builtin_macro_create(US"_HAVE_TLS"); | |
132 | # ifdef USE_GNUTLS | |
133 | builtin_macro_create(US"_HAVE_GNUTLS"); | |
134 | # else | |
135 | builtin_macro_create(US"_HAVE_OPENSSL"); | |
136 | # endif | |
137 | #endif | |
138 | #ifdef SUPPORT_TRANSLATE_IP_ADDRESS | |
139 | builtin_macro_create(US"_HAVE_TRANSLATE_IP_ADDRESS"); | |
140 | #endif | |
141 | #ifdef SUPPORT_MOVE_FROZEN_MESSAGES | |
142 | builtin_macro_create(US"_HAVE_MOVE_FROZEN_MESSAGES"); | |
143 | #endif | |
144 | #ifdef WITH_CONTENT_SCAN | |
145 | builtin_macro_create(US"_HAVE_CONTENT_SCANNING"); | |
146 | #endif | |
147 | #ifndef DISABLE_DKIM | |
148 | builtin_macro_create(US"_HAVE_DKIM"); | |
149 | #endif | |
150 | #ifndef DISABLE_DNSSEC | |
151 | builtin_macro_create(US"_HAVE_DNSSEC"); | |
152 | #endif | |
153 | #ifndef DISABLE_EVENT | |
154 | builtin_macro_create(US"_HAVE_EVENT"); | |
155 | #endif | |
156 | #ifdef SUPPORT_I18N | |
157 | builtin_macro_create(US"_HAVE_I18N"); | |
158 | #endif | |
159 | #ifndef DISABLE_OCSP | |
160 | builtin_macro_create(US"_HAVE_OCSP"); | |
161 | #endif | |
162 | #ifndef DISABLE_PRDR | |
163 | builtin_macro_create(US"_HAVE_PRDR"); | |
164 | #endif | |
165 | #ifdef SUPPORT_PROXY | |
166 | builtin_macro_create(US"_HAVE_PROXY"); | |
167 | #endif | |
168 | #ifdef SUPPORT_SOCKS | |
169 | builtin_macro_create(US"_HAVE_SOCKS"); | |
170 | #endif | |
171 | #ifdef TCP_FASTOPEN | |
172 | builtin_macro_create(US"_HAVE_TCP_FASTOPEN"); | |
173 | #endif | |
174 | #ifdef EXPERIMENTAL_LMDB | |
175 | builtin_macro_create(US"_HAVE_LMDB"); | |
176 | #endif | |
7952eef9 | 177 | #ifdef SUPPORT_SPF |
d185889f JH |
178 | builtin_macro_create(US"_HAVE_SPF"); |
179 | #endif | |
180 | #ifdef EXPERIMENTAL_SRS | |
181 | builtin_macro_create(US"_HAVE_SRS"); | |
182 | #endif | |
617d3932 JH |
183 | #ifdef EXPERIMENTAL_ARC |
184 | builtin_macro_create(US"_HAVE_ARC"); | |
185 | #endif | |
d185889f JH |
186 | #ifdef EXPERIMENTAL_BRIGHTMAIL |
187 | builtin_macro_create(US"_HAVE_BRIGHTMAIL"); | |
188 | #endif | |
c0635b6d | 189 | #ifdef SUPPORT_DANE |
d185889f JH |
190 | builtin_macro_create(US"_HAVE_DANE"); |
191 | #endif | |
192 | #ifdef EXPERIMENTAL_DCC | |
193 | builtin_macro_create(US"_HAVE_DCC"); | |
194 | #endif | |
195 | #ifdef EXPERIMENTAL_DMARC | |
196 | builtin_macro_create(US"_HAVE_DMARC"); | |
197 | #endif | |
198 | #ifdef EXPERIMENTAL_DSN_INFO | |
199 | builtin_macro_create(US"_HAVE_DSN_INFO"); | |
200 | #endif | |
201 | ||
202 | #ifdef LOOKUP_LSEARCH | |
203 | builtin_macro_create(US"_HAVE_LOOKUP_LSEARCH"); | |
204 | #endif | |
205 | #ifdef LOOKUP_CDB | |
206 | builtin_macro_create(US"_HAVE_LOOKUP_CDB"); | |
207 | #endif | |
208 | #ifdef LOOKUP_DBM | |
209 | builtin_macro_create(US"_HAVE_LOOKUP_DBM"); | |
210 | #endif | |
211 | #ifdef LOOKUP_DNSDB | |
212 | builtin_macro_create(US"_HAVE_LOOKUP_DNSDB"); | |
213 | #endif | |
214 | #ifdef LOOKUP_DSEARCH | |
215 | builtin_macro_create(US"_HAVE_LOOKUP_DSEARCH"); | |
216 | #endif | |
217 | #ifdef LOOKUP_IBASE | |
218 | builtin_macro_create(US"_HAVE_LOOKUP_IBASE"); | |
219 | #endif | |
220 | #ifdef LOOKUP_LDAP | |
221 | builtin_macro_create(US"_HAVE_LOOKUP_LDAP"); | |
222 | #endif | |
223 | #ifdef EXPERIMENTAL_LMDB | |
224 | builtin_macro_create(US"_HAVE_LOOKUP_LMDB"); | |
225 | #endif | |
226 | #ifdef LOOKUP_MYSQL | |
227 | builtin_macro_create(US"_HAVE_LOOKUP_MYSQL"); | |
228 | #endif | |
229 | #ifdef LOOKUP_NIS | |
230 | builtin_macro_create(US"_HAVE_LOOKUP_NIS"); | |
231 | #endif | |
232 | #ifdef LOOKUP_NISPLUS | |
233 | builtin_macro_create(US"_HAVE_LOOKUP_NISPLUS"); | |
234 | #endif | |
235 | #ifdef LOOKUP_ORACLE | |
236 | builtin_macro_create(US"_HAVE_LOOKUP_ORACLE"); | |
237 | #endif | |
238 | #ifdef LOOKUP_PASSWD | |
239 | builtin_macro_create(US"_HAVE_LOOKUP_PASSWD"); | |
240 | #endif | |
241 | #ifdef LOOKUP_PGSQL | |
242 | builtin_macro_create(US"_HAVE_LOOKUP_PGSQL"); | |
243 | #endif | |
244 | #ifdef LOOKUP_REDIS | |
245 | builtin_macro_create(US"_HAVE_LOOKUP_REDIS"); | |
246 | #endif | |
247 | #ifdef LOOKUP_SQLITE | |
248 | builtin_macro_create(US"_HAVE_LOOKUP_SQLITE"); | |
249 | #endif | |
250 | #ifdef LOOKUP_TESTDB | |
251 | builtin_macro_create(US"_HAVE_LOOKUP_TESTDB"); | |
252 | #endif | |
253 | #ifdef LOOKUP_WHOSON | |
254 | builtin_macro_create(US"_HAVE_LOOKUP_WHOSON"); | |
255 | #endif | |
256 | ||
257 | #ifdef TRANSPORT_APPENDFILE | |
258 | # ifdef SUPPORT_MAILDIR | |
259 | builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILDIR"); | |
260 | # endif | |
261 | # ifdef SUPPORT_MAILSTORE | |
262 | builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILSTORE"); | |
263 | # endif | |
264 | # ifdef SUPPORT_MBX | |
265 | builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MBX"); | |
266 | # endif | |
267 | #endif | |
c11d665d JH |
268 | |
269 | #ifdef WITH_CONTENT_SCAN | |
270 | features_malware(); | |
271 | #endif | |
260958d6 JH |
272 | |
273 | features_crypto(); | |
d185889f JH |
274 | } |
275 | ||
276 | ||
277 | static void | |
278 | options(void) | |
279 | { | |
280 | options_main(); | |
281 | options_routers(); | |
282 | options_transports(); | |
283 | options_auths(); | |
284 | } | |
285 | ||
970424a5 JH |
286 | static void |
287 | params(void) | |
288 | { | |
215e8e5f | 289 | #ifndef DISABLE_DKIM |
a2701501 | 290 | params_dkim(); |
215e8e5f | 291 | #endif |
970424a5 JH |
292 | } |
293 | ||
d185889f JH |
294 | |
295 | int | |
296 | main(void) | |
297 | { | |
298 | printf("#include \"exim.h\"\n"); | |
299 | features(); | |
300 | options(); | |
970424a5 | 301 | params(); |
d185889f | 302 | |
1a7c9a48 JH |
303 | printf("macro_item * macros = &p%d;\n", mp_index-1); |
304 | printf("macro_item * mlast = &p0;\n"); | |
f1f7d0cd | 305 | exit(0); |
d185889f | 306 | } |