
On Thu, Apr 08, 2021 at 13:19:51 +0200, Tim Wiederhake wrote:
Convenience function to return the value of a yes / no XML attribute.
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> --- src/libvirt_private.syms | 1 + src/util/virxml.c | 49 ++++++++++++++++++++++++++++++++++++++++ src/util/virxml.h | 10 ++++++++ 3 files changed, 60 insertions(+)
[...]
diff --git a/src/util/virxml.c b/src/util/virxml.c index 4a6fe09468..0b822d7c4d 100644 diff --git a/src/util/virxml.h b/src/util/virxml.h index d32f77b867..53de416a7f 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -28,10 +28,16 @@ #include <libxml/relaxng.h>
#include "virbuffer.h" +#include "virenum.h"
xmlXPathContextPtr virXMLXPathContextNew(xmlDocPtr xml) G_GNUC_WARN_UNUSED_RESULT;
+typedef enum { + VIR_XML_PROP_OPTIONAL = 0, /* Attribute may be absent */ + VIR_XML_PROP_REQUIRED = 1 << 0, /* Attribute may not be absent */ +} virXMLPropFlags; + int virXPathBoolean(const char *xpath, xmlXPathContextPtr ctxt); char * virXPathString(const char *xpath, @@ -77,6 +83,10 @@ char * virXMLPropStringLimit(xmlNodePtr node, const char *name, size_t maxlen); char * virXMLNodeContentString(xmlNodePtr node); +int virXMLPropTristateBool(xmlNodePtr node, + const char *name, + virXMLPropFlags flags, + virTristateBool *result);
I've posted https://listman.redhat.com/archives/libvir-list/2021-April/msg00659.html to fix the terrible header formatting so that we don't just keep adding more and more use.