jabberd2  2.5.0
xhash.h
Go to the documentation of this file.
1 /*
2  * jabberd - Jabber Open Source Server
3  * Copyright (c) 2002-2004 Jeremie Miller, Thomas Muldowney,
4  * Ryan Eatmon, Robert Norris
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
19  */
20 
27 #ifndef INCL_UTIL_XHASH_H
28 #define INCL_UTIL_XHASH_H 1
29 
30 #ifdef HAVE_CONFIG_H
31 # include <config.h>
32 #endif
33 
34 #include "pool.h"
35 
36 typedef struct xhn_struct
37 {
38  struct xhn_struct *next;
39  struct xhn_struct *prev;
40  const char *key;
41  int keylen;
42  void *val;
43 } *xhn, _xhn;
44 
45 typedef struct xht_struct
46 {
48  int prime;
49  int dirty;
50  int count;
51  struct xhn_struct *zen;
52  struct xhn_struct *free_list; // list of zaped elements to be reused.
55  int *stat;
56 } *xht, _xht;
57 
58 JABBERD2_API xht xhash_new(int prime);
59 JABBERD2_API void xhash_put(xht h, const char *key, void *val);
60 JABBERD2_API void xhash_putx(xht h, const char *key, int len, void *val);
61 JABBERD2_API void *xhash_get(xht h, const char *key);
62 JABBERD2_API void *xhash_getx(xht h, const char *key, int len);
63 JABBERD2_API void xhash_zap(xht h, const char *key);
64 JABBERD2_API void xhash_zapx(xht h, const char *key, int len);
67 typedef void (*xhash_walker)(const char *key, int keylen, void *val, void *arg);
68 JABBERD2_API void xhash_walk(xht h, xhash_walker w, void *arg);
72 
73 /* iteration functions */
77 JABBERD2_API int xhash_iter_get(xht h, const char **key, int *keylen, void **val);
78 
79 #endif
JABBERD2_API void xhash_zap(xht h, const char *key)
Definition: xhash.c:235
int count
Definition: xhash.h:50
struct xht_struct * xht
JABBERD2_API void * xhash_get(xht h, const char *key)
Definition: xhash.c:184
int * stat
Definition: xhash.h:55
struct xhn_struct * free_list
Definition: xhash.h:52
JABBERD2_API void xhash_stat(xht h)
Definition: xhash.c:250
JABBERD2_API void xhash_iter_zap(xht h)
Definition: xhash.c:363
#define JABBERD2_API
Definition: mio.h:39
int prime
Definition: xhash.h:48
JABBERD2_API int xhash_dirty(xht h)
return the dirty flag (and reset)
Definition: xhash.c:285
int keylen
Definition: xhash.h:41
int dirty
Definition: xhash.h:49
pool_t p
Definition: xhash.h:47
JABBERD2_API int xhash_iter_next(xht h)
Definition: xhash.c:320
void(* xhash_walker)(const char *key, int keylen, void *val, void *arg)
Definition: xhash.h:67
JABBERD2_API void xhash_putx(xht h, const char *key, int len, void *val)
Definition: xhash.c:130
JABBERD2_API void xhash_walk(xht h, xhash_walker w, void *arg)
Definition: xhash.c:268
const char * key
Definition: xhash.h:40
struct xhn_struct * xhn
void * val
Definition: xhash.h:42
JABBERD2_API void * xhash_getx(xht h, const char *key, int len)
Definition: xhash.c:170
JABBERD2_API int xhash_iter_get(xht h, const char **key, int *keylen, void **val)
Definition: xhash.c:374
int iter_bucket
Definition: xhash.h:53
xhn iter_node
Definition: xhash.h:54
JABBERD2_API xht xhash_new(int prime)
Definition: xhash.c:96
struct xht_struct _xht
JABBERD2_API void xhash_free(xht h)
Definition: xhash.c:241
JABBERD2_API int xhash_count(xht h)
return the total number of entries in this xht
Definition: xhash.c:297
JABBERD2_API void xhash_zapx(xht h, const char *key, int len)
Definition: xhash.c:219
struct xhn_struct * prev
Definition: xhash.h:39
JABBERD2_API int xhash_iter_first(xht h)
iteration
Definition: xhash.c:311
struct xhn_struct * zen
Definition: xhash.h:51
pool - base node for a pool.
Definition: pool.h:80
struct xhn_struct * next
Definition: xhash.h:38
struct xhn_struct _xhn
JABBERD2_API pool_t xhash_pool(xht h)
get our pool
Definition: xhash.c:305
JABBERD2_API void xhash_put(xht h, const char *key, void *val)
Definition: xhash.c:163