diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-05-20 09:45:40 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-05-20 09:45:40 +0000 |
commit | 7c00a3c8814a486051da93f6c6cb45c141075923 (patch) | |
tree | 614543e8a8adc674d35e0c2a4d1a6c9cfc7984e8 /src/main.c | |
parent | 89b68ce3e3fb9d837bff8d1a2a231d143ef568bd (diff) | |
download | mailfromd-7c00a3c8814a486051da93f6c6cb45c141075923.tar.gz mailfromd-7c00a3c8814a486051da93f6c6cb45c141075923.tar.bz2 |
Implement built-in and external preprocessors
git-svn-id: file:///svnroot/mailfromd/trunk@1456 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 51 |
1 files changed, 42 insertions, 9 deletions
@@ -53,3 +53,3 @@ char *script_file = DEFAULT_SCRIPT_FILE; int script_check; /* Check config file syntax and exit */ -int script_ldebug; /* Enable tracing the lexical analyzer */ +extern int yy_flex_debug; /* Enable tracing the lexical analyzer */ int script_ydebug; /* Enable tracing the parser */ @@ -59,2 +59,11 @@ int script_dump_macros; /* Dump used Sendmail macros */ int script_dump_xref; /* Dump cross-reference */ +int preprocess_option; /* Only preprocess the sources */ + +#ifdef DEFAULT_PREPROCESSOR +# define DEF_EXT_PP DEFAULT_PREPROCESSOR +#else +# define DEF_EXT_PP NULL +#endif +char *ext_pp = DEF_EXT_PP; /* External preprocessor to use */ + int do_transcript; /* Enable session transript */ @@ -819,2 +828,3 @@ enum mailfromd_option { OPTION_MTASIM, + OPTION_NO_PREPROCESSOR, OPTION_PIDFILE, @@ -822,2 +832,3 @@ enum mailfromd_option { OPTION_PREDICT_NEXT, + OPTION_PREPROCESSOR, OPTION_SHOW_DEFAULTS, @@ -856,2 +867,4 @@ static struct argp_option options[] = { + { NULL, 'E', NULL, 0, + N_("Preprocess source files and exit"), GRP+1 }, /* Reserved for future use: */ @@ -928,2 +941,6 @@ static struct argp_option options[] = { N_("Read relayed domains from FILE"), GRP+1 }, + { "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 @@ -1022,2 +1039,6 @@ parse_opt (int key, char *arg, struct argp_state *state) + case 'E': + preprocess_option = 1; + break; + case 'e': @@ -1070,2 +1091,10 @@ parse_opt (int key, char *arg, struct argp_state *state) + case OPTION_PREPROCESSOR: + ext_pp = arg; + break; + + case OPTION_NO_PREPROCESSOR: + ext_pp = NULL; + break; + case OPTION_TIME_FORMAT: @@ -1189,3 +1218,3 @@ parse_opt (int key, char *arg, struct argp_state *state) case OPTION_DUMP_LEX_TRACE: - script_ldebug = 1; + yy_flex_debug = 1; break; @@ -1660,2 +1689,3 @@ mailfromd_show_defaults() printf("script file: %s\n", script_file); + printf("preprocessor: %s\n", ext_pp ? ext_pp : "none"); printf("user: %s\n", user); @@ -1718,3 +1748,3 @@ main(int argc, char **argv) int index; - + #ifdef ENABLE_NLS @@ -1731,5 +1761,6 @@ main(int argc, char **argv) argp_program_version_hook = version; + yy_flex_debug = 0; /* Set default logging */ - log_facility = DEFAULT_LOG_FACILITY; + log_facility = DEFAULT_LOG_FACILITY; log_setup(!stderr_closed_p()); @@ -1740,3 +1771,3 @@ main(int argc, char **argv) db_format_setup(); - lex_setup(); + include_path_setup(); save_cmdline(argc, argv); @@ -1745,4 +1776,4 @@ main(int argc, char **argv) - log_setup(log_to_stderr); - + log_setup(log_to_stderr); + argv += index; @@ -1775,3 +1806,5 @@ main(int argc, char **argv) save_cmdline(0, NULL); /* Clear saved command line */ - if (parse_program(script_file, script_ydebug, script_ldebug)) + if (preprocess_option) + exit(preprocess_input(ext_pp)); + if (parse_program(script_file, script_ydebug)) exit(EX_CONFIG); @@ -1801,3 +1834,3 @@ main(int argc, char **argv) || script_dump_code || script_dump_tree - || script_ldebug || script_ydebug) + || yy_flex_debug || script_ydebug) exit(EX_OK); |