aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2007-05-20 09:45:40 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2007-05-20 09:45:40 +0000
commit7c00a3c8814a486051da93f6c6cb45c141075923 (patch)
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')
-rw-r--r--src/main.c51
1 files changed, 42 insertions, 9 deletions
diff --git a/src/main.c b/src/main.c
index ce8cf993..aa0c69a8 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
51 configuration file */ 51 configuration file */
52char *script_file = DEFAULT_SCRIPT_FILE; 52char *script_file = DEFAULT_SCRIPT_FILE;
53int script_check; /* Check config file syntax and exit */ 53int script_check; /* Check config file syntax and exit */
54int script_ldebug; /* Enable tracing the lexical analyzer */ 54extern int yy_flex_debug; /* Enable tracing the lexical analyzer */
55int script_ydebug; /* Enable tracing the parser */ 55int script_ydebug; /* Enable tracing the parser */
56int script_dump_tree; /* Dump created config tree to stdout */ 56int script_dump_tree; /* Dump created config tree to stdout */
57int script_dump_code; /* Dump disassembled code to stdout */ 57int script_dump_code; /* Dump disassembled code to stdout */
58int script_dump_macros; /* Dump used Sendmail macros */ 58int script_dump_macros; /* Dump used Sendmail macros */
59int script_dump_xref; /* Dump cross-reference */ 59int script_dump_xref; /* Dump cross-reference */
60int preprocess_option; /* Only preprocess the sources */
61
62#ifdef DEFAULT_PREPROCESSOR
63# define DEF_EXT_PP DEFAULT_PREPROCESSOR
64#else
65# define DEF_EXT_PP NULL
66#endif
67char *ext_pp = DEF_EXT_PP; /* External preprocessor to use */
68
60int do_transcript; /* Enable session transript */ 69int do_transcript; /* Enable session transript */
61int do_trace; /* Enable tracing configuration */ 70int do_trace; /* Enable tracing configuration */
62int mtasim_option; /* mtasim compatibility mode */ 71int mtasim_option; /* mtasim compatibility mode */
@@ -817,9 +826,11 @@ enum mailfromd_option {
817 OPTION_LOCK_RETRY_TIMEOUT, 826 OPTION_LOCK_RETRY_TIMEOUT,
818 OPTION_MILTER_TIMEOUT, 827 OPTION_MILTER_TIMEOUT,
819 OPTION_MTASIM, 828 OPTION_MTASIM,
829 OPTION_NO_PREPROCESSOR,
820 OPTION_PIDFILE, 830 OPTION_PIDFILE,
821 OPTION_POSTMASTER_EMAIL, 831 OPTION_POSTMASTER_EMAIL,
822 OPTION_PREDICT_NEXT, 832 OPTION_PREDICT_NEXT,
833 OPTION_PREPROCESSOR,
823 OPTION_SHOW_DEFAULTS, 834 OPTION_SHOW_DEFAULTS,
824 OPTION_SINGLE_PROCESS, 835 OPTION_SINGLE_PROCESS,
825 OPTION_STACK_TRACE, 836 OPTION_STACK_TRACE,
@@ -854,6 +865,8 @@ static struct argp_option options[] = {
854 { "daemon", OPTION_DAEMON, NULL, 0, 865 { "daemon", OPTION_DAEMON, NULL, 0,
855 N_("Run in daemon mode (default)"), GRP+1 }, 866 N_("Run in daemon mode (default)"), GRP+1 },
856 867
868 { NULL, 'E', NULL, 0,
869 N_("Preprocess source files and exit"), GRP+1 },
857 /* Reserved for future use: */ 870 /* Reserved for future use: */
858 { "compile", 'c', NULL, OPTION_HIDDEN, 871 { "compile", 'c', NULL, OPTION_HIDDEN,
859 N_("Compile files"), GRP+1 }, 872 N_("Compile files"), GRP+1 },
@@ -926,6 +939,10 @@ static struct argp_option options[] = {
926 N_("Assign VALUE to VAR"), GRP+1 }, 939 N_("Assign VALUE to VAR"), GRP+1 },
927 { "relayed-domain-file", OPTION_DOMAIN_FILE, N_("FILE"), 0, 940 { "relayed-domain-file", OPTION_DOMAIN_FILE, N_("FILE"), 0,
928 N_("Read relayed domains from FILE"), GRP+1 }, 941 N_("Read relayed domains from FILE"), GRP+1 },
942 { "preprocessor", OPTION_PREPROCESSOR, N_("COMMAND"), 0,
943 N_("Use command as external preprocessor"), GRP+1 },
944 { "no-preprocessor", OPTION_NO_PREPROCESSOR, NULL, 0,
945 N_("Disable the use of external preprocessor"), GRP+1 },
929#undef GRP 946#undef GRP
930 947
931#undef GRP 948#undef GRP
@@ -1020,6 +1037,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
1020 set_option("debug", arg, 1); 1037 set_option("debug", arg, 1);
1021 break; 1038 break;
1022 1039
1040 case 'E':
1041 preprocess_option = 1;
1042 break;
1043
1023 case 'e': 1044 case 'e':
1024 set_option("expire-interval", arg, 1); 1045 set_option("expire-interval", arg, 1);
1025 break; 1046 break;
@@ -1068,6 +1089,14 @@ parse_opt (int key, char *arg, struct argp_state *state)
1068 mode = MAILFROMD_LIST; 1089 mode = MAILFROMD_LIST;
1069 break; 1090 break;
1070 1091
1092 case OPTION_PREPROCESSOR:
1093 ext_pp = arg;
1094 break;
1095
1096 case OPTION_NO_PREPROCESSOR:
1097 ext_pp = NULL;
1098 break;
1099
1071 case OPTION_TIME_FORMAT: 1100 case OPTION_TIME_FORMAT:
1072 time_format_string = arg; 1101 time_format_string = arg;
1073 break; 1102 break;
@@ -1187,7 +1216,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
1187 break; 1216 break;
1188 1217
1189 case OPTION_DUMP_LEX_TRACE: 1218 case OPTION_DUMP_LEX_TRACE:
1190 script_ldebug = 1; 1219 yy_flex_debug = 1;
1191 break; 1220 break;
1192 1221
1193 case OPTION_DUMP_MACROS: 1222 case OPTION_DUMP_MACROS:
@@ -1658,6 +1687,7 @@ mailfromd_show_defaults()
1658{ 1687{
1659 printf("version: %s\n", VERSION); 1688 printf("version: %s\n", VERSION);
1660 printf("script file: %s\n", script_file); 1689 printf("script file: %s\n", script_file);
1690 printf("preprocessor: %s\n", ext_pp ? ext_pp : "none");
1661 printf("user: %s\n", user); 1691 printf("user: %s\n", user);
1662 printf("statedir: %s\n", mailfromd_state_dir); 1692 printf("statedir: %s\n", mailfromd_state_dir);
1663 printf("socket: %s\n", portspec); 1693 printf("socket: %s\n", portspec);
@@ -1716,7 +1746,7 @@ int
1716main(int argc, char **argv) 1746main(int argc, char **argv)
1717{ 1747{
1718 int index; 1748 int index;
1719 1749
1720#ifdef ENABLE_NLS 1750#ifdef ENABLE_NLS
1721 mu_init_nls(); 1751 mu_init_nls();
1722 setlocale (LC_ALL, ""); 1752 setlocale (LC_ALL, "");
@@ -1729,22 +1759,23 @@ main(int argc, char **argv)
1729 if (!program_invocation_short_name) 1759 if (!program_invocation_short_name)
1730 program_invocation_short_name = argv[0]; 1760 program_invocation_short_name = argv[0];
1731 argp_program_version_hook = version; 1761 argp_program_version_hook = version;
1762 yy_flex_debug = 0;
1732 1763
1733 /* Set default logging */ 1764 /* Set default logging */
1734 log_facility = DEFAULT_LOG_FACILITY; 1765 log_facility = DEFAULT_LOG_FACILITY;
1735 log_setup(!stderr_closed_p()); 1766 log_setup(!stderr_closed_p());
1736 1767
1737 init_names(); 1768 init_names();
1738 init_string_space(); 1769 init_string_space();
1739 builtin_setup(); 1770 builtin_setup();
1740 db_format_setup(); 1771 db_format_setup();
1741 lex_setup(); 1772 include_path_setup();
1742 save_cmdline(argc, argv); 1773 save_cmdline(argc, argv);
1743 mu_argp_init(program_version, "<" PACKAGE_BUGREPORT ">"); 1774 mu_argp_init(program_version, "<" PACKAGE_BUGREPORT ">");
1744 mu_argp_parse(&argp, &argc, &argv, 0, capa, &index, NULL); 1775 mu_argp_parse(&argp, &argc, &argv, 0, capa, &index, NULL);
1745 1776
1746 log_setup(log_to_stderr); 1777 log_setup(log_to_stderr);
1747 1778
1748 argv += index; 1779 argv += index;
1749 argc -= index; 1780 argc -= index;
1750 1781
@@ -1773,7 +1804,9 @@ main(int argc, char **argv)
1773 } 1804 }
1774 if (script_file[0] != '/') 1805 if (script_file[0] != '/')
1775 save_cmdline(0, NULL); /* Clear saved command line */ 1806 save_cmdline(0, NULL); /* Clear saved command line */
1776 if (parse_program(script_file, script_ydebug, script_ldebug)) 1807 if (preprocess_option)
1808 exit(preprocess_input(ext_pp));
1809 if (parse_program(script_file, script_ydebug))
1777 exit(EX_CONFIG); 1810 exit(EX_CONFIG);
1778 } 1811 }
1779 process_options(); 1812 process_options();
@@ -1799,7 +1832,7 @@ main(int argc, char **argv)
1799 1832
1800 if (script_check || script_dump_macros 1833 if (script_check || script_dump_macros
1801 || script_dump_code || script_dump_tree 1834 || script_dump_code || script_dump_tree
1802 || script_ldebug || script_ydebug) 1835 || yy_flex_debug || script_ydebug)
1803 exit(EX_OK); 1836 exit(EX_OK);
1804 1837
1805 free_symbols(); 1838 free_symbols();

Return to:

Send suggestions and report system problems to the System administrator.