1
/* Copyright (c) 2005 PrimeBase Technologies GmbH
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
* 2005-01-15 Paul McCullagh
23
#ifndef __xt_hashtab_h__
24
#define __xt_hashtab_h__
30
#define xtHashValue u_int
32
typedef xtBool (*XTHTCompareFunc)(void *key, void *data);
33
typedef xtHashValue (*XTHTHashFunc)(xtBool is_key, void *key_data);
34
typedef void (*XTHTFreeFunc)(struct XTThread *self, void *item);
36
typedef struct XTHashItem {
37
struct XTHashItem *hi_next;
40
} XTHashItemRec, *XTHashItemPtr;
42
typedef struct XTHashTab {
43
XTHTCompareFunc ht_comp_func;
44
XTHTHashFunc ht_hash_func;
45
XTHTFreeFunc ht_free_func;
46
xt_mutex_type *ht_lock;
47
xt_cond_type *ht_cond;
49
xtHashValue ht_tab_size;
50
XTHashItemPtr ht_items[XT_VAR_LENGTH];
51
} XTHashTabRec, *XTHashTabPtr;
53
typedef struct XTHashEnum {
55
XTHashItemPtr he_item;
57
} XTHashEnumRec, *XTHashEnumPtr;
59
XTHashTabPtr xt_new_hashtable(struct XTThread *self, XTHTCompareFunc comp_func, XTHTHashFunc hash_func, XTHTFreeFunc free_func, xtBool with_lock, xtBool with_cond);
60
void xt_free_hashtable(struct XTThread *self, XTHashTabPtr ht);
62
void xt_ht_put(struct XTThread *self, XTHashTabPtr ht, void *data);
63
void *xt_ht_get(struct XTThread *self, XTHashTabPtr ht, void *key);
64
xtBool xt_ht_del(struct XTThread *self, XTHashTabPtr ht, void *key);
66
xtHashValue xt_ht_hash(char *s);
67
xtHashValue xt_ht_casehash(char *s);
69
xtBool xt_ht_lock(struct XTThread *self, XTHashTabPtr ht);
70
void xt_ht_unlock(struct XTThread *self, XTHashTabPtr ht);
71
void xt_ht_wait(struct XTThread *self, XTHashTabPtr ht);
72
void xt_ht_timed_wait(struct XTThread *self, XTHashTabPtr ht, u_long milli_sec);
73
void xt_ht_signal(struct XTThread *self, XTHashTabPtr ht);
75
void xt_ht_enum(struct XTThread *self, XTHashTabPtr ht, XTHashEnumPtr en);
76
void *xt_ht_next(struct XTThread *self, XTHashEnumPtr en);