Re: [libvirt-glib 3/7] Add gvir_config_xml_node_to_string helper

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

 



On Mon, Feb 06, 2012 at 12:56:13PM +0100, Christophe Fergeau wrote:
> ---
>  libvirt-gconfig/libvirt-gconfig-helpers-private.h |    1 +
>  libvirt-gconfig/libvirt-gconfig-helpers.c         |   20 ++++++++++++++++++++
>  2 files changed, 21 insertions(+), 0 deletions(-)
> 
> diff --git a/libvirt-gconfig/libvirt-gconfig-helpers-private.h b/libvirt-gconfig/libvirt-gconfig-helpers-private.h
> index 96ec02e..514aeb0 100644
> --- a/libvirt-gconfig/libvirt-gconfig-helpers-private.h
> +++ b/libvirt-gconfig/libvirt-gconfig-helpers-private.h
> @@ -56,6 +56,7 @@ char *gvir_config_xml_get_child_element_content_glib (xmlNode    *node,
>                                                        const char *child_name);
>  xmlChar *gvir_config_xml_get_attribute_content(xmlNodePtr node,
>                                                 const char *attr_name);
> +char *gvir_config_xml_node_to_string(xmlNodePtr node);
>  char *gvir_config_xml_get_attribute_content_glib(xmlNodePtr node,
>                                                   const char *attr_name);
>  const char *gvir_config_genum_get_nick (GType enum_type, gint value);
> diff --git a/libvirt-gconfig/libvirt-gconfig-helpers.c b/libvirt-gconfig/libvirt-gconfig-helpers.c
> index a9aaa0b..c34a312 100644
> --- a/libvirt-gconfig/libvirt-gconfig-helpers.c
> +++ b/libvirt-gconfig/libvirt-gconfig-helpers.c
> @@ -308,3 +308,23 @@ gvir_config_genum_get_value (GType enum_type, const char *nick,
>  
>      g_return_val_if_reached(default_value);
>  }
> +
> +G_GNUC_INTERNAL char *
> +gvir_config_xml_node_to_string(xmlNodePtr node)
> +{
> +    xmlBufferPtr xmlbuf;
> +    char *xml;
> +
> +    if (node == NULL)
> +        return NULL;
> +
> +    xmlbuf = xmlBufferCreate();
> +    if (xmlNodeDump(xmlbuf, node->doc, node, 0, 0) < 0)
> +        return NULL;
> +    else
> +        xml = g_strndup((gchar *)xmlBufferContent(xmlbuf), xmlBufferLength(xmlbuf));
> +
> +    xmlBufferFree(xmlbuf);
> +
> +    return xml;
> +}

In gvir_config_object_to_xml() we pass '1' for the 'format' argument
to get pretty-printed XML. Perhaps we should do the same here too ?

ACK either way

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]