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:29
Showing 5 changed files
... ...
@@ -12,4 +12,6 @@ LIBS=
12 12
 
13 13
 DEFS+=-DOPENSER_MOD_INTERFACE
14 14
 
15
+SERLIBPATH=../../lib
16
+SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1
15 17
 include ../../Makefile.modules
... ...
@@ -36,7 +36,7 @@
36 36
 
37 37
 #include <string.h>
38 38
 #include "../../dprint.h"               /* Logging */
39
-#include "../../db/db.h"                /* Generic database API */
39
+#include "../../lib/srdb1/db.h"                /* Generic database API */
40 40
 #include "../../ut.h"
41 41
 #include "../../parser/digest/digest.h" /* get_authorized_cred */
42 42
 #include "../../parser/hf.h"            /* Header Field types */
... ...
@@ -142,7 +142,7 @@ int is_user_in(struct sip_msg* _msg, char* _hf, char* _grp)
142 142
 	db_key_t keys[3];
143 143
 	db_val_t vals[3];
144 144
 	db_key_t col[1];
145
-	db_res_t* res = NULL;
145
+	db1_res_t* res = NULL;
146 146
 
147 147
 	keys[0] = &user_column;
148 148
 	keys[1] = &group_column;
... ...
@@ -160,7 +160,7 @@ int is_user_in(struct sip_msg* _msg, char* _hf, char* _grp)
160 160
 		return -1;
161 161
 	}
162 162
 
163
-	VAL_TYPE(vals) = VAL_TYPE(vals + 1) = VAL_TYPE(vals + 2) = DB_STR;
163
+	VAL_TYPE(vals) = VAL_TYPE(vals + 1) = VAL_TYPE(vals + 2) = DB1_STR;
164 164
 	VAL_NULL(vals) = VAL_NULL(vals + 1) = VAL_NULL(vals + 2) = 0;
165 165
 
166 166
 	VAL_STR(vals + 1) = *((str*)_grp);
... ...
@@ -126,7 +126,7 @@ int multiple_gid  = 1;
126 126
 
127 127
 /* DB functions and handlers */
128 128
 db_func_t group_dbf;
129
-db_con_t* group_dbh = 0;
129
+db1_con_t* group_dbh = 0;
130 130
 
131 131
 
132 132
 /*!
... ...
@@ -35,7 +35,7 @@
35 35
 #ifndef GROUP_MOD_H
36 36
 #define GROUP_MOD_H
37 37
 
38
-#include "../../db/db.h"
38
+#include "../../lib/srdb1/db.h"
39 39
 #include "../../str.h"
40 40
 #include "../../parser/digest/digest.h" /* auth_body_t */
41 41
 #include "../../parser/msg_parser.h"    /* struct sip_msg */
... ...
@@ -57,7 +57,7 @@ extern int multiple_gid;
57 57
 
58 58
 /* DB functions and handlers */
59 59
 extern db_func_t group_dbf;
60
-extern db_con_t* group_dbh;
60
+extern db1_con_t* group_dbh;
61 61
 
62 62
 
63 63
 #endif
... ...
@@ -96,7 +96,7 @@ error:
96 96
 int load_re( str *table )
97 97
 {
98 98
 	db_key_t cols[2];
99
-	db_res_t* res = NULL;
99
+	db1_res_t* res = NULL;
100 100
 	db_row_t* row;
101 101
 	int n;
102 102
 
... ...
@@ -116,12 +116,12 @@ int load_re( str *table )
116 116
 	for( n=0 ; n<RES_ROW_N(res) ; n++) {
117 117
 		row = &res->rows[n];
118 118
 		/* validate row */
119
-		if (row->values[0].nul || row->values[0].type!=DB_STRING) {
119
+		if (row->values[0].nul || row->values[0].type!=DB1_STRING) {
120 120
 			LM_ERR("empty or non-string "
121 121
 				"value for <%s>(re) column\n",re_exp_column.s);
122 122
 			goto error1;
123 123
 		}
124
-		if (row->values[1].nul || row->values[1].type!=DB_INT) {
124
+		if (row->values[1].nul || row->values[1].type!=DB1_INT) {
125 125
 			LM_ERR("empty or non-integer "
126 126
 				"value for <%s>(gid) column\n",re_gid_column.s);
127 127
 			goto error1;