11 |
|
extern "C" { |
12 |
|
#endif |
13 |
|
|
14 |
< |
typedef void lut_free_t(void*); |
14 |
> |
typedef void lut_free_t(void *p); |
15 |
> |
typedef unsigned long lut_hashf_t(void*); |
16 |
> |
typedef int lut_keycmpf_t(const void*, const void*); |
17 |
|
|
18 |
|
typedef struct { |
19 |
|
char *key; /* key name */ |
22 |
|
} LUENT; |
23 |
|
|
24 |
|
typedef struct { |
25 |
< |
unsigned long (*hashf)(char*); /* key hash function */ |
26 |
< |
int (*keycmp)(const char*, const char*); /* key comparison function */ |
25 |
> |
lut_hashf_t *hashf; /* key hash function */ |
26 |
> |
lut_keycmpf_t *keycmp; /* key comparison function */ |
27 |
|
lut_free_t *freek; /* free a key */ |
28 |
|
lut_free_t *freed; /* free the data */ |
29 |
|
int tsiz; /* current table size */ |
31 |
|
int ndel; /* number of deleted entries */ |
32 |
|
} LUTAB; |
33 |
|
|
32 |
– |
#undef strcmp |
33 |
– |
#define LU_SINIT(fk,fd) {lu_shash,strcmp,fk,\ |
34 |
– |
fd,0,NULL,0} |
34 |
|
|
35 |
|
/* |
36 |
|
* The lu_init routine is called to initialize a table. The number of |
79 |
|
* allocated table itself. |
80 |
|
*/ |
81 |
|
|
82 |
+ |
typedef int lut_doallf_t(LUENT *p); |
83 |
+ |
|
84 |
+ |
extern lut_keycmpf_t lu_strcmp; |
85 |
|
extern int lu_init(LUTAB *tbl, int nel); |
86 |
< |
extern unsigned long lu_shash(char *s); |
86 |
> |
extern unsigned long lu_shash(void *s); |
87 |
|
extern LUENT *lu_find(LUTAB *tbl, char *key); |
88 |
|
extern void lu_delete(LUTAB *tbl, char *key); |
89 |
< |
extern int lu_doall(LUTAB *tbl, int (*f)(LUENT*)); |
89 |
> |
extern int lu_doall(LUTAB *tbl, lut_doallf_t *f); |
90 |
|
extern void lu_done(LUTAB *tbl); |
91 |
|
|
92 |
+ |
#define LU_SINIT(fk,fd) {lu_shash,lu_strcmp,fk,fd,0,NULL,0} |
93 |
|
|
94 |
|
#ifdef __cplusplus |
95 |
|
} |