Browse code

- bind_dbmod now accepts one parameter, all modules updated - added DB_BITMAP into dbtext

Jan Janak authored on 24/10/2003 20:37:39
Showing 12 changed files
... ...
@@ -282,7 +282,7 @@ static int mod_init( void )
282 282
 		return -1;
283 283
 
284 284
 #ifdef SQL_ACC
285
-	if (bind_dbmod()) {
285
+	if (bind_dbmod(db_url)) {
286 286
 		LOG(L_ERR, "ERROR: acc: init_child bind_db failed..."
287 287
 				"did you load a database module?\n");
288 288
 		return -1;
... ...
@@ -152,7 +152,7 @@ static int mod_init(void)
152 152
 	DBG("auth_db module - initializing\n");
153 153
 	
154 154
 	     /* Find a database module */
155
-	if (bind_dbmod()) {
155
+	if (bind_dbmod(db_url)) {
156 156
 		LOG(L_ERR, "mod_init(): Unable to bind database module\n");
157 157
 		return -1;
158 158
 	}
... ...
@@ -169,6 +169,31 @@ db_res_t* new_result(void)
169 169
 }
170 170
 
171 171
 
172
+/*
173
+ * Fill the structure with data from database
174
+ */
175
+int convert_result(db_con_t* _h, db_res_t* _r)
176
+{
177
+	if ((!_h) || (!_r)) {
178
+#ifdef DBT_EXTRA_DEBUG
179
+		LOG(L_ERR, "DBT:convert_result: Invalid parameter\n");
180
+#endif
181
+		return -1;
182
+	}
183
+	if (get_columns(_h, _r) < 0) {
184
+		LOG(L_ERR, "DBT:convert_result: Error while getting column names\n");
185
+		return -2;
186
+	}
187
+
188
+	if (convert_rows(_h, _r) < 0) {
189
+		LOG(L_ERR, "DBT:convert_result: Error while converting rows\n");
190
+		free_columns(_r);
191
+		return -3;
192
+	}
193
+	return 0;
194
+}
195
+
196
+
172 197
 /*
173 198
  * Retrieve result set
174 199
  */
... ...
@@ -206,30 +231,6 @@ int get_result(db_con_t* _h, db_res_t** _r)
206 231
 	return 0;
207 232
 }
208 233
 
209
-/*
210
- * Fill the structure with data from database
211
- */
212
-int convert_result(db_con_t* _h, db_res_t* _r)
213
-{
214
-	if ((!_h) || (!_r)) {
215
-#ifdef DBT_EXTRA_DEBUG
216
-		LOG(L_ERR, "DBT:convert_result: Invalid parameter\n");
217
-#endif
218
-		return -1;
219
-	}
220
-	if (get_columns(_h, _r) < 0) {
221
-		LOG(L_ERR, "DBT:convert_result: Error while getting column names\n");
222
-		return -2;
223
-	}
224
-
225
-	if (convert_rows(_h, _r) < 0) {
226
-		LOG(L_ERR, "DBT:convert_result: Error while converting rows\n");
227
-		free_columns(_r);
228
-		return -3;
229
-	}
230
-	return 0;
231
-}
232
-
233 234
 /*
234 235
  * Get and convert columns from a result
235 236
  */
... ...
@@ -411,6 +412,12 @@ int convert_row(db_con_t* _h, db_res_t* _res, db_row_t* _r)
411 412
 						DBT_CON_ROW(_h)->fields[i].val.str_val.len;
412 413
 				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB_STR;
413 414
 			break;
415
+
416
+		        case DB_BITMAP:
417
+				VAL_BITMAP(&(ROW_VALUES(_r)[i])) =
418
+					DBT_CON_ROW(_h)->fields[i].val.bitmap_val;
419
+				VAL_TYPE(&(ROW_VALUES(_r)[i])) = DB_BITMAP;
420
+			break;
414 421
 		}
415 422
 	}
416 423
 	return 0;
... ...
@@ -40,6 +40,8 @@
40 40
 
41 41
 #include "../../db/db_op.h"
42 42
 #include "../../db/db_res.h"
43
+#include "../../db/db_con.h"
44
+#include "../../db/db_row.h"
43 45
 
44 46
 int free_columns(db_res_t* _r);
45 47
 
... ...
@@ -78,4 +80,7 @@ int convert_rows(db_con_t* _h, db_res_t* _r);
78 80
  */
79 81
 int convert_row(db_con_t* _h, db_res_t* _res, db_row_t* _r);
80 82
 
83
+
84
+int use_table(db_con_t* _h, const char* _t);
85
+
81 86
 #endif
... ...
@@ -487,6 +487,11 @@ int dbt_cmp_val(dbt_val_p _vp, db_val_t* _v)
487 487
 			if(_l==_vp->val.str_val.len)
488 488
 				return -1;
489 489
 			return 1;
490
+	        case DB_BITMAP:
491
+		        return (_vp->val.bitmap_val<_v->val.bitmap_val)?-1:
492
+				(_vp->val.bitmap_val>_v->val.bitmap_val)?1:0;
493
+
494
+			return 1;
490 495
 	}
491 496
 	return -2;
492 497
 }
... ...
@@ -524,9 +529,13 @@ int dbt_is_neq_type(db_type_t _t0, db_type_t _t1)
524 529
 		case DB_INT:
525 530
 			if(_t0==DB_DATETIME)
526 531
 				return 0;
532
+			if(_t0==DB_BITMAP)
533
+				return 0;
527 534
 		case DB_DATETIME:
528 535
 			if(_t0==DB_INT)
529 536
 				return 0;
537
+			if(_t0==DB_BITMAP)
538
+				return 0;
530 539
 		case DB_DOUBLE:
531 540
 		break;
532 541
 		case DB_STRING:
... ...
@@ -538,6 +547,11 @@ int dbt_is_neq_type(db_type_t _t0, db_type_t _t1)
538 547
 		case DB_BLOB:
539 548
 			if(_t0==DB_STR)
540 549
 				return 0;
550
+	        case DB_BITMAP:
551
+			if (_t0==DB_INT)
552
+				return 0;
553
+			if (_t0==DB_DATETIME)
554
+				return 0;
541 555
 	}
542 556
 	return 1;
543 557
 }
... ...
@@ -42,6 +42,7 @@
42 42
 #include "../../sr_module.h"
43 43
 #include "dbtext.h"
44 44
 #include "dbt_lib.h"
45
+#include "dbt_api.h"
45 46
 
46 47
 MODULE_VERSION
47 48
 
... ...
@@ -112,7 +112,7 @@ static int mod_init(void)
112 112
 	DBG("domain - initializing\n");
113 113
 	
114 114
 	/* Check if database module has been loaded */
115
-	if (bind_dbmod()) {
115
+	if (bind_dbmod(db_url)) {
116 116
 		LOG(L_ERR, "domain:mod_init(): Unable to bind database module\n");
117 117
 		return -1;
118 118
 	}
... ...
@@ -141,7 +141,7 @@ static int mod_init(void)
141 141
 	DBG("group module - initializing\n");
142 142
 	
143 143
 	     /* Find a database module */
144
-	if (bind_dbmod()) {
144
+	if (bind_dbmod(db_url)) {
145 145
 		LOG(L_ERR, "mod_init(): Unable to bind database module\n");
146 146
 		return -1;
147 147
 	}
... ...
@@ -203,7 +203,7 @@ static int mod_init(void)
203 203
 	DBG("MSILO: initializing ...\n");
204 204
 
205 205
 	/* binding to mysql module  */
206
-	if (bind_dbmod())
206
+	if (bind_dbmod(db_url))
207 207
 	{
208 208
 		DBG("MSILO: ERROR: Database module not found\n");
209 209
 		return -1;
... ...
@@ -138,7 +138,7 @@ static int mod_init(void)
138 138
 {
139 139
 	DBG("uri - initializing\n");
140 140
 
141
-	if (bind_dbmod()) {
141
+	if (bind_dbmod(db_url)) {
142 142
 		LOG(L_ERR, "uri:mod_init(): No database module found\n");
143 143
 		return -1;
144 144
 	}
... ...
@@ -166,7 +166,7 @@ static int mod_init(void)
166 166
 
167 167
 	     /* Shall we use database ? */
168 168
 	if (db_mode != NO_DB) { /* Yes */
169
-		if (bind_dbmod() < 0) { /* Find database module */
169
+		if (bind_dbmod(db_url) < 0) { /* Find database module */
170 170
 			LOG(L_ERR, "mod_init(): Can't bind database module\n");
171 171
 			return -1;
172 172
 		}
... ...
@@ -155,7 +155,7 @@ static int vm_mod_init(void)
155 155
 		return -1;
156 156
 	}
157 157
 
158
-	if (bind_dbmod()) {
158
+	if (bind_dbmod(vm_db_url)) {
159 159
 		LOG(L_ERR, "ERROR: vm_mod_init: unable to bind db\n");
160 160
 		return -1;
161 161
 	}