Fix lpc2xml for old libxml version

This commit is contained in:
Yann Diorcet 2013-01-17 10:57:59 +01:00
parent 56470e4ddd
commit 3016ec37d0
3 changed files with 9 additions and 5 deletions

View file

@ -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.])

View file

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "lpc2xml.h"
#include <string.h>
#include <libxml/xmlsave.h>
#include <libxml/xmlversion.h>
#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;

View file

@ -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_