From 622fb9169d5c554d5f5c8ca42e978f133be5bb45 Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Fri, 28 Nov 2008 11:47:38 +0100 Subject: Added minimum API version check when loading database driver. --- database/eurephiadb.c | 11 ++++++++++- database/eurephiadb.h | 2 +- plugin/eurephia.c | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/database/eurephiadb.c b/database/eurephiadb.c index 9a6ecbd..bbc655f 100644 --- a/database/eurephiadb.c +++ b/database/eurephiadb.c @@ -49,7 +49,7 @@ int eDBlink_close(eurephiaCTX *ctx) } -int eDBlink_init(eurephiaCTX *ctx, const char *dbl) +int eDBlink_init(eurephiaCTX *ctx, const char *dbl, const int minver) { #ifdef MEMWATCH mwStatistics(3); @@ -76,6 +76,15 @@ int eDBlink_init(eurephiaCTX *ctx, const char *dbl) eurephia_log(ctx, LOG_INFO, 1, "Driver loaded: %s (API version %i)", eDB_DriverVersion(), eDB_DriverAPIVersion()); + // Check that we are using at least a new enough driver + if( eDB_DriverAPIVersion() < minver ) { + eurephia_log(ctx, LOG_FATAL, 0, + "The requested eurephiaDB driver is too old. This program needs " + "API version %i, but this driver only supports API version %i.\n", + minver, eDB_DriverAPIVersion()); + return 0; + } + // Configure functions contained in the driver, defined by API version switch( eDB_DriverAPIVersion() ) { default: diff --git a/database/eurephiadb.h b/database/eurephiadb.h index 1e4a547..b2311d7 100644 --- a/database/eurephiadb.h +++ b/database/eurephiadb.h @@ -25,7 +25,7 @@ #ifndef EUREPHIADB_H_ # define EUREPHIADB_H_ -int eDBlink_init(eurephiaCTX *, const char *); +int eDBlink_init(eurephiaCTX *, const char *, const int); int eDBlink_close(eurephiaCTX *); #endif diff --git a/plugin/eurephia.c b/plugin/eurephia.c index 8dc01e2..4853591 100644 --- a/plugin/eurephia.c +++ b/plugin/eurephia.c @@ -170,7 +170,7 @@ eurephiaCTX *eurephiaInit(const char **argv) ctx->loglevel = loglvl; // Load the database driver - if( (error == 0) && eDBlink_init(ctx, dbi) ) { + if( (error == 0) && eDBlink_init(ctx, dbi, 1) ) { // Connect to the database if( !eDBconnect(ctx, dbargc, dbargv) ) { eurephia_log(ctx, LOG_PANIC, 0, "Could not connect to the database"); -- cgit