summaryrefslogtreecommitdiffabout
path: root/src/main.c
authorSergey Poznyakoff <gray@gnu.org.ua>2007-05-20 09:45:40 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2007-05-20 09:45:40 (GMT)
commit7c00a3c8814a486051da93f6c6cb45c141075923 (patch) (side-by-side diff)
tree614543e8a8adc674d35e0c2a4d1a6c9cfc7984e8 /src/main.c
parent89b68ce3e3fb9d837bff8d1a2a231d143ef568bd (diff)
downloadmailfromd-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') (more/less context) (ignore whitespace changes)
-rw-r--r--src/main.c51
1 files changed, 42 insertions, 9 deletions
diff --git a/src/main.c b/src/main.c
index ce8cf99..aa0c69a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -51,12 +51,21 @@ int need_config = 1;/* Set if the current mode requires reading the
configuration file */
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 */
int script_dump_tree; /* Dump created config tree to stdout */
int script_dump_code; /* Dump disassembled code to stdout */
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 */
int do_trace; /* Enable tracing configuration */
int mtasim_option; /* mtasim compatibility mode */
@@ -817,9 +826,11 @@ enum mailfromd_option {
OPTION_LOCK_RETRY_TIMEOUT,
OPTION_MILTER_TIMEOUT,
OPTION_MTASIM,
+ OPTION_NO_PREPROCESSOR,
OPTION_PIDFILE,
OPTION_POSTMASTER_EMAIL,
OPTION_PREDICT_NEXT,
+ OPTION_PREPROCESSOR,
OPTION_SHOW_DEFAULTS,
OPTION_SINGLE_PROCESS,
OPTION_STACK_TRACE,
@@ -854,6 +865,8 @@ static struct argp_option options[] = {
{ "daemon", OPTION_DAEMON, NULL, 0,
N_("Run in daemon mode (default)"), GRP+1 },
+ { NULL, 'E', NULL, 0,
+ N_("Preprocess source files and exit"), GRP+1 },
/* Reserved for future use: */
{ "compile", 'c', NULL, OPTION_HIDDEN,
N_("Compile files"), GRP+1 },
@@ -926,6 +939,10 @@ 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 },
+ { "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
#undef GRP
@@ -1020,6 +1037,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
set_option("debug", arg, 1);
break;
+ case 'E':
+ preprocess_option = 1;
+ break;
+
case 'e':
set_option("expire-interval", arg, 1);
break;
@@ -1068,6 +1089,14 @@ parse_opt (int key, char *arg, struct argp_state *state)
mode = MAILFROMD_LIST;
break;
+ case OPTION_PREPROCESSOR:
+ ext_pp = arg;
+ break;
+
+ case OPTION_NO_PREPROCESSOR:
+ ext_pp = NULL;
+ break;
+
case OPTION_TIME_FORMAT:
time_format_string = arg;
break;
@@ -1187,7 +1216,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
break;
case OPTION_DUMP_LEX_TRACE:
- script_ldebug = 1;
+ yy_flex_debug = 1;
break;
case OPTION_DUMP_MACROS:
@@ -1658,6 +1687,7 @@ mailfromd_show_defaults()
{
printf("version: %s\n", VERSION);
printf("script file: %s\n", script_file);
+ printf("preprocessor: %s\n", ext_pp ? ext_pp : "none");
printf("user: %s\n", user);
printf("statedir: %s\n", mailfromd_state_dir);
printf("socket: %s\n", portspec);
@@ -1716,7 +1746,7 @@ int
main(int argc, char **argv)
{
int index;
-
+
#ifdef ENABLE_NLS
mu_init_nls();
setlocale (LC_ALL, "");
@@ -1729,22 +1759,23 @@ main(int argc, char **argv)
if (!program_invocation_short_name)
program_invocation_short_name = argv[0];
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());
init_names();
init_string_space();
builtin_setup();
db_format_setup();
- lex_setup();
+ include_path_setup();
save_cmdline(argc, argv);
mu_argp_init(program_version, "<" PACKAGE_BUGREPORT ">");
mu_argp_parse(&argp, &argc, &argv, 0, capa, &index, NULL);
- log_setup(log_to_stderr);
-
+ log_setup(log_to_stderr);
+
argv += index;
argc -= index;
@@ -1773,7 +1804,9 @@ main(int argc, char **argv)
}
if (script_file[0] != '/')
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);
}
process_options();
@@ -1799,7 +1832,7 @@ main(int argc, char **argv)
if (script_check || script_dump_macros
|| script_dump_code || script_dump_tree
- || script_ldebug || script_ydebug)
+ || yy_flex_debug || script_ydebug)
exit(EX_OK);
free_symbols();

Return to:

Send suggestions and report system problems to the System administrator.