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:21
Showing 4 changed files
... ...
@@ -14,4 +14,6 @@ DEFS+=
14 14
 
15 15
 DEFS+=-DOPENSER_MOD_INTERFACE
16 16
 
17
+SERLIBPATH=../../lib
18
+SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1
17 19
 include ../../Makefile.modules
... ...
@@ -30,7 +30,7 @@
30 30
 #include <stdio.h>
31 31
 #include <string.h>
32 32
 #include "../../sr_module.h"
33
-#include "../../db/db.h"
33
+#include "../../lib/srdb1/db.h"
34 34
 #include "../../dprint.h"
35 35
 #include "../../error.h"
36 36
 #include "../../mem/mem.h"
... ...
@@ -64,7 +64,7 @@ str domain_prefix       = {NULL, 0};
64 64
 int use_domain          = 0;
65 65
 int ald_append_branches = 0;
66 66
 
67
-db_con_t* db_handle;   /* Database connection handle */
67
+db1_con_t* db_handle;   /* Database connection handle */
68 68
 db_func_t adbf;  /* DB functions */
69 69
 
70 70
 /* Exported functions */
... ...
@@ -30,7 +30,7 @@
30 30
 #ifndef _ALIAS_DB_H_
31 31
 #define _ALIAS_DB_H_
32 32
 
33
-#include "../../db/db.h"
33
+#include "../../lib/srdb1/db.h"
34 34
 #include "../../parser/msg_parser.h"
35 35
 
36 36
 
... ...
@@ -44,6 +44,6 @@ extern str domain_prefix;
44 44
 extern int use_domain;      /* use or not the domain for alias lookup */
45 45
 extern int ald_append_branches;  /* append branches after an alias lookup */
46 46
 
47
-extern db_con_t* db_handle;   /* Database connection handle */
47
+extern db1_con_t* db_handle;   /* Database connection handle */
48 48
 
49 49
 #endif /* _ALIAS_DB_H_ */
... ...
@@ -33,7 +33,7 @@
33 33
 #include "../../config.h"
34 34
 #include "../../ut.h"
35 35
 #include "../../parser/parse_uri.h"
36
-#include "../../db/db.h"
36
+#include "../../lib/srdb1/db.h"
37 37
 #include "../../mod_fix.h"
38 38
 #include "../../dset.h"
39 39
 
... ...
@@ -75,7 +75,7 @@ int alias_db_lookup(struct sip_msg* _msg, char* _table, char* _str2)
75 75
 	db_key_t db_keys[2] = {&alias_user_column, &alias_domain_column};
76 76
 	db_val_t db_vals[2];
77 77
 	db_key_t db_cols[] = {&user_column, &domain_column};
78
-	db_res_t* db_res = NULL;
78
+	db1_res_t* db_res = NULL;
79 79
 	int i;
80 80
 	
81 81
 	if(_table==NULL || fixup_get_svalue(_msg, (gparam_p)_table, &table_s)!=0)
... ...
@@ -87,14 +87,14 @@ int alias_db_lookup(struct sip_msg* _msg, char* _table, char* _str2)
87 87
 	if (parse_sip_msg_uri(_msg) < 0)
88 88
 		return -1;
89 89
 	
90
-	db_vals[0].type = DB_STR;
90
+	db_vals[0].type = DB1_STR;
91 91
 	db_vals[0].nul = 0;
92 92
 	db_vals[0].val.str_val.s = _msg->parsed_uri.user.s;
93 93
 	db_vals[0].val.str_val.len = _msg->parsed_uri.user.len;
94 94
 
95 95
 	if (use_domain)
96 96
 	{
97
-		db_vals[1].type = DB_STR;
97
+		db_vals[1].type = DB1_STR;
98 98
 		db_vals[1].nul = 0;
99 99
 		db_vals[1].val.str_val.s = _msg->parsed_uri.host.s;
100 100
 		db_vals[1].val.str_val.len = _msg->parsed_uri.host.len;
... ...
@@ -132,18 +132,18 @@ int alias_db_lookup(struct sip_msg* _msg, char* _table, char* _str2)
132 132
 		user_s.s = useruri_buf+4;
133 133
 		switch(RES_ROWS(db_res)[i].values[0].type)
134 134
 		{ 
135
-			case DB_STRING:
135
+			case DB1_STRING:
136 136
 				strcpy(user_s.s, 
137 137
 					(char*)RES_ROWS(db_res)[i].values[0].val.string_val);
138 138
 				user_s.len += strlen(user_s.s);
139 139
 			break;
140
-			case DB_STR:
140
+			case DB1_STR:
141 141
 				strncpy(user_s.s, 
142 142
 					(char*)RES_ROWS(db_res)[i].values[0].val.str_val.s,
143 143
 					RES_ROWS(db_res)[i].values[0].val.str_val.len);
144 144
 				user_s.len += RES_ROWS(db_res)[i].values[0].val.str_val.len;
145 145
 			break;
146
-			case DB_BLOB:
146
+			case DB1_BLOB:
147 147
 				strncpy(user_s.s, 
148 148
 					(char*)RES_ROWS(db_res)[i].values[0].val.blob_val.s,
149 149
 					RES_ROWS(db_res)[i].values[0].val.blob_val.len);
... ...
@@ -166,19 +166,19 @@ int alias_db_lookup(struct sip_msg* _msg, char* _table, char* _str2)
166 166
 		user_s.s = useruri_buf+user_s.len;
167 167
 		switch(RES_ROWS(db_res)[i].values[1].type)
168 168
 		{ 
169
-			case DB_STRING:
169
+			case DB1_STRING:
170 170
 				strcpy(user_s.s, 
171 171
 					(char*)RES_ROWS(db_res)[i].values[1].val.string_val);
172 172
 				user_s.len += strlen(user_s.s);
173 173
 			break;
174
-			case DB_STR:
174
+			case DB1_STR:
175 175
 				strncpy(user_s.s, 
176 176
 					(char*)RES_ROWS(db_res)[i].values[1].val.str_val.s,
177 177
 					RES_ROWS(db_res)[i].values[1].val.str_val.len);
178 178
 				user_s.len += RES_ROWS(db_res)[i].values[1].val.str_val.len;
179 179
 				useruri_buf[user_s.len] = '\0';
180 180
 			break;
181
-			case DB_BLOB:
181
+			case DB1_BLOB:
182 182
 				strncpy(user_s.s, 
183 183
 					(char*)RES_ROWS(db_res)[i].values[1].val.blob_val.s,
184 184
 					RES_ROWS(db_res)[i].values[1].val.blob_val.len);