diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 32 | ||||
-rw-r--r-- | src/mfdbtool.c | 13 | ||||
-rw-r--r-- | src/srvcfg.c | 75 |
3 files changed, 62 insertions, 58 deletions
@@ -261,8 +261,7 @@ host_in_relayed_domain_p(char *client) static void -set_milter_timeout(void *value) +set_milter_timeout(union mf_option_value *val) { - time_t to = *(time_t*) value; - free(value); - if (smfi_settimeout(to) == MI_FAILURE) { - mu_error(_("invalid milter timeout: %lu"), (unsigned long) to); + if (smfi_settimeout(val->ov_time) == MI_FAILURE) { + mu_error(_("invalid milter timeout: %lu"), + (unsigned long)val->ov_time); exit(EX_USAGE); @@ -279,5 +278,6 @@ load_relay_file(void *item, void *data) static void -set_relay(void *value) +set_relay(union mf_option_value *val) { - mu_list_foreach(value, load_relay_file, NULL); + mu_list_foreach(val->ov_list, load_relay_file, NULL); + mu_list_destroy(&val->ov_list); } @@ -285,5 +285,5 @@ set_relay(void *value) void -set_stack_trace(void *value) +set_stack_trace(union mf_option_value *val) { - stack_trace_option = (int) value; + stack_trace_option = val->ov_bool; } @@ -291,7 +291,7 @@ set_stack_trace(void *value) static int -option_relay(char *opt, void **pval, char *newval) +option_relay(char const *opt, union mf_option_value *val, char const *newval) { - if (!*pval) - mu_list_create((mu_list_t*)pval); - mu_list_append(*pval, strdup(newval)); + if (!val->ov_list) + mu_list_create(&val->ov_list); + mu_list_append(val->ov_list, strdup(newval)); return 0; @@ -300,5 +300,5 @@ option_relay(char *opt, void **pval, char *newval) struct mf_option_cache option_cache[] = { - { "stack-trace", NULL, mf_option_boolean, set_stack_trace }, - { "milter-timeout", NULL, mf_option_time, set_milter_timeout }, - { "relay", NULL, option_relay, set_relay }, + { "stack-trace", mf_option_boolean, set_stack_trace }, + { "milter-timeout", mf_option_timeout, set_milter_timeout }, + { "relay", option_relay, set_relay }, { NULL } diff --git a/src/mfdbtool.c b/src/mfdbtool.c index dd723c38..4af386ad 100644 --- a/src/mfdbtool.c +++ b/src/mfdbtool.c @@ -360,5 +360,5 @@ struct mu_cfg_param mfdbtool_cfg_param[] = { static void -set_state_directory(void *value) +set_state_directory(union mf_option_value *val) { - state_dir = value; + state_dir = val->ov_string; } @@ -366,5 +366,6 @@ set_state_directory(void *value) static void -set_debug(void *value) +set_debug(union mf_option_value *val) { - mu_debug_parse_spec(value); + mu_debug_parse_spec(val->ov_string); + free(val->ov_string); } @@ -372,4 +373,4 @@ set_debug(void *value) static struct mf_option_cache option_cache[] = { - { "state-directory", NULL, mf_option_string, set_state_directory }, - { "debug", NULL, mf_option_string, set_debug }, + { "state-directory", mf_option_string, set_state_directory }, + { "debug", mf_option_string, set_debug }, diff --git a/src/srvcfg.c b/src/srvcfg.c index 40d56b89..4b338f82 100644 --- a/src/srvcfg.c +++ b/src/srvcfg.c @@ -139,5 +139,6 @@ parse_milter_url(const char *str) static void -set_debug(void *value) +set_debug(union mf_option_value *val) { - mu_debug_parse_spec(value); + mu_debug_parse_spec(val->ov_string); + free(val->ov_string); } @@ -145,5 +146,5 @@ set_debug(void *value) void -set_source_info(void *value) +set_source_info(union mf_option_value *val) { - mu_debug_line_info = (int) value; + mu_debug_line_info = val->ov_bool; } @@ -151,5 +152,5 @@ set_source_info(void *value) static void -set_user(void *value) +set_user(union mf_option_value *val) { - mf_server_user = value; + mf_server_user = val->ov_string; } @@ -187,5 +188,5 @@ mf_option_group(const char *arg) static int -option_group(char *opt, void **pval, char *newval) +option_group(char const *opt, union mf_option_value *val, char const *arg) { - return mf_option_group(newval); + return mf_option_group(arg); } @@ -193,5 +194,5 @@ option_group(char *opt, void **pval, char *newval) static int -option_pidfile(char *opt, void **pval, char *newval) +option_pidfile(char const *opt, union mf_option_value *val, char const *arg) { - if (newval[0] != '/') { + if (arg[0] != '/') { mu_error(_("invalid pidfile name: must be absolute")); @@ -199,3 +200,3 @@ option_pidfile(char *opt, void **pval, char *newval) } - return mf_option_string(opt, pval, newval); + return mf_option_string(opt, val, arg); } @@ -203,5 +204,5 @@ option_pidfile(char *opt, void **pval, char *newval) static void -set_pidfile(void *value) +set_pidfile(union mf_option_value *val) { - pidfile = value; + pidfile = val->ov_string; } @@ -209,6 +210,5 @@ set_pidfile(void *value) static void -set_io_timeout(void *value) +set_io_timeout(union mf_option_value *val) { - io_timeout = *(time_t*) value; - free(value); + io_timeout = val->ov_time; } @@ -216,5 +216,5 @@ set_io_timeout(void *value) static void -set_logger_option(void *value) +set_logger_option(union mf_option_value *val) { - log_stream = value; + log_stream = val->ov_string; } @@ -245,3 +245,3 @@ mf_option_state_directory(const char *arg) void -set_state_directory(void *value) +set_state_directory(union mf_option_value *val) { @@ -251,5 +251,6 @@ set_state_directory(void *value) int -option_state_directory(char *opt, void **pval, char *newval) +option_state_directory(char const *opt, union mf_option_value *val, + char const *arg) { - return mf_option_state_directory(newval); + return mf_option_state_directory(arg); } @@ -284,5 +285,6 @@ mf_srvcfg_add(const char *type, const char *urlstr) static void -set_port(void *value) +set_port(union mf_option_value *val) { - mf_srvcfg_add("default", value); + mf_srvcfg_add("default", val->ov_string); + free(val->ov_string); } @@ -290,3 +292,3 @@ set_port(void *value) static void -set_source_ip(void *value) +set_source_ip(union mf_option_value *val) { @@ -299,3 +301,3 @@ set_source_ip(void *value) hints.protocol = IPPROTO_TCP; - rc = mu_sockaddr_from_node(&source_address, (char*)value, NULL, + rc = mu_sockaddr_from_node(&source_address, val->ov_string, NULL, &hints); @@ -303,4 +305,5 @@ set_source_ip(void *value) mu_error(_("cannot convert %s to sockaddr: %s"), - (char*)value, mu_strerror(rc)); + val->ov_string, mu_strerror(rc)); } + free(val->ov_string); } @@ -308,13 +311,13 @@ set_source_ip(void *value) static struct mf_option_cache srv_option_cache[] = { - { "debug", NULL, mf_option_string, set_debug }, - { "source-info", NULL, mf_option_boolean, set_source_info }, - { "user", NULL, mf_option_string, set_user }, - { "group", NULL, option_group, NULL }, - { "pidfile", NULL, option_pidfile, set_pidfile }, - { "source-ip", NULL, mf_option_string, set_source_ip }, - { "io-timeout", NULL, mf_option_time, set_io_timeout }, - { "logger", NULL, mf_option_string, set_logger_option }, - { "state-directory", NULL, option_state_directory, + { "debug", mf_option_string, set_debug }, + { "source-info", mf_option_boolean, set_source_info }, + { "user", mf_option_string, set_user }, + { "group", option_group, NULL }, + { "pidfile", option_pidfile, set_pidfile }, + { "source-ip", mf_option_string, set_source_ip }, + { "io-timeout", mf_option_timeout, set_io_timeout }, + { "logger", mf_option_string, set_logger_option }, + { "state-directory", option_state_directory, set_state_directory }, - { "port", NULL, mf_option_string, set_port }, + { "port", mf_option_string, set_port }, { NULL } |