1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
/**
* $Id$
*
* Copyright (C) 2008 Elena-Ramona Modroiu (asipto.com)
*
* This file is part of kamailio, a free SIP server.
*
* Kamailio 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
*
* Kamailio 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _HT_API_H_
#define _HT_API_H_
#include <time.h>
#include "../../usr_avp.h"
#include "../../locking.h"
#include "../../pvar.h"
#define ht_compute_hash(_s) core_case_hash(_s,0,0)
#define ht_get_entry(_h,_size) (_h)&((_size)-1)
typedef struct _ht_cell
{
unsigned int cellid;
unsigned int msize;
int flags;
str name;
int_str value;
time_t expire;
struct _ht_cell *prev;
struct _ht_cell *next;
} ht_cell_t;
typedef struct _ht_entry
{
unsigned int esize;
ht_cell_t *first;
gen_lock_t lock;
} ht_entry_t;
typedef struct _ht
{
str name;
unsigned int htid;
unsigned int htexpire;
str dbtable;
int dbmode;
int flags;
int_str initval;
int updateexpire;
unsigned int htsize;
int dmqreplicate;
int evrt_expired;
ht_entry_t *entries;
struct _ht *next;
} ht_t;
typedef struct _ht_pv {
str htname;
ht_t *ht;
pv_elem_t *pve;
} ht_pv_t, *ht_pv_p;
int ht_add_table(str *name, int autoexp, str *dbtable, int size, int dbmode,
int itype, int_str *ival, int updateexpire, int dmqreplicate);
int ht_init_tables(void);
int ht_destroy(void);
int ht_set_cell(ht_t *ht, str *name, int type, int_str *val, int mode);
int ht_del_cell(ht_t *ht, str *name);
ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
ht_cell_t *old);
int ht_dbg(void);
ht_cell_t* ht_cell_pkg_copy(ht_t *ht, str *name, ht_cell_t *old);
int ht_cell_pkg_free(ht_cell_t *cell);
int ht_cell_free(ht_cell_t *cell);
int ht_table_spec(char *spec);
ht_t* ht_get_table(str *name);
int ht_db_load_tables(void);
int ht_db_sync_tables(void);
int ht_has_autoexpire(void);
void ht_timer(unsigned int ticks, void *param);
void ht_handle_expired_record(ht_t *ht, ht_cell_t *cell);
void ht_expired_run_event_route(int routeid);
int ht_set_cell_expire(ht_t *ht, str *name, int type, int_str *val);
int ht_get_cell_expire(ht_t *ht, str *name, unsigned int *val);
int ht_rm_cell_re(str *sre, ht_t *ht, int mode);
int ht_count_cells_re(str *sre, ht_t *ht, int mode);
ht_t *ht_get_root(void);
int ht_reset_content(ht_t *ht);
void ht_iterator_init(void);
int ht_iterator_start(str *iname, str *hname);
int ht_iterator_next(str *iname);
int ht_iterator_end(str *iname);
ht_cell_t* ht_iterator_get_current(str *iname);
#endif
|