const char* name,
int (*strToInt)(const char*),
virXMLPropFlags flags,
- unsigned int *result)
+ unsigned int *result,
+ unsigned int defaultResult)
{
g_autofree char *tmp = NULL;
int ret;
+ *result = defaultResult;
+
if (!(tmp = virXMLPropString(node, name))) {
if (!(flags & VIR_XML_PROP_REQUIRED))
return 0;
{
flags |= VIR_XML_PROP_NONZERO;
- *result = VIR_TRISTATE_BOOL_ABSENT;
-
return virXMLPropEnumInternal(node, name, virTristateBoolTypeFromString,
- flags, result);
+ flags, result, VIR_TRISTATE_BOOL_ABSENT);
}
{
flags |= VIR_XML_PROP_NONZERO;
- *result = VIR_TRISTATE_SWITCH_ABSENT;
-
return virXMLPropEnumInternal(node, name, virTristateSwitchTypeFromString,
- flags, result);
+ flags, result, VIR_TRISTATE_SWITCH_ABSENT);
}
unsigned int *result,
unsigned int defaultResult)
{
- *result = defaultResult;
-
- return virXMLPropEnumInternal(node, name, strToInt, flags, result);
+ return virXMLPropEnumInternal(node, name, strToInt, flags, result, defaultResult);
}
* @result: The returned value
*
* Convenience function to return value of an enum attribute.
+ * @result is initialized to 0 on error or if the element is not found.
*
* Returns 1 in case of success in which case @result is set,
* or 0 if the attribute is not present,
virXMLPropFlags flags,
unsigned int *result)
{
- return virXMLPropEnumInternal(node, name, strToInt, flags, result);
+ return virXMLPropEnumInternal(node, name, strToInt, flags, result, 0);
}