Updating the ChangeLog file
[enscript.git] / afmlib / strhash.h
1 /*
2  * String hash table.
3  * Copyright (c) 1995, 1996, 1997 Markku Rossi.
4  *
5  * Author: Markku Rossi <mtr@iki.fi>
6  */
7
8 /*
9  * Enscript is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * Enscript is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with Enscript.  If not, see <http://www.gnu.org/licenses/>.
21  */
22
23 #ifndef STRHASH_H
24 #define STRHASH_H
25
26 #ifndef ___P
27 #if PROTOTYPES
28 #define ___P(protos) protos
29 #else /* no PROTOTYPES */
30 #define ___P(protos) ()
31 #endif /* no PROTOTYPES */
32 #endif
33
34 typedef struct stringhash_st *StringHashPtr;
35
36 /*
37  * Init a hash and return a hash handle or NULL if there were errors.
38  */
39 StringHashPtr strhash_init ___P ((void));
40
41 /*
42  * Free hash <hash>. Frees all resources that hash has allocated. <hash>
43  * shouldn't be used after this function is called.
44  */
45 void strhash_free ___P ((StringHashPtr hash));
46
47 /*
48  * Put key <key> to hash <hash>. <data> will be bind to <key>. Returns
49  * true (1) if operation was successful or false (0) otherwise. If <key>
50  * is already bind to another data, then <old_data> will be set to old
51  * data. Otherwise it will be set to NULL.
52  */
53 int strhash_put ___P ((StringHashPtr hash, char *key, int keylen, void *data,
54                        void **old_data_return));
55
56 /*
57  * Get data associated to key <key>. Data is returned in <*data>.
58  * Returns true (1) is key was found or false (0) otherwise.
59  */
60 int strhash_get ___P ((StringHashPtr hash, const char *key, int keylen,
61                        void **data_return));
62
63 /*
64  * Deletes key <key> form <hash>. Data is returned in <*data>. Returns
65  * true (1) if <key> was found or false (0) if <key> was not found or
66  * errors were encountered.
67  */
68 int strhash_delete ___P ((StringHashPtr hash, const char *key, int keylen,
69                           void **data_return));
70
71 /*
72  * Get first item from hash <hash>.  Returns 1 if there were items
73  * or 0 otherwise.
74  */
75 int strhash_get_first ___P ((StringHashPtr hash, char **key_return,
76                              int *keylen_return, void **data_return));
77
78 /*
79  * Get next item from hash <hash>.  Returns 1 if there were items
80  * or 0 otherwise.
81  */
82 int strhash_get_next ___P ((StringHashPtr hash, char **key_return,
83                             int *keylen_return, void **data_return));
84
85 #endif /* not STRHASH_H */