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:38
Showing 3 changed files
... ...
@@ -10,4 +10,6 @@ LIBS+=-lglib-2.0 -lpurple -lxml2
10 10
 
11 11
 DEFS+=-DOPENSER_MOD_INTERFACE
12 12
 
13
+SERLIBPATH=../../lib
14
+SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1
13 15
 include ../../Makefile.modules
... ...
@@ -22,7 +22,7 @@
22 22
 #include <string.h>
23 23
 
24 24
 #include "../../str.h"
25
-#include "../../db/db.h"
25
+#include "../../lib/srdb1/db.h"
26 26
 #include "../../dprint.h"
27 27
 
28 28
 #include "mapping.h"
... ...
@@ -99,13 +99,13 @@ char *find_sip_user(char *extern_user) {
99 99
 	int n_query_cols = 0, n_result_cols = 0;
100 100
 	db_row_t *row;
101 101
 	db_val_t *row_vals;
102
-	db_res_t *result = NULL;
102
+	db1_res_t *result = NULL;
103 103
 	int sip_user_col;
104 104
 
105 105
 	str q_ext_user = {"ext_user", 8};
106 106
 	query_cols[n_query_cols] = &q_ext_user;
107 107
 	query_ops[n_query_cols] = OP_EQ;
108
-	query_vals[n_query_cols].type = DB_STR;
108
+	query_vals[n_query_cols].type = DB1_STR;
109 109
 	query_vals[n_query_cols].nul = 0;
110 110
 	query_vals[n_query_cols].val.str_val = ext_user;
111 111
 	n_query_cols++;
... ...
@@ -113,7 +113,7 @@ char *find_sip_user(char *extern_user) {
113 113
 	str r_sip_user = {"sip_user", 8};
114 114
 	result_cols[sip_user_col=n_result_cols++] = &r_sip_user;
115 115
 
116
-	db_con_t *pa_db;
116
+	db1_con_t *pa_db;
117 117
 	pa_db = pa_dbf.init(&db_url);
118 118
 	if (!pa_db) {
119 119
 		LM_ERR("error connecting database\n");
... ...
@@ -165,13 +165,13 @@ extern_account_t *find_accounts(char* sip_user, int* count) {
165 165
 	int n_query_cols = 0, n_result_cols = 0;
166 166
 	db_row_t *row;
167 167
 	db_val_t *row_vals;
168
-	db_res_t *result = NULL;
168
+	db1_res_t *result = NULL;
169 169
 	int ext_prot_col, ext_user_col, ext_pass_col;
170 170
 
171 171
 	str q_sip_user = {"sip_user", 8};
172 172
 	query_cols[n_query_cols] = &q_sip_user;
173 173
 	query_ops[n_query_cols] = OP_EQ;
174
-	query_vals[n_query_cols].type = DB_STRING;
174
+	query_vals[n_query_cols].type = DB1_STRING;
175 175
 	query_vals[n_query_cols].nul = 0;
176 176
 	query_vals[n_query_cols].val.string_val = sip_user;
177 177
 	n_query_cols++;
... ...
@@ -183,7 +183,7 @@ extern_account_t *find_accounts(char* sip_user, int* count) {
183 183
 	result_cols[ext_user_col=n_result_cols++] = &r_ext_user;
184 184
 	result_cols[ext_pass_col=n_result_cols++] = &r_ext_pass;
185 185
 
186
-	db_con_t *pa_db;
186
+	db1_con_t *pa_db;
187 187
 	pa_db = pa_dbf.init(&db_url);
188 188
 	if (!pa_db) {
189 189
 		LM_ERR("error connecting database\n");
... ...
@@ -254,13 +254,13 @@ extern_user_t *find_users(char *sip_user, int* count) {
254 254
 	int n_query_cols = 0, n_result_cols = 0;
255 255
 	db_row_t *row;
256 256
 	db_val_t *row_vals;
257
-	db_res_t *result = NULL;
257
+	db1_res_t *result = NULL;
258 258
 	int ext_prot_col, ext_user_col;
259 259
 	
260 260
 	str q_sip_user = {"sip_user", 8};
261 261
 	query_cols[n_query_cols] = &q_sip_user;
262 262
 	query_ops[n_query_cols] = OP_EQ;
263
-	query_vals[n_query_cols].type = DB_STRING;
263
+	query_vals[n_query_cols].type = DB1_STRING;
264 264
 	query_vals[n_query_cols].nul = 0;
265 265
 	query_vals[n_query_cols].val.string_val = sip_user;
266 266
 	n_query_cols++;
... ...
@@ -270,7 +270,7 @@ extern_user_t *find_users(char *sip_user, int* count) {
270 270
 	result_cols[ext_prot_col=n_result_cols++] = &r_ext_prot;
271 271
 	result_cols[ext_user_col=n_result_cols++] = &r_ext_user;
272 272
 
273
-	db_con_t *pa_db;
273
+	db1_con_t *pa_db;
274 274
 	pa_db = pa_dbf.init(&db_url);
275 275
 	if (!pa_db) {
276 276
 		LM_ERR("error connecting database\n");
... ...
@@ -23,7 +23,7 @@
23 23
 #include <unistd.h>
24 24
 #include <libxml/parser.h>
25 25
 
26
-#include "../../db/db.h"
26
+#include "../../lib/srdb1/db.h"
27 27
 #include "../../sr_module.h"
28 28
 #include "../../data_lump_rpl.h"
29 29
 #include "../../parser/msg_parser.h"
... ...
@@ -50,7 +50,7 @@ static int fixup_subscribe(void** param, int param_no);
50 50
 
51 51
 int pipefds[2] = {-1, -1};
52 52
 
53
-db_con_t *pa_db = NULL;
53
+db1_con_t *pa_db = NULL;
54 54
 db_func_t pa_dbf;
55 55
 str db_table = {"purplemap", 0};
56 56
 str db_url = {DEFAULT_RODB_URL, DEFAULT_RODB_URL_LEN};