From 9118f5224d84b2be235cfabc1004074ae6ea1b0c Mon Sep 17 00:00:00 2001 From: Remco Rijnders Date: Wed, 22 Aug 2012 19:41:43 +0200 Subject: [PATCH] Clean up old-style parameter declarations for res.c functions --- src/res.c | 117 +++++++++++++++--------------------------------------- 1 file changed, 31 insertions(+), 86 deletions(-) diff --git a/src/res.c b/src/res.c index 98c8dc1..3733607 100644 --- a/src/res.c +++ b/src/res.c @@ -23,13 +23,6 @@ #undef DEBUG /* because there is a lot of debug code in here :-) */ -#ifndef __GLIBC__ -extern int dn_expand PROTO ((char *, char *, char *, char *, int)); -extern int dn_skipname PROTO ((char *, char *)); -extern int res_mkquery PROTO ((int, char *, int, int, char *, int, - struct rrec *, char *, int)); -#endif - extern int errno, h_errno; extern int highest_fd; extern aClient *local[]; @@ -42,7 +35,6 @@ static aCache *cachetop = NULL; static ResRQ *last, *first; static void rem_cache PROTO ((aCache *)); -static void rem_request PROTO ((ResRQ *)); static int do_query_name PROTO ((Link *, char *, ResRQ *)); static int do_query_number PROTO ((Link *, struct in_addr *, ResRQ *)); static void resend_query PROTO ((ResRQ *)); @@ -51,8 +43,6 @@ static int query_name PROTO ((char *, int, int, ResRQ *)); static aCache *make_cache PROTO ((ResRQ *)); static aCache *find_cache_name PROTO ((char *)); static aCache *find_cache_number PROTO ((ResRQ *, char *)); -static int add_request PROTO ((ResRQ *)); -static ResRQ *make_request PROTO ((Link *)); static int send_res_msg PROTO ((char *, int, int)); static ResRQ *find_id PROTO ((int)); static int hash_number PROTO ((unsigned char *)); @@ -125,8 +115,7 @@ int init_resolver (op) return ret; } -static int add_request (new) - ResRQ *new; +static int add_request (ResRQ *new) { if (!new) return -1; @@ -145,8 +134,7 @@ static int add_request (new) * remove a request from the list. This must also free any memory that has * been allocated for temporary storage of DNS results. */ -static void rem_request (old) - ResRQ *old; +static void rem_request (ResRQ *old) { ResRQ **rptr, *r2ptr = NULL; int i; @@ -181,8 +169,7 @@ static void rem_request (old) /* * Create a DNS request record for the server. */ -static ResRQ *make_request (lp) - Link *lp; +static ResRQ *make_request (Link *lp) { ResRQ *nreq; @@ -209,8 +196,7 @@ static ResRQ *make_request (lp) * Remove queries from the list which have been there too long without * being resolved. */ -time_t timeout_query_list (now) - time_t now; +time_t timeout_query_list (time_t now) { ResRQ *rptr, *r2ptr; time_t next = 0, tout; @@ -272,8 +258,7 @@ time_t timeout_query_list (now) * del_queries - called by the server to cleanup outstanding queries for * which there no longer exist clients or conf lines. */ -void del_queries (cp) - char *cp; +void del_queries (char *cp) { ResRQ *rptr, *r2ptr; @@ -291,9 +276,7 @@ void del_queries (cp) * isn't present. Returns number of messages successfully sent to * nameservers or -1 if no successful sends. */ -static int send_res_msg (msg, len, rcount) - char *msg; - int len, rcount; +static int send_res_msg (char *msg, int len, int rcount) { int i; int sent = 0, max; @@ -324,8 +307,7 @@ static int send_res_msg (msg, len, rcount) /* * find a dns request id (id is determined by dn_mkquery) */ -static ResRQ *find_id (id) - int id; +static ResRQ *find_id (int id) { ResRQ *rptr; @@ -335,9 +317,7 @@ static ResRQ *find_id (id) return NULL; } -struct hostent *gethost_byname (name, lp) - char *name; - Link *lp; +struct hostent *gethost_byname (char *name, Link *lp) { aCache *cp; @@ -350,9 +330,7 @@ struct hostent *gethost_byname (name, lp) return NULL; } -struct hostent *gethost_byaddr (addr, lp) - char *addr; - Link *lp; +struct hostent *gethost_byaddr (char *addr, Link *lp) { aCache *cp; @@ -365,10 +343,7 @@ struct hostent *gethost_byaddr (addr, lp) return NULL; } -static int do_query_name (lp, name, rptr) - Link *lp; - char *name; - ResRQ *rptr; +static int do_query_name (Link *lp, char *name, ResRQ *rptr) { char hname[HOSTLEN + 1]; int len; @@ -397,10 +372,7 @@ static int do_query_name (lp, name, rptr) /* * Use this to do reverse IP# lookups. */ -static int do_query_number (lp, numb, rptr) - Link *lp; - struct in_addr *numb; - ResRQ *rptr; +static int do_query_number (Link *lp, struct in_addr *numb, ResRQ *rptr) { char ipbuf[32]; u_char *cp; @@ -423,10 +395,7 @@ static int do_query_number (lp, numb, rptr) /* * generate a query based on class, type and name. */ -static int query_name (name, class, type, rptr) - char *name; - int class, type; - ResRQ *rptr; +static int query_name (char *name, int class, int type, ResRQ *rptr) { struct timeval tv; char buf[MAXPACKET]; @@ -469,8 +438,7 @@ static int query_name (name, class, type, rptr) return 0; } -static void resend_query (rptr) - ResRQ *rptr; +static void resend_query (ResRQ *rptr) { if (rptr->resend == 0) return; @@ -491,10 +459,7 @@ static void resend_query (rptr) /* * process name server reply. */ -static int proc_answer (rptr, hptr, buf, eob) - ResRQ *rptr; - char *buf, *eob; - HEADER *hptr; +static int proc_answer (ResRQ *rptr, HEADER *hptr, char *buf, char *eob) { char *cp, **alias; struct hent *hp; @@ -509,11 +474,7 @@ static int proc_answer (rptr, hptr, buf, eob) alias = hp->h_aliases; while (*alias) alias++; -#ifdef SOL20 /* brain damaged compiler (Solaris2) it seems */ - for (; hptr->qdcount > 0; hptr->qdcount--) -#else while (hptr->qdcount-- > 0) -#endif /* SOL20 */ if ((n = dn_skipname (cp, eob)) == -1) break; else @@ -614,8 +575,7 @@ static int proc_answer (rptr, hptr, buf, eob) /* * read a dns reply from the nameserver and process it. */ -struct hostent *get_res (lp) - char *lp; +struct hostent *get_res (char *lp) { static char buf[sizeof (HEADER) + MAXPACKET]; HEADER *hptr; @@ -781,8 +741,7 @@ struct hostent *get_res (lp) return (struct hostent *) NULL; } -static int hash_number (ip) - unsigned char *ip; +static int hash_number (unsigned char *ip) { u_int hashv = 0; @@ -795,8 +754,7 @@ static int hash_number (ip) return (hashv); } -static int hash_name (name) - register char *name; +static int hash_name (char *name) { u_int hashv = 0; @@ -814,8 +772,7 @@ static int hash_name (name) /* ** Add a new cache item to the queue and hash table. */ -static aCache *add_to_cache (ocp) - aCache *ocp; +static aCache *add_to_cache (aCache *ocp) { aCache *cp = NULL; int hashv; @@ -861,11 +818,9 @@ static aCache *add_to_cache (ocp) /* ** update_list does not alter the cache structure passed. It is assumed that ** it already contains the correct expire time, if it is a new entry. Old - ** entries have the expirey time updated. + ** entries have the expiration time updated. */ -static void update_list (rptr, cachep) - ResRQ *rptr; - aCache *cachep; +static void update_list (ResRQ *rptr, aCache *cachep) { aCache **cpp, *cp = cachep; char *s, *t, **base; @@ -971,8 +926,7 @@ static void update_list (rptr, cachep) return; } -static aCache *find_cache_name (name) - char *name; +static aCache *find_cache_name (char *name) { aCache *cp; char *s; @@ -1014,9 +968,7 @@ static aCache *find_cache_name (name) /* * find a cache entry by ip# and update its expire time */ -static aCache *find_cache_number (rptr, numb) - ResRQ *rptr; - char *numb; +static aCache *find_cache_number (ResRQ *rptr, char *numb) { aCache *cp; int hashv, i; @@ -1062,8 +1014,7 @@ static aCache *find_cache_number (rptr, numb) return NULL; } -static aCache *make_cache (rptr) - ResRQ *rptr; +static aCache *make_cache (ResRQ *rptr) { aCache *cp; int i, n; @@ -1151,8 +1102,7 @@ static aCache *make_cache (rptr) * delete a cache entry from the cache structures and lists and return * all memory used for the cache back to the memory pool. */ -static void rem_cache (ocp) - aCache *ocp; +static void rem_cache (aCache *ocp) { aCache **cp; struct hostent *hp = &ocp->he; @@ -1233,11 +1183,10 @@ static void rem_cache (ocp) } /* - * removes entries from the cache which are older than their expirey times. + * removes entries from the cache which are older than their expiration time. * returns the time at which the server should next poll the cache. */ -time_t expire_cache (now) - time_t now; +time_t expire_cache (time_t now) { aCache *cp, *cp2; time_t next = 0; @@ -1266,10 +1215,7 @@ void flush_cache () rem_cache (cp); } -int m_dns (cptr, sptr, parc, parv) - aClient *cptr, *sptr; - int parc; - char *parv[]; +int m_dns (aClient *cptr, aClient *sptr, int parc, char *parv[]) { aCache *cp; int i; @@ -1304,12 +1250,11 @@ int m_dns (cptr, sptr, parc, parv) return 0; } -u_long cres_mem (sptr) - aClient *sptr; +u_long cres_mem (aClient *sptr) { - register aCache *c = cachetop; - register struct hostent *h; - register int i; + aCache *c = cachetop; + struct hostent *h; + int i; u_long nm = 0, im = 0, sm = 0, ts = 0; for (; c; c = c->list_next) { -- 2.30.2