]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
suppress error message from libxml when reading XML from stdin. 443/head 446/head
authorPeter Stamfest <peter@stamfest.at>
Wed, 19 Feb 2014 21:34:20 +0000 (22:34 +0100)
committerPeter Stamfest <peter@stamfest.at>
Wed, 19 Feb 2014 21:34:20 +0000 (22:34 +0100)
This avoids breakage of the pipe protocol in case of errors.

src/rrd_restore.c

index 1f1924f3940ef219c99b34b7c596d8eddf8d8ded..53380dbde2a12681a3d0217d47307fe00fc1ac95 100644 (file)
@@ -1148,6 +1148,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)
 {
@@ -1157,6 +1168,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) {
@@ -1168,6 +1181,8 @@ static rrd_t *parse_file(
        sctx->closed = 0;
        sctx->eofchar = 0x1A; /* ctrl-Z */
 
+       xmlSetGenericErrorFunc(NULL, ignoringErrorFunc);
+
         reader = xmlReaderForIO(stdioXmlInputReadCallback,
                                 stdioXmlInputCloseCallback,
                                 sctx,