diff options
-rw-r--r-- | src/utils/xml.cpp | 44 | ||||
-rw-r--r-- | src/utils/xml.h | 1 |
2 files changed, 22 insertions, 23 deletions
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index fea5589f..252a9bd2 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -21,10 +21,6 @@ #include "utils/xml.h" -#include <iostream> -#include <fstream> -#include <cstring> - #include <libxml/parser.h> #include <libxml/xmlerror.h> @@ -37,14 +33,33 @@ namespace XML { - static void xmlLogger(void *ctx, xmlErrorPtr error); - struct XMLContext { std::string file; bool resman; }; +#if LIBXML_VERSION >= 21200 + static void xmlLogger(void *ctx, const xmlError *error) +#else + static void xmlLogger(void *ctx, xmlErrorPtr error) +#endif + { + auto *context = static_cast<XMLContext*>(ctx); + + if (context) + logger->log("Error in XML file '%s' on line %d", + context->file.c_str(), error->line); + else + logger->log("Error in unknown xml file on line %d", + error->line); + + logger->log("%s", error->message); + + // No need to keep errors around + xmlCtxtResetLastError(error->ctxt); + } + Document::Document(const std::string &filename, bool useResman): mDoc(nullptr) { @@ -160,23 +175,6 @@ namespace XML return nullptr; } - static void xmlLogger(void *ctx, xmlErrorPtr error) - { - auto *context = static_cast<XMLContext*>(ctx); - - if (context) - logger->log("Error in XML file '%s' on line %d", - context->file.c_str(), error->line); - else - logger->log("Error in unknown xml file on line %d", - error->line); - - logger->log("%s", error->message); - - // No need to keep errors around - xmlCtxtResetLastError(error->ctxt); - } - void init() { // Initialize libxml2 and check for potential ABI mismatches between diff --git a/src/utils/xml.h b/src/utils/xml.h index df8dd1bd..256a964b 100644 --- a/src/utils/xml.h +++ b/src/utils/xml.h @@ -22,6 +22,7 @@ #ifndef XML_H #define XML_H +#include <libxml/parser.h> #include <libxml/tree.h> #include <string> |