diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-02-19 08:12:56 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-02-19 08:12:56 +0000 |
commit | 59570db68d1c94a36d82d4ede356880d2dcea0ef (patch) | |
tree | 75b75e29c05b6106c253124e65cd897c27777ebe | |
parent | fd20b4cc9033e02cd41fc91265c70b2b078cf478 (diff) | |
download | mailfromd-59570db68d1c94a36d82d4ede356880d2dcea0ef.tar.gz mailfromd-59570db68d1c94a36d82d4ede356880d2dcea0ef.tar.bz2 |
Syntax cleanup
git-svn-id: file:///svnroot/mailfromd/trunk@1254 7a8a7f39-df28-0410-adc6-e0d955640f24
-rw-r--r-- | src/dns.h | 11 | ||||
-rw-r--r-- | src/dnsbase.c | 48 | ||||
-rw-r--r-- | src/main.c | 64 | ||||
-rw-r--r-- | src/prog.c | 1 | ||||
-rw-r--r-- | src/spf.c | 10 | ||||
-rw-r--r-- | src/spf.h | 20 |
6 files changed, 75 insertions, 79 deletions
@@ -66,8 +66,8 @@ typedef char *mxbuf_t[MAXMXCOUNT]; res_querydomain(name,domain,class,type,answer,anslen) #endif -int dns_str_is_ipv4(char *addr); -dns_status dns_get_mx_records(char *host, int maxdepth, mxbuf_t mxbuf, +int dns_str_is_ipv4(const char *addr); +dns_status dns_get_mx_records(const char *host, int maxdepth, mxbuf_t mxbuf, size_t *mxcount, unsigned long *ttl); void dns_freemx(mxbuf_t mxbuf); @@ -77,17 +77,18 @@ dns_status dns_resolve_ipstr(const char *ipstr, const char *domain, char *answer, size_t answer_size, char *hbuf, size_t hbsize, unsigned long *ttl); -dns_status dns_resolve_hostname(char *host, char *answer, size_t answer_size, +dns_status dns_resolve_hostname(const char *host, + char *answer, size_t answer_size, char *ipbuf, size_t ipbsize, unsigned long *ttl); -dns_status a_lookup(char *host, +dns_status a_lookup(const char *host, GACOPYZ_UINT32_T *ipbuf, size_t ipbsize, size_t *ipcount, unsigned long *ttl, char *answer, size_t answer_size); dns_status ptr_lookup(struct in_addr ip, char **names, size_t maxnames, unsigned long *ttl, char *answer, size_t answer_size); -dns_status txt_lookup(char *name, +dns_status txt_lookup(const char *name, char **names, size_t maxnames, unsigned long *ttl, char *answer, size_t answer_size); diff --git a/src/dnsbase.c b/src/dnsbase.c index 5158bd36..203ce012 100644 --- a/src/dnsbase.c +++ b/src/dnsbase.c @@ -55,7 +55,7 @@ comp_pref(const void *a, const void *b) Let's hope that someday this stupidity will change. */ static dns_status -_getmx(char *host, char *answer, size_t answer_size, mxbuf_t mxbuf, +_getmx(const char *host, char *answer, size_t answer_size, mxbuf_t mxbuf, size_t *pcount, unsigned long *pttl) { int i, n, nmx; @@ -154,7 +154,7 @@ _getmx(char *host, char *answer, size_t answer_size, mxbuf_t mxbuf, } int -dns_str_is_ipv4(char *addr) +dns_str_is_ipv4(const char *addr) { int dot_count; int digit_count; @@ -181,8 +181,8 @@ MUTEX_DCL(dns_mutex) to its parent domains until any record is found or recursion depth reaches MAXDEPTH */ dns_status -dns_get_mx_records(char *host, int maxdepth, mxbuf_t mxbuf, size_t *mxcount, - unsigned long *ttl) +dns_get_mx_records(const char *host, int maxdepth, mxbuf_t mxbuf, + size_t *mxcount, unsigned long *ttl) { char *hbuf = NULL; dns_status status = dns_failure; @@ -199,7 +199,7 @@ dns_get_mx_records(char *host, int maxdepth, mxbuf_t mxbuf, size_t *mxcount, if (!answer) status = dns_failure; else { - char *p; + const char *p; int depth; for (p = host, depth = 0; p && depth < maxdepth; @@ -518,7 +518,6 @@ dns_resolve_ipstr(const char *ipstr, const char *domain, char *answer, size_t answer_size, char *hbuf, size_t hbsize, unsigned long *ttl) { - int i; char namebuf[NSIZE]; char domainbuf[NSIZE]; struct loop_data ld; @@ -565,15 +564,15 @@ dns_resolve_ipstr(const char *ipstr, const char *domain, } dns_status -dns_resolve_hostname(char *host, char *answer, size_t answer_size, +dns_resolve_hostname(const char *host, char *answer, size_t answer_size, char *ipbuf, size_t ipbsize, unsigned long *ttl) { struct loop_data ld; char domainbuf[256] = ""; ld.qtype = ld.atype = T_A; - ld.name = host; - ld.name_size = strlen(host); + ld.name = xstrdup(host); + ld.name_size = strlen(ld.name); ld.domain = domainbuf; ld.domain_size = sizeof domainbuf; ld.answer = answer; @@ -587,6 +586,8 @@ dns_resolve_hostname(char *host, char *answer, size_t answer_size, cnameloop(&ld); + free(ld.name); + if (ld.status == dns_success && ld.atype == T_A) { struct in_addr s; char *p; @@ -601,7 +602,7 @@ dns_resolve_hostname(char *host, char *answer, size_t answer_size, dns_status -a_lookup(char *host, +a_lookup(const char *host, GACOPYZ_UINT32_T *ipbuf, size_t ipbsize, size_t *ipcount, unsigned long *ttl, char *answer, size_t answer_size) { @@ -609,8 +610,8 @@ a_lookup(char *host, char domainbuf[256] = ""; ld.qtype = ld.atype = T_A; - ld.name = host; - ld.name_size = strlen(host); + ld.name = xstrdup(host); + ld.name_size = strlen(ld.name); ld.domain = domainbuf; ld.domain_size = sizeof domainbuf; ld.answer = answer; @@ -623,7 +624,7 @@ a_lookup(char *host, ld.loopcnt = MAXCNAMEDEPTH; cnameloop(&ld); - + free(ld.name); if (ld.status == dns_success) { if (ipcount) *ipcount = ld.hbcount; @@ -650,8 +651,6 @@ ptr_lookup(struct in_addr ip, char **names, size_t maxnames, unsigned long *ttl, char *answer, size_t answer_size) { - int i; - IPBUF ipstr; char namebuf[NSIZE]; char domainbuf[NSIZE]; char hbuf[NSIZE]; @@ -689,22 +688,18 @@ ptr_lookup(struct in_addr ip, } dns_status -txt_lookup(char *name, +txt_lookup(const char *name, char **names, size_t maxnames, unsigned long *ttl, char *answer, size_t answer_size) { - int i; - IPBUF ipstr; - char namebuf[NSIZE]; char domainbuf[NSIZE]; char hbuf[NSIZE]; struct loop_data ld; - char *p; ld.qtype = T_TXT; ld.atype = T_TXT; - ld.name = name; - ld.name_size = strlen(name); + ld.name = xstrdup(name); + ld.name_size = strlen(ld.name); ld.domain = domainbuf; ld.domain_size = sizeof domainbuf; ld.answer = answer; @@ -718,6 +713,8 @@ txt_lookup(char *name, cnameloop(&ld); + free(ld.name); + if (ld.status == dns_success) { textbuf_to_argv(ld.hbuf, ld.hbcount, names, maxnames); if (ttl) @@ -727,11 +724,12 @@ txt_lookup(char *name, return ld.status; } -/* FIXME: This is a placeholder for a function that should look up for any SPF or TXT - records for DOMAIN. If any SPF are found, TXT should be discarded. +/* FIXME: This is a placeholder for a function that should look up for any + SPF or TXT records for DOMAIN. If any SPF are found, TXT should be + discarded. For the time being, it handles only TXT */ dns_status -spf_lookup(char *domain, +spf_lookup(const char *domain, char **txt, size_t maxtxt, unsigned long *ttl, char *answer, size_t answer_size) { @@ -450,15 +450,17 @@ host_in_relayed_domain_p(char *client) values in option_cache. Finally, process_options() is called that scans the cache and actually sets any options found there. */ +static int option_string(char *opt, void **pval, char *newval); + /* Deprecated options: */ -int +static int option_deprecated(char *opt, void **pval, char *newval) { parse_warning("deprecated option %s ignored", opt); return 0; } -int +static int option_ehlo(char *opt, void **pval, char *newval) { if (get_locus()->file) @@ -474,13 +476,13 @@ option_ehlo(char *opt, void **pval, char *newval) return option_string(opt, pval, newval); } -void +static void set_ehlo(void *value) { defer_initialize_variable("ehlo_domain", value); } -int +static int option_mailfrom(char *opt, void **pval, char *newval) { int rc; @@ -510,7 +512,7 @@ option_mailfrom(char *opt, void **pval, char *newval) return option_string(opt, pval, newval); } -void +static void set_mailfrom(void *value) { int rc; @@ -533,53 +535,53 @@ set_mailfrom(void *value) /* Other options */ -void +static void set_debug(void *value) { enable_debug_list(value); } -void +static void set_positive_expire(void *value) { cache_format->expire_interval = *(time_t*) value; free(value); } -void +static void set_negative_expire(void *value) { negative_expire_interval = *(time_t*) value; free(value); } -void +static void set_expire(void *value) { expire_interval = *(time_t*) value; free(value); } -void +static void set_rates_expire(void *value) { rate_format->expire_interval = *(time_t*) value; free(value); } -void +static void set_port(void *value) { portspec = value; } -void +static void set_user(void *value) { user = value; } -void +static void set_milter_timeout(void *value) { time_t to = *(time_t*) value; @@ -590,27 +592,27 @@ set_milter_timeout(void *value) } } -void +static void set_pidfile(void *value) { pidfile = value; } -void +static void set_io_timeout(void *value) { io_timeout = *(time_t*) value; free(value); } -void +static void set_connect_timeout(void *value) { connect_timeout = *(time_t*) value; free(value); } -void +static void set_response_timeout(void *value) { response_timeout = *(time_t*) value; @@ -624,19 +626,19 @@ load_relay_file(void *item, void *data) return 0; } -void +static void set_relay(void *value) { mu_list_do(value, load_relay_file, NULL); } -void +static void set_source(void *value) { source_address = *(unsigned long*)value; } -void +static void set_group(void *value) { /* do nothing */ @@ -648,20 +650,20 @@ set_source_info(void *value) source_info_option = (int) value; } -void +static void set_lock_retry_count(void *value) { lock_retry_count_option = strtoul(value, NULL, 0); } -void +static void set_lock_retry_timeout(void *value) { lock_retry_timeout_option = *(time_t*) value; free(value); } -int +static int option_string(char *opt, void **pval, char *newval) { if (*pval) @@ -670,7 +672,7 @@ option_string(char *opt, void **pval, char *newval) return 0; } -int +static int option_number(char *opt, void **pval, char *newval) { char *p; @@ -683,7 +685,7 @@ option_number(char *opt, void **pval, char *newval) return option_string(opt, pval, newval); } -int +static int option_boolean(char *opt, void **pval, char *newval) { int val; @@ -710,13 +712,13 @@ option_boolean(char *opt, void **pval, char *newval) return 0; } -int +static int option_debug(char *opt, void **pval, char *newval) { return option_string(opt, pval, newval); } -int +static int option_time(char *opt, void **pval, char *newval) { time_t interval; @@ -732,7 +734,7 @@ option_time(char *opt, void **pval, char *newval) return 0; } -int +static int option_pidfile(char *opt, void **pval, char *newval) { if (newval[0] != '/') { @@ -743,7 +745,7 @@ option_pidfile(char *opt, void **pval, char *newval) return 0; } -int +static int option_relay(char *opt, void **pval, char *newval) { if (!*pval) @@ -752,7 +754,7 @@ option_relay(char *opt, void **pval, char *newval) return 0; } -int +static int option_source(char *opt, void **pval, char *newval) { unsigned long address = inet_addr (newval); @@ -780,7 +782,7 @@ gid_comp(const void *item, const void *data) return (gid_t) item != (gid_t) data; } -int +static int option_group(char *opt, void **pval, char *newval) { struct group *group = getgrnam(newval); @@ -2038,7 +2038,6 @@ print_code() size_t epcount = 0; /* Number of entry points */ size_t i; struct enum_data d; - prog_counter_t ip; /* Count all available entry points: */ for (tag = smtp_state_first; tag < smtp_state_count; tag++) @@ -386,7 +386,7 @@ spf_expand_do(struct spf_data *dat, int allow_exp, const char **pptr) int _spf_macro_expand(const char *input, struct spf_data *dat, int allow_exp) { - const char *p, *start; + const char *p; while (p = strchr(input, '%')) { size_t len = p - input; @@ -615,7 +615,6 @@ static spf_term_result mech_mx(spf_data *dat, spf_term_arg *arg, unsigned long masklen) { unsigned long netmask = make_netmask(masklen); - dns_status dstat; mxbuf_t mxbuf; size_t i, mxcount; spf_term_result result = spf_term_nomatch; @@ -660,7 +659,7 @@ mech_ptr(spf_data *dat, spf_term_arg *arg, unsigned long masklen) char **vnames; size_t vcount; size_t i; - char *domain_spec; + const char *domain_spec; spf_term_result result = spf_term_nomatch; if (arg) @@ -716,8 +715,6 @@ mech_ip6(spf_data *dat, spf_term_arg *arg, unsigned long masklen) static spf_term_result mech_exists(spf_data *dat, spf_term_arg *arg, unsigned long masklen) { - dns_status dstat; - if (!arg) { debug(1, "exists used without argument"); dat->result = spf_perm_error; @@ -736,8 +733,6 @@ mech_exists(spf_data *dat, spf_term_arg *arg, unsigned long masklen) static spf_term_result mod_redirect(spf_data *dat, spf_term_arg *arg, unsigned long masklen) { - spf_result res; - dat->result = spf_check_host(dat->ipstr, arg->v.domain_spec, dat->sender, dat->helo, dat->my_domain); if (dat->result == spf_none) @@ -1097,7 +1092,6 @@ spf_check_host(const char *ip, const char *domain, const char *sender, if (strlen(domain) > 63) SPF_RETURN(spf_none, "domain to long"); - switch (spf_lookup(domain, txt_rec, NELEMS(txt_rec), NULL, NULL, 0)) { case dns_success: break; @@ -23,15 +23,17 @@ typedef enum { spf_fail, spf_soft_fail, spf_temp_error, - spf_perm_error, + spf_perm_error - max_spf_result +#define max_spf_result (spf_perm_error+1) } spf_result; -spf_result -spf_check_host(const char *ip, const char *domain, const char *sender, - const char *helo_domain, const char *my_domain); -spf_result -spf_test_record(const char *rec, - const char *ip, const char *domain, const char *sender, - const char *helo_domain, const char *my_domain); +spf_result spf_check_host(const char *ip, const char *domain, + const char *sender, + const char *helo_domain, const char *my_domain); +spf_result spf_test_record(const char *rec, + const char *ip, const char *domain, + const char *sender, + const char *helo_domain, const char *my_domain); +dns_status spf_lookup(const char *domain, char **txt, size_t maxtxt, + unsigned long *ttl, char *answer, size_t answer_size); |