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