jabberd2
2.2.16
|
00001 /* 00002 * jabberd - Jabber Open Source Server 00003 * Copyright (c) 2002-2004 Jeremie Miller, Thomas Muldowney, 00004 * Ryan Eatmon, Robert Norris 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA 00019 */ 00020 00027 #ifndef INCL_UTIL_XHASH_H 00028 #define INCL_UTIL_XHASH_H 1 00029 00030 #ifdef HAVE_CONFIG_H 00031 # include <config.h> 00032 #endif 00033 00034 #include "pool.h" 00035 00036 typedef struct xhn_struct 00037 { 00038 struct xhn_struct *next; 00039 struct xhn_struct *prev; 00040 const char *key; 00041 int keylen; 00042 void *val; 00043 } *xhn, _xhn; 00044 00045 typedef struct xht_struct 00046 { 00047 pool_t p; 00048 int prime; 00049 int dirty; 00050 int count; 00051 struct xhn_struct *zen; 00052 struct xhn_struct *free_list; // list of zaped elements to be reused. 00053 int iter_bucket; 00054 xhn iter_node; 00055 int *stat; 00056 } *xht, _xht; 00057 00058 JABBERD2_API xht xhash_new(int prime); 00059 JABBERD2_API void xhash_put(xht h, const char *key, void *val); 00060 JABBERD2_API void xhash_putx(xht h, const char *key, int len, void *val); 00061 JABBERD2_API void *xhash_get(xht h, const char *key); 00062 JABBERD2_API void *xhash_getx(xht h, const char *key, int len); 00063 JABBERD2_API void xhash_zap(xht h, const char *key); 00064 JABBERD2_API void xhash_zapx(xht h, const char *key, int len); 00065 JABBERD2_API void xhash_stat(xht h); 00066 JABBERD2_API void xhash_free(xht h); 00067 typedef void (*xhash_walker)(const char *key, int keylen, void *val, void *arg); 00068 JABBERD2_API void xhash_walk(xht h, xhash_walker w, void *arg); 00069 JABBERD2_API int xhash_dirty(xht h); 00070 JABBERD2_API int xhash_count(xht h); 00071 JABBERD2_API pool_t xhash_pool(xht h); 00072 00073 /* iteration functions */ 00074 JABBERD2_API int xhash_iter_first(xht h); 00075 JABBERD2_API int xhash_iter_next(xht h); 00076 JABBERD2_API void xhash_iter_zap(xht h); 00077 JABBERD2_API int xhash_iter_get(xht h, const char **key, int *keylen, void **val); 00078 00079 #endif