summaryrefslogtreecommitdiffabout
path: root/src/main.c
authorSergey Poznyakoff <gray@gnu.org.ua>2015-04-27 10:11:18 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2015-04-27 10:19:06 (GMT)
commitef07786925303a1f8588a061b66034e066f533da (patch) (side-by-side diff)
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') (more/less context) (show whitespace changes)
-rw-r--r--src/main.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/main.c b/src/main.c
index 5fbc368..65329a4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -259,12 +259,11 @@ 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);
}
}
@@ -277,30 +276,31 @@ 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);
}
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 }
};

Return to:

Send suggestions and report system problems to the System administrator.