| 7 |
|
|
| 8 |
|
#include <stdio.h> |
| 9 |
|
#include <stdlib.h> |
| 10 |
+ |
#include <string.h> |
| 11 |
|
|
| 12 |
|
#include "lookup.h" |
| 13 |
|
|
| 49 |
|
|
| 50 |
|
extern unsigned long |
| 51 |
|
lu_shash( /* hash a nul-terminated string */ |
| 52 |
< |
void *s |
| 52 |
> |
const void *s |
| 53 |
|
) |
| 54 |
|
{ |
| 55 |
|
static unsigned char shuffle[256] = { |
| 80 |
|
}; |
| 81 |
|
register int i = 0; |
| 82 |
|
register unsigned long h = 0; |
| 83 |
< |
register unsigned char *t = (unsigned char *)s; |
| 83 |
> |
register unsigned const char *t = (unsigned const char *)s; |
| 84 |
|
|
| 85 |
|
while (*t) |
| 86 |
|
h ^= (unsigned long)shuffle[*t++] << ((i+=11) & 0xf); |
| 92 |
|
extern LUENT * |
| 93 |
|
lu_find( /* find a table entry */ |
| 94 |
|
register LUTAB *tbl, |
| 95 |
< |
char *key |
| 95 |
> |
const char *key |
| 96 |
|
) |
| 97 |
|
{ |
| 98 |
|
unsigned long hval; |
| 148 |
|
extern void |
| 149 |
|
lu_delete( /* delete a table entry */ |
| 150 |
|
register LUTAB *tbl, |
| 151 |
< |
char *key |
| 151 |
> |
const char *key |
| 152 |
|
) |
| 153 |
|
{ |
| 154 |
|
register LUENT *le; |
| 166 |
|
|
| 167 |
|
extern int |
| 168 |
|
lu_doall( /* loop through all valid table entries */ |
| 169 |
< |
register LUTAB *tbl, |
| 170 |
< |
//int (*f)(LUENT *) |
| 171 |
< |
lut_doallf_t *f |
| 169 |
> |
register const LUTAB *tbl, |
| 170 |
> |
/* int (*f)(const LUENT *) */ |
| 171 |
> |
lut_doallf_t *f, |
| 172 |
> |
void *p |
| 173 |
|
) |
| 174 |
|
{ |
| 175 |
|
int rval = 0; |
| 176 |
< |
register LUENT *tp; |
| 176 |
> |
register const LUENT *tp; |
| 177 |
|
|
| 178 |
|
for (tp = tbl->tabl + tbl->tsiz; tp-- > tbl->tabl; ) |
| 179 |
|
if (tp->data != NULL) { |
| 180 |
< |
if (f != NULL) |
| 181 |
< |
rval += (*f)(tp); |
| 182 |
< |
else |
| 180 |
> |
if (f != NULL) { |
| 181 |
> |
int r = (*f)(tp, p); |
| 182 |
> |
if (r < 0) |
| 183 |
> |
return(-1); |
| 184 |
> |
rval += r; |
| 185 |
> |
} else |
| 186 |
|
rval++; |
| 187 |
|
} |
| 188 |
|
return(rval); |