git://git.jankratochvil.net
/
tac_plus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Initial "gts1" commit.
[tac_plus.git]
/
hash.c
diff --git
a/hash.c
b/hash.c
index
443d42b
..
2db807b
100644
(file)
--- a/
hash.c
+++ b/
hash.c
@@
-1,4
+1,4
@@
-/*
+/*
Copyright (c) 1995-1998 by Cisco systems, Inc.
Permission to use, copy, modify, and distribute this software for
Copyright (c) 1995-1998 by Cisco systems, Inc.
Permission to use, copy, modify, and distribute this software for
@@
-17,19
+17,24
@@
FITNESS FOR A PARTICULAR PURPOSE.
*/
FITNESS FOR A PARTICULAR PURPOSE.
*/
+
#include "tac_plus.h"
#include "tac_plus.h"
+#include "hash.h"
+#include "utils.h"
+
+
struct entry {
char *name;
void *hash;
};
struct entry {
char *name;
void *hash;
};
-
typedef struct entry ENTRY
;
+
static int calculate_hash TAC_ARGS((const char *name))
;
/* Calculate hash value from a string */
static int
calculate_hash(name)
/* Calculate hash value from a string */
static int
calculate_hash(name)
-char *name;
+c
onst c
har *name;
{
int i;
int len = strlen(name);
{
int i;
int len = strlen(name);
@@
-43,12
+48,14
@@
char *name;
return (hashval);
}
return (hashval);
}
+void *hash_lookup TAC_ARGS((void **hashtab, const char *name));
+
/* Lookup a name in a hash table. Return its node if it exists, NULL
otherwise */
void *
hash_lookup(hashtab, name)
void **hashtab;
/* Lookup a name in a hash table. Return its node if it exists, NULL
otherwise */
void *
hash_lookup(hashtab, name)
void **hashtab;
-char *name;
+c
onst c
har *name;
{
ENTRY *entry;
int hashval = calculate_hash(name);
{
ENTRY *entry;
int hashval = calculate_hash(name);
@@
-64,6
+71,8
@@
char *name;
return (NULL);
}
return (NULL);
}
+void *hash_add_entry TAC_ARGS((void **hashtab, ENTRY *newentry));
+
/* Add a node to a hash table. Return node if it exists, NULL
otherwise */
void *
/* Add a node to a hash table. Return node if it exists, NULL
otherwise */
void *
@@
-86,6
+95,8
@@
ENTRY *newentry;
}
}
+void **hash_get_entries TAC_ARGS((void **hashtab));
+
/* Return an array of pointers to all the entries in a hash table */
void **
hash_get_entries(hashtab)
/* Return an array of pointers to all the entries in a hash table */
void **
hash_get_entries(hashtab)