summaryrefslogtreecommitdiffstats
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
parent5d0772225abdff04580a14128b8a86d2dc4f4fd4 (diff)
downloadeurephia-b8af944163777a6a0936f61627e7efbb26b305ae.tar.gz
eurephia-b8af944163777a6a0936f61627e7efbb26b305ae.tar.xz
eurephia-b8af944163777a6a0936f61627e7efbb26b305ae.zip
Moved eDBadminAttemptsLog() function into administration/attempts.c
-rw-r--r--database/sqlite/administration.c66
-rw-r--r--database/sqlite/administration/attempts.c52
2 files changed, 52 insertions, 66 deletions
diff --git a/database/sqlite/administration.c b/database/sqlite/administration.c
index e460e6e..45fb1d0 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_OVPNATTEMPTS /**< fieldmapping.h: Include declaration of tbl_sqlite_attempts */
#define FMAP_OVPNBLACKLIST /**< fieldmapping.h: Include declaration of tbl_sqlite_blacklist */
#include "fieldmapping.h"
@@ -1311,71 +1310,6 @@ xmlDoc *eDBadminGetLastlog(eurephiaCTX *ctx, xmlDoc *srch_xml, const char *sortk
return doc;
}
-// The XML document format for attempts log actions is:
-// <eurephia format="1">
-// <attemptslog mode="{search|reset|delete}">
-// <fieldMapping table="attempts">
-// <{field name}>{field value}</{field field}>
-// </fieldMapping>
-// </attemptslog>
-// </eurehpia>
-//
-// It can be several field tags to limit the search even more.
-//
-xmlDoc *attempts_list(eurephiaCTX *ctx, eDBfieldMap *fmap);
-xmlDoc *attempts_reset(eurephiaCTX *ctx, eDBfieldMap *fmap);
-xmlDoc *attempts_delete(eurephiaCTX *ctx, eDBfieldMap *fmap);
-
-
-/**
- * @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;
-
-}
// The XML document format for blacklist actions is:
// <eurephia format="1">
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;
+}