summaryrefslogtreecommitdiffstats
path: root/database/sqlite/administration
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2009-09-13 21:50:37 +0200
committerDavid Sommerseth <dazo@users.sourceforge.net>2009-09-13 21:50:37 +0200
commitb8af944163777a6a0936f61627e7efbb26b305ae (patch)
treefbbbfd9daecee159d62851a4c8a1a92e6b4a9f1e /database/sqlite/administration
parent5d0772225abdff04580a14128b8a86d2dc4f4fd4 (diff)
downloadeurephia-b8af944163777a6a0936f61627e7efbb26b305ae.tar.gz
eurephia-b8af944163777a6a0936f61627e7efbb26b305ae.tar.xz
eurephia-b8af944163777a6a0936f61627e7efbb26b305ae.zip
Moved eDBadminAttemptsLog() function into administration/attempts.c
Diffstat (limited to 'database/sqlite/administration')
-rw-r--r--database/sqlite/administration/attempts.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/database/sqlite/administration/attempts.c b/database/sqlite/administration/attempts.c
index e1e5d19..08c6dc1 100644
--- a/database/sqlite/administration/attempts.c
+++ b/database/sqlite/administration/attempts.c
@@ -55,6 +55,8 @@
#include "../sqlite.h"
+#define FMAP_OVPNATTEMPTS /**< fieldmapping.h: Include declaration of tbl_sqlite_attempts */
+#include "../fieldmapping.h"
/**
* Internal function. Retrieves a list of all registered entries in the attempts table
@@ -187,3 +189,53 @@ xmlDoc *attempts_delete(eurephiaCTX *ctx, eDBfieldMap *fmap) {
}
return ret;
}
+
+
+/**
+ * @copydoc eDBadminAttemptsLog()
+ */
+xmlDoc *eDBadminAttemptsLog(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: eDBadminAttemptsLog(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, "attemptslog", 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_attempts, NULL, fieldmap_n);
+
+ if( strcmp(mode, "list") == 0 ) {
+ resxml = attempts_list(ctx, fmap);
+ } else if( strcmp(mode, "reset") == 0 ) {
+ resxml = attempts_reset(ctx, fmap);
+ } else if( strcmp(mode, "delete") == 0 ) {
+ resxml = attempts_delete(ctx, fmap);
+ } else {
+ eurephia_log(ctx, LOG_ERROR, 0, "Attempts - Unknown mode: '%s'", mode);
+ resxml = eurephiaXML_ResultMsg(ctx, exmlERROR, "Unknown mode '%s'", mode);
+ }
+ eDBfreeMapping(fmap);
+ return resxml;
+}