From 86615e43bbac2315aa069ca3ef4712477d61605c Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 9 Nov 2017 17:47:47 +0100 Subject: Fix IO callback signatures --- xmlIO.c | 6 ++---- xmllint.c | 24 +++++++++++------------- xmlwriter.c | 12 +++++------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/xmlIO.c b/xmlIO.c index 1d490954..e61e7800 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -2843,10 +2843,8 @@ xmlOutputBufferCreateBuffer(xmlBufferPtr buffer, if (buffer == NULL) return(NULL); - ret = xmlOutputBufferCreateIO((xmlOutputWriteCallback) - xmlBufferWrite, - (xmlOutputCloseCallback) - NULL, (void *) buffer, encoder); + ret = xmlOutputBufferCreateIO(xmlBufferWrite, NULL, (void *) buffer, + encoder); return(ret); } diff --git a/xmllint.c b/xmllint.c index a691aa68..75d2f9b4 100644 --- a/xmllint.c +++ b/xmllint.c @@ -814,13 +814,14 @@ xmlShellReadline(char *prompt) { * * ************************************************************************/ -static int myRead(FILE *f, char * buf, int len) { - return(fread(buf, 1, len, f)); +static int myRead(void *f, char *buf, int len) { + return(fread(buf, 1, len, (FILE *) f)); } -static void myClose(FILE *f) { - if (f != stdin) { - fclose(f); - } +static int myClose(void *context) { + FILE *f = (FILE *) context; + if (f == stdin) + return(0); + return(fclose(f)); } /************************************************************************ @@ -2303,14 +2304,11 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { #endif if (f != NULL) { if (rectxt == NULL) - doc = xmlReadIO((xmlInputReadCallback) myRead, - (xmlInputCloseCallback) myClose, f, - filename, NULL, options); + doc = xmlReadIO(myRead, myClose, f, filename, NULL, + options); else - doc = xmlCtxtReadIO(rectxt, - (xmlInputReadCallback) myRead, - (xmlInputCloseCallback) myClose, f, - filename, NULL, options); + doc = xmlCtxtReadIO(rectxt, myRead, myClose, f, + filename, NULL, options); } else doc = NULL; } diff --git a/xmlwriter.c b/xmlwriter.c index 2533a23d..b5cd171f 100644 --- a/xmlwriter.c +++ b/xmlwriter.c @@ -110,7 +110,7 @@ static void xmlFreeTextWriterNsStackEntry(xmlLinkPtr lk); static int xmlCmpTextWriterNsStackEntry(const void *data0, const void *data1); static int xmlTextWriterWriteDocCallback(void *context, - const xmlChar * str, int len); + const char *str, int len); static int xmlTextWriterCloseDocCallback(void *context); static xmlChar *xmlTextWriterVSprintf(const char *format, va_list argptr) LIBXML_ATTR_FORMAT(1,0); @@ -325,9 +325,7 @@ xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, return NULL; } - out = xmlOutputBufferCreateIO((xmlOutputWriteCallback) - xmlTextWriterWriteDocCallback, - (xmlOutputCloseCallback) + out = xmlOutputBufferCreateIO(xmlTextWriterWriteDocCallback, xmlTextWriterCloseDocCallback, (void *) ctxt, NULL); if (out == NULL) { @@ -4418,12 +4416,12 @@ xmlCmpTextWriterNsStackEntry(const void *data0, const void *data1) * Returns -1, 0, 1 */ static int -xmlTextWriterWriteDocCallback(void *context, const xmlChar * str, int len) +xmlTextWriterWriteDocCallback(void *context, const char *str, int len) { xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) context; int rc; - if ((rc = xmlParseChunk(ctxt, (const char *) str, len, 0)) != 0) { + if ((rc = xmlParseChunk(ctxt, str, len, 0)) != 0) { xmlWriterErrMsgInt(NULL, XML_ERR_INTERNAL_ERROR, "xmlTextWriterWriteDocCallback : XML error %d !\n", rc); @@ -4449,7 +4447,7 @@ xmlTextWriterCloseDocCallback(void *context) if ((rc = xmlParseChunk(ctxt, NULL, 0, 1)) != 0) { xmlWriterErrMsgInt(NULL, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterWriteDocCallback : XML error %d !\n", + "xmlTextWriterCloseDocCallback : XML error %d !\n", rc); return -1; } -- cgit v1.2.1