libidav/config.c

changeset 837
b5984d5cc40c
parent 836
7842c7665cd0
child 838
d262210f8454
--- a/libidav/config.c	Sun Oct 27 15:22:08 2024 +0100
+++ b/libidav/config.c	Sun Oct 27 15:39:23 2024 +0100
@@ -142,6 +142,28 @@
     set_xml_content(cbool->node, content);
 }
 
+void dav_cfg_int_set_value(DavConfig *config, CfgInt *cint, xmlNode *parent, int64_t new_value, const char *nodename) {
+    char content[32];
+    snprintf(content, 32, "%" PRId64, new_value);
+    cint->value = new_value;
+    if(!cint->node) {
+        cint->node = xmlNewNode(NULL, (const xmlChar*) nodename);
+        xmlAddChild(parent, cint->node);
+    }
+    set_xml_content(cint->node, content);
+}
+
+void dav_cfg_uint_set_value(DavConfig *config, CfgUInt *cint, xmlNode *parent, uint64_t new_value, const char *nodename) {
+    char content[32];
+    snprintf(content, 32, "%" PRIu64, new_value);
+    cint->value = new_value;
+    if(!cint->node) {
+        cint->node = xmlNewNode(NULL, (const xmlChar*) nodename);
+        xmlAddChild(parent, cint->node);
+    }
+    set_xml_content(cint->node, content);
+}
+
 void dav_cfg_string_remove(CfgString *str) {
     if(str->node) {
         xmlUnlinkNode(str->node);
@@ -158,6 +180,22 @@
     }
 }
 
+void dav_cfg_int_remove(CfgInt *cint) {
+    if(cint->node) {
+        xmlUnlinkNode(cint->node);
+        xmlFreeNode(cint->node);
+        cint->node = NULL;
+    }
+}
+
+void dav_cfg_uint_remove(CfgUInt *cint) {
+    if(cint->node) {
+        xmlUnlinkNode(cint->node);
+        xmlFreeNode(cint->node);
+        cint->node = NULL;
+    }
+}
+
 
 DavConfig* dav_config_new(xmlDoc *doc) {
     CxMempool *cfg_mp = cxMempoolCreate(128, NULL);

mercurial