aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c65
1 files changed, 62 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 19eb2f4f..ae73aa47 100644
--- a/src/main.c
+++ b/src/main.c
@@ -71,6 +71,7 @@ int preprocess_option; /* Only preprocess the sources */
# define DEF_EXT_PP NULL
#endif
char *ext_pp = DEF_EXT_PP; /* External preprocessor to use */
+char *ext_pp_options;
int do_transcript; /* Enable session transript */
int do_trace; /* Enable tracing configuration */
@@ -130,6 +131,50 @@ time_t io_timeout = 3;
time_t response_timeout = 30;
+/* Preprocessor helper function */
+static void
+add_pp_option(const char *opt, const char *arg)
+{
+ size_t len;
+
+ len = 1 + strlen(opt) + (arg ? strlen(arg) : 0);
+ if (ext_pp_options) {
+ len += strlen(ext_pp_options);
+ ext_pp_options = xrealloc(ext_pp_options, len + 1);
+ } else {
+ ext_pp_options = xmalloc(len + 1);
+ }
+ strcat(ext_pp_options, " ");
+ strcat(ext_pp_options, opt);
+ strcat(ext_pp_options, arg);
+}
+
+static void
+alloc_ext_pp()
+{
+ if (ext_pp_options) {
+ size_t len;
+ char *p;
+
+ if (!ext_pp) {
+ if (!DEF_EXT_PP) {
+ mu_error(_("Default preprocessor is not set; "
+ "use --preprocessor option"));
+ exit(EX_USAGE);
+ }
+ ext_pp = DEF_EXT_PP;
+ }
+
+ len = strlen(ext_pp) + strlen(ext_pp_options);
+ p = xmalloc(len + 1);
+ strcpy(p, ext_pp);
+ strcat(p, ext_pp_options);
+ ext_pp = p;
+ }
+}
+
+
+
/* Logging & debugging */
int
@@ -1034,11 +1079,21 @@ static struct argp_option options[] = {
N_("Assign VALUE to VAR"), GRP+1 },
{ "relayed-domain-file", OPTION_DOMAIN_FILE, N_("FILE"), 0,
N_("Read relayed domains from FILE"), GRP+1 },
+
+#undef GRP
+#define GRP 25
+ { NULL, 0, NULL, 0,
+ N_("Preprocessor options"), GRP },
{ "preprocessor", OPTION_PREPROCESSOR, N_("COMMAND"), 0,
N_("Use command as external preprocessor"), GRP+1 },
{ "no-preprocessor", OPTION_NO_PREPROCESSOR, NULL, 0,
N_("Disable the use of external preprocessor"), GRP+1 },
-#undef GRP
+ { "define", 'D', N_("NAME[=VALUE]"), 0,
+ N_("Define a preprocessor symbol NAME as having VALUE, or empty"),
+ GRP+1 },
+ { "undefine", 'U', N_("NAME"), 0,
+ N_("Undefine a preprocessor symbol NAME"),
+ GRP+1 },
#undef GRP
#define GRP 30
@@ -1096,7 +1151,6 @@ static struct argp_option options[] = {
#undef GRP
/*DEPRECATED OPTIONS*/
- { "domain", 'D', N_("STRING"), OPTION_HIDDEN, "", 1 },
{ "ehlo", 0, NULL, OPTION_ALIAS|OPTION_HIDDEN, NULL, 1 },
{ "postmaster-email", OPTION_POSTMASTER_EMAIL, N_("EMAIL"),
OPTION_HIDDEN, "", 1 },
@@ -1131,9 +1185,12 @@ parse_opt (int key, char *arg, struct argp_state *state)
{
switch (key) {
case 'D':
- set_option("ehlo", arg, 1);
+ add_pp_option("-D", arg);
break;
+ case 'U':
+ add_pp_option("-U", arg);
+
case 'd':
set_option("debug", arg, 1);
break;
@@ -2135,6 +2192,8 @@ main(int argc, char **argv)
if (rc)
exit (EX_CONFIG);
+ alloc_ext_pp();
+
log_setup(log_to_stderr);
argv += index;

Return to:

Send suggestions and report system problems to the System administrator.