2015-05-18 15:27:46 +02:00
|
|
|
#ifndef _HASH_H
|
|
|
|
|
#define _HASH_H
|
|
|
|
|
|
|
|
|
|
struct hashlist {
|
|
|
|
|
char *name;
|
|
|
|
|
void *ptr;
|
|
|
|
|
struct hashlist *next;
|
|
|
|
|
};
|
|
|
|
|
|
2016-06-23 16:13:18 +02:00
|
|
|
struct hashdict {
|
|
|
|
|
int hashsize;
|
|
|
|
|
int hashfirstindex;
|
|
|
|
|
struct hashlist *hashfirstptr;
|
|
|
|
|
struct hashlist **hashtab;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2021-11-17 02:06:15 +01:00
|
|
|
void InitializeHashTable(struct hashdict *dict, int size);
|
|
|
|
|
int RecurseHashTable(struct hashdict *dict,
|
2015-05-18 15:27:46 +02:00
|
|
|
int (*func)(struct hashlist *elem));
|
2021-11-17 02:06:15 +01:00
|
|
|
int RecurseHashTableValue(struct hashdict *dict,
|
2015-05-18 15:27:46 +02:00
|
|
|
int (*func)(struct hashlist *elem, int), int);
|
2021-11-17 02:06:15 +01:00
|
|
|
struct nlist *RecurseHashTablePointer(struct hashdict *dict,
|
2016-06-23 16:13:18 +02:00
|
|
|
struct nlist *(*func)(struct hashlist *elem, void *),
|
|
|
|
|
void *pointer);
|
2021-11-17 02:06:15 +01:00
|
|
|
void HashDelete(char *name, struct hashdict *dict);
|
|
|
|
|
void HashIntDelete(char *name, int value, struct hashdict *dict);
|
|
|
|
|
void HashKill(struct hashdict *dict);
|
2015-05-18 15:27:46 +02:00
|
|
|
|
|
|
|
|
|
2021-11-17 02:06:15 +01:00
|
|
|
int CountHashTableEntries(struct hashlist *p);
|
|
|
|
|
int CountHashTableBinsUsed(struct hashlist *p);
|
2015-05-18 15:27:46 +02:00
|
|
|
|
|
|
|
|
/* these functions return a pointer to a hash list element */
|
2021-11-17 02:06:15 +01:00
|
|
|
struct hashlist *HashInstall(char *name, struct hashdict *dict);
|
|
|
|
|
struct hashlist *HashPtrInstall(char *name, void *ptr,
|
2016-06-23 16:13:18 +02:00
|
|
|
struct hashdict *dict);
|
2021-11-17 02:06:15 +01:00
|
|
|
struct hashlist *HashIntPtrInstall(char *name, int value, void *ptr,
|
2016-06-23 16:13:18 +02:00
|
|
|
struct hashdict *dict);
|
2021-11-17 02:06:15 +01:00
|
|
|
struct hashlist *HashInt2PtrInstall(char *name, int c, void *ptr,
|
2016-06-23 16:13:18 +02:00
|
|
|
struct hashdict *dict);
|
2015-05-18 15:27:46 +02:00
|
|
|
|
|
|
|
|
/* these functions return the ->ptr field of a struct hashlist */
|
2021-11-17 02:06:15 +01:00
|
|
|
void *HashLookup(char *s, struct hashdict *dict);
|
|
|
|
|
void *HashIntLookup(char *s, int i, struct hashdict *dict);
|
|
|
|
|
void *HashInt2Lookup(char *s, int c, struct hashdict *dict);
|
|
|
|
|
void *HashFirst(struct hashdict *dict);
|
|
|
|
|
void *HashNext(struct hashdict *dict);
|
|
|
|
|
|
|
|
|
|
unsigned long hashnocase(char *s, int hashsize);
|
|
|
|
|
unsigned long my_hash(char *s, int hashsize);
|
2015-05-18 15:27:46 +02:00
|
|
|
|
|
|
|
|
extern int (*matchfunc)(char *, char *);
|
|
|
|
|
/* matchintfunc() compares based on the name and the first */
|
|
|
|
|
/* entry of the pointer value, which is cast as an integer */
|
|
|
|
|
extern int (*matchintfunc)(char *, char *, int, int);
|
|
|
|
|
extern unsigned long (*hashfunc)(char *, int);
|
|
|
|
|
|
|
|
|
|
#endif /* _HASH_H */
|