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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
/*
* $Id$
*
* DBText library
*
* Copyright (C) 2001-2003 FhG Fokus
*
* 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
*
* History:
* --------
* 2003-01-30 created by Daniel
*
*/
#ifndef _DBT_LIB_H_
#define _DBT_LIB_H_
#include "../../str.h"
#include "../../lib/srdb1/db_val.h"
#include "../../locking.h"
#define DBT_FLAG_UNSET 0
#define DBT_FLAG_NULL 1
#define DBT_FLAG_AUTO 2
#define DBT_TBFL_ZERO 0
#define DBT_TBFL_MODI 1
#define DBT_FL_IGN -1
#define DBT_FL_SET 0
#define DBT_FL_UNSET 1
#define DBT_DELIM ':'
#define DBT_DELIM_C ' '
#define DBT_DELIM_R '\n'
/*
* * Module parameters variables
* */
extern int db_mode; /* Database usage mode: 0 = no cache, 1 = cache */
typedef db_val_t dbt_val_t, *dbt_val_p;
typedef struct _dbt_row
{
dbt_val_p fields;
struct _dbt_row *prev;
struct _dbt_row *next;
} dbt_row_t, *dbt_row_p;
typedef struct _dbt_column
{
str name;
int type;
int flag;
struct _dbt_column *prev;
struct _dbt_column *next;
} dbt_column_t, *dbt_column_p;
typedef struct _dbt_table
{
str dbname;
str name;
int hash;
int mark;
int flag;
int auto_col;
int auto_val;
int nrcols;
dbt_column_p cols;
dbt_column_p *colv;
int nrrows;
dbt_row_p rows;
time_t mt;
struct _dbt_table *next;
struct _dbt_table *prev;
} dbt_table_t, *dbt_table_p;
typedef struct _dbt_tbl_cachel
{
gen_lock_t sem;
dbt_table_p dtp;
} dbt_tbl_cachel_t, *dbt_tbl_cachel_p;
typedef struct _dbt_cache
{
str name;
int flags;
struct _dbt_cache *next;
} dbt_cache_t, *dbt_cache_p;
int dbt_init_cache(void);
int dbt_cache_destroy(void);
int dbt_cache_print(int);
dbt_cache_p dbt_cache_get_db(str*);
int dbt_cache_check_db(str*);
int dbt_cache_del_db(str*);
dbt_table_p dbt_db_get_table(dbt_cache_p, const str*);
int dbt_release_table(dbt_cache_p, const str*);
int dbt_cache_free(dbt_cache_p);
dbt_column_p dbt_column_new(char*, int);
dbt_row_p dbt_row_new(int);
dbt_table_p dbt_table_new(const str*, const str*, const char*);
int dbt_row_free(dbt_table_p, dbt_row_p);
int dbt_column_free(dbt_column_p);
int dbt_table_free_rows(dbt_table_p);
int dbt_table_free(dbt_table_p);
int dbt_row_set_val(dbt_row_p, dbt_val_p, int, int);
int dbt_row_update_val(dbt_row_p, dbt_val_p, int, int);
int dbt_table_add_row(dbt_table_p, dbt_row_p);
int dbt_table_check_row(dbt_table_p, dbt_row_p);
int dbt_table_update_flags(dbt_table_p, int, int, int);
int dbt_check_mtime(const str *, const str *, time_t *);
dbt_table_p dbt_load_file(const str *, const str *);
int dbt_print_table(dbt_table_p, str *);
int dbt_is_neq_type(db_type_t _t0, db_type_t _t1);
#endif
|