xref: /netbsd-src/external/ibm-public/postfix/dist/src/util/htable.h (revision a5847cc334d9a7029f6352b847e9e8d71a0f9e0c)
1 /*	$NetBSD: htable.h,v 1.1.1.2 2010/06/17 18:07:14 tron Exp $	*/
2 
3 #ifndef _HTABLE_H_INCLUDED_
4 #define _HTABLE_H_INCLUDED_
5 
6 /*++
7 /* NAME
8 /*	htable 3h
9 /* SUMMARY
10 /*	hash table manager
11 /* SYNOPSIS
12 /*	#include <htable.h>
13 /* DESCRIPTION
14 /* .nf
15 
16  /* Structure of one hash table entry. */
17 
18 typedef struct HTABLE_INFO {
19     char   *key;			/* lookup key */
20     char   *value;			/* associated value */
21     struct HTABLE_INFO *next;		/* colliding entry */
22     struct HTABLE_INFO *prev;		/* colliding entry */
23 } HTABLE_INFO;
24 
25  /* Structure of one hash table. */
26 
27 typedef struct HTABLE {
28     int     size;			/* length of entries array */
29     int     used;			/* number of entries in table */
30     HTABLE_INFO **data;			/* entries array, auto-resized */
31     HTABLE_INFO **seq_bucket;		/* current sequence hash bucket */
32     HTABLE_INFO *seq_element;		/* current sequence element */
33 } HTABLE;
34 
35 extern HTABLE *htable_create(int);
36 extern HTABLE_INFO *htable_enter(HTABLE *, const char *, char *);
37 extern HTABLE_INFO *htable_locate(HTABLE *, const char *);
38 extern char *htable_find(HTABLE *, const char *);
39 extern void htable_delete(HTABLE *, const char *, void (*) (char *));
40 extern void htable_free(HTABLE *, void (*) (char *));
41 extern void htable_walk(HTABLE *, void (*) (HTABLE_INFO *, char *), char *);
42 extern HTABLE_INFO **htable_list(HTABLE *);
43 extern HTABLE_INFO *htable_sequence(HTABLE *, int);
44 
45 #define HTABLE_SEQ_FIRST	0
46 #define HTABLE_SEQ_NEXT		1
47 #define HTABLE_SEQ_STOP		(-1)
48 
49 /* LICENSE
50 /* .ad
51 /* .fi
52 /*	The Secure Mailer license must be distributed with this software.
53 /* AUTHOR(S)
54 /*	Wietse Venema
55 /*	IBM T.J. Watson Research
56 /*	P.O. Box 704
57 /*	Yorktown Heights, NY 10598, USA
58 /* CREATION DATE
59 /*	Fri Feb 14 13:43:19 EST 1997
60 /* LAST MODIFICATION
61 /*	%E% %U%
62 /* VERSION/RELEASE
63 /*	%I%
64 /*--*/
65 
66 #endif
67