Postfix3.3.1
htable.h
[詳解]
1 #ifndef _HTABLE_H_INCLUDED_
2 #define _HTABLE_H_INCLUDED_
3 
4 /*++
5 /* NAME
6 /* htable 3h
7 /* SUMMARY
8 /* hash table manager
9 /* SYNOPSIS
10 /* #include <htable.h>
11 /* DESCRIPTION
12 /* .nf
13 
14  /* Structure of one hash table entry. */
15 
16 typedef struct HTABLE_INFO {
17  char *key; /* lookup key */
18  void *value; /* associated value */
19  struct HTABLE_INFO *next; /* colliding entry */
20  struct HTABLE_INFO *prev; /* colliding entry */
21 } HTABLE_INFO;
22 
23  /* Structure of one hash table. */
24 
25 typedef struct HTABLE {
26  ssize_t size; /* length of entries array */
27  ssize_t used; /* number of entries in table */
28  HTABLE_INFO **data; /* entries array, auto-resized */
29  HTABLE_INFO **seq_bucket; /* current sequence hash bucket */
30  HTABLE_INFO **seq_element; /* current sequence element */
31 } HTABLE;
32 
33 extern HTABLE *htable_create(ssize_t);
34 extern HTABLE_INFO *htable_enter(HTABLE *, const char *, void *);
35 extern HTABLE_INFO *htable_locate(HTABLE *, const char *);
36 extern void *htable_find(HTABLE *, const char *);
37 extern void htable_delete(HTABLE *, const char *, void (*) (void *));
38 extern void htable_free(HTABLE *, void (*) (void *));
39 extern void htable_walk(HTABLE *, void (*) (HTABLE_INFO *, void *), void *);
40 extern HTABLE_INFO **htable_list(HTABLE *);
41 extern HTABLE_INFO *htable_sequence(HTABLE *, int);
42 
43 #define HTABLE_SEQ_FIRST 0
44 #define HTABLE_SEQ_NEXT 1
45 #define HTABLE_SEQ_STOP (-1)
46 
47  /*
48  * Correct only when casting (char *) to (void *).
49  */
50 #define HTABLE_ACTION_FN_CAST(f) ((void *)(HTABLE_INFO *, void *)) (f)
51 #define HTABLE_FREE_FN_CAST(f) ((void *)(void *)) (f)
52 
53 /* LICENSE
54 /* .ad
55 /* .fi
56 /* The Secure Mailer license must be distributed with this software.
57 /* AUTHOR(S)
58 /* Wietse Venema
59 /* IBM T.J. Watson Research
60 /* P.O. Box 704
61 /* Yorktown Heights, NY 10598, USA
62 /* CREATION DATE
63 /* Fri Feb 14 13:43:19 EST 1997
64 /* LAST MODIFICATION
65 /* %E% %U%
66 /* VERSION/RELEASE
67 /* %I%
68 /*--*/
69 
70 #endif
void * value
Definition: htable.h:18
struct HTABLE_INFO * next
Definition: htable.h:19
ssize_t size
Definition: htable.h:26
struct HTABLE_INFO HTABLE_INFO
ssize_t used
Definition: htable.h:27
HTABLE_INFO ** seq_element
Definition: htable.h:30
HTABLE_INFO * htable_enter(HTABLE *, const char *, void *)
Definition: htable.c:212
HTABLE_INFO ** seq_bucket
Definition: htable.h:29
Definition: htable.h:25
HTABLE_INFO ** data
Definition: htable.h:28
char * key
Definition: htable.h:17
HTABLE_INFO ** htable_list(HTABLE *)
Definition: htable.c:330
void htable_walk(HTABLE *, void(*)(HTABLE_INFO *, void *), void *)
Definition: htable.c:315
HTABLE_INFO * htable_sequence(HTABLE *, int)
Definition: htable.c:351
HTABLE * htable_create(ssize_t)
Definition: htable.c:179
void htable_free(HTABLE *, void(*)(void *))
Definition: htable.c:287
HTABLE_INFO * htable_locate(HTABLE *, const char *)
Definition: htable.c:242
struct HTABLE HTABLE
void * htable_find(HTABLE *, const char *)
Definition: htable.c:227
struct HTABLE_INFO * prev
Definition: htable.h:20
void htable_delete(HTABLE *, const char *, void(*)(void *))
Definition: htable.c:257