diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2017-11-09 17:47:47 +0100 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2017-11-09 17:47:47 +0100 |
commit | 86615e43bbac2315aa069ca3ef4712477d61605c (patch) | |
tree | f6fd6a6a734f140516026ae8d6e42142986bc54e | |
parent | e5f33e56bafc332fd63f6643b687ebfe14bcba56 (diff) | |
download | libxml2-86615e43bbac2315aa069ca3ef4712477d61605c.tar.gz |
Fix IO callback signatures
-rw-r--r-- | xmlIO.c | 6 | ||||
-rw-r--r-- | xmllint.c | 24 | ||||
-rw-r--r-- | xmlwriter.c | 12 |
3 files changed, 18 insertions, 24 deletions
@@ -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); } @@ -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; } |