libidav/resource.c

changeset 361
b6f2462ee055
parent 355
5da2cf15eb44
child 441
99c26b1b7327
--- a/libidav/resource.c	Mon Dec 18 16:24:32 2017 +0100
+++ b/libidav/resource.c	Mon Jan 01 19:53:36 2018 +0100
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright 2016 Olaf Wintermann. All rights reserved.
+ * Copyright 2018 Olaf Wintermann. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -475,14 +475,14 @@
     return property;
 }
 
-void dav_set_property(DavResource *res, char *name, char *value) {
+void dav_set_string_property(DavResource *res, char *name, char *value) {
     char *pns;
     char *pname;
     dav_get_property_namespace_str(res->session->context, name, &pns, &pname);
-    dav_set_property_ns(res, pns, pname, value);
+    dav_set_string_property_ns(res, pns, pname, value);
 }
 
-void dav_set_property_ns(DavResource *res, char *ns, char *name, char *value) {
+void dav_set_string_property_ns(DavResource *res, char *ns, char *name, char *value) {
     UcxAllocator *a = res->session->mp->allocator;
     DavResourceData *data = res->data;
     
@@ -502,6 +502,33 @@
     data->set = ucx_list_append_a(a, data->set, property);
 }
 
+void dav_set_property(DavResource *res, char *name, DavXmlNode *value) {
+    char *pns;
+    char *pname;
+    dav_get_property_namespace_str(res->session->context, name, &pns, &pname);
+    dav_set_property_ns(res, pns, pname, value);
+}
+
+void dav_set_property_ns(DavResource *res, char *ns, char *name, DavXmlNode *value) {
+    UcxAllocator *a = res->session->mp->allocator;
+    DavResourceData *data = res->data;
+    
+    DavProperty *property = dav_session_malloc(
+            res->session,
+            sizeof(DavProperty));
+    property->name = dav_session_strdup(res->session, name);
+    property->value = value; // TODO: copy node?
+    
+    DavNamespace *namespace = dav_session_malloc(
+            res->session,
+            sizeof(DavNamespace));
+    namespace->prefix = NULL;
+    namespace->name = dav_session_strdup(res->session, ns);
+    property->ns = namespace;
+    
+    data->set = ucx_list_append_a(a, data->set, property);
+}
+
 void dav_remove_property(DavResource *res, char *name) {
     char *pns;
     char *pname;

mercurial