diff options
Diffstat (limited to 'src/utils/xml.cpp')
-rw-r--r-- | src/utils/xml.cpp | 44 |
1 files changed, 21 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 |