diff options
| author | David Sommerseth <dazo@users.sourceforge.net> | 2011-01-09 23:39:08 +0100 |
|---|---|---|
| committer | David Sommerseth <davids@redhat.com> | 2011-12-19 11:05:38 +0100 |
| commit | 8d2f8d68e6ae9726fdd2d941e55a7377e3cdf927 (patch) | |
| tree | a778cb9ee6f06b41f256a22450af8fd7916a3ed8 /database/sqlite/administration/configuration.c | |
| parent | f0434a3ad51bf1159a78003a020eeb82a26dfc7f (diff) | |
| download | eurephia-8d2f8d68e6ae9726fdd2d941e55a7377e3cdf927.tar.gz eurephia-8d2f8d68e6ae9726fdd2d941e55a7377e3cdf927.tar.xz eurephia-8d2f8d68e6ae9726fdd2d941e55a7377e3cdf927.zip | |
Modified the whole edb-sqlite driver to use a better error handling
This will change the driver to use the new error routines made available
in the SQLite3 framework. Some of the code is also restructured a little
bit to simplify the code with these changes.
The functionality should be the same as for, but better error messages
are now sent back to the caller on the functions supporting XML.
Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Diffstat (limited to 'database/sqlite/administration/configuration.c')
| -rw-r--r-- | database/sqlite/administration/configuration.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/database/sqlite/administration/configuration.c b/database/sqlite/administration/configuration.c index f336238..735c25b 100644 --- a/database/sqlite/administration/configuration.c +++ b/database/sqlite/administration/configuration.c @@ -68,8 +68,10 @@ static int config_set(eurephiaCTX *ctx, const char *key, const char *val) { } res = sqlite_query(ctx, "SELECT count(*) FROM openvpn_config WHERE datakey = '%q'", key); - if( !res ) { + if( sqlite_query_status(res) != dbSUCCESS ) { eurephia_log(ctx, LOG_ERROR, 0, "Could not query configuration table"); + sqlite_log_error(ctx, res); + sqlite_free_results(res); return 0; } found = atoi_nullsafe(sqlite_get_value(res, 0, 0)); @@ -84,8 +86,10 @@ static int config_set(eurephiaCTX *ctx, const char *key, const char *val) { val, key); } - if( res == NULL ) { + if( sqlite_query_status(res) != dbSUCCESS ) { eurephia_log(ctx, LOG_ERROR, 0, "Could not register configuration entry (%s = '%s'", key, val); + sqlite_log_error(ctx, res); + sqlite_free_results(res); return 0; } sqlite_free_results(res); @@ -125,8 +129,9 @@ static int config_delete(eurephiaCTX *ctx, const char *key) { // Delete the config parameter from the database res = sqlite_query(ctx, "DELETE FROM openvpn_config WHERE datakey = '%q'", key); - if( !res ) { - eurephia_log(ctx, LOG_ERROR, 0, "Could delete config configuration entry (%s)", key); + if( sqlite_query_status(res) != dbSUCCESS ) { + eurephia_log(ctx, LOG_ERROR, 0, "Could not delete config configuration entry (%s)", key); + sqlite_log_error(ctx, res); return 0; } sqlite_free_results(res); |
