Browse code

- Database capability check

Jan Janak authored on 14/09/2004 12:43:37
Showing 8 changed files
... ...
@@ -228,6 +228,12 @@ int group_db_bind(char* db_url)
228 228
 				" module\n");
229 229
 		return -1;
230 230
 	}
231
+
232
+	if (!DB_CAPABILITY(group_dbf, DB_CAP_QUERY)) {
233
+		LOG(L_ERR, "ERROR: group_db_bind: Database module does not implement 'query' function\n");
234
+		return -1;
235
+	}
236
+
231 237
 	return 0;
232 238
 }
233 239
 
... ...
@@ -207,6 +207,12 @@ static int mod_init(void)
207 207
 		LOG(L_ERR, "XJAB:mod_init: error - database module not found\n");
208 208
 		return -1;
209 209
 	}
210
+
211
+	if (!DB_CAPABILITY(jabber_dbf, DB_CAP_QUERY)) {
212
+		LOG(L_ERR, "XJAB:mod_init: Database module does not implement 'query' function\n");
213
+		return -1;
214
+	}
215
+
210 216
 	db_con = (db_con_t**)shm_malloc(nrw*sizeof(db_con_t*));
211 217
 	if (db_con == NULL)
212 218
 	{
... ...
@@ -214,12 +214,12 @@ static int mod_init(void)
214 214
 		return -1;
215 215
 	}
216 216
 
217
-	/* check table version */
218
-	if (msilo_dbf.init==0)
219
-	{
220
-		LOG(L_CRIT, "BUG: msilo: mod_init: database not bound\n");
217
+	if (!DB_CAPABILITY(msilo_dbf, DB_CAP_ALL)) {
218
+		LOG(L_ERR, "MSILO: ERROR: Database module does not implement "
219
+		    "all functions needed by the module\n");
221 220
 		return -1;
222 221
 	}
222
+
223 223
 	db_con = msilo_dbf.init(ms_db_url);
224 224
 	if (!db_con)
225 225
 	{
... ...
@@ -235,7 +235,7 @@ static int mod_init(void)
235 235
 				" need v%d\n", ver, ms_db_table, S_TABLE_VERSION);
236 236
 		return -1;
237 237
 	}
238
-	if(db_con && msilo_dbf.close)
238
+	if(db_con)
239 239
 		msilo_dbf.close(db_con);
240 240
 	db_con = NULL;
241 241
 
... ...
@@ -206,6 +206,11 @@ static int pa_mod_init(void)
206 206
 			LOG(L_ERR, "pa_mod_init(): Can't bind database module via url %s\n", db_url.s);
207 207
 			return -1;
208 208
 		}
209
+
210
+		if (!DB_CAPABILITY(pa_dbf, DB_CAP_ALL)) {
211
+			LOG(L_ERR, "pa_mod_init(): Database module does not implement all functions needed by the module\n");
212
+			return -1;
213
+		}
209 214
 	}
210 215
 
211 216
 	default_priority = ((double)default_priority_percentage) / 100.0;
... ...
@@ -257,6 +257,12 @@ static int mod_init(void)
257 257
 		goto error1;
258 258
 	}
259 259
 
260
+	if (!DB_CAPABILITY(pdt_dbf, DB_CAP_ALL)) {
261
+		LOG(L_ERR, "PDT: mod_init: Database module does not "
262
+		    "implement all functions needed by the module\n");
263
+		goto error1;
264
+	}
265
+
260 266
 	/* open a connection with the database */
261 267
 	db_con = pdt_dbf.init(db_url);
262 268
 	if(!db_con)
... ...
@@ -73,6 +73,12 @@ int init_trusted(void)
73 73
 					"load a database support module\n");
74 74
 			return -1;
75 75
 		}
76
+
77
+		if (!DB_CAPABILITY(perm_dbf, DB_CAP_QUERY)) {
78
+			LOG(L_ERR, "ERROR: permissions: init_trusted: "
79
+			    "Database module does not implement 'query' function\n");
80
+			return -1;
81
+		}
76 82
 	}
77 83
 
78 84
 	hash_table_1 = hash_table_2 = 0;
... ...
@@ -280,6 +280,13 @@ int uridb_db_bind(char* db_url)
280 280
 				" module\n");
281 281
 		return -1;
282 282
 	}
283
+
284
+	if (!DB_CAPABILITY(uridb_dbf, DB_CAP_QUERY)) {
285
+		LOG(L_ERR, "ERROR: uridb_db_bind: Database module does not "
286
+		    "implement 'query' function\n");
287
+		return -1;
288
+	}
289
+
283 290
 	return 0;
284 291
 }
285 292
 
... ...
@@ -243,6 +243,11 @@ static int mod_init(void)
243 243
 		}
244 244
 	}
245 245
 
246
+	if (!DB_CAPABILITY(ul_dbf, DB_CAP_ALL)) {
247
+		LOG(L_ERR, "usrloc:mod_init: Database module does not implement all functions needed by the module\n");
248
+		return -1;
249
+	}
250
+
246 251
 	return 0;
247 252
 }
248 253