00001
00023 #ifndef _HT_API_H_
00024 #define _HT_API_H_
00025
00026 #include <time.h>
00027
00028 #include "../../usr_avp.h"
00029 #include "../../locking.h"
00030 #include "../../pvar.h"
00031
00032 typedef struct _ht_cell
00033 {
00034 unsigned int cellid;
00035 unsigned int msize;
00036 int flags;
00037 str name;
00038 int_str value;
00039 time_t expire;
00040 struct _ht_cell *prev;
00041 struct _ht_cell *next;
00042 } ht_cell_t;
00043
00044 typedef struct _ht_entry
00045 {
00046 unsigned int esize;
00047 ht_cell_t *first;
00048 gen_lock_t lock;
00049 } ht_entry_t;
00050
00051 typedef struct _ht
00052 {
00053 str name;
00054 unsigned int htid;
00055 unsigned int htexpire;
00056 str dbtable;
00057 int dbmode;
00058 int flags;
00059 int_str initval;
00060 int updateexpire;
00061 unsigned int htsize;
00062 ht_entry_t *entries;
00063 struct _ht *next;
00064 } ht_t;
00065
00066 typedef struct _ht_pv {
00067 str htname;
00068 ht_t *ht;
00069 pv_elem_t *pve;
00070 } ht_pv_t, *ht_pv_p;
00071
00072 int ht_add_table(str *name, int autoexp, str *dbtable, int size, int dbmode,
00073 int itype, int_str *ival, int updateexpire);
00074 int ht_init_tables(void);
00075 int ht_destroy(void);
00076 int ht_set_cell(ht_t *ht, str *name, int type, int_str *val, int mode);
00077 int ht_del_cell(ht_t *ht, str *name);
00078 ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
00079 ht_cell_t *old);
00080
00081 int ht_dbg(void);
00082 ht_cell_t* ht_cell_pkg_copy(ht_t *ht, str *name, ht_cell_t *old);
00083 int ht_cell_pkg_free(ht_cell_t *cell);
00084 int ht_cell_free(ht_cell_t *cell);
00085
00086 int ht_table_spec(char *spec);
00087 ht_t* ht_get_table(str *name);
00088 int ht_db_load_tables(void);
00089 int ht_db_sync_tables(void);
00090
00091 int ht_has_autoexpire(void);
00092 void ht_timer(unsigned int ticks, void *param);
00093 int ht_set_cell_expire(ht_t *ht, str *name, int type, int_str *val);
00094 int ht_get_cell_expire(ht_t *ht, str *name, unsigned int *val);
00095
00096 int ht_rm_cell_re(str *sre, ht_t *ht, int mode);
00097 int ht_count_cells_re(str *sre, ht_t *ht, int mode);
00098
00099 #endif