Add CVS 1.12.11.
[dragonfly.git] / contrib / cvs-1.12.11 / src / hash.h
1 /*
2  * Copyright (c) 1992, Brian Berliner and Jeff Polk
3  * 
4  * You may distribute under the terms of the GNU General Public License as
5  * specified in the README file that comes with the CVS source distribution.
6  */
7
8 /*
9  * The number of buckets for the hash table contained in each list.  This
10  * should probably be prime.
11  */
12 #define HASHSIZE        151
13
14 /*
15  * Types of nodes
16  */
17 enum ntype
18 {
19     NT_UNKNOWN, HEADER, ENTRIES, FILES, LIST, RCSNODE,
20     RCSVERS, DIRS, UPDATE, LOCK, NDBMNODE, FILEATTR,
21     VARIABLE, RCSFIELD, RCSCMPFLD
22 };
23 typedef enum ntype Ntype;
24
25 struct node
26 {
27     Ntype type;
28     struct node *next;
29     struct node *prev;
30     struct node *hashnext;
31     struct node *hashprev;
32     char *key;
33     void *data;
34     void (*delproc) (struct node *);
35 };
36 typedef struct node Node;
37
38 struct list
39 {
40     Node *list;
41     Node *hasharray[HASHSIZE];
42     struct list *next;
43 };
44 typedef struct list List;
45
46 List *getlist (void);
47 Node *findnode (List * list, const char *key);
48 Node *findnode_fn (List * list, const char *key);
49 Node *getnode (void);
50 int insert_before (List * list, Node * marker, Node * p);
51 int addnode (List * list, Node * p);
52 int addnode_at_front (List * list, Node * p);
53 int walklist (List * list, int (*)(Node *n, void *closure), void *closure);
54 int list_isempty (List *list);
55 void dellist (List ** listp);
56 void delnode (Node * p);
57 void freenode (Node * p);
58 void sortlist (List * list, int (*)(const Node *, const Node *));
59 int fsortcmp (const Node * p, const Node * q);