Browse code

Various db api changes needed after migration to libsrdb1

This patch makes the module compatible with the changes done in the
database library of kamailio/ser when it was converted to shared library
libsrdb1. These changes are mostly needed to avoid conflicts with the
symbols defined in the newer version of the library libsrdb2.

List of changes:
* Rename db_con_t to db1_con_t
* Rename db_res_t to db1_res_t
* Rename db field type names from DB_* to DB1_*
* Updated header paths to files in ../../lib/srdb1
* Link with libsrdb1

Jan Janak authored on 03/03/2009 14:41:25
Showing 12 changed files
... ...
@@ -15,4 +15,6 @@ LIBS=
15 15
 
16 16
 DEFS+=-DOPENSER_MOD_INTERFACE
17 17
 
18
+SERLIBPATH=../../lib
19
+SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1
18 20
 include ../../Makefile.modules
... ...
@@ -29,13 +29,13 @@
29 29
 
30 30
 #include <string.h>
31 31
 
32
-#include "../../db/db.h"
32
+#include "../../lib/srdb1/db.h"
33 33
 #include "../../mem/mem.h"
34 34
 
35 35
 #include "dbt_res.h"
36 36
 #include "dbt_api.h"
37 37
 
38
-int dbt_use_table(db_con_t* _h, const str* _t)
38
+int dbt_use_table(db1_con_t* _h, const str* _t)
39 39
 {
40 40
 	return db_use_table(_h, _t);
41 41
 }
... ...
@@ -44,7 +44,7 @@ int dbt_use_table(db_con_t* _h, const str* _t)
44 44
 /*
45 45
  * Get and convert columns from a result
46 46
  */
47
-static int dbt_get_columns(db_con_t* _h, db_res_t* _r)
47
+static int dbt_get_columns(db1_con_t* _h, db1_res_t* _r)
48 48
 {
49 49
 	int col;
50 50
 	
... ...
@@ -83,19 +83,19 @@ static int dbt_get_columns(db_con_t* _h, db_res_t* _r)
83 83
 
84 84
 		switch(DBT_CON_RESULT(_h)->colv[col].type)
85 85
 		{
86
-			case DB_STR:
87
-			case DB_STRING:
88
-			case DB_BLOB:
89
-			case DB_INT:
90
-			case DB_DATETIME:
91
-			case DB_DOUBLE:
86
+			case DB1_STR:
87
+			case DB1_STRING:
88
+			case DB1_BLOB:
89
+			case DB1_INT:
90
+			case DB1_DATETIME:
91
+			case DB1_DOUBLE:
92 92
 				RES_TYPES(_r)[col] = DBT_CON_RESULT(_h)->colv[col].type;
93 93
 			break;
94 94
 			default:
95 95
 				LM_WARN("unhandled data type column (%.*s) type id (%d), "
96 96
 						"use STR as default\n", RES_NAMES(_r)[col]->len,
97 97
 						RES_NAMES(_r)[col]->s, DBT_CON_RESULT(_h)->colv[col].type);
98
-				RES_TYPES(_r)[col] = DB_STR;
98
+				RES_TYPES(_r)[col] = DB1_STR;
99 99
 			break;
100 100
 		}
101 101
 	}
... ...
@@ -105,7 +105,7 @@ static int dbt_get_columns(db_con_t* _h, db_res_t* _r)
105 105
 /*
106 106
  * Convert a row from result into db API representation
107 107
  */
108
-static int dbt_convert_row(db_con_t* _h, db_res_t* _res, db_row_t* _r)
108
+static int dbt_convert_row(db1_con_t* _h, db1_res_t* _res, db_row_t* _r)
109 109
 {
110 110
 	int i;
111 111
 	if (!_h || !_r || !_res) {
... ...
@@ -122,59 +122,59 @@ static int dbt_convert_row(db_con_t* _h, db_res_t* _res, db_row_t* _r)
122 122
 		(ROW_VALUES(_r)[i]).nul = DBT_CON_ROW(_h)->fields[i].nul;
123 123
 		switch(RES_TYPES(_res)[i])
124 124
 		{
125
-			case DB_INT:
125
+			case DB1_INT:
126 126
 				VAL_INT(&(ROW_VALUES(_r)[i])) = 
127 127
 						DBT_CON_ROW(_h)->fields[i].val.int_val;
128
-				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB_INT;
128
+				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB1_INT;
129 129
 			break;
130 130
 
131
-			case DB_BIGINT:
131
+			case DB1_BIGINT:
132 132
 				LM_ERR("BIGINT not supported");
133 133
 				return -1;
134 134
 
135
-			case DB_DOUBLE:
135
+			case DB1_DOUBLE:
136 136
 				VAL_DOUBLE(&(ROW_VALUES(_r)[i])) = 
137 137
 						DBT_CON_ROW(_h)->fields[i].val.double_val;
138
-				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB_DOUBLE;
138
+				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB1_DOUBLE;
139 139
 			break;
140 140
 
141
-			case DB_STRING:
141
+			case DB1_STRING:
142 142
 				VAL_STR(&(ROW_VALUES(_r)[i])).s = 
143 143
 						DBT_CON_ROW(_h)->fields[i].val.str_val.s;
144 144
 				VAL_STR(&(ROW_VALUES(_r)[i])).len =
145 145
 						DBT_CON_ROW(_h)->fields[i].val.str_val.len;
146
-				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB_STRING;
146
+				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB1_STRING;
147 147
 				VAL_FREE(&(ROW_VALUES(_r)[i])) = 0;
148 148
 			break;
149 149
 
150
-			case DB_STR:
150
+			case DB1_STR:
151 151
 				VAL_STR(&(ROW_VALUES(_r)[i])).s = 
152 152
 						DBT_CON_ROW(_h)->fields[i].val.str_val.s;
153 153
 				VAL_STR(&(ROW_VALUES(_r)[i])).len =
154 154
 						DBT_CON_ROW(_h)->fields[i].val.str_val.len;
155
-				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB_STR;
155
+				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB1_STR;
156 156
 				VAL_FREE(&(ROW_VALUES(_r)[i])) = 0;
157 157
 			break;
158 158
 
159
-			case DB_DATETIME:
159
+			case DB1_DATETIME:
160 160
 				VAL_INT(&(ROW_VALUES(_r)[i])) = 
161 161
 						DBT_CON_ROW(_h)->fields[i].val.int_val;
162
-				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB_DATETIME;
162
+				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB1_DATETIME;
163 163
 			break;
164 164
 
165
-			case DB_BLOB:
165
+			case DB1_BLOB:
166 166
 				VAL_STR(&(ROW_VALUES(_r)[i])).s =
167 167
 						DBT_CON_ROW(_h)->fields[i].val.str_val.s;
168 168
 				VAL_STR(&(ROW_VALUES(_r)[i])).len =
169 169
 						DBT_CON_ROW(_h)->fields[i].val.str_val.len;
170
-				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB_BLOB;
170
+				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB1_BLOB;
171 171
 				VAL_FREE(&(ROW_VALUES(_r)[i])) = 0;
172 172
 			break;
173 173
 
174
-			case DB_BITMAP:
174
+			case DB1_BITMAP:
175 175
 				VAL_INT(&(ROW_VALUES(_r)[i])) =
176 176
 					DBT_CON_ROW(_h)->fields[i].val.bitmap_val;
177
-				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB_INT;
177
+				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB1_INT;
178 178
 			break;
179 179
 		}
180 180
 	}
... ...
@@ -185,7 +185,7 @@ static int dbt_convert_row(db_con_t* _h, db_res_t* _res, db_row_t* _r)
185 185
 /*
186 186
  * Convert rows from internal to db API representation
187 187
  */
188
-static int dbt_convert_rows(db_con_t* _h, db_res_t* _r)
188
+static int dbt_convert_rows(db1_con_t* _h, db1_res_t* _r)
189 189
 {
190 190
 	int col;
191 191
 	dbt_row_p _rp = NULL;
... ...
@@ -227,7 +227,7 @@ static int dbt_convert_rows(db_con_t* _h, db_res_t* _r)
227 227
 /*
228 228
  * Fill the structure with data from database
229 229
  */
230
-static int dbt_convert_result(db_con_t* _h, db_res_t* _r)
230
+static int dbt_convert_result(db1_con_t* _h, db1_res_t* _r)
231 231
 {
232 232
 	if (!_h || !_r) {
233 233
 		LM_ERR("invalid parameter\n");
... ...
@@ -249,7 +249,7 @@ static int dbt_convert_result(db_con_t* _h, db_res_t* _r)
249 249
 /*
250 250
  * Retrieve result set
251 251
  */
252
-int dbt_get_result(db_con_t* _h, db_res_t** _r)
252
+int dbt_get_result(db1_con_t* _h, db1_res_t** _r)
253 253
 {
254 254
 	if (!_h || !_r) {
255 255
 		LM_ERR("invalid parameter value\n");
... ...
@@ -31,16 +31,16 @@
31 31
 #ifndef _DBT_API_H_
32 32
 #define _DBT_API_H_
33 33
 
34
-#include "../../db/db_op.h"
35
-#include "../../db/db_res.h"
36
-#include "../../db/db_con.h"
37
-#include "../../db/db_row.h"
34
+#include "../../lib/srdb1/db_op.h"
35
+#include "../../lib/srdb1/db_res.h"
36
+#include "../../lib/srdb1/db_con.h"
37
+#include "../../lib/srdb1/db_row.h"
38 38
 
39 39
 /*
40 40
  * Retrieve result set
41 41
  */
42
-int dbt_get_result(db_con_t* _h, db_res_t** _r);
42
+int dbt_get_result(db1_con_t* _h, db1_res_t** _r);
43 43
 
44
-int dbt_use_table(db_con_t* _h, const str* _t);
44
+int dbt_use_table(db1_con_t* _h, const str* _t);
45 45
 
46 46
 #endif
... ...
@@ -48,9 +48,9 @@
48 48
 /*
49 49
  * Initialize database connection
50 50
  */
51
-db_con_t* dbt_init(const str* _sqlurl)
51
+db1_con_t* dbt_init(const str* _sqlurl)
52 52
 {
53
-	db_con_t* _res;
53
+	db1_con_t* _res;
54 54
 	str _s;
55 55
 	char dbt_path[DBT_PATH_LEN];
56 56
 	
... ...
@@ -87,14 +87,14 @@ db_con_t* dbt_init(const str* _sqlurl)
87 87
 		_s.s = dbt_path;
88 88
 	}
89 89
 	
90
-	_res = pkg_malloc(sizeof(db_con_t)+sizeof(dbt_con_t));
90
+	_res = pkg_malloc(sizeof(db1_con_t)+sizeof(dbt_con_t));
91 91
 	if (!_res)
92 92
 	{
93 93
 		LM_ERR("no pkg memory left\n");
94 94
 		return NULL;
95 95
 	}
96
-	memset(_res, 0, sizeof(db_con_t) + sizeof(dbt_con_t));
97
-	_res->tail = (unsigned long)((char*)_res+sizeof(db_con_t));
96
+	memset(_res, 0, sizeof(db1_con_t) + sizeof(dbt_con_t));
97
+	_res->tail = (unsigned long)((char*)_res+sizeof(db1_con_t));
98 98
 
99 99
 	LM_INFO("using database at: %.*s", _s.len, _s.s);
100 100
 	DBT_CON_CONNECTION(_res) = dbt_cache_get_db(&_s);
... ...
@@ -111,7 +111,7 @@ db_con_t* dbt_init(const str* _sqlurl)
111 111
 /*
112 112
  * Close a database connection
113 113
  */
114
-void dbt_close(db_con_t* _h)
114
+void dbt_close(db1_con_t* _h)
115 115
 {
116 116
 	if (!_h) 
117 117
 	{
... ...
@@ -130,7 +130,7 @@ void dbt_close(db_con_t* _h)
130 130
 /*
131 131
  * Free all memory allocated by get_result
132 132
  */
133
-int dbt_free_result(db_con_t* _h, db_res_t* _r)
133
+int dbt_free_result(db1_con_t* _h, db1_res_t* _r)
134 134
 {
135 135
 	if ((!_h) || (!_r))
136 136
 	{
... ...
@@ -167,8 +167,8 @@ int dbt_free_result(db_con_t* _h, db_res_t* _r)
167 167
  * _o: order by the specified column
168 168
  */
169 169
 
170
-int dbt_query(db_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, 
171
-			db_key_t* _c, int _n, int _nc, db_key_t _o, db_res_t** _r)
170
+int dbt_query(db1_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, 
171
+			db_key_t* _c, int _n, int _nc, db_key_t _o, db1_res_t** _r)
172 172
 {
173 173
 	dbt_table_p _tbc = NULL;
174 174
 	dbt_row_p _drp = NULL;
... ...
@@ -328,7 +328,7 @@ clean:
328 328
 /*
329 329
  * Raw SQL query -- is not the case to have this method
330 330
  */
331
-int dbt_raw_query(db_con_t* _h, char* _s, db_res_t** _r)
331
+int dbt_raw_query(db1_con_t* _h, char* _s, db1_res_t** _r)
332 332
 {
333 333
 	*_r = NULL;
334 334
     return -1;
... ...
@@ -337,7 +337,7 @@ int dbt_raw_query(db_con_t* _h, char* _s, db_res_t** _r)
337 337
 /*
338 338
  * Insert a row into table
339 339
  */
340
-int dbt_insert(db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n)
340
+int dbt_insert(db1_con_t* _h, db_key_t* _k, db_val_t* _v, int _n)
341 341
 {
342 342
 	dbt_table_p _tbc = NULL;
343 343
 	dbt_row_p _drp = NULL;
... ...
@@ -390,7 +390,7 @@ int dbt_insert(db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n)
390 390
 			LM_ERR("incompatible types v[%d] - c[%d]!\n", i, j);
391 391
 			goto clean;
392 392
 		}
393
-		if(_v[i].type == DB_STRING && !_v[i].nul)
393
+		if(_v[i].type == DB1_STRING && !_v[i].nul)
394 394
 			_v[i].val.str_val.len = strlen(_v[i].val.string_val);
395 395
 		if(dbt_row_set_val(_drp, &(_v[i]), _tbc->colv[j]->type, j))
396 396
 		{
... ...
@@ -439,7 +439,7 @@ clean:
439 439
 /*
440 440
  * Delete a row from table
441 441
  */
442
-int dbt_delete(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, int _n)
442
+int dbt_delete(db1_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, int _n)
443 443
 {
444 444
 	dbt_table_p _tbc = NULL;
445 445
 	dbt_row_p _drp = NULL, _drp0 = NULL;
... ...
@@ -516,7 +516,7 @@ error:
516 516
 /*
517 517
  * Update a row in table
518 518
  */
519
-int dbt_update(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v,
519
+int dbt_update(db1_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v,
520 520
 	      db_key_t* _uk, db_val_t* _uv, int _n, int _un)
521 521
 {
522 522
 	dbt_table_p _tbc = NULL;
... ...
@@ -187,27 +187,27 @@ dbt_table_p dbt_load_file(const str *tbn, const str *dbn)
187 187
 				{
188 188
 					case 's':
189 189
 					case 'S':
190
-						colp->type = DB_STR;
190
+						colp->type = DB1_STR;
191 191
 						LM_DBG("column[%d] is STR!\n", ccol+1);
192 192
 					break;
193 193
 					case 'i':
194 194
 					case 'I':
195
-						colp->type = DB_INT;
195
+						colp->type = DB1_INT;
196 196
 						LM_DBG("column[%d] is INT!\n", ccol+1);
197 197
 					break;
198 198
 					case 'd':
199 199
 					case 'D':
200
-						colp->type = DB_DOUBLE;
200
+						colp->type = DB1_DOUBLE;
201 201
 						LM_DBG("column[%d] is DOUBLE!\n", ccol+1);
202 202
 					break;
203 203
 					case 'b':
204 204
 					case 'B':
205
-						colp->type = DB_BLOB;
205
+						colp->type = DB1_BLOB;
206 206
 						LM_DBG("column[%d] is BLOB!\n", ccol+1);
207 207
 					break;
208 208
 					case 't':
209 209
 					case 'T':
210
-						colp->type = DB_DATETIME;
210
+						colp->type = DB1_DATETIME;
211 211
 						LM_DBG("column[%d] is TIME!\n", ccol+1);
212 212
 					break;
213 213
 					default:
... ...
@@ -217,9 +217,9 @@ dbt_table_p dbt_load_file(const str *tbn, const str *dbn)
217 217
 
218 218
 				while(c!='\n' && c!=EOF && c!=')' && c!= ',')
219 219
 				{
220
-					if(colp->type == DB_STR && (c=='i'|| c=='I'))
220
+					if(colp->type == DB1_STR && (c=='i'|| c=='I'))
221 221
 					{
222
-						colp->type = DB_STRING;
222
+						colp->type = DB1_STRING;
223 223
 						LM_DBG("column[%d] is actually STRING!\n", ccol+1);
224 224
 					}
225 225
 					c = fgetc(fin);
... ...
@@ -235,7 +235,7 @@ dbt_table_p dbt_load_file(const str *tbn, const str *dbn)
235 235
 						//LM_DBG("NULL flag set!\n");
236 236
 						colp->flag |= DBT_FLAG_NULL;
237 237
 					}
238
-					else if(colp->type==DB_INT && dtp->auto_col<0
238
+					else if(colp->type==DB1_INT && dtp->auto_col<0
239 239
 							&& (c=='A' || c=='a'))
240 240
 					{
241 241
 						//LM_DBG("AUTO flag set!\n");
... ...
@@ -310,8 +310,8 @@ dbt_table_p dbt_load_file(const str *tbn, const str *dbn)
310 310
 				
311 311
 				switch(dtp->colv[ccol]->type)
312 312
 				{
313
-					case DB_INT:
314
-					case DB_DATETIME:
313
+					case DB1_INT:
314
+					case DB1_DATETIME:
315 315
 						//LM_DBG("INT value!\n");
316 316
 						dtval.val.int_val = 0;
317 317
 						dtval.type = dtp->colv[ccol]->type;
... ...
@@ -350,10 +350,10 @@ dbt_table_p dbt_load_file(const str *tbn, const str *dbn)
350 350
 									dtval.val.int_val:max_auto;
351 351
 					break;
352 352
 					
353
-					case DB_DOUBLE:
353
+					case DB1_DOUBLE:
354 354
 						//LM_DBG("DOUBLE value!\n");
355 355
 						dtval.val.double_val = 0.0;
356
-						dtval.type = DB_DOUBLE;
356
+						dtval.type = DB1_DOUBLE;
357 357
 
358 358
 						if(c==DBT_DELIM || 
359 359
 								(ccol==dtp->nrcols-1
... ...
@@ -393,13 +393,13 @@ dbt_table_p dbt_load_file(const str *tbn, const str *dbn)
393 393
 						}
394 394
 						if(c!=DBT_DELIM && c!=DBT_DELIM_R && c!=EOF)
395 395
 							goto clean;
396
-						if(dbt_row_set_val(rowp,&dtval,DB_DOUBLE,ccol))
396
+						if(dbt_row_set_val(rowp,&dtval,DB1_DOUBLE,ccol))
397 397
 							goto clean;
398 398
 					break;
399 399
 					
400
-					case DB_STR:
401
-					case DB_STRING:
402
-					case DB_BLOB:
400
+					case DB1_STR:
401
+					case DB1_STRING:
402
+					case DB1_BLOB:
403 403
 						//LM_DBG("STR value!\n");
404 404
 						
405 405
 						dtval.val.str_val.s = NULL;
... ...
@@ -523,22 +523,22 @@ int dbt_print_table(dbt_table_p _dtp, str *_dbn)
523 523
 	{
524 524
 		switch(colp->type)
525 525
 		{
526
-			case DB_INT:
526
+			case DB1_INT:
527 527
 				fprintf(fout, "%.*s(int", colp->name.len, colp->name.s);
528 528
 			break;
529
-			case DB_DOUBLE:
529
+			case DB1_DOUBLE:
530 530
 				fprintf(fout, "%.*s(double", colp->name.len, colp->name.s);
531 531
 			break;
532
-			case DB_STR:
532
+			case DB1_STR:
533 533
 				fprintf(fout, "%.*s(str", colp->name.len, colp->name.s);
534 534
 			break;
535
-			case DB_STRING:
535
+			case DB1_STRING:
536 536
 				fprintf(fout, "%.*s(string", colp->name.len, colp->name.s);
537 537
 			break;
538
-			case DB_BLOB:
538
+			case DB1_BLOB:
539 539
 				fprintf(fout, "%.*s(blob", colp->name.len, colp->name.s);
540 540
 			break;
541
-			case DB_DATETIME:
541
+			case DB1_DATETIME:
542 542
 				fprintf(fout, "%.*s(time", colp->name.len, colp->name.s);
543 543
 			break;
544 544
 			default:
... ...
@@ -549,7 +549,7 @@ int dbt_print_table(dbt_table_p _dtp, str *_dbn)
549 549
 		
550 550
 		if(colp->flag & DBT_FLAG_NULL)
551 551
 				fprintf(fout,",null");
552
-		else if(colp->type==DB_INT && colp->flag & DBT_FLAG_AUTO)
552
+		else if(colp->type==DB1_INT && colp->flag & DBT_FLAG_AUTO)
553 553
 					fprintf(fout,",auto");
554 554
 		fprintf(fout,")");
555 555
 		
... ...
@@ -565,20 +565,20 @@ int dbt_print_table(dbt_table_p _dtp, str *_dbn)
565 565
 		{
566 566
 			switch(_dtp->colv[ccol]->type)
567 567
 			{
568
-				case DB_DATETIME:
569
-				case DB_INT:
568
+				case DB1_DATETIME:
569
+				case DB1_INT:
570 570
 					if(!rowp->fields[ccol].nul)
571 571
 						fprintf(fout,"%d",
572 572
 								rowp->fields[ccol].val.int_val);
573 573
 				break;
574
-				case DB_DOUBLE:
574
+				case DB1_DOUBLE:
575 575
 					if(!rowp->fields[ccol].nul)
576 576
 						fprintf(fout, "%.2f",
577 577
 								rowp->fields[ccol].val.double_val);
578 578
 				break;
579
-				case DB_STR:
580
-				case DB_STRING:
581
-				case DB_BLOB:
579
+				case DB1_STR:
580
+				case DB1_STRING:
581
+				case DB1_BLOB:
582 582
 					if(!rowp->fields[ccol].nul)
583 583
 					{
584 584
 						p = rowp->fields[ccol].val.str_val.s;
... ...
@@ -432,32 +432,32 @@ int dbt_is_neq_type(db_type_t _t0, db_type_t _t1)
432 432
 		return 0;
433 433
 	switch(_t1)
434 434
 	{
435
-		case DB_INT:
436
-			if(_t0==DB_DATETIME || _t0==DB_BITMAP)
435
+		case DB1_INT:
436
+			if(_t0==DB1_DATETIME || _t0==DB1_BITMAP)
437 437
 				return 0;
438 438
 
439
-		case DB_BIGINT:
439
+		case DB1_BIGINT:
440 440
 			LM_ERR("BIGINT not supported");
441 441
 			return 0;
442 442
 
443
-		case DB_DATETIME:
444
-			if(_t0==DB_INT)
443
+		case DB1_DATETIME:
444
+			if(_t0==DB1_INT)
445 445
 				return 0;
446
-			if(_t0==DB_BITMAP)
446
+			if(_t0==DB1_BITMAP)
447 447
 				return 0;
448
-		case DB_DOUBLE:
448
+		case DB1_DOUBLE:
449 449
 			break;
450
-		case DB_STRING:
451
-			if(_t0==DB_STR)
450
+		case DB1_STRING:
451
+			if(_t0==DB1_STR)
452 452
 				return 0;
453
-		case DB_STR:
454
-			if(_t0==DB_STRING || _t0==DB_BLOB)
453
+		case DB1_STR:
454
+			if(_t0==DB1_STRING || _t0==DB1_BLOB)
455 455
 				return 0;
456
-		case DB_BLOB:
457
-			if(_t0==DB_STR)
456
+		case DB1_BLOB:
457
+			if(_t0==DB1_STR)
458 458
 				return 0;
459
-		case DB_BITMAP:
460
-			if (_t0==DB_INT)
459
+		case DB1_BITMAP:
460
+			if (_t0==DB1_INT)
461 461
 				return 0;
462 462
 	}
463 463
 	return 1;
... ...
@@ -32,7 +32,7 @@
32 32
 #define _DBT_LIB_H_
33 33
 
34 34
 #include "../../str.h"
35
-#include "../../db/db_val.h"
35
+#include "../../lib/srdb1/db_val.h"
36 36
 #include "../../locking.h"
37 37
 
38 38
 #define DBT_FLAG_UNSET  0
... ...
@@ -117,8 +117,8 @@ int dbt_result_free(dbt_result_p _dres)
117 117
 		{
118 118
 			for(i=0; i<_dres->nrcols; i++)
119 119
 			{
120
-				if((_dres->colv[i].type==DB_STR 
121
-							|| _dres->colv[i].type==DB_STRING)
120
+				if((_dres->colv[i].type==DB1_STR 
121
+							|| _dres->colv[i].type==DB1_STRING)
122 122
 						&& _rp0->fields[i].val.str_val.s)
123 123
 					pkg_free(_rp0->fields[i].val.str_val.s);
124 124
 			}
... ...
@@ -262,19 +262,19 @@ int dbt_result_extract_fields(dbt_table_p _dtp, dbt_row_p _drp,
262 262
 		
263 263
 		switch(_dres->colv[i].type)
264 264
 		{
265
-			case DB_INT:
266
-			case DB_DATETIME:
267
-			case DB_BITMAP:
265
+			case DB1_INT:
266
+			case DB1_DATETIME:
267
+			case DB1_BITMAP:
268 268
 				_rp->fields[i].type = _dres->colv[i].type;
269 269
 				_rp->fields[i].val.int_val = _drp->fields[n].val.int_val;
270 270
 			break;
271
-			case DB_DOUBLE:
272
-				_rp->fields[i].type = DB_DOUBLE;
271
+			case DB1_DOUBLE:
272
+				_rp->fields[i].type = DB1_DOUBLE;
273 273
 				_rp->fields[i].val.double_val=_drp->fields[n].val.double_val;
274 274
 			break;
275
-			case DB_STRING:
276
-			case DB_STR:
277
-			case DB_BLOB:
275
+			case DB1_STRING:
276
+			case DB1_STR:
277
+			case DB1_BLOB:
278 278
 				_rp->fields[i].type = _dres->colv[i].type;
279 279
 				_rp->fields[i].val.str_val.len =
280 280
 						_drp->fields[n].val.str_val.len;
... ...
@@ -304,9 +304,9 @@ clean:
304 304
 	LM_DBG("make clean!\n");
305 305
 	while(i>=0)
306 306
 	{
307
-		if((_rp->fields[i].type == DB_STRING
308
-					|| _rp->fields[i].type == DB_STR
309
-					|| _rp->fields[i].type == DB_BLOB)
307
+		if((_rp->fields[i].type == DB1_STRING
308
+					|| _rp->fields[i].type == DB1_STR
309
+					|| _rp->fields[i].type == DB1_BLOB)
310 310
 				&& !_rp->fields[i].nul
311 311
 				&& _rp->fields[i].val.str_val.s)
312 312
 			pkg_free(_rp->fields[i].val.str_val.s);
... ...
@@ -336,21 +336,21 @@ int dbt_result_print(dbt_result_p _dres)
336 336
 	{
337 337
 		switch(_dres->colv[i].type)
338 338
 		{
339
-			case DB_INT:
339
+			case DB1_INT:
340 340
 				fprintf(fout, "%.*s(int", _dres->colv[i].name.len,
341 341
 								_dres->colv[i].name.s);
342 342
 				if(_dres->colv[i].flag & DBT_FLAG_NULL)
343 343
 					fprintf(fout, ",null");
344 344
 				fprintf(fout, ") ");
345 345
 			break;
346
-			case DB_DOUBLE:
346
+			case DB1_DOUBLE:
347 347
 				fprintf(fout, "%.*s(double", _dres->colv[i].name.len,
348 348
 							_dres->colv[i].name.s);
349 349
 				if(_dres->colv[i].flag & DBT_FLAG_NULL)
350 350
 					fprintf(fout, ",null");
351 351
 				fprintf(fout, ") ");
352 352
 			break;
353
-			case DB_STR:
353
+			case DB1_STR:
354 354
 				fprintf(fout, "%.*s(str", _dres->colv[i].name.len,
355 355
 						_dres->colv[i].name.s);
356 356
 				if(_dres->colv[i].flag & DBT_FLAG_NULL)
... ...
@@ -369,21 +369,21 @@ int dbt_result_print(dbt_result_p _dres)
369 369
 		{
370 370
 			switch(_dres->colv[i].type)
371 371
 			{
372
-				case DB_INT:
372
+				case DB1_INT:
373 373
 					if(rowp->fields[i].nul)
374 374
 						fprintf(fout, "N ");
375 375
 					else
376 376
 						fprintf(fout, "%d ",
377 377
 								rowp->fields[i].val.int_val);
378 378
 				break;
379
-				case DB_DOUBLE:
379
+				case DB1_DOUBLE:
380 380
 					if(rowp->fields[i].nul)
381 381
 						fprintf(fout, "N ");
382 382
 					else
383 383
 						fprintf(fout, "%.2f ",
384 384
 								rowp->fields[i].val.double_val);
385 385
 				break;
386
-				case DB_STR:
386
+				case DB1_STR:
387 387
 					fprintf(fout, "\"");
388 388
 					if(!rowp->fields[i].nul)
389 389
 					{
... ...
@@ -449,21 +449,21 @@ int dbt_cmp_val(dbt_val_p _vp, db_val_t* _v)
449 449
 	
450 450
 	switch(VAL_TYPE(_v))
451 451
 	{
452
-		case DB_INT:
452
+		case DB1_INT:
453 453
 			return (_vp->val.int_val<_v->val.int_val)?-1:
454 454
 					(_vp->val.int_val>_v->val.int_val)?1:0;
455 455
 
456
-		case DB_BIGINT:
456
+		case DB1_BIGINT:
457 457
 			LM_ERR("BIGINT not supported");
458 458
 			return -1;
459 459
 
460
-		case DB_DOUBLE:
460
+		case DB1_DOUBLE:
461 461
 			return (_vp->val.double_val<_v->val.double_val)?-1:
462 462
 					(_vp->val.double_val>_v->val.double_val)?1:0;
463
-		case DB_DATETIME:
463
+		case DB1_DATETIME:
464 464
 			return (_vp->val.int_val<_v->val.time_val)?-1:
465 465
 					(_vp->val.int_val>_v->val.time_val)?1:0;
466
-		case DB_STRING:
466
+		case DB1_STRING:
467 467
 			_l = strlen(_v->val.string_val);
468 468
 			_l = (_l>_vp->val.str_val.len)?_vp->val.str_val.len:_l;
469 469
 			_n = strncasecmp(_vp->val.str_val.s, _v->val.string_val, _l);
... ...
@@ -474,7 +474,7 @@ int dbt_cmp_val(dbt_val_p _vp, db_val_t* _v)
474 474
 			if(_l==_vp->val.str_val.len)
475 475
 				return -1;
476 476
 			return 1;
477
-		case DB_STR:
477
+		case DB1_STR:
478 478
 			_l = _v->val.str_val.len;
479 479
 			_l = (_l>_vp->val.str_val.len)?_vp->val.str_val.len:_l;
480 480
 			_n = strncasecmp(_vp->val.str_val.s, _v->val.str_val.s, _l);
... ...
@@ -485,7 +485,7 @@ int dbt_cmp_val(dbt_val_p _vp, db_val_t* _v)
485 485
 			if(_l==_vp->val.str_val.len)
486 486
 				return -1;
487 487
 			return 1;
488
-		case DB_BLOB:
488
+		case DB1_BLOB:
489 489
 			_l = _v->val.blob_val.len;
490 490
 			_l = (_l>_vp->val.str_val.len)?_vp->val.str_val.len:_l;
491 491
 			_n = strncasecmp(_vp->val.str_val.s, _v->val.blob_val.s, _l);
... ...
@@ -496,7 +496,7 @@ int dbt_cmp_val(dbt_val_p _vp, db_val_t* _v)
496 496
 			if(_l==_vp->val.str_val.len)
497 497
 				return -1;
498 498
 			return 1;
499
-		case DB_BITMAP:
499
+		case DB1_BITMAP:
500 500
 			return (_vp->val.int_val<_v->val.bitmap_val)?-1:
501 501
 				(_vp->val.int_val>_v->val.bitmap_val)?1:0;
502 502
 	}
... ...
@@ -797,16 +797,16 @@ void dbt_project_result(dbt_result_p _dres, int _o_nc)
797 797
 	/* check whether there are string columns, free them */
798 798
 	for (_i = _dres->nrcols - _o_nc; _i < _dres->nrcols; _i++)
799 799
 	{
800
-		if (_dres->colv[_i].type == DB_STRING ||
801
-				_dres->colv[_i].type == DB_STR ||
802
-				_dres->colv[_i].type == DB_BLOB)
800
+		if (_dres->colv[_i].type == DB1_STRING ||
801
+				_dres->colv[_i].type == DB1_STR ||
802
+				_dres->colv[_i].type == DB1_BLOB)
803 803
 		{
804 804
 			for (_drp=_dres->rows; _drp != NULL; _drp = _drp->next)
805 805
 			{
806 806
 				if (! _drp->fields[_i].nul &&
807
-					(_drp->fields[_i].type == DB_STRING ||
808
-					_drp->fields[_i].type == DB_STR ||
809
-					_drp->fields[_i].type == DB_BLOB ))
807
+					(_drp->fields[_i].type == DB1_STRING ||
808
+					_drp->fields[_i].type == DB1_STR ||
809
+					_drp->fields[_i].type == DB1_BLOB ))
810 810
 				{
811 811
 					pkg_free(_drp->fields[_i].val.str_val.s);
812 812
 					_drp->fields[_i].val.str_val.s = NULL;
... ...
@@ -31,8 +31,8 @@
31 31
 #ifndef _DBT_RES_H_
32 32
 #define _DBT_RES_H_
33 33
 
34
-#include "../../db/db_op.h"
35
-#include "../../db/db_res.h"
34
+#include "../../lib/srdb1/db_op.h"
35
+#include "../../lib/srdb1/db_res.h"
36 36
 
37 37
 #include "dbt_lib.h"
38 38
 
... ...
@@ -44,7 +44,7 @@ typedef struct _dbt_result
44 44
 	dbt_row_p rows;
45 45
 } dbt_result_t, *dbt_result_p;
46 46
 
47
-//typedef db_res_t dbt_result_t, *dbt_result_p;
47
+//typedef db1_res_t dbt_result_t, *dbt_result_p;
48 48
 
49 49
 typedef struct _dbt_con
50 50
 {
... ...
@@ -125,8 +125,8 @@ int dbt_row_free(dbt_table_p _dtp, dbt_row_p _drp)
125 125
 	if(_drp->fields)
126 126
 	{
127 127
 		for(i=0; i<_dtp->nrcols; i++)
128
-			if((_dtp->colv[i]->type==DB_STR || _dtp->colv[i]->type==DB_STRING
129
-						|| _dtp->colv[i]->type==DB_BLOB)
128
+			if((_dtp->colv[i]->type==DB1_STR || _dtp->colv[i]->type==DB1_STRING
129
+						|| _dtp->colv[i]->type==DB1_BLOB)
130 130
 					&& _drp->fields[i].val.str_val.s)
131 131
 				shm_free(_drp->fields[i].val.str_val.s);
132 132
 		shm_free(_drp->fields);
... ...
@@ -285,8 +285,8 @@ int dbt_row_set_val(dbt_row_p _drp, dbt_val_p _vp, int _t, int _idx)
285 285
 	{
286 286
 		switch(_t)
287 287
 		{
288
-			case DB_STR:
289
-			case DB_BLOB:
288
+			case DB1_STR:
289
+			case DB1_BLOB:
290 290
 				_drp->fields[_idx].type = _t;
291 291
 				_drp->fields[_idx].val.str_val.s = 
292 292
 					(char*)shm_malloc((_vp->val.str_val.len+1)*sizeof(char));
... ...
@@ -301,7 +301,7 @@ int dbt_row_set_val(dbt_row_p _drp, dbt_val_p _vp, int _t, int _idx)
301 301
 				_drp->fields[_idx].val.str_val.len = _vp->val.str_val.len;
302 302
 			break;
303 303
 			
304
-			case DB_STRING:
304
+			case DB1_STRING:
305 305
 				_drp->fields[_idx].type = _t;
306 306
 				_drp->fields[_idx].val.str_val.len=_vp->val.str_val.len;
307 307
 				
... ...
@@ -318,23 +318,23 @@ int dbt_row_set_val(dbt_row_p _drp, dbt_val_p _vp, int _t, int _idx)
318 318
 				_drp->fields[_idx].val.str_val.s[_drp->fields[_idx].val.str_val.len] = '\0';
319 319
 			break;
320 320
 			
321
-			case DB_DOUBLE:
322
-				_drp->fields[_idx].type = DB_DOUBLE;
321
+			case DB1_DOUBLE:
322
+				_drp->fields[_idx].type = DB1_DOUBLE;
323 323
 				_drp->fields[_idx].val.double_val = _vp->val.double_val;
324 324
 			break;
325 325
 			
326
-			case DB_INT:
327
-				_drp->fields[_idx].type = DB_INT;
326
+			case DB1_INT:
327
+				_drp->fields[_idx].type = DB1_INT;
328 328
 				_drp->fields[_idx].val.int_val = _vp->val.int_val;
329 329
 			break;
330 330
 			
331
-			case DB_DATETIME:
331
+			case DB1_DATETIME:
332 332
 				_drp->fields[_idx].type = _t;
333 333
 				_drp->fields[_idx].val.int_val = (int)_vp->val.time_val;
334 334
 			break;
335 335
 			
336
-			case DB_BITMAP:
337
-				_drp->fields[_idx].type = DB_INT;
336
+			case DB1_BITMAP:
337
+				_drp->fields[_idx].type = DB1_INT;
338 338
 				_drp->fields[_idx].val.int_val = (int)_vp->val.bitmap_val;
339 339
 			break;
340 340
 			
... ...
@@ -362,8 +362,8 @@ int dbt_row_update_val(dbt_row_p _drp, dbt_val_p _vp, int _t, int _idx)
362 362
 	{
363 363
 		switch(_t)
364 364
 		{
365
-			case DB_BLOB:
366
-			case DB_STR:
365
+			case DB1_BLOB:
366
+			case DB1_STR:
367 367
 				_drp->fields[_idx].type = _t;
368 368
 				// free if already exists
369 369
 				if(_drp->fields[_idx].val.str_val.s)
... ...
@@ -382,13 +382,13 @@ int dbt_row_update_val(dbt_row_p _drp, dbt_val_p _vp, int _t, int _idx)
382 382
 				_drp->fields[_idx].val.str_val.len = _vp->val.str_val.len;
383 383
 			break;
384 384
 			
385
-			case DB_STRING:
385
+			case DB1_STRING:
386 386
 				/* free if already exists */
387 387
 				if(_drp->fields[_idx].val.str_val.s)
388 388
 					shm_free(_drp->fields[_idx].val.str_val.s);
389 389
 
390 390
 				_drp->fields[_idx].type = _t;
391
-				if(_vp->type==DB_STR)
391
+				if(_vp->type==DB1_STR)
392 392
 					_drp->fields[_idx].val.str_val.len=_vp->val.str_val.len;
393 393
 				else
394 394
 					_drp->fields[_idx].val.str_val.len
... ...
@@ -407,22 +407,22 @@ int dbt_row_update_val(dbt_row_p _drp, dbt_val_p _vp, int _t, int _idx)
407 407
 				_drp->fields[_idx].val.str_val.s[_vp->val.str_val.len] = '\0';
408 408
 			break;
409 409
 			
410
-			case DB_DOUBLE:
410
+			case DB1_DOUBLE:
411 411
 				_drp->fields[_idx].type = _t;
412 412
 				_drp->fields[_idx].val.double_val = _vp->val.double_val;
413 413
 			break;
414 414
 			
415
-			case DB_INT:
415
+			case DB1_INT:
416 416
 				_drp->fields[_idx].type = _t;
417 417
 				_drp->fields[_idx].val.int_val = _vp->val.int_val;
418 418
 			break;
419 419
 			
420
-			case DB_DATETIME:
420
+			case DB1_DATETIME:
421 421
 				_drp->fields[_idx].type = _t;
422 422
 				_drp->fields[_idx].val.int_val = (int)_vp->val.time_val;
423 423
 			break;
424 424
 			
425
-			case DB_BITMAP:
425
+			case DB1_BITMAP:
426 426
 				_drp->fields[_idx].type = _t;
427 427
 				_drp->fields[_idx].val.int_val = (int)_vp->val.bitmap_val;
428 428
 			break;
... ...
@@ -461,7 +461,7 @@ int dbt_table_check_row(dbt_table_p _dtp, dbt_row_p _drp)
461 461
 		if(!_drp->fields[i].nul)
462 462
 			continue;
463 463
 
464
-		if(_dtp->colv[i]->type==DB_INT
464
+		if(_dtp->colv[i]->type==DB1_INT
465 465
 			&& (_dtp->colv[i]->flag & DBT_FLAG_AUTO)
466 466
 			&& i==_dtp->auto_col)
467 467
 		{
... ...
@@ -33,7 +33,7 @@
33 33
 #include <unistd.h>
34 34
 
35 35
 #include "../../sr_module.h"
36
-#include "../../db/db.h"
36
+#include "../../lib/srdb1/db.h"
37 37
 #include "dbtext.h"
38 38
 #include "dbt_lib.h"
39 39
 #include "dbt_api.h"
... ...
@@ -31,60 +31,60 @@
31 31
 #ifndef _DBTEXT_H_
32 32
 #define _DBTEXT_H_
33 33
 
34
-#include "../../db/db_con.h"
35
-#include "../../db/db_res.h"
36
-#include "../../db/db_key.h"
37
-#include "../../db/db_op.h"
38
-#include "../../db/db_val.h"
34
+#include "../../lib/srdb1/db_con.h"
35
+#include "../../lib/srdb1/db_res.h"
36
+#include "../../lib/srdb1/db_key.h"
37
+#include "../../lib/srdb1/db_op.h"
38
+#include "../../lib/srdb1/db_val.h"
39 39
 
40 40
 
41 41
 /*
42 42
  * Initialize database connection
43 43
  */
44
-db_con_t* dbt_init(const str* _sqlurl);
44
+db1_con_t* dbt_init(const str* _sqlurl);
45 45
 
46 46
 
47 47
 /*
48 48
  * Close a database connection
49 49
  */
50
-void dbt_close(db_con_t* _h);
50
+void dbt_close(db1_con_t* _h);
51 51
 
52 52
 
53 53
 /*
54 54
  * Free all memory allocated by get_result
55 55
  */
56
-int dbt_free_result(db_con_t* _h, db_res_t* _r);
56
+int dbt_free_result(db1_con_t* _h, db1_res_t* _r);
57 57
 
58 58
 
59 59
 /*
60 60
  * Do a query
61 61
  */
62
-int dbt_query(db_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, 
63
-			db_key_t* _c, int _n, int _nc, db_key_t _o, db_res_t** _r);
62
+int dbt_query(db1_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, 
63
+			db_key_t* _c, int _n, int _nc, db_key_t _o, db1_res_t** _r);
64 64
 
65 65
 
66 66
 /*
67 67
  * Raw SQL query
68 68
  */
69
-int dbt_raw_query(db_con_t* _h, char* _s, db_res_t** _r);
69
+int dbt_raw_query(db1_con_t* _h, char* _s, db1_res_t** _r);
70 70
 
71 71
 
72 72
 /*
73 73
  * Insert a row into table
74 74
  */
75
-int dbt_insert(db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n);
75
+int dbt_insert(db1_con_t* _h, db_key_t* _k, db_val_t* _v, int _n);
76 76
 
77 77
 
78 78
 /*
79 79
  * Delete a row from table
80 80
  */
81
-int dbt_delete(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, int _n);
81
+int dbt_delete(db1_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, int _n);
82 82
 
83 83
 
84 84
 /*
85 85
  * Update a row in table
86 86
  */
87
-int dbt_update(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v,
87
+int dbt_update(db1_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v,
88 88
 	      db_key_t* _uk, db_val_t* _uv, int _n, int _un);
89 89
 
90 90
 #endif