From: Peter Stamfest Date: Wed, 19 Feb 2014 21:34:20 +0000 (+0100) Subject: suppress error message from libxml when reading XML from stdin. X-Git-Tag: v1.5.0-rc1~132^2^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3bddfe0696862834f06fac48ad2994ab152ab554;p=thirdparty%2Frrdtool-1.x.git suppress error message from libxml when reading XML from stdin. This avoids breakage of the pipe protocol in case of errors. --- diff --git a/src/rrd_restore.c b/src/rrd_restore.c index 2910557c..01ec422f 100644 --- a/src/rrd_restore.c +++ b/src/rrd_restore.c @@ -1150,6 +1150,17 @@ static int stdioXmlInputCloseCallback(void *context) return 0; /* everything is OK */ } +/* an XML error reporting function that just suppresses all error messages. + This is used when parsing an XML file from stdin. This should help to + not break the pipe interface protocol by suppressing the sending out of + XML error messages. */ +static void ignoringErrorFunc( + void *ctx, + const char * msg, + ...) +{ +} + static rrd_t *parse_file( const char *filename) { @@ -1159,6 +1170,8 @@ static rrd_t *parse_file( rrd_t *rrd; stdioXmlReaderContext *sctx = NULL; + /* special handling for XML on stdin (like it is the case when using + the pipe interface) */ if (strcmp(filename, "-") == 0) { sctx = malloc(sizeof(*sctx)); if (sctx == NULL) { @@ -1170,6 +1183,8 @@ static rrd_t *parse_file( sctx->closed = 0; sctx->eofchar = 0x1A; /* ctrl-Z */ + xmlSetGenericErrorFunc(NULL, ignoringErrorFunc); + reader = xmlReaderForIO(stdioXmlInputReadCallback, stdioXmlInputCloseCallback, sctx,