X-Git-Url: http://git.jankratochvil.net/?p=tac_plus.git;a=blobdiff_plain;f=hash.c;h=2db807bfacbe041719600d9299ca7392143dafde;hp=443d42bad0151f6f92bcf4096b6d0ff7811070e6;hb=413c510553a773cd16e2b538e4a208b4c4d9f775;hpb=a296ccf128acec69a7db2312ebcc231cd18e5944 diff --git a/hash.c b/hash.c index 443d42b..2db807b 100644 --- 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 @@ -17,19 +17,24 @@ FITNESS FOR A PARTICULAR PURPOSE. */ + #include "tac_plus.h" +#include "hash.h" +#include "utils.h" + + 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) -char *name; +const char *name; { int i; int len = strlen(name); @@ -43,12 +48,14 @@ char *name; 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; -char *name; +const char *name; { ENTRY *entry; int hashval = calculate_hash(name); @@ -64,6 +71,8 @@ char *name; 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 * @@ -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)