diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-13 21:56:54 +0200 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-13 21:56:54 +0200 |
commit | 05a337c0a201441ef34f98490df2e7dccc87531c (patch) | |
tree | 6c4e9682cd37d5db3541f97e11ab1dc6cf970035 /database/sqlite | |
parent | c452fcbc4502ca960f48981a4091ee490cfbe79f (diff) | |
download | eurephia-05a337c0a201441ef34f98490df2e7dccc87531c.tar.gz eurephia-05a337c0a201441ef34f98490df2e7dccc87531c.tar.xz eurephia-05a337c0a201441ef34f98490df2e7dccc87531c.zip |
Moved eDBadminBlacklist() function into administration/blacklist.c
Diffstat (limited to 'database/sqlite')
-rw-r--r-- | database/sqlite/administration.c | 68 | ||||
-rw-r--r-- | database/sqlite/administration/blacklist.c | 54 |
2 files changed, 54 insertions, 68 deletions
diff --git a/database/sqlite/administration.c b/database/sqlite/administration.c index 45fb1d0..a27c220 100644 --- a/database/sqlite/administration.c +++ b/database/sqlite/administration.c @@ -67,7 +67,6 @@ #define FMAP_CERTS /**< fieldmapping.h: Include declaration of tbl_sqlite_certs */ #define FMAP_ADMINACCESS /**< fieldmapping.h: Include declaration of tbl_sqlite_eurephiaadmacc */ #define FMAP_LASTLOG /**< fieldmapping.h: Include declaration of tbl_sqlite_lastlog */ -#define FMAP_OVPNBLACKLIST /**< fieldmapping.h: Include declaration of tbl_sqlite_blacklist */ #include "fieldmapping.h" #if (DRIVERAPIVERSION > 1) || defined(DOXYGEN) @@ -1309,71 +1308,4 @@ xmlDoc *eDBadminGetLastlog(eurephiaCTX *ctx, xmlDoc *srch_xml, const char *sortk sqlite_free_results(res); return doc; } - - -// The XML document format for blacklist actions is: -// <eurephia format="1"> -// <blacklist mode="{list|add|delete}"> -// <fieldMapping table="blacklist"> -// <{field name}>{field value}</{field field}> -// </fieldMapping> -// </blacklist> -// </eurehpia> -// -// For listing and delete mode it be several field tags to limit the search even more. -// For add mode only username, IP address or certificate digest can be given. -// -xmlDoc *blacklist_list(eurephiaCTX *ctx, eDBfieldMap *fmap); -xmlDoc *blacklist_add(eurephiaCTX *ctx, eDBfieldMap *fmap); -xmlDoc *blacklist_delete(eurephiaCTX *ctx, eDBfieldMap *fmap); - - -/** - * @copydoc eDBadminBlacklist() - */ -xmlDoc *eDBadminBlacklist(eurephiaCTX *ctx, xmlDoc *qryxml) { - eDBfieldMap *fmap = NULL; - char *mode = NULL; - xmlDoc *resxml = NULL; - xmlNode *root_n = NULL, *fieldmap_n = NULL; - - DEBUG(ctx, 20, "Function call: eDBadminBlacklist(ctx, {xmlDoc})"); - assert( (ctx != NULL) && (qryxml != NULL) ); - - if( (ctx->context_type != ECTX_ADMIN_CONSOLE) && (ctx->context_type != ECTX_ADMIN_WEB) ) { - eurephia_log(ctx, LOG_CRITICAL, 0, - "eurephia admin function call attempted with wrong context type"); - return NULL; - } - - root_n = eurephiaXML_getRoot(ctx, qryxml, "blacklist", 1); - if( root_n == NULL ) { - eurephia_log(ctx, LOG_CRITICAL, 0, "Invalid XML input."); - return NULL; - } - mode = xmlGetAttrValue(root_n->properties, "mode"); - if( mode == NULL ) { - eurephia_log(ctx, LOG_ERROR, 0, "Missing mode attribute"); - return NULL; - } - - fieldmap_n = xmlFindNode(root_n, "fieldMapping"); - if( fieldmap_n == NULL ) { - eurephia_log(ctx, LOG_ERROR, 0, "Missing fieldMapping"); - } - fmap = eDBxmlMapping(ctx, tbl_sqlite_blacklist, NULL, fieldmap_n); - - if( strcmp(mode, "list") == 0 ) { - resxml = blacklist_list(ctx, fmap); - } else if( strcmp(mode, "add") == 0 ) { - resxml = blacklist_add(ctx, fmap); - } else if( strcmp(mode, "delete") == 0 ) { - resxml = blacklist_delete(ctx, fmap); - } else { - eurephia_log(ctx, LOG_ERROR, 0, "Blacklist - Unknown mode: '%s'", mode); - resxml = eurephiaXML_ResultMsg(ctx, exmlERROR, "Unknown mode '%s'", mode); - } - eDBfreeMapping(fmap); - return resxml; -} #endif diff --git a/database/sqlite/administration/blacklist.c b/database/sqlite/administration/blacklist.c index 12130c3..d8824ea 100644 --- a/database/sqlite/administration/blacklist.c +++ b/database/sqlite/administration/blacklist.c @@ -55,6 +55,9 @@ #include "../sqlite.h" +#define FMAP_OVPNBLACKLIST /**< fieldmapping.h: Include declaration of tbl_sqlite_blacklist */ +#include "../fieldmapping.h" + /** * Internal function. Retrieves a list of all registered entries in the blacklist table @@ -182,3 +185,54 @@ xmlDoc *blacklist_delete(eurephiaCTX *ctx, eDBfieldMap *fmap) { } return ret; } + + +/** + * @copydoc eDBadminBlacklist() + */ +xmlDoc *eDBadminBlacklist(eurephiaCTX *ctx, xmlDoc *qryxml) { + eDBfieldMap *fmap = NULL; + char *mode = NULL; + xmlDoc *resxml = NULL; + xmlNode *root_n = NULL, *fieldmap_n = NULL; + + DEBUG(ctx, 20, "Function call: eDBadminBlacklist(ctx, {xmlDoc})"); + assert( (ctx != NULL) && (qryxml != NULL) ); + + if( (ctx->context_type != ECTX_ADMIN_CONSOLE) && (ctx->context_type != ECTX_ADMIN_WEB) ) { + eurephia_log(ctx, LOG_CRITICAL, 0, + "eurephia admin function call attempted with wrong context type"); + return NULL; + } + + root_n = eurephiaXML_getRoot(ctx, qryxml, "blacklist", 1); + if( root_n == NULL ) { + eurephia_log(ctx, LOG_CRITICAL, 0, "Invalid XML input."); + return NULL; + } + mode = xmlGetAttrValue(root_n->properties, "mode"); + if( mode == NULL ) { + eurephia_log(ctx, LOG_ERROR, 0, "Missing mode attribute"); + return NULL; + } + + fieldmap_n = xmlFindNode(root_n, "fieldMapping"); + if( fieldmap_n == NULL ) { + eurephia_log(ctx, LOG_ERROR, 0, "Missing fieldMapping"); + } + fmap = eDBxmlMapping(ctx, tbl_sqlite_blacklist, NULL, fieldmap_n); + + if( strcmp(mode, "list") == 0 ) { + resxml = blacklist_list(ctx, fmap); + } else if( strcmp(mode, "add") == 0 ) { + resxml = blacklist_add(ctx, fmap); + } else if( strcmp(mode, "delete") == 0 ) { + resxml = blacklist_delete(ctx, fmap); + } else { + eurephia_log(ctx, LOG_ERROR, 0, "Blacklist - Unknown mode: '%s'", mode); + resxml = eurephiaXML_ResultMsg(ctx, exmlERROR, "Unknown mode '%s'", mode); + } + eDBfreeMapping(fmap); + return resxml; + +} |