aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2015-04-27 13:11:18 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2015-04-27 13:19:06 +0300
commitef07786925303a1f8588a061b66034e066f533da (patch)
tree7318ebaddf37e5afa790ba13535a05b7b1075cfd /src/main.c
parentb6173eeaf3311d9de26d530d5ff07fdf6ddddcad (diff)
downloadmailfromd-ef07786925303a1f8588a061b66034e066f533da.tar.gz
mailfromd-ef07786925303a1f8588a061b66034e066f533da.tar.bz2
Avoid casts between pointers and integers (optcache)
* lib/libmf.h (mf_option_value): Union. (mf_option_cache): Rearrange members. (handler,set): Change signature. (isset): New member. (mf_optcache_set_option): Change signature. (mf_option_string,mf_option_boolean): Likewise. (mf_option_time_t,mf_option_size_t): Remove. (mf_option_timeout,mf_option_size): New prototypes. * lib/optcache.c (optcache_dup): Clear isset member for each element. (mf_optcache_set_option): Rewrite. (mf_option_string, mf_option_boolean): Rewrite. (mf_option_time_t,mf_option_size_t): Remove. (mf_option_timeout,mf_option_size): New functions. * lib/utils.c: Change the use of mf_optcache functions. * src/main.c: Likewise. * src/mfdbtool.c: Likewise. * src/srvcfg.c: Likewise.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/main.c b/src/main.c
index 5fbc3682..65329a42 100644
--- a/src/main.c
+++ b/src/main.c
@@ -256,54 +256,54 @@ host_in_relayed_domain_p(char *client)
free(hbuf);
return rc;
}
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);
}
}
static int
load_relay_file(void *item, void *data)
{
read_domain_file(item);
return 0;
}
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);
}
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;
}
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;
}
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 }
};
/* Command line parsing */

Return to:

Send suggestions and report system problems to the System administrator.