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:44
Showing 4 changed files
... ...
@@ -16,4 +16,6 @@ LIBS+=-L$(SYSBASE)/include/lib -L$(LOCALBASE)/lib -lcurl
16 16
 
17 17
 DEFS+=-DOPENSER_MOD_INTERFACE
18 18
 
19
+SERLIBPATH=../../lib
20
+SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1
19 21
 include ../../Makefile.modules
... ...
@@ -37,7 +37,7 @@
37 37
 #include <curl/curl.h>
38 38
 
39 39
 #include "../../pt.h"
40
-#include "../../db/db.h"
40
+#include "../../lib/srdb1/db.h"
41 41
 #include "../../sr_module.h"
42 42
 #include "../../dprint.h"
43 43
 #include "../../error.h"
... ...
@@ -74,7 +74,7 @@ str str_port_col = str_init("port");
74 74
 
75 75
 
76 76
 /* database connection */
77
-db_con_t *xcap_db = NULL;
77
+db1_con_t *xcap_db = NULL;
78 78
 db_func_t xcap_dbf;
79 79
 
80 80
 void query_xcap_update(unsigned int ticks, void* param);
... ...
@@ -168,7 +168,7 @@ void query_xcap_update(unsigned int ticks, void* param)
168 168
 	db_val_t query_vals[3], update_vals[3];
169 169
 	db_key_t result_cols[7];
170 170
 	int n_result_cols = 0, n_query_cols= 0, n_update_cols= 0;
171
-	db_res_t* result= NULL;
171
+	db1_res_t* result= NULL;
172 172
 	int user_col, domain_col, doc_type_col, etag_col, doc_uri_col, port_col; 
173 173
 	db_row_t *row ;	
174 174
 	db_val_t *row_vals ;
... ...
@@ -180,22 +180,22 @@ void query_xcap_update(unsigned int ticks, void* param)
180 180
 
181 181
 	/* query the ones I have to handle */
182 182
 	query_cols[n_query_cols] = &str_source_col;
183
-	query_vals[n_query_cols].type = DB_INT;
183
+	query_vals[n_query_cols].type = DB1_INT;
184 184
 	query_vals[n_query_cols].nul = 0;
185 185
 	query_vals[n_query_cols].val.int_val= XCAP_CL_MOD;
186 186
 	n_query_cols++;
187 187
 
188 188
 	query_cols[n_query_cols] = &str_path_col;
189
-	query_vals[n_query_cols].type = DB_STR;
189
+	query_vals[n_query_cols].type = DB1_STR;
190 190
 	query_vals[n_query_cols].nul = 0;
191 191
 
192 192
 	update_cols[u_doc_col=n_update_cols] = &str_doc_col;
193
-	update_vals[n_update_cols].type = DB_STRING;
193
+	update_vals[n_update_cols].type = DB1_STRING;
194 194
 	update_vals[n_update_cols].nul = 0;
195 195
 	n_update_cols++;
196 196
 
197 197
 	update_cols[u_etag_col=n_update_cols] = &str_etag_col;
198
-	update_vals[n_update_cols].type = DB_STRING;
198
+	update_vals[n_update_cols].type = DB1_STRING;
199 199
 	update_vals[n_update_cols].nul = 0;
200 200
 	n_update_cols++;
201 201
 
... ...
@@ -29,7 +29,7 @@
29 29
 #ifndef XCAP_CL_H
30 30
 #define XCAP_CL_H
31 31
 
32
-#include "../../db/db.h"
32
+#include "../../lib/srdb1/db.h"
33 33
 #include "xcap_callbacks.h"
34 34
 
35 35
 extern xcap_callback_t* xcapcb_list;
... ...
@@ -47,7 +47,7 @@ extern str str_doc_uri_col;
47 47
 extern str str_port_col;
48 48
 
49 49
 /* database connection */
50
-extern db_con_t *xcap_db;
50
+extern db1_con_t *xcap_db;
51 51
 extern db_func_t xcap_dbf;
52 52
 
53 53
 extern int periodical_query;
... ...
@@ -36,7 +36,7 @@
36 36
 #include <time.h>
37 37
 #include <curl/curl.h>
38 38
 #include "../../mem/mem.h"
39
-#include "../../db/db.h"
39
+#include "../../lib/srdb1/db.h"
40 40
 #include "xcap_functions.h"
41 41
 #include "xcap_client.h"
42 42
 #include "../presence/hash.h"
... ...
@@ -335,49 +335,49 @@ char* xcapGetNewDoc(xcap_get_req_t req, str user, str domain)
335 335
 	}
336 336
 	/* insert in xcap table*/
337 337
 	query_cols[n_query_cols] = &str_username_col;
338
-	query_vals[n_query_cols].type = DB_STR;
338
+	query_vals[n_query_cols].type = DB1_STR;
339 339
 	query_vals[n_query_cols].nul = 0;
340 340
 	query_vals[n_query_cols].val.str_val = user;
341 341
 	n_query_cols++;
342 342
 	
343 343
 	query_cols[n_query_cols] = &str_domain_col;
344
-	query_vals[n_query_cols].type = DB_STR;
344
+	query_vals[n_query_cols].type = DB1_STR;
345 345
 	query_vals[n_query_cols].nul = 0;
346 346
 	query_vals[n_query_cols].val.str_val = domain;
347 347
 	n_query_cols++;
348 348
 	
349 349
 	query_cols[n_query_cols] = &str_doc_type_col;
350
-	query_vals[n_query_cols].type = DB_INT;
350
+	query_vals[n_query_cols].type = DB1_INT;
351 351
 	query_vals[n_query_cols].nul = 0;
352 352
 	query_vals[n_query_cols].val.int_val= req.doc_sel.doc_type;
353 353
 	n_query_cols++;
354 354
 
355 355
 	query_cols[n_query_cols] = &str_doc_col;
356
-	query_vals[n_query_cols].type = DB_STRING;
356
+	query_vals[n_query_cols].type = DB1_STRING;
357 357
 	query_vals[n_query_cols].nul = 0;
358 358
 	query_vals[n_query_cols].val.string_val= doc;
359 359
 	n_query_cols++;
360 360
 
361 361
 	query_cols[n_query_cols] = &str_etag_col;
362
-	query_vals[n_query_cols].type = DB_STRING;
362
+	query_vals[n_query_cols].type = DB1_STRING;
363 363
 	query_vals[n_query_cols].nul = 0;
364 364
 	query_vals[n_query_cols].val.string_val= etag;
365 365
 	n_query_cols++;
366 366
 
367 367
 	query_cols[n_query_cols] = &str_source_col;
368
-	query_vals[n_query_cols].type = DB_INT;
368
+	query_vals[n_query_cols].type = DB1_INT;
369 369
 	query_vals[n_query_cols].nul = 0;
370 370
 	query_vals[n_query_cols].val.int_val= XCAP_CL_MOD;
371 371
 	n_query_cols++;
372 372
 
373 373
 	query_cols[n_query_cols] = &str_doc_uri_col;
374
-	query_vals[n_query_cols].type = DB_STRING;
374
+	query_vals[n_query_cols].type = DB1_STRING;
375 375
 	query_vals[n_query_cols].nul = 0;
376 376
 	query_vals[n_query_cols].val.string_val= path;
377 377
 	n_query_cols++;
378 378
 	
379 379
 	query_cols[n_query_cols] = &str_port_col;
380
-	query_vals[n_query_cols].type = DB_INT;
380
+	query_vals[n_query_cols].type = DB1_INT;
381 381
 	query_vals[n_query_cols].nul = 0;
382 382
 	query_vals[n_query_cols].val.int_val= req.port;
383 383
 	n_query_cols++;