1 /* hashlib.h -- the data structures used in hashing in Bash. */
3 /* Copyright (C) 1993 Free Software Foundation, Inc.
5 This file is part of GNU Bash, the Bourne Again SHell.
7 Bash is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License along
18 with Bash; see the file COPYING. If not, write to the Free Software
19 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 #if !defined (_HASHLIB_H_)
24 typedef struct bucket_contents {
25 struct bucket_contents *next; /* Link to next hashed key in this bucket. */
26 char *key; /* What we look up. */
27 char *data; /* What we really want. */
28 int times_found; /* Number of times this item has been found. */
31 typedef struct hash_table {
32 BUCKET_CONTENTS **bucket_array; /* Where the data is kept. */
33 int nbuckets; /* How many buckets does this table have. */
34 int nentries; /* How many entries does this table have. */
37 extern int hash_string ();
38 extern HASH_TABLE *make_hash_table ();
39 extern BUCKET_CONTENTS *find_hash_item ();
40 extern BUCKET_CONTENTS *remove_hash_item ();
41 extern BUCKET_CONTENTS *add_hash_item ();
42 extern BUCKET_CONTENTS *get_hash_bucket ();
43 extern void flush_hash_table ();
45 /* Redefine the function as a macro for speed. */
46 #define get_hash_bucket(bucket, table) \
47 ((table && (bucket < table->nbuckets)) ? \
48 table->bucket_array[bucket] : \
49 (BUCKET_CONTENTS *)NULL)
51 /* Default number of buckets in the hash table. */
52 #define DEFAULT_HASH_BUCKETS 107
55 # if defined (__STDC__)
56 # define NULL ((void *) 0)
59 # endif /* !__STDC__ */
62 #endif /* _HASHLIB_H */