[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [libvirt-glib 5/7] Add gvir_config_object_set_namespace helper



---
 libvirt-gconfig/libvirt-gconfig-object-private.h |    3 +++
 libvirt-gconfig/libvirt-gconfig-object.c         |   20 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h b/libvirt-gconfig/libvirt-gconfig-object-private.h
index afd28f0..41cbfe8 100644
--- a/libvirt-gconfig/libvirt-gconfig-object-private.h
+++ b/libvirt-gconfig/libvirt-gconfig-object-private.h
@@ -93,6 +93,9 @@ void gvir_config_object_foreach_child(GVirConfigObject *object,
                                       const char *parent_name,
                                       GVirConfigXmlNodeIterator iter_func,
                                       gpointer opaque);
+gboolean gvir_config_object_set_namespace(GVirConfigObject *object,
+                                          const char *ns,
+                                          const char *ns_uri);
 
 G_END_DECLS
 
diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
index 9d99faf..a42b36c 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -871,3 +871,23 @@ gvir_config_object_remove_attribute(GVirConfigObject *object,
         status = xmlUnsetProp(object->priv->node, (xmlChar *)attr_name);
     } while (status == 0);
 }
+
+G_GNUC_INTERNAL gboolean
+gvir_config_object_set_namespace(GVirConfigObject *object, const char *ns,
+                                 const char *ns_uri)
+{
+    xmlNsPtr namespace;
+
+    g_return_val_if_fail(GVIR_CONFIG_IS_OBJECT(object), FALSE);
+    g_return_val_if_fail(ns != NULL, FALSE);
+    g_return_val_if_fail(ns_uri != NULL, FALSE);
+
+    namespace = xmlNewNs(object->priv->node,
+                         (xmlChar *)ns_uri, (xmlChar *)ns);
+    if (namespace == NULL)
+        return FALSE;
+
+    xmlSetNs(object->priv->node, namespace);
+
+    return TRUE;
+}
-- 
1.7.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]