summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8f9fc8e)
raw | patch | inline | side by side (parent: 8f9fc8e)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 17 Jan 2009 11:16:18 +0000 (12:16 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 17 Jan 2009 11:16:18 +0000 (12:16 +0100) |
src/bind.c | patch | blob | history |
diff --git a/src/bind.c b/src/bind.c
index d6914999a73859a87d597bb30c4406378fb56238..f09a08eb6938ab744165fdd37be4d00144a30fc4 100644 (file)
--- a/src/bind.c
+++ b/src/bind.c
@@ -367,7 +367,7 @@ static int bind_xml_stats_v1(xmlDoc *doc, xmlXPathContext *xpathCtx, xmlNode *st
xmlXPathFreeObject(xpathObj);
}
return 0;
-}
+} /* int bind_xml_stats_v1 */
/* Bind 9.6.x */
static int bind_xml_stats_v2(xmlDoc *doc, xmlXPathContext *xpathCtx, xmlNode *statsnode)
@@ -562,7 +562,7 @@ static int bind_xml_stats_v2(xmlDoc *doc, xmlXPathContext *xpathCtx, xmlNode *st
xmlXPathFreeObject(xpathObj);
}
return 0;
-}
+} /* int bind_xml_stats_v2 */
static int bind_xml (const char *data)
{
xmlXPathObjectPtr xpathObj = NULL;
int ret = -1;
- doc = xmlParseMemory (data, strlen (data));
- if (doc == NULL) {
- ERROR ("bind plugin: xmlParseMemory failed.");
- goto out;
- }
+ do
+ {
+ doc = xmlParseMemory (data, strlen (data));
+ if (doc == NULL) {
+ ERROR ("bind plugin: xmlParseMemory failed.");
+ break;
+ }
- if ((xpathCtx = xmlXPathNewContext(doc)) == NULL) {
- ERROR ("bind plugin: xmlXPathNewContext failed.");
- goto out;
- }
- /* Look for /isc/bind/statistics[@version='2.0'] */
- if ((xpathObj = xmlXPathEvalExpression(BAD_CAST "/isc[@version='1.0']/bind/statistics[@version='1.0']", xpathCtx)) == NULL) {
- ERROR("bind plugin: unable to evaluate XPath expression StatsV1");
- goto out;
- } else if (xpathObj->nodesetval && xpathObj->nodesetval->nodeNr > 0) {
- /* We have Bind-9.5.x */
- ret = bind_xml_stats_v1(doc, xpathCtx, xpathObj->nodesetval->nodeTab[0]);
- goto out;
- } else {
+ if ((xpathCtx = xmlXPathNewContext(doc)) == NULL) {
+ ERROR ("bind plugin: xmlXPathNewContext failed.");
+ break;
+ }
+
+ /* Look for /isc/bind/statistics[@version='1.0'] */
+ xpathObj = xmlXPathEvalExpression(BAD_CAST "/isc[@version='1.0']/bind/statistics[@version='1.0']", xpathCtx);
+ if (xpathObj == NULL)
+ {
+ ERROR("bind plugin: unable to evaluate XPath expression StatsV1");
+ break;
+ }
+ else if (xpathObj->nodesetval && xpathObj->nodesetval->nodeNr > 0)
+ {
+ /* We have Bind-9.5.x */
+ ret = bind_xml_stats_v1(doc, xpathCtx, xpathObj->nodesetval->nodeTab[0]);
+ break;
+ }
+
+ /* Not Bind-9.5.x. Let's clear up and try Bind-9.6.x instead. */
xmlXPathFreeObject(xpathObj);
xpathObj = NULL;
- }
- if ((xpathObj = xmlXPathEvalExpression(BAD_CAST "/isc[@version='1.0']/bind/statistics[@version='2.0']", xpathCtx)) == NULL) {
- ERROR("bind plugin: unable to evaluate XPath expression StatsV2");
- goto out;
- } else if (xpathObj->nodesetval && xpathObj->nodesetval->nodeNr > 0) {
- /* We have Bind-9.6.x */
- ret = bind_xml_stats_v2(doc, xpathCtx, xpathObj->nodesetval->nodeTab[0]);
- goto out;
- } else {
+
+ /* Look for /isc/bind/statistics[@version='2.0'] */
+ xpathObj = xmlXPathEvalExpression(BAD_CAST "/isc[@version='1.0']/bind/statistics[@version='2.0']", xpathCtx);
+ if (xpathObj == NULL)
+ {
+ ERROR("bind plugin: unable to evaluate XPath expression StatsV2");
+ break;
+ }
+ else if (xpathObj->nodesetval && xpathObj->nodesetval->nodeNr > 0)
+ {
+ /* We have Bind-9.6.x */
+ ret = bind_xml_stats_v2(doc, xpathCtx, xpathObj->nodesetval->nodeTab[0]);
+ break;
+ }
+
+ ERROR("bind plugin: unable to find statistics in supported version.");
+ } while (0);
+
+ if (xpathObj != NULL)
xmlXPathFreeObject(xpathObj);
- xpathObj = NULL;
- }
- ERROR("bind plugin: unable to find statistics in supported version.");
+ if (xpathCtx != NULL)
+ xmlXPathFreeContext(xpathCtx);
+ if (doc != NULL)
+ xmlFreeDoc (doc);
-out:
- xmlXPathFreeObject(xpathObj);
- xmlXPathFreeContext(xpathCtx);
- xmlFreeDoc (doc);
return (ret);
} /* int bind_xml */