diff options
Diffstat (limited to 'database/sqlite/administration/blacklist.c')
-rw-r--r-- | database/sqlite/administration/blacklist.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/database/sqlite/administration/blacklist.c b/database/sqlite/administration/blacklist.c index 677a692..66a5f6f 100644 --- a/database/sqlite/administration/blacklist.c +++ b/database/sqlite/administration/blacklist.c @@ -71,8 +71,10 @@ xmlDoc *blacklist_list(eurephiaCTX *ctx, eDBfieldMap *fmap) { " registered, last_accessed, blid" " FROM openvpn_blacklist", NULL, fmap, "blid"); - if( res == NULL ) { + if( sqlite_query_status(res) != dbSUCCESS ) { eurephia_log(ctx, LOG_ERROR, 0, "Error querying the blacklist register"); + sqlite_log_error(ctx, res); + sqlite_free_results(res); return NULL; } @@ -137,13 +139,17 @@ xmlDoc *blacklist_add(eurephiaCTX *ctx, eDBfieldMap *fmap) { } res = sqlite_query_mapped(ctx, SQL_INSERT, "INSERT INTO openvpn_blacklist", fmap, NULL, NULL); - if( res == NULL ) { - eurephia_log(ctx, LOG_FATAL, 0, "Could not blacklist the requested data"); - ret = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Blacklisting failed"); - } else { + if( sqlite_query_status(res) == dbSUCCESS ) { ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL, "Record registered in the blacklist"); - sqlite_free_results(res); + } else { + xmlNode *err_n = NULL; + + eurephia_log(ctx, LOG_FATAL, 0, "Could not blacklist the requested data"); + err_n = sqlite_log_error_xml(ctx, res); + ret = eurephiaXML_ResultMsg(ctx, exmlERROR, err_n, "Blacklisting failed"); + xmlFreeNode(err_n); } + sqlite_free_results(res); return ret; } @@ -168,13 +174,17 @@ xmlDoc *blacklist_delete(eurephiaCTX *ctx, eDBfieldMap *fmap) { } res = sqlite_query_mapped(ctx, SQL_DELETE, "DELETE FROM openvpn_blacklist", NULL, fmap, NULL); - if( res == NULL ) { - eurephia_log(ctx, LOG_FATAL, 0, "Could not remove blacklisting"); - ret = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Failed to remove the blacklisting"); - } else { + if( sqlite_query_status(res) == dbSUCCESS ) { ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL, "Blacklisting removed"); - sqlite_free_results(res); + } else { + xmlNode *err_n = NULL; + + eurephia_log(ctx, LOG_FATAL, 0, "Could not remove blacklisting"); + err_n = sqlite_log_error_xml(ctx, res); + ret = eurephiaXML_ResultMsg(ctx, exmlERROR, err_n, "Failed to remove the blacklisting"); + xmlFreeNode(err_n); } + sqlite_free_results(res); return ret; } |