blob: d15cbca0fe00c04e36ec23240d012c4aae5f1394 [file] [log] [blame]
PulkoMandy17fc7592022-07-28 18:27:54 +02001/*
2 * (c) Thomas Pornin 1998, 1999, 2000
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 4. The name of the authors may not be used to endorse or promote
13 * products derived from this software without specific prior written
14 * permission.
15 *
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
22 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30#ifndef UCPP__HASH__
31#define UCPP__HASH__
32
33struct hash_item;
34
35struct HT {
36 struct hash_item **lists;
37 int nb_lists;
38 int (*cmpdata)(void *, void *);
39 int (*hash)(void *);
40 void (*deldata)(void *);
41};
42
43int hash_string(char *);
44struct HT *newHT(int, int (*)(void *, void *), int (*)(void *),
45 void (*)(void *));
46void *putHT(struct HT *, void *);
47void *forceputHT(struct HT *, void *);
48void *getHT(struct HT *, void *);
49int delHT(struct HT *, void *);
50struct HT *copyHT(struct HT *);
51void killHT(struct HT *);
52void saveHT(struct HT *, void **);
53void restoreHT(struct HT *, void **);
54void scanHT(struct HT *, void (*)(void *));
55int hash_struct(void *);
56int cmp_struct(void *, void *);
57
58#endif