diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2016-10-28 20:36:29 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2016-10-28 20:46:42 +0300 |
commit | 8a851aaa1382d188ca2968e7bbd813e99507c4ff (patch) | |
tree | f10b7611125dc5124a66a0a5cda7d544a93d14d1 /src | |
parent | f964cda496a9e01e5c941da71a9841fb0c2b2174 (diff) | |
download | mailfromd-8a851aaa1382d188ca2968e7bbd813e99507c4ff.tar.gz mailfromd-8a851aaa1382d188ca2968e7bbd813e99507c4ff.tar.bz2 |
Finish conversion. Version 7.99.96
Diffstat (limited to 'src')
-rw-r--r-- | src/calloutd.c | 63 | ||||
-rw-r--r-- | src/mailfromd.h | 1 | ||||
-rw-r--r-- | src/main.c | 42 | ||||
-rw-r--r-- | src/mfdbtool.c | 310 |
4 files changed, 136 insertions, 280 deletions
diff --git a/src/calloutd.c b/src/calloutd.c index b5c2d56b..4ad4103f 100644 --- a/src/calloutd.c +++ b/src/calloutd.c | |||
@@ -29,8 +29,7 @@ | |||
29 | #include <sysexits.h> | 29 | #include <sysexits.h> |
30 | 30 | ||
31 | #include <mailutils/mailutils.h> | 31 | #include <mailutils/mailutils.h> |
32 | #include <mailutils/libcfg.h> | 32 | #include <mailutils/cli.h> |
33 | #include <mailutils/libargp.h> | ||
34 | #include <mailutils/daemon.h> | 33 | #include <mailutils/daemon.h> |
35 | 34 | ||
36 | #include "libmf.h" | 35 | #include "libmf.h" |
@@ -45,33 +44,9 @@ callout_alloc_die() | |||
45 | mu_error(_("not enough memory")); | 44 | mu_error(_("not enough memory")); |
46 | abort(); | 45 | abort(); |
47 | } | 46 | } |
48 | |||
49 | |||
50 | static void | ||
51 | version(FILE *stream, struct argp_state *state) | ||
52 | { | ||
53 | mailfromd_version("calloutd", stream); | ||
54 | } | ||
55 | |||
56 | 47 | ||
57 | const char *program_version = "calloutd (" PACKAGE_STRING ")"; | 48 | const char *program_version = "calloutd (" PACKAGE_STRING ")"; |
58 | static char doc[] = N_("calloutd -- a call out server"); | 49 | static char prog_doc[] = N_("calloutd -- a call out server"); |
59 | static char args_doc[] = ""; | ||
60 | |||
61 | static struct argp_option options[] = { | ||
62 | { NULL } | ||
63 | }; | ||
64 | |||
65 | static error_t | ||
66 | parse_opt(int key, char *arg, struct argp_state *state) | ||
67 | { | ||
68 | switch (key) { | ||
69 | default: | ||
70 | return ARGP_ERR_UNKNOWN; | ||
71 | } | ||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | 50 | ||
76 | struct mu_cfg_param callout_cfg_param[] = { | 51 | struct mu_cfg_param callout_cfg_param[] = { |
77 | { ".mfd:server", mu_cfg_section, NULL, 0, NULL, NULL }, | 52 | { ".mfd:server", mu_cfg_section, NULL, 0, NULL, NULL }, |
@@ -90,24 +65,13 @@ struct mu_cfg_param callout_cfg_param[] = { | |||
90 | 65 | ||
91 | extern char **environ; | 66 | extern char **environ; |
92 | 67 | ||
93 | static const char *capa[] = { | 68 | static char *capa[] = { |
94 | "common", | ||
95 | "debug", | 69 | "debug", |
96 | "logging", | 70 | "logging", |
97 | "locking", | 71 | "locking", |
72 | ".mfd:server", | ||
98 | NULL | 73 | NULL |
99 | }; | 74 | }; |
100 | |||
101 | static struct argp argp = { | ||
102 | options, | ||
103 | parse_opt, | ||
104 | args_doc, | ||
105 | doc, | ||
106 | NULL, | ||
107 | NULL, | ||
108 | NULL | ||
109 | }; | ||
110 | |||
111 | 75 | ||
112 | int | 76 | int |
113 | mf_server_function(const char *key, struct mf_srvcfg *cfg) | 77 | mf_server_function(const char *key, struct mf_srvcfg *cfg) |
@@ -116,7 +80,12 @@ mf_server_function(const char *key, struct mf_srvcfg *cfg) | |||
116 | return 0; | 80 | return 0; |
117 | } | 81 | } |
118 | 82 | ||
119 | extern char *program_invocation_short_name;//FIXME | 83 | static char const calloutd_config_file[] = SYSCONFDIR "/calloutd.conf"; |
84 | |||
85 | struct mu_cli_setup cli = { | ||
86 | .cfg = callout_cfg_param, | ||
87 | .prog_doc = prog_doc, | ||
88 | }; | ||
120 | 89 | ||
121 | int | 90 | int |
122 | main(int argc, char **argv) | 91 | main(int argc, char **argv) |
@@ -126,9 +95,6 @@ main(int argc, char **argv) | |||
126 | mf_init_nls(); | 95 | mf_init_nls(); |
127 | mf_proctitle_init(argc, argv, environ); | 96 | mf_proctitle_init(argc, argv, environ); |
128 | mu_alloc_die_hook = callout_alloc_die; | 97 | mu_alloc_die_hook = callout_alloc_die; |
129 | if (!program_invocation_short_name) | ||
130 | program_invocation_short_name = argv[0]; | ||
131 | argp_program_version_hook = version; | ||
132 | /* Set default logging */ | 98 | /* Set default logging */ |
133 | mu_log_facility = DEFAULT_LOG_FACILITY; | 99 | mu_log_facility = DEFAULT_LOG_FACILITY; |
134 | mu_stdstream_setup(MU_STDSTREAM_RESET_NONE); | 100 | mu_stdstream_setup(MU_STDSTREAM_RESET_NONE); |
@@ -140,18 +106,11 @@ main(int argc, char **argv) | |||
140 | mf_server_save_cmdline(argc, argv); | 106 | mf_server_save_cmdline(argc, argv); |
141 | dnsbase_init(); | 107 | dnsbase_init(); |
142 | database_cfg_init(); | 108 | database_cfg_init(); |
143 | mf_init_lock_options(); | ||
144 | mu_acl_cfg_init(); | 109 | mu_acl_cfg_init(); |
145 | srvman_init(); | 110 | srvman_init(); |
146 | mf_srvcfg_init(argv[0], NULL); | 111 | mf_srvcfg_init(argv[0], NULL); |
112 | mf_getopt(&cli, &argc, &argv, capa, 0, calloutd_config_file); | ||
147 | 113 | ||
148 | mu_argp_init(program_version, "<" PACKAGE_BUGREPORT ">"); | ||
149 | mu_site_rcfile = SYSCONFDIR "/calloutd.conf"; | ||
150 | rc = mu_app_init(&argp, capa, callout_cfg_param, argc, argv, | ||
151 | 0, NULL, NULL); | ||
152 | if (rc) | ||
153 | exit(EX_CONFIG); | ||
154 | mf_optcache_flush(); | ||
155 | mf_srvcfg_flush(); | 114 | mf_srvcfg_flush(); |
156 | 115 | ||
157 | mf_server_lint_option = "--config-lint"; | 116 | mf_server_lint_option = "--config-lint"; |
diff --git a/src/mailfromd.h b/src/mailfromd.h index a0c2fc1e..892188ae 100644 --- a/src/mailfromd.h +++ b/src/mailfromd.h | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <mfapi.h> | 21 | #include <mfapi.h> |
22 | #include <dns.h> | 22 | #include <dns.h> |
23 | #include <mailutils/alloc.h> | 23 | #include <mailutils/alloc.h> |
24 | #include <argp.h> | ||
25 | #include <sysexits.h> | 24 | #include <sysexits.h> |
26 | #define obstack_chunk_alloc malloc | 25 | #define obstack_chunk_alloc malloc |
27 | #define obstack_chunk_free free | 26 | #define obstack_chunk_free free |
@@ -647,6 +647,7 @@ static char *capa[] = { | |||
647 | "logging", | 647 | "logging", |
648 | "locking", | 648 | "locking", |
649 | "mailer", | 649 | "mailer", |
650 | ".mfd:server", | ||
650 | NULL | 651 | NULL |
651 | }; | 652 | }; |
652 | 653 | ||
@@ -1008,7 +1009,7 @@ mailfromd_show_defaults() | |||
1008 | } | 1009 | } |
1009 | 1010 | ||
1010 | static int | 1011 | static int |
1011 | argpflag(int argc, char **argv) | 1012 | args_in_order(int argc, char **argv) |
1012 | { | 1013 | { |
1013 | int i; | 1014 | int i; |
1014 | int flag = 0; | 1015 | int flag = 0; |
@@ -1017,16 +1018,15 @@ argpflag(int argc, char **argv) | |||
1017 | if (len > 3 | 1018 | if (len > 3 |
1018 | && (memcmp(argv[i], "--ru", 4) == 0 | 1019 | && (memcmp(argv[i], "--ru", 4) == 0 |
1019 | || memcmp(argv[i], "--run", 5) == 0)) { | 1020 | || memcmp(argv[i], "--run", 5) == 0)) { |
1020 | flag = ARGP_IN_ORDER; | 1021 | return 1; |
1021 | break; | ||
1022 | } | 1022 | } |
1023 | } | 1023 | } |
1024 | return flag; | 1024 | return 0; |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | 1027 | ||
1028 | static void | 1028 | static void |
1029 | provide_default_milter_server() | 1029 | provide_default_milter_server(void) |
1030 | { | 1030 | { |
1031 | if (mfd_srvman_count_servers() == 0) { | 1031 | if (mfd_srvman_count_servers() == 0) { |
1032 | mu_diag_output(MU_DIAG_WARNING, | 1032 | mu_diag_output(MU_DIAG_WARNING, |
@@ -1135,33 +1135,6 @@ struct mu_cli_setup cli = { | |||
1135 | }; | 1135 | }; |
1136 | 1136 | ||
1137 | int | 1137 | int |
1138 | mf_getopt(struct mu_cli_setup *cli, int *pargc, char ***pargv, char **capa) | ||
1139 | { | ||
1140 | struct mu_parseopt pohint; | ||
1141 | struct mu_cfg_parse_hints cfhint; | ||
1142 | |||
1143 | cfhint.site_rcfile = DEFAULT_CONFIG_FILE; | ||
1144 | cfhint.flags = MU_CFG_PARSE_SITE_RCFILE; | ||
1145 | |||
1146 | pohint.po_flags = 0; | ||
1147 | |||
1148 | pohint.po_package_name = PACKAGE_NAME; | ||
1149 | pohint.po_flags |= MU_PARSEOPT_PACKAGE_NAME; | ||
1150 | |||
1151 | pohint.po_package_url = PACKAGE_URL; | ||
1152 | pohint.po_flags |= MU_PARSEOPT_PACKAGE_URL; | ||
1153 | |||
1154 | pohint.po_bug_address = PACKAGE_BUGREPORT; | ||
1155 | pohint.po_flags |= MU_PARSEOPT_BUG_ADDRESS; | ||
1156 | |||
1157 | pohint.po_version_hook = mailfromd_version; | ||
1158 | pohint.po_flags |= MU_PARSEOPT_VERSION_HOOK; | ||
1159 | |||
1160 | mu_cli_ext (*pargc, *pargv, cli, &pohint, &cfhint, capa, NULL, | ||
1161 | pargc, pargv); | ||
1162 | } | ||
1163 | |||
1164 | int | ||
1165 | main(int argc, char **argv) | 1138 | main(int argc, char **argv) |
1166 | { | 1139 | { |
1167 | int rc; | 1140 | int rc; |
@@ -1206,12 +1179,11 @@ main(int argc, char **argv) | |||
1206 | srvman_init(); |