summaryrefslogtreecommitdiffstats
path: root/database/sqlite/administration/usercerts.c
diff options
context:
space:
mode:
Diffstat (limited to 'database/sqlite/administration/usercerts.c')
-rw-r--r--database/sqlite/administration/usercerts.c56
1 files changed, 42 insertions, 14 deletions
diff --git a/database/sqlite/administration/usercerts.c b/database/sqlite/administration/usercerts.c
index 6dd091c..408891f 100644
--- a/database/sqlite/administration/usercerts.c
+++ b/database/sqlite/administration/usercerts.c
@@ -1,4 +1,4 @@
-/* usercerts.c -- Admin functions - user-certitificate table
+/* usercerts.c -- Admin functions - user-certificate table
*
* GPLv2 only - Copyright (C) 2008, 2009
* David Sommerseth <dazo@users.sourceforge.net>
@@ -19,6 +19,15 @@
*
*/
+/**
+ * @file sqlite/administration/usercerts.c
+ * @author David Sommerseth <dazo@users.sourceforge.net>
+ * @date 2009-08-29
+ *
+ * @brief Functions for working with the openvpn_usercerts table
+ *
+ */
+
#include <string.h>
#include <unistd.h>
#include <assert.h>
@@ -50,6 +59,16 @@
void xmlReplaceChars(xmlChar *str, char s, char r);
+
+/**
+ * Internal function. Queries the database for a list of user-certificate links
+ *
+ * @param ctx eurephiaCTX
+ * @param where_m eDBfieldMap containing the search criteria
+ * @param sortkeys String containing the sort order of the data
+ *
+ * @return Returns a valid eurephia XML document on success, otherwise NULL
+ */
xmlDoc *usercerts_search(eurephiaCTX *ctx, eDBfieldMap *where_m, const char *sortkeys) {
xmlDoc *list_xml = NULL;
xmlNode *link_root_n = NULL, *link_n = NULL, *tmp_n = NULL;
@@ -126,6 +145,15 @@ xmlDoc *usercerts_search(eurephiaCTX *ctx, eDBfieldMap *where_m, const char *sor
}
+/**
+ * Internal function. Adds or deletes a user-certificate link
+ *
+ * @param ctx eurephiaCTX
+ * @param mode String containing the operation mode. Must be "register" or "remove"
+ * @param usrcrt_m eDBfieldMap containing information about the link to add or remove
+ *
+ * @return Returns an eurephia ResultMsg XML document, with success message or an error message
+ */
xmlDoc *usercerts_add_del(eurephiaCTX *ctx, const char *mode, eDBfieldMap *usrcrt_m) {
xmlDoc *res = NULL;
dbresult *dbres = NULL;
@@ -168,6 +196,16 @@ xmlDoc *usercerts_add_del(eurephiaCTX *ctx, const char *mode, eDBfieldMap *usrcr
}
+/**
+ * Internal function. Updates a user-certs link in the database
+ *
+ * @param ctx eurephiaCTX
+ * @param uicid String containing the numeric record ID (uicid field) of the record to be updated
+ * @param usrcrt_m eDBfieldMap containing the new information for the record. Only the fields being
+ * changed needs to be set.
+ *
+ * @return Returns an eurephia ResultMsg XML document, with success message or an error message
+ */
xmlDoc *usercerts_update(eurephiaCTX *ctx, const char *uicid, eDBfieldMap *usrcrt_m) {
xmlNode *where_n = NULL;
eDBfieldMap *where_m = NULL;
@@ -215,19 +253,9 @@ xmlDoc *usercerts_update(eurephiaCTX *ctx, const char *uicid, eDBfieldMap *usrcr
}
-// The XML document format:
-// <eurephia format="1">
-// <usercerts mode="{search|register|remove|update}" [uicid="{uicid}"]>
-// <fieldMapping table="usercerts">
-// <{field name}>{search value}</{field name}>
-// </fieldMapping>
-// [<sortfields>{field name}[, {field name},...]</sortfields>] <!-- Only for mode='search' -->
-// </usercerts
-// </eurehpia>
-//
-// It can be several field name tags to limit the search even more.
-// If mode is 'update' the 'uicid' attribute must be present in the usercerts tag.
-//
+/**
+ * @copydoc eDBadminUserCertsLink()
+ */
xmlDoc *eDBadminUserCertsLink(eurephiaCTX *ctx, xmlDoc *usrcrt_xml) {
xmlNode *usrcrt_n = NULL, *tmp_n = NULL;
xmlDoc *resxml = NULL;