From f1f7d0cddd4fb38d0bcf81be13d6e272789ff9c7 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sat, 8 Jul 2017 17:54:44 +0100 Subject: [PATCH] Prebuild the data structure for builtin macros --- src/src/macro_predef.c | 9 +++++---- src/src/macro_predef.h | 1 + src/src/readconf.c | 2 +- src/src/route.c | 2 +- src/src/transport.c | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/src/macro_predef.c b/src/src/macro_predef.c index e133b8e1b..5ba237929 100644 --- a/src/src/macro_predef.c +++ b/src/src/macro_predef.c @@ -29,11 +29,11 @@ if (mp_index == 0) else printf("&p%d,", mp_index-1); -printf(" FALSE, %d, \"%s\", \"y\" };\n", Ustrlen(name), name); +printf(" FALSE, %d, \"%s\", \"y\" };\n", Ustrlen(name), CS name); mp_index++; } -static void +void spf(uschar * buf, int len, const uschar * fmt, ...) { va_list ap; @@ -73,9 +73,9 @@ expansion. */ for (i = 0; i < nopt; i++) if (*(s = US opts[i].name) && *s != '*') { if (group) - spf(buf, sizeof(buf), "_OPT_%T_%T_%T", section, group, s); + spf(buf, sizeof(buf), CUS"_OPT_%T_%T_%T", section, group, s); else - spf(buf, sizeof(buf), "_OPT_%T_%T", section, s); + spf(buf, sizeof(buf), CUS"_OPT_%T_%T", section, s); builtin_macro_create(buf); } } @@ -273,4 +273,5 @@ options(); printf("macro_item * macros = &p%d;\n", mp_index-1); printf("macro_item * mlast = &p0;\n"); +exit(0); } diff --git a/src/src/macro_predef.h b/src/src/macro_predef.h index e77f4bec1..1d3ba7f74 100644 --- a/src/src/macro_predef.h +++ b/src/src/macro_predef.h @@ -7,6 +7,7 @@ /* Global functions */ +extern void spf(uschar *, int, const uschar *, ...); extern void builtin_macro_create(const uschar *); extern void options_from_list(optionlist *, unsigned, const uschar *, uschar *); diff --git a/src/src/readconf.c b/src/src/readconf.c index 045b992a4..53f815d53 100644 --- a/src/src/readconf.c +++ b/src/src/readconf.c @@ -395,7 +395,7 @@ options_from_list(optionlist_auths, optionlist_auths_size, US"AUTHENTICATORS", N for (ai = auths_available; ai->driver_name[0]; ai++) { - snprintf(buf, sizeof(buf), "_DRIVER_AUTHENTICATOR_%T", ai->driver_name); + spf(buf, sizeof(buf), "_DRIVER_AUTHENTICATOR_%T", ai->driver_name); builtin_macro_create(buf); options_from_list(ai->options, (unsigned)*ai->options_count, US"AUTHENTICATOR", ai->driver_name); } diff --git a/src/src/route.c b/src/src/route.c index e30ae0e68..857fc65db 100644 --- a/src/src/route.c +++ b/src/src/route.c @@ -157,7 +157,7 @@ options_from_list(optionlist_routers, nelem(optionlist_routers), US"ROUTERS", NU for (ri = routers_available; ri->driver_name[0]; ri++) { - snprintf(buf, sizeof(buf), "_DRIVER_ROUTER_%T", ri->driver_name); + spf(buf, sizeof(buf), "_DRIVER_ROUTER_%T", ri->driver_name); builtin_macro_create(buf); options_from_list(ri->options, (unsigned)*ri->options_count, US"ROUTER", ri->driver_name); } diff --git a/src/src/transport.c b/src/src/transport.c index 49ea29e0a..6590fa7fb 100644 --- a/src/src/transport.c +++ b/src/src/transport.c @@ -101,7 +101,7 @@ options_from_list(optionlist_transports, nelem(optionlist_transports), US"TRANSP for (ti = transports_available; ti->driver_name[0]; ti++) { - snprintf(buf, sizeof(buf), "_DRIVER_TRANSPORT_%T", ti->driver_name); + spf(buf, sizeof(buf), "_DRIVER_TRANSPORT_%T", ti->driver_name); builtin_macro_create(buf); options_from_list(ti->options, (unsigned)*ti->options_count, US"TRANSPORT", ti->driver_name); } -- 2.25.1