return (0);
}
-/**
- * virXPathLong:
- * @xpath: the XPath string to evaluate
- * @ctxt: an XPath context
- * @value: the returned long value
- *
- * Convenience function to evaluate an XPath number
- *
- * Returns 0 in case of success in which case @value is set,
- * or -1 if the XPath evaluation failed or -2 if the
- * value doesn't have a long format.
- */
-int
-virXPathLong(virConnectPtr conn,
- const char *xpath,
- xmlXPathContextPtr ctxt,
- long *value)
+static int
+virXPathLongBase(virConnectPtr conn,
+ const char *xpath,
+ xmlXPathContextPtr ctxt,
+ int base,
+ long *value)
{
xmlXPathObjectPtr obj;
xmlNodePtr relnode;
char *conv = NULL;
long val;
- val = strtol((const char *) obj->stringval, &conv, 10);
+ val = strtol((const char *) obj->stringval, &conv, base);
if (conv == (const char *) obj->stringval) {
ret = -2;
} else {
}
/**
- * virXPathULong:
+ * virXPathLong:
* @xpath: the XPath string to evaluate
* @ctxt: an XPath context
* @value: the returned long value
* value doesn't have a long format.
*/
int
-virXPathULong(virConnectPtr conn,
- const char *xpath,
- xmlXPathContextPtr ctxt,
- unsigned long *value)
+virXPathLong(virConnectPtr conn,
+ const char *xpath,
+ xmlXPathContextPtr ctxt,
+ long *value)
+{
+ return virXPathLongBase(conn, xpath, ctxt, 10, value);
+}
+
+/**
+ * virXPathLongHex:
+ * @xpath: the XPath string to evaluate
+ * @ctxt: an XPath context
+ * @value: the returned long value
+ *
+ * Convenience function to evaluate an XPath number
+ * according to a base of 16
+ *
+ * Returns 0 in case of success in which case @value is set,
+ * or -1 if the XPath evaluation failed or -2 if the
+ * value doesn't have a long format.
+ */
+int
+virXPathLongHex(virConnectPtr conn,
+ const char *xpath,
+ xmlXPathContextPtr ctxt,
+ long *value)
+{
+ return virXPathLongBase(conn, xpath, ctxt, 16, value);
+}
+
+static int
+virXPathULongBase(virConnectPtr conn,
+ const char *xpath,
+ xmlXPathContextPtr ctxt,
+ int base,
+ unsigned long *value)
{
xmlXPathObjectPtr obj;
xmlNodePtr relnode;
char *conv = NULL;
long val;
- val = strtoul((const char *) obj->stringval, &conv, 10);
+ val = strtoul((const char *) obj->stringval, &conv, base);
if (conv == (const char *) obj->stringval) {
ret = -2;
} else {
return (ret);
}
+/**
+ * virXPathULong:
+ * @xpath: the XPath string to evaluate
+ * @ctxt: an XPath context
+ * @value: the returned long value
+ *
+ * Convenience function to evaluate an XPath number
+ *
+ * Returns 0 in case of success in which case @value is set,
+ * or -1 if the XPath evaluation failed or -2 if the
+ * value doesn't have a long format.
+ */
+int
+virXPathULong(virConnectPtr conn,
+ const char *xpath,
+ xmlXPathContextPtr ctxt,
+ unsigned long *value)
+{
+ return virXPathULongBase(conn, xpath, ctxt, 10, value);
+}
+
+/**
+ * virXPathUHex:
+ * @xpath: the XPath string to evaluate
+ * @ctxt: an XPath context
+ * @value: the returned long value
+ *
+ * Convenience function to evaluate an XPath number
+ * according to base of 16
+ *
+ * Returns 0 in case of success in which case @value is set,
+ * or -1 if the XPath evaluation failed or -2 if the
+ * value doesn't have a long format.
+ */
+int
+virXPathULongHex(virConnectPtr conn,
+ const char *xpath,
+ xmlXPathContextPtr ctxt,
+ unsigned long *value)
+{
+ return virXPathULongBase(conn, xpath, ctxt, 16, value);
+}
+
char *
virXMLPropString(xmlNodePtr node,
const char *name)