]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
provide new write_fh function
authorPeter Stamfest <peter@stamfest.at>
Mon, 24 Feb 2014 19:08:40 +0000 (20:08 +0100)
committerPeter Stamfest <peter@stamfest.at>
Wed, 26 Feb 2014 10:29:02 +0000 (11:29 +0100)
src/rrd_restore.c
src/rrd_restore.h

index 1ab92d8a9f04a28541b9507f882af341cd663193..1dc3795f8ef323f507d66492649241e490fc9832 100644 (file)
@@ -1127,8 +1127,6 @@ int write_file(
     rrd_t *rrd)
 {
     FILE     *fh;
-    unsigned int i;
-    unsigned int rra_offset;
 
     if (strcmp("-", file_name) == 0)
         fh = stdout;
@@ -1157,6 +1155,28 @@ int write_file(
             return (-1);
         }
     }
+
+    int rc = write_fh(fh, rrd);
+
+    /* lets see if we had an error */
+    if (ferror(fh)) {
+        rrd_set_error("a file error occurred while creating '%s'", file_name);
+        fclose(fh);
+        return (-1);
+    }
+
+    fclose(fh);
+    
+    return rc;
+}
+
+int write_fh(
+    FILE *fh,
+    rrd_t *rrd)
+{
+    unsigned int i;
+    unsigned int rra_offset;
+
     if (atoi(rrd->stat_head->version) < 3) {
         /* we output 3 or higher */
         strcpy(rrd->stat_head->version, "0003");
@@ -1188,14 +1208,6 @@ int write_file(
         }
     }
 
-    /* lets see if we had an error */
-    if (ferror(fh)) {
-        rrd_set_error("a file error occurred while creating '%s'", file_name);
-        fclose(fh);
-        return (-1);
-    }
-
-    fclose(fh);
     return (0);
 }                       /* int write_file */
 
index a6c528031c3d8afe3656a69024bc29a7075b7f52..94d06f600a496c206d596a746313859c848e0e1b 100644 (file)
@@ -10,12 +10,17 @@ extern    "C" {
 #ifndef _RRD_RESTORE_H
 #define _RRD_RESTORE_H
 
+#include <stdio.h>
 #include "rrd.h"
 
 int write_file(
     const char *file_name,
     rrd_t *rrd);
 
+int write_fh(
+    FILE *fh,
+    rrd_t *rrd);
+
 #endif