summaryrefslogtreecommitdiff
path: root/hashlib.h
diff options
context:
space:
mode:
authorJari Aalto <jari.aalto@cante.net>1996-12-23 17:02:34 +0000
committerJari Aalto <jari.aalto@cante.net>2009-09-12 16:46:49 +0000
commitccc6cda312fea9f0468ee65b8f368e9653e1380b (patch)
treeb059878adcfd876c4acb8030deda1eeb918c7e75 /hashlib.h
parent726f63884db0132f01745f1fb4465e6621088ccf (diff)
downloadbash-ccc6cda312fea9f0468ee65b8f368e9653e1380b.tar.gz
Imported from ../bash-2.0.tar.gz.
Diffstat (limited to 'hashlib.h')
-rw-r--r--hashlib.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/hashlib.h b/hashlib.h
new file mode 100644
index 00000000..95a9164b
--- /dev/null
+++ b/hashlib.h
@@ -0,0 +1,62 @@
+/* hashlib.h -- the data structures used in hashing in Bash. */
+
+/* Copyright (C) 1993 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#if !defined (_HASHLIB_H_)
+#define _HASHLIB_H_
+
+typedef struct bucket_contents {
+ struct bucket_contents *next; /* Link to next hashed key in this bucket. */
+ char *key; /* What we look up. */
+ char *data; /* What we really want. */
+ int times_found; /* Number of times this item has been found. */
+} BUCKET_CONTENTS;
+
+typedef struct hash_table {
+ BUCKET_CONTENTS **bucket_array; /* Where the data is kept. */
+ int nbuckets; /* How many buckets does this table have. */
+ int nentries; /* How many entries does this table have. */
+} HASH_TABLE;
+
+extern int hash_string ();
+extern HASH_TABLE *make_hash_table ();
+extern BUCKET_CONTENTS *find_hash_item ();
+extern BUCKET_CONTENTS *remove_hash_item ();
+extern BUCKET_CONTENTS *add_hash_item ();
+extern BUCKET_CONTENTS *get_hash_bucket ();
+extern void flush_hash_table ();
+
+/* Redefine the function as a macro for speed. */
+#define get_hash_bucket(bucket, table) \
+ ((table && (bucket < table->nbuckets)) ? \
+ table->bucket_array[bucket] : \
+ (BUCKET_CONTENTS *)NULL)
+
+/* Default number of buckets in the hash table. */
+#define DEFAULT_HASH_BUCKETS 107
+
+#if !defined (NULL)
+# if defined (__STDC__)
+# define NULL ((void *) 0)
+# else
+# define NULL 0x0
+# endif /* !__STDC__ */
+#endif /* !NULL */
+
+#endif /* _HASHLIB_H */