2 |
|
/* |
3 |
|
* Header file for general associative table lookup routines |
4 |
|
*/ |
5 |
+ |
#ifndef _MGF_LOOKUP_H_ |
6 |
+ |
#define _MGF_LOOKUP_H_ |
7 |
+ |
#ifdef __cplusplus |
8 |
+ |
extern "C" { |
9 |
+ |
#endif |
10 |
|
|
11 |
+ |
|
12 |
|
typedef struct { |
13 |
|
char *key; /* key name */ |
14 |
|
long hval; /* key hash value (for efficiency) */ |
15 |
|
char *data; /* pointer to client data */ |
16 |
|
} LUENT; |
17 |
|
|
12 |
– |
#ifdef NOPROTO |
18 |
|
typedef struct { |
14 |
– |
unsigned long (*hashf)(); /* key hash function */ |
15 |
– |
int (*keycmp)(); /* key comparison function */ |
16 |
– |
void (*freek)(); /* free a key */ |
17 |
– |
void (*freed)(); /* free the data */ |
18 |
– |
int tsiz; /* current table size */ |
19 |
– |
LUENT *tabl; /* table, if allocated */ |
20 |
– |
int ndel; /* number of deleted entries */ |
21 |
– |
} LUTAB; |
22 |
– |
#else |
23 |
– |
typedef struct { |
19 |
|
unsigned long (*hashf)(char *); /* key hash function */ |
20 |
|
int (*keycmp)(const char *, const char *); /* key comparison function */ |
21 |
|
void (*freek)(char *); /* free a key */ |
24 |
|
LUENT *tabl; /* table, if allocated */ |
25 |
|
int ndel; /* number of deleted entries */ |
26 |
|
} LUTAB; |
32 |
– |
#endif |
27 |
|
|
28 |
|
#define LU_SINIT(fk,fd) {lu_shash,strcmp,(void (*)())(fk),\ |
29 |
|
(void (*)())(fd),0,NULL,0} |
69 |
|
* allocated table itself. |
70 |
|
*/ |
71 |
|
|
78 |
– |
#ifdef NOPROTO |
79 |
– |
extern int lu_init(); |
80 |
– |
extern LUENT *lu_find(); |
81 |
– |
extern void lu_delete(); |
82 |
– |
extern void lu_done(); |
83 |
– |
extern unsigned long lu_shash(); |
84 |
– |
#else |
72 |
|
extern int lu_init(LUTAB *, int); |
73 |
|
extern LUENT *lu_find(LUTAB *, char *); |
74 |
|
extern void lu_delete(LUTAB *, char *); |
75 |
|
extern void lu_done(LUTAB *); |
76 |
|
extern unsigned long lu_shash(char *); |
77 |
+ |
|
78 |
+ |
|
79 |
+ |
#ifdef __cplusplus |
80 |
+ |
} |
81 |
|
#endif |
82 |
+ |
#endif /* _MGF_LOOKUP_H_ */ |
83 |
+ |
|