diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2006-12-05 14:18:33 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2006-12-05 14:18:33 +0000 |
commit | 6039f8f72fb733cd9d7c7cb7b70e70cafd3913d1 (patch) | |
tree | 5523232301940b6f3e7991985d06d6bd7734d953 /src/main.c | |
parent | cbf39a08057f6deb8ab724ebf8b027d8d968904f (diff) | |
download | mailfromd-6039f8f72fb733cd9d7c7cb7b70e70cafd3913d1.tar.gz mailfromd-6039f8f72fb733cd9d7c7cb7b70e70cafd3913d1.tar.bz2 |
Remove -c option. Remove the inconsistent usage of config_ prefix.
git-svn-id: file:///svnroot/mailfromd/trunk@1079 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 98 |
1 files changed, 66 insertions, 32 deletions
@@ -47,14 +47,14 @@ int mode = MAILFROMD_DAEMON; /* Default operation mode */ enum smtp_state test_state = smtp_state_envfrom; /* State for --test mode */ int need_config = 1;/* Set if the current mode requires reading the configuration file */ -char *config_file = DEFAULT_CONFIG_FILE; -int config_check; /* Check config file syntax and exit */ -int config_ldebug; /* Enable tracing the lexical analyzer */ -int config_ydebug; /* Enable tracing the parser */ -int config_dump_tree; /* Dump created config tree to stdout */ -int config_dump_code; /* Dump disassembled code to stdout */ -int config_dump_macros; /* Dump used Sendmail macros */ -int config_dump_xref; /* Dump cross-reference */ +char *script_file = DEFAULT_SCRIPT_FILE; +int script_check; /* Check config file syntax and exit */ +int script_ldebug; /* 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 do_transcript; /* Enable session transript */ int do_trace; /* Enable tracing configuration */ int debug_level; /* Debugging level */ @@ -847,11 +847,12 @@ process_options() const char *program_version = "mailfromd (" PACKAGE_STRING ")"; static char doc[] = N_("mailfromd -- MAIL FROM milter checker"); -static char args_doc[] = "[var=value...]"; +static char args_doc[] = "[var=value...][SCRIPT]"; enum mailfromd_option { OPTION_ALL = 256, OPTION_COMPACT, + OPTION_CONFIG_FILE, OPTION_DAEMON, OPTION_DELETE, OPTION_DOMAIN_FILE, @@ -902,6 +903,10 @@ static struct argp_option options[] = { { "daemon", OPTION_DAEMON, NULL, 0, N_("Run in daemon mode (default)"), GRP+1 }, + /* Reserved for future use: */ + { "compile", 'c', NULL, OPTION_HIDDEN, + N_("Compile files"), GRP+1 }, + #undef GRP #define GRP 15 { NULL, 0, NULL, 0, @@ -932,7 +937,7 @@ static struct argp_option options[] = { #define GRP 20 { NULL, 0, NULL, 0, N_("General options"), GRP }, - { "config-file", 'c', N_("FILE"), 0, + { "config-file", OPTION_CONFIG_FILE, N_("FILE"), OPTION_HIDDEN, N_("Read configuration from FILE"), GRP+1 }, { "include", 'I', N_("DIR"), 0, N_("Add the directory dir to the list of directories to be " @@ -1012,8 +1017,8 @@ static struct argp_option options[] = { #undef GRP #if 0 -/* This entry is to pacify `make check-docs'. The --log-facility option - is defined in libmailutils. +/* This entry is to pacify `make check-docs'. The options below + are defined in libmailutils. */ { "log-facility", } { "mailer", } @@ -1040,7 +1045,8 @@ parse_opt (int key, char *arg, struct argp_state *state) { switch (key) { case 'c': - config_file = arg; + argp_error(state, + "-c is obsolete; give filter script as an argument"); break; case 'D': @@ -1073,6 +1079,11 @@ parse_opt (int key, char *arg, struct argp_state *state) all_option = 1; break; + case OPTION_CONFIG_FILE: + mu_error("warning: --config-file is obsolete; give filter script as an argument"); + script_file = arg; + break; + case OPTION_IGNORE_FAILED_READS: ignore_failed_reads_option = 1; break; @@ -1100,7 +1111,7 @@ parse_opt (int key, char *arg, struct argp_state *state) break; case 'l': - config_check = 1; + script_check = 1; break; case 'p': @@ -1176,27 +1187,27 @@ parse_opt (int key, char *arg, struct argp_state *state) break; case OPTION_DUMP_CODE: - config_dump_code = 1; + script_dump_code = 1; break; case OPTION_DUMP_GRAMMAR_TRACE: - config_ydebug = 1; + script_ydebug = 1; break; case OPTION_DUMP_LEX_TRACE: - config_ldebug = 1; + script_ldebug = 1; break; case OPTION_DUMP_MACROS: - config_dump_macros = 1; + script_dump_macros = 1; break; case OPTION_DUMP_TREE: - config_dump_tree = 1; + script_dump_tree = 1; break; case OPTION_DUMP_XREF: - config_dump_xref = 1; + script_dump_xref = 1; break; case OPTION_EXPIRE: @@ -1569,7 +1580,7 @@ void mailfromd_show_defaults() { printf("version: %s\n", VERSION); - printf("configuration file: %s\n", DEFAULT_CONFIG_FILE); + printf("script file: %s\n", DEFAULT_SCRIPT_FILE); printf("user: %s\n", DEFAULT_USER); printf("statedir: %s\n", MAILFROMSTATEDIR); printf("socket: %s\n", DEFAULT_SOCKET); @@ -1605,9 +1616,32 @@ main(int argc, char **argv) argv += index; argc -= index; - if (need_config - && parse_config(config_file, config_ydebug, config_ldebug)) - exit(EX_CONFIG); + if (need_config) { + if (argc) { + int i, n = -1; + for (i = 0; i < argc; i++) { + if (strchr(argv[i], '=') == 0) { + if (n == -1) + n = i; + else { + mu_error("script file " + "specified twice " + "(%s and %s)", + argv[n], argv[i]); + exit(EX_USAGE); + } + } + } + if (n >= 0) { + script_file = argv[n]; + memmove(argv + n, argv + n + 1, + (argc - n + 1) * sizeof argv[0]); + argc--; + } + } + if (parse_program(script_file, script_ydebug, script_ldebug)) + exit(EX_CONFIG); + } process_options(); /* Process some special options */ @@ -1617,12 +1651,12 @@ main(int argc, char **argv) builtin_post_setup(); - if (config_dump_tree) - print_config(); - if (config_dump_code) + if (script_dump_tree) + print_syntax_tree(); + if (script_dump_code) print_code(); - if (config_dump_xref) + if (script_dump_xref) print_xref(); /* Set up default values */ @@ -1631,12 +1665,12 @@ main(int argc, char **argv) mu_error_set_print(syslog_error_printer); } - if (config_dump_macros) + if (script_dump_macros) print_used_macros(); - if (config_check || config_dump_macros - || config_dump_code || config_dump_tree - || config_ldebug || config_ydebug) + if (script_check || script_dump_macros + || script_dump_code || script_dump_tree + || script_ldebug || script_ydebug) exit(EX_OK); switch (mode) { |