diff options
Diffstat (limited to 'source3/include')
-rw-r--r-- | source3/include/hash.h | 75 | ||||
-rw-r--r-- | source3/include/includes.h | 1 | ||||
-rw-r--r-- | source3/include/proto.h | 10 |
3 files changed, 86 insertions, 0 deletions
diff --git a/source3/include/hash.h b/source3/include/hash.h new file mode 100644 index 0000000000..2de7031855 --- /dev/null +++ b/source3/include/hash.h @@ -0,0 +1,75 @@ +/* + Unix SMB/Netbios implementation. + Version 2.0 + + Copyright (C) Ying Chen 2000. + + This program 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 of the License, or + (at your option) any later version. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef _HASH_H_ +#define _HASH_H_ + +#define MAX_HASH_TABLE_SIZE 32768 +#define HASH_TABLE_INCREMENT 2 + +typedef int (*compare_function)(char *, char *); +typedef int (*hash_function)(int, char *); + +/* + * lru_link: links the node to the LRU list. + * hash_elem: the pointer to the element that is tied onto the link. + */ +typedef struct lru_node { + ubi_dlNode lru_link; + void *hash_elem; +} lru_node; + +/* + * bucket_link: link the hash element to the bucket chain that it belongs to. + * lru_link: this element ties the hash element to the lru list. + * bucket: a pointer to the hash bucket that this element belongs to. + * value: a pointer to the hash element content. It can be anything. + * key: stores the string key. The hash_element is always allocated with + * more memory space than the structure shown below to accomodate the space + * used for the whole string. But the memory is always appended at the + * end of the structure, so keep "key" at the end of the structure. + * Don't move it. + */ +typedef struct hash_element { + ubi_dlNode bucket_link; + lru_node lru_link; + ubi_dlList *bucket; + void *value; + char key[1]; +} hash_element; + +/* + * buckets: a list of buckets, implemented as a dLinkList. + * lru_chain: the lru list of all the hash elements. + * num_elements: the # of elements in the hash table. + * size: the hash table size. + * comp_func: the compare function used during hash key comparisons. + */ + +typedef struct hash_table { + ubi_dlList *buckets; + ubi_dlList lru_chain; + int num_elements; + int size; + compare_function comp_func; +} hash_table; + +#endif /* _HASH_H_ */ diff --git a/source3/include/includes.h b/source3/include/includes.h index a872c1d306..a049b725c4 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -619,6 +619,7 @@ extern int errno; #include "../tdb/tdb.h" #include "talloc.h" #include "interfaces.h" +#include "hash.h" #ifdef HAVE_FNMATCH #include <fnmatch.h> diff --git a/source3/include/proto.h b/source3/include/proto.h index 03fc5b1353..205031a2a8 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -97,6 +97,15 @@ void generate_random_buffer( unsigned char *out, int len, BOOL re_seed); char *getsmbpass(char *prompt) ; +/*The following definitions come from lib/hash.c */ + +BOOL hash_table_init(hash_table *table, int num_buckets, compare_function compare_func); +int string_hash(int hash_size, const char *key); +hash_element *hash_lookup(hash_table *table, char *key); +hash_element *hash_insert(hash_table *table, char *value, char *key); +void hash_remove(hash_table *table, hash_element *hash_elem); +void hash_clear(hash_table *table); + /*The following definitions come from lib/interface.c */ void load_interfaces(void); @@ -2636,6 +2645,7 @@ void print_stat_cache_statistics(void); BOOL unix_convert(char *name,connection_struct *conn,char *saved_last_component, BOOL *bad_path, SMB_STRUCT_STAT *pst); BOOL check_name(char *name,connection_struct *conn); +BOOL reset_stat_cache( void ); /*The following definitions come from smbd/files.c */ |