db_val.h

Go to the documentation of this file.
00001 /* 
00002  * $Id$ 
00003  *
00004  * Copyright (C) 2001-2003 FhG Fokus
00005  * Copyright (C) 2007-2008 1&1 Internet AG
00006  *
00007  * This file is part of Kamailio, a free SIP server.
00008  *
00009  * Kamailio is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version
00013  *
00014  * Kamailio is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License 
00020  * along with this program; if not, write to the Free Software 
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022  */
00023 
00037 #ifndef DB1_VAL_H
00038 #define DB1_VAL_H
00039 
00040 #include "db_con.h"
00041 #include <time.h>
00042 #include "../../str.h"
00043 
00044 
00051 typedef enum {
00052         DB1_INT,        
00053         DB1_BIGINT,     
00054         DB1_DOUBLE,     
00055         DB1_STRING,     
00056         DB1_STR,        
00057         DB1_DATETIME,   
00058         DB1_BLOB,       
00059         DB1_BITMAP      
00060 } db_type_t;
00061 
00062 
00077 typedef struct {
00078         db_type_t type; 
00079         int nul;                
00080         int free;               
00082         union {
00083                 int           int_val;    
00084                 long long     ll_val;     
00085                 double        double_val; 
00086                 time_t        time_val;   
00087                 const char*   string_val; 
00088                 str           str_val;    
00089                 str           blob_val;   
00090                 unsigned int  bitmap_val; 
00091         } val;
00092 } db_val_t;
00093 
00094 
00103 #define VAL_TYPE(dv)   ((dv)->type)
00104 
00105 
00111 #define VAL_NULL(dv)   ((dv)->nul)
00112 
00113 
00119 #define VAL_FREE(dv)   ((dv)->free)
00120 
00121 
00125 #define VAL_INT(dv)    ((dv)->val.int_val)
00126 
00127 
00132 #define VAL_UINT(dv)    ((unsigned int)(dv)->val.int_val)
00133 
00134 
00138 #define VAL_BIGINT(dv)    ((dv)->val.ll_val)
00139 
00140 
00144 #define VAL_DOUBLE(dv) ((dv)->val.double_val)
00145 
00146 
00150 #define VAL_TIME(dv)   ((dv)->val.time_val)
00151 
00152 
00156 #define VAL_STRING(dv) ((dv)->val.string_val)
00157 
00158 
00162 #define VAL_STR(dv)    ((dv)->val.str_val)
00163 
00164 
00168 #define VAL_BLOB(dv)   ((dv)->val.blob_val)
00169 
00170 
00174 #define VAL_BITMAP(dv) ((dv)->val.bitmap_val)
00175 
00176 
00188 int db_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int _l,
00189                 const unsigned int _cpy);
00190 
00191 
00203 int db_val2str(const db1_con_t* _c, const db_val_t* _v, char* _s, int* _len);
00204 
00205 #endif /* DB1_VAL_H */