00001
00023 #ifndef _DS_HT_H_
00024 #define _DS_HT_H_
00025
00026 #include <time.h>
00027
00028 #include "../../str.h"
00029 #include "../../locking.h"
00030
00031 #define DS_LOAD_INIT 0
00032 #define DS_LOAD_CONFIRMED 1
00033
00034 typedef struct _ds_cell
00035 {
00036 unsigned int cellid;
00037 str callid;
00038 str duid;
00039 int dset;
00040 int state;
00041 time_t expire;
00042 time_t initexpire;
00043 struct _ds_cell *prev;
00044 struct _ds_cell *next;
00045 } ds_cell_t;
00046
00047 typedef struct _ds_entry
00048 {
00049 unsigned int esize;
00050 ds_cell_t *first;
00051 gen_lock_t lock;
00052 } ds_entry_t;
00053
00054 typedef struct _ds_ht
00055 {
00056 unsigned int htexpire;
00057 unsigned int htinitexpire;
00058 unsigned int htsize;
00059 ds_entry_t *entries;
00060 struct _ds_ht *next;
00061 } ds_ht_t;
00062
00063 ds_ht_t *ds_ht_init(unsigned int htsize, int expire, int initexpire);
00064 int ds_ht_destroy(ds_ht_t *dsht);
00065 int ds_add_cell(ds_ht_t *dsht, str *cid, str *did, int dset);
00066 int ds_del_cell(ds_ht_t *dsht, str *cid);
00067 ds_cell_t* ds_get_cell(ds_ht_t *dsht, str *cid);
00068 int ds_unlock_cell(ds_ht_t *dsht, str *cid);
00069
00070 int ds_ht_dbg(ds_ht_t *dsht);
00071 int ds_cell_free(ds_cell_t *cell);
00072 int ds_ht_clear_slots(ds_ht_t *dsht);
00073
00074 #endif