Files
heimdal/lib/asn1/hash.h
Assar Westerlund b55aed018f Now uses generated ASN1-code.
kinit should be able to get a initial message from FOO.SE.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@844 ec53bebd-3082-4978-b11e-865c3cabbd6b
1996-10-13 21:13:38 +00:00

55 lines
1.3 KiB
C

/*
* hash.h. Header file for hash table functions
*/
/* $Id$ */
struct hashentry { /* Entry in bucket */
struct hashentry **prev;
struct hashentry *next;
void *ptr;
};
typedef struct hashentry Hashentry;
struct hashtab { /* Hash table */
int (*cmp)(void *, void *); /* Compare function */
unsigned (*hash)(void *); /* hash function */
int sz; /* Size */
Hashentry *tab[1]; /* The table */
};
typedef struct hashtab Hashtab;
/* prototypes */
Hashtab *hashtabnew(int sz,
int (*cmp)(void *, void *),
unsigned (*hash)(void *)); /* Make new hash table */
void *hashtabsearch(Hashtab *htab, /* The hash table */
void *ptr); /* The key */
void *hashtabadd(Hashtab *htab, /* The hash table */
void *ptr); /* The element */
int _hashtabdel(Hashtab *htab, /* The table */
void *ptr, /* Key */
int freep); /* Free data part? */
void hashtabforeach(Hashtab *htab,
int (*func)(void *ptr, void *arg),
void *arg);
unsigned hashadd(const char *s); /* Standard hash function */
unsigned hashcaseadd(const char *s); /* Standard hash function */
unsigned hashjpw(const char *s); /* another hash function */
/* macros */
/* Don't free space */
#define hashtabdel(htab,key) _hashtabdel(htab,key,FALSE)
#define hashtabfree(htab,key) _hashtabdel(htab,key,TRUE) /* Do! */