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/administration | |
| 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/administration')
| -rw-r--r-- | database/sqlite/administration/blacklist.c | 54 |
1 files changed, 54 insertions, 0 deletions
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; + +} |
