dbt_lib.h

Go to the documentation of this file.
00001 /*
00002  * $Id: dbt_lib.h 5003 2008-09-26 11:01:51Z henningw $
00003  *
00004  * DBText library
00005  *
00006  * Copyright (C) 2001-2003 FhG Fokus
00007  *
00008  * This file is part of Kamailio, a free SIP server.
00009  *
00010  * Kamailio is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * Kamailio is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License 
00021  * along with this program; if not, write to the Free Software 
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  * 
00024  * History:
00025  * --------
00026  * 2003-01-30 created by Daniel
00027  * 
00028  */
00029 
00030 
00031 #ifndef _DBT_LIB_H_
00032 #define _DBT_LIB_H_
00033 
00034 #include "../../str.h"
00035 #include "../../db/db_val.h"
00036 #include "../../locking.h"
00037 
00038 #define DBT_FLAG_UNSET  0
00039 #define DBT_FLAG_NULL   1
00040 #define DBT_FLAG_AUTO   2
00041 
00042 #define DBT_TBFL_ZERO   0
00043 #define DBT_TBFL_MODI   1
00044 
00045 #define DBT_FL_IGN      -1
00046 #define DBT_FL_SET      0
00047 #define DBT_FL_UNSET 1
00048 
00049 #define DBT_DELIM ':'
00050 #define DBT_DELIM_C  ' '
00051 #define DBT_DELIM_R  '\n'
00052 
00053 /*
00054  *  * Module parameters variables
00055  *   */
00056 extern int db_mode; /* Database usage mode: 0 = no cache, 1 = cache */
00057 
00058 typedef db_val_t dbt_val_t, *dbt_val_p;
00059 
00060 typedef struct _dbt_row
00061 {
00062    dbt_val_p fields;
00063    struct _dbt_row *prev;
00064    struct _dbt_row *next;
00065    
00066 } dbt_row_t, *dbt_row_p;
00067 
00068 typedef struct _dbt_column
00069 {
00070    str name;
00071    int type;
00072    int flag;
00073    struct _dbt_column *prev;
00074    struct _dbt_column *next;
00075    
00076 } dbt_column_t, *dbt_column_p;
00077 
00078 
00079 typedef struct _dbt_table
00080 {
00081    str dbname;
00082    str name;
00083    int hash;
00084    int mark;
00085    int flag;
00086    int auto_col;
00087    int auto_val;
00088    int nrcols;
00089    dbt_column_p cols;
00090    dbt_column_p *colv;
00091    int nrrows;
00092    dbt_row_p rows;
00093    time_t mt;
00094    struct _dbt_table *next;
00095    struct _dbt_table *prev;
00096 } dbt_table_t, *dbt_table_p;
00097 
00098 typedef struct _dbt_tbl_cachel
00099 {
00100    gen_lock_t sem;
00101    dbt_table_p dtp;
00102 } dbt_tbl_cachel_t, *dbt_tbl_cachel_p;
00103 
00104 typedef struct _dbt_cache 
00105 {
00106    str name;
00107    int flags;
00108    struct _dbt_cache *next;
00109 } dbt_cache_t, *dbt_cache_p;
00110 
00111 
00112 
00113 int dbt_init_cache(void);
00114 int dbt_cache_destroy(void);
00115 int dbt_cache_print(int);
00116 
00117 dbt_cache_p dbt_cache_get_db(str*);
00118 int dbt_cache_check_db(str*);
00119 int dbt_cache_del_db(str*);
00120 dbt_table_p dbt_db_get_table(dbt_cache_p, const str*);
00121 int dbt_release_table(dbt_cache_p, const str*);
00122 
00123 int dbt_cache_free(dbt_cache_p);
00124 
00125 dbt_column_p dbt_column_new(char*, int);
00126 dbt_row_p dbt_row_new(int);
00127 dbt_table_p dbt_table_new(const str*, const str*, const char*);
00128 
00129 int dbt_row_free(dbt_table_p, dbt_row_p);
00130 int dbt_column_free(dbt_column_p);
00131 int dbt_table_free_rows(dbt_table_p);
00132 int dbt_table_free(dbt_table_p);
00133 
00134 
00135 int dbt_row_set_val(dbt_row_p, dbt_val_p, int, int);
00136 int dbt_row_update_val(dbt_row_p, dbt_val_p, int, int);
00137 int dbt_table_add_row(dbt_table_p, dbt_row_p);
00138 int dbt_table_check_row(dbt_table_p, dbt_row_p);
00139 int dbt_table_update_flags(dbt_table_p, int, int, int);
00140 
00141 int dbt_check_mtime(const str *, const str *, time_t *);
00142 dbt_table_p dbt_load_file(const str *, const str *);
00143 int dbt_print_table(dbt_table_p, str *);
00144 int dbt_is_neq_type(db_type_t _t0, db_type_t _t1);
00145 
00146 #endif
00147 

Generated on Tue May 22 14:00:25 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6