From 3016ec37d0ec238b5c70a61d9b52fe39973db56b Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Thu, 17 Jan 2013 10:57:59 +0100 Subject: [PATCH] Fix lpc2xml for old libxml version --- configure.ac | 2 +- tools/lpc2xml.c | 10 +++++++--- tools/lpc2xml.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index dc411434..1d8f9227 100644 --- a/configure.ac +++ b/configure.ac @@ -150,7 +150,7 @@ AC_ARG_ENABLE(tools, dnl check libxml2 (needed for tools) if test "$build_tools" != "false" ; then - PKG_CHECK_MODULES(LIBXML2, [libxml-2.0 >= 2.9 ],[], + PKG_CHECK_MODULES(LIBXML2, [libxml-2.0],[], [ if test "$build_tools" = "true" ; then AC_MSG_ERROR([Could not found libxml2, tools cannot be compiled.]) diff --git a/tools/lpc2xml.c b/tools/lpc2xml.c index 12af7532..feabdde2 100644 --- a/tools/lpc2xml.c +++ b/tools/lpc2xml.c @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "lpc2xml.h" #include #include - +#include #define LPC2XML_BZ 2048 @@ -216,7 +216,7 @@ int lpc2xml_convert_fd(lpc2xml_context* context, int fd) { return ret; } -int lpc2xml_convert_string(lpc2xml_context* context, unsigned char **content) { +int lpc2xml_convert_string(lpc2xml_context* context, char **content) { int ret = 0; xmlBufferPtr buffer = xmlBufferCreate(); xmlSaveCtxtPtr save_ctx = xmlSaveToBuffer(buffer, "UTF-8", XML_SAVE_FORMAT); @@ -226,7 +226,11 @@ int lpc2xml_convert_string(lpc2xml_context* context, unsigned char **content) { } xmlSaveClose(save_ctx); if(ret == 0) { - *content = xmlBufferDetach(buffer); +#if LIBXML_VERSION >= 20800 + *content = (char *)xmlBufferDetach(buffer); +#else + *content = strdup((const char *)xmlBufferContent(buffer)); +#endif } xmlBufferFree(buffer); return ret; diff --git a/tools/lpc2xml.h b/tools/lpc2xml.h index f1583109..02540090 100644 --- a/tools/lpc2xml.h +++ b/tools/lpc2xml.h @@ -40,7 +40,7 @@ int lpc2xml_set_lpc(lpc2xml_context* context, const LpConfig *lpc); int lpc2xml_convert_file(lpc2xml_context* context, const char *filename); int lpc2xml_convert_fd(lpc2xml_context* context, int fd); -int lpc2xml_convert_string(lpc2xml_context* context, unsigned char **content); +int lpc2xml_convert_string(lpc2xml_context* context, char **content); #endif //LPC2XML_H_ -- 2.39.2