From: hno <> Date: Wed, 17 Oct 2001 23:55:23 +0000 (+0000) Subject: Converted to ANSI C X-Git-Tag: SQUID_3_0_PRE1~1348 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1df14bea0dc4f8dfaeed9ea51020268d543f433c;p=thirdparty%2Fsquid.git Converted to ANSI C --- diff --git a/include/radix.h b/include/radix.h index 49d756c94e..de0f91e09d 100644 --- a/include/radix.h +++ b/include/radix.h @@ -1,5 +1,5 @@ /* - * $Id: radix.h,v 1.10 2001/10/08 16:18:31 hno Exp $ + * $Id: radix.h,v 1.11 2001/10/17 17:55:23 hno Exp $ */ #ifndef SQUID_RADIX_H @@ -41,9 +41,6 @@ */ #undef RN_DEBUG -#ifndef __P -#define __P(x) x -#endif /* * Radix search tree node layout. */ @@ -116,44 +113,45 @@ struct radix_node_head { int rnh_addrsize; /* permit, but not require fixed keys */ int rnh_pktsize; /* permit, but not require fixed keys */ struct radix_node *(*rnh_addaddr) /* add based on sockaddr */ - __P((void *v, void *mask, - struct radix_node_head * head, struct radix_node nodes[])); + (void *v, void *mask, + struct radix_node_head * head, struct radix_node nodes[]); struct radix_node *(*rnh_addpkt) /* add based on packet hdr */ - __P((void *v, void *mask, - struct radix_node_head * head, struct radix_node nodes[])); + (void *v, void *mask, + struct radix_node_head * head, struct radix_node nodes[]); struct radix_node *(*rnh_deladdr) /* remove based on sockaddr */ - __P((void *v, void *mask, struct radix_node_head * head)); + (void *v, void *mask, struct radix_node_head * head); struct radix_node *(*rnh_delpkt) /* remove based on packet hdr */ - __P((void *v, void *mask, struct radix_node_head * head)); + (void *v, void *mask, struct radix_node_head * head); struct radix_node *(*rnh_matchaddr) /* locate based on sockaddr */ - __P((void *v, struct radix_node_head * head)); + (void *v, struct radix_node_head * head); struct radix_node *(*rnh_lookup) /* locate based on sockaddr */ - __P((void *v, void *mask, struct radix_node_head * head)); + (void *v, void *mask, struct radix_node_head * head); struct radix_node *(*rnh_matchpkt) /* locate based on packet hdr */ - __P((void *v, struct radix_node_head * head)); + (void *v, struct radix_node_head * head); int (*rnh_walktree) /* traverse tree */ - __P((struct radix_node_head * head, int (*f) (), void *w)); + (struct radix_node_head * head, int (*f) (struct radix_node *, void *), void *w); struct radix_node rnh_nodes[3]; /* empty tree for common case */ }; #define Bcmp(a, b, n) memcmp(((char *)(a)), ((char *)(b)), (n)) #define Bcopy(a, b, n) memcpy(((char *)(b)), ((char *)(a)), (unsigned)(n)) -#define Bzero(p, n) memset((char *)(p),'\0', (int)(n)); +#define Bzero(p, n) memset((char *)(p),'\0', (int)(n)) #define R_Malloc(p, t, n) (p = (t) xmalloc((unsigned int)(n))) -#define Free(p) xfree((char *)p); +#define Free(p) xfree((char *)p) -void rn_init __P((void)); -int rn_inithead __P((void **, int)); -int rn_refines __P((void *, void *)); -int rn_walktree __P((struct radix_node_head *, int (*)(), void *)); -struct radix_node - *rn_addmask __P((void *, int, int)), *rn_addroute __P((void *, void *, struct radix_node_head *, - struct radix_node[2])), *rn_delete __P((void *, void *, struct radix_node_head *)), - *rn_insert __P((void *, struct radix_node_head *, int *, - struct radix_node[2])), *rn_match __P((void *, struct radix_node_head *)), - *rn_newpair __P((void *, int, struct radix_node[2])), *rn_search __P((void *, struct radix_node *)), - *rn_search_m __P((void *, struct radix_node *, void *)); +extern void rn_init (void); +extern int rn_inithead(void **, int); +extern int rn_refines(void *, void *); +extern int rn_walktree(struct radix_node_head *, int (*)(struct radix_node *, void *), void *); +extern struct radix_node *rn_addmask(void *, int, int); +extern struct radix_node *rn_addroute(void *, void *, struct radix_node_head *, struct radix_node[2]); +extern struct radix_node *rn_delete(void *, void *, struct radix_node_head *); +extern struct radix_node *rn_insert(void *, struct radix_node_head *, int *, struct radix_node[2]); +extern struct radix_node *rn_match(void *, struct radix_node_head *); +extern struct radix_node *rn_newpair(void *, int, struct radix_node[2]); +extern struct radix_node *rn_search(void *, struct radix_node *); +extern struct radix_node *rn_search_m(void *, struct radix_node *, void *); extern struct radix_node *rn_lookup(void *, void *, struct radix_node_head *); #define min(x,y) ((x)<(y)? (x) : (y)) diff --git a/lib/radix.c b/lib/radix.c index 6b1b77b60f..0577dd5d89 100644 --- a/lib/radix.c +++ b/lib/radix.c @@ -1,5 +1,5 @@ /* - * $Id: radix.c,v 1.14 2001/08/03 16:55:21 wessels Exp $ + * $Id: radix.c,v 1.15 2001/10/17 17:55:23 hno Exp $ * * DEBUG: section 53 Radix tree data structure implementation * AUTHOR: NetBSD Derived @@ -159,9 +159,7 @@ static char *rn_zeros, *rn_ones; */ struct radix_node * -rn_search(v_arg, head) - void *v_arg; - struct radix_node *head; +rn_search(void *v_arg, struct radix_node *head) { register struct radix_node *x; register caddr_t v; @@ -176,9 +174,7 @@ rn_search(v_arg, head) } struct radix_node * -rn_search_m(v_arg, head, m_arg) - struct radix_node *head; - void *v_arg, *m_arg; +rn_search_m(void *v_arg, struct radix_node *head, void *m_arg) { register struct radix_node *x; register caddr_t v = v_arg, m = m_arg; @@ -194,8 +190,7 @@ rn_search_m(v_arg, head, m_arg) } int -rn_refines(m_arg, n_arg) - void *m_arg, *n_arg; +rn_refines(void *m_arg, void *n_arg) { register caddr_t m = m_arg, n = n_arg; register caddr_t lim, lim2 = lim = n + *(u_char *) n; @@ -221,9 +216,7 @@ rn_refines(m_arg, n_arg) } struct radix_node * -rn_lookup(v_arg, m_arg, head) - void *v_arg, *m_arg; - struct radix_node_head *head; +rn_lookup(void *v_arg, void *m_arg, struct radix_node_head *head) { register struct radix_node *x; caddr_t netmask = 0; @@ -241,12 +234,8 @@ rn_lookup(v_arg, m_arg, head) return x; } -static -int -rn_satsifies_leaf(trial, leaf, skip) - char *trial; - register struct radix_node *leaf; - int skip; +static int +rn_satsifies_leaf (char *trial, register struct radix_node *leaf, int skip) { register char *cp = trial, *cp2 = leaf->rn_key, *cp3 = leaf->rn_mask; char *cplim; @@ -266,9 +255,7 @@ rn_satsifies_leaf(trial, leaf, skip) } struct radix_node * -rn_match(v_arg, head) - void *v_arg; - struct radix_node_head *head; +rn_match(void *v_arg, struct radix_node_head *head) { caddr_t v = v_arg; register struct radix_node *t = head->rnh_treetop, *x; @@ -375,10 +362,7 @@ int rn_debug = 1; #endif struct radix_node * -rn_newpair(v, b, nodes) - void *v; - int b; - struct radix_node nodes[2]; +rn_newpair(void *v, int b, struct radix_node nodes[2]) { register struct radix_node *tt = nodes, *t = tt + 1; t->rn_b = b; @@ -400,11 +384,7 @@ rn_newpair(v, b, nodes) } struct radix_node * -rn_insert(v_arg, head, dupentry, nodes) - void *v_arg; - struct radix_node_head *head; - int *dupentry; - struct radix_node nodes[2]; +rn_insert(void *v_arg, struct radix_node_head *head, int *dupentry, struct radix_node nodes[2]) { caddr_t v = v_arg; struct radix_node *top = head->rnh_treetop; @@ -470,9 +450,7 @@ rn_insert(v_arg, head, dupentry, nodes) } struct radix_node * -rn_addmask(n_arg, search, skip) - int search, skip; - void *n_arg; +rn_addmask(void *n_arg, int search, int skip) { caddr_t netmask = (caddr_t) n_arg; register struct radix_node *x; @@ -544,8 +522,7 @@ rn_addmask(n_arg, search, skip) } static int /* XXX: arbitrary ordering for non-contiguous masks */ -rn_lexobetter(m_arg, n_arg) - void *m_arg, *n_arg; +rn_lexobetter(void *m_arg, void *n_arg) { register u_char *mp = m_arg, *np = n_arg, *lim; @@ -559,9 +536,7 @@ rn_lexobetter(m_arg, n_arg) } static struct radix_mask * -rn_new_radix_mask(tt, next) - register struct radix_node *tt; - register struct radix_mask *next; +rn_new_radix_mask(struct radix_node *tt, struct radix_mask *next) { register struct radix_mask *m; @@ -583,10 +558,7 @@ rn_new_radix_mask(tt, next) } struct radix_node * -rn_addroute(v_arg, n_arg, head, treenodes) - void *v_arg, *n_arg; - struct radix_node_head *head; - struct radix_node treenodes[2]; +rn_addroute(void *v_arg, void *n_arg, struct radix_node_head *head, struct radix_node treenodes[2]) { caddr_t v = (caddr_t) v_arg, netmask = (caddr_t) n_arg; register struct radix_node *t, *x = NULL, *tt; @@ -738,9 +710,7 @@ rn_addroute(v_arg, n_arg, head, treenodes) } struct radix_node * -rn_delete(v_arg, netmask_arg, head) - void *v_arg, *netmask_arg; - struct radix_node_head *head; +rn_delete(void *v_arg, void *netmask_arg, struct radix_node_head *head) { register struct radix_node *t, *p, *x, *tt; struct radix_mask *m, *saved_m, **mp; @@ -920,10 +890,7 @@ rn_delete(v_arg, netmask_arg, head) } int -rn_walktree(h, f, w) - struct radix_node_head *h; - int (*f) (); - void *w; +rn_walktree(struct radix_node_head *h, int (*f)(struct radix_node *, void *), void *w) { int error; struct radix_node *base, *next; @@ -959,9 +926,7 @@ rn_walktree(h, f, w) } int -rn_inithead(head, off) - void **head; - int off; +rn_inithead(void **head, int off) { register struct radix_node_head *rnh; register struct radix_node *t, *tt, *ttt; @@ -991,7 +956,7 @@ rn_inithead(head, off) } void -rn_init() +rn_init(void) { char *cp, *cplim; #ifdef KERNEL