summaryrefslogtreecommitdiffstats
path: root/database/sqlite/administration/firewalladmin.c
diff options
context:
space:
mode:
Diffstat (limited to 'database/sqlite/administration/firewalladmin.c')
-rw-r--r--database/sqlite/administration/firewalladmin.c57
1 files changed, 40 insertions, 17 deletions
diff --git a/database/sqlite/administration/firewalladmin.c b/database/sqlite/administration/firewalladmin.c
index 0e8e91a..378f265 100644
--- a/database/sqlite/administration/firewalladmin.c
+++ b/database/sqlite/administration/firewalladmin.c
@@ -19,6 +19,15 @@
*
*/
+/**
+ * @file sqlite/administration/firewalladmin.c
+ * @author David Sommerseth <dazo@users.sourceforge.net>
+ * @date 2009-03-28
+ *
+ * @brief Functions for managing firewall profiles
+ *
+ */
+
#include <string.h>
#include <unistd.h>
#include <assert.h>
@@ -52,6 +61,14 @@
void xmlReplaceChars(xmlChar *str, char s, char r);
+/**
+ * Internal function. Queries the database for a list of user-certificate links
+ *
+ * @param ctx eurephiaCTX
+ * @param fmap eDBfieldMap containing the search criteria
+ *
+ * @return Returns a valid eurephia XML document on success, otherwise NULL
+ */
xmlDoc *fwadmin_search(eurephiaCTX *ctx, eDBfieldMap *fmap) {
dbresult *res = NULL;
xmlDoc *doc = NULL;
@@ -82,7 +99,7 @@ xmlDoc *fwadmin_search(eurephiaCTX *ctx, eDBfieldMap *fmap) {
NULL, fmap, "accessprofile, uid, c.certid");
if( res == NULL ) {
eurephia_log(ctx, LOG_ERROR, 0, "Error querying the database for firewall profiles");
- return 0;
+ return NULL;
}
eurephiaXML_CreateDoc(ctx, 1, "firewall_profiles", &doc, &root_n);
@@ -135,6 +152,14 @@ xmlDoc *fwadmin_search(eurephiaCTX *ctx, eDBfieldMap *fmap) {
}
+/**
+ * Internal function. Registers a new firewall profile
+ *
+ * @param ctx eurephiaCTX
+ * @param fmap eDBfieldMap containing information about the new profile
+ *
+ * @return Returns an eurephia ResultMsg XML document, with success message or an error message
+ */
xmlDoc *fwadmin_add(eurephiaCTX *ctx, eDBfieldMap *fmap) {
dbresult *res = NULL;
xmlDoc *ret = NULL;
@@ -158,6 +183,14 @@ xmlDoc *fwadmin_add(eurephiaCTX *ctx, eDBfieldMap *fmap) {
}
+/**
+ * Internal function. Deletes firewall profile(s) from the database
+ *
+ * @param ctx eurephiaCTX
+ * @param fmap eDBfieldMap containing information about the profile(s) to be deleted
+ *
+ * @return Returns an eurephia ResultMsg XML document, with success message or an error message
+ */
xmlDoc *fwadmin_delete(eurephiaCTX *ctx, eDBfieldMap *fmap) {
dbresult *res = NULL;
xmlDoc *ret = NULL;
@@ -212,26 +245,17 @@ xmlDoc *fwadmin_delete(eurephiaCTX *ctx, eDBfieldMap *fmap) {
}
-// The search XML document format is:
-// <eurephia format="1">
-// <firewall_profiles mode="{search|add|delete}">
-// <fieldMapping table="fwprofiles">
-// <{field name}>{search value}</{field name}>
-// </fieldMapping>
-// </firewall_profiles>
-// </eurehpia>
-//
-// It can be several field name tags to limit the search even more.
-// For the add mode, the fw_profile field name tag must be present.
-//
-xmlDoc *eDBadminFirewallProfiles(eurephiaCTX *ctx, xmlDoc *srch) {
+/**
+ * @copydoc eDBadminFirewallProfiles()
+ */
+xmlDoc *eDBadminFirewallProfiles(eurephiaCTX *ctx, xmlDoc *xmlqry) {
eDBfieldMap *fmap = NULL;
char *mode = NULL;
xmlDoc *resxml = NULL;
xmlNode *root_n = NULL, *fieldmap_n = NULL;
DEBUG(ctx, 20, "Function call: eDBadminFirewallProfiles(ctx, {xmlDoc})");
- assert( (ctx != NULL) && (srch != NULL) );
+ assert( (ctx != NULL) && (xmlqry != NULL) );
if( (ctx->context_type != ECTX_ADMIN_CONSOLE) && (ctx->context_type != ECTX_ADMIN_WEB) ) {
eurephia_log(ctx, LOG_CRITICAL, 0,
@@ -239,7 +263,7 @@ xmlDoc *eDBadminFirewallProfiles(eurephiaCTX *ctx, xmlDoc *srch) {
return NULL;
}
- root_n = eurephiaXML_getRoot(ctx, srch, "firewall_profiles", 1);
+ root_n = eurephiaXML_getRoot(ctx, xmlqry, "firewall_profiles", 1);
if( root_n == NULL ) {
eurephia_log(ctx, LOG_CRITICAL, 0, "Invalid XML input.");
return NULL;
@@ -269,4 +293,3 @@ xmlDoc *eDBadminFirewallProfiles(eurephiaCTX *ctx, xmlDoc *srch) {
eDBfreeMapping(fmap);
return resxml;
}
-