X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_dump.c;h=0feafd72b87e7eca6613ecd0bac30b7d0c4364c7;hb=2e3ab4d5b17d1264c1908026df77242aeefb9b18;hp=707789ca5ecbbb8aece996583a1900056312e77c;hpb=161ecf9c20dbf285f7746aad42327edb8bfeeccc;p=rrdtool.git diff --git a/src/rrd_dump.c b/src/rrd_dump.c index 707789c..0feafd7 100644 --- a/src/rrd_dump.c +++ b/src/rrd_dump.c @@ -48,58 +48,6 @@ extern char *tzname[2]; #endif -int rrd_dump( - int argc, - char **argv) -{ - int rc; - int opt_noheader = 0; - /* init rrd clean */ - - optind = 0; - opterr = 0; /* initialize getopt */ - - while (42) { - int opt; - int option_index = 0; - static struct option long_options[] = { - {"no-header", no_argument, 0, 'n'}, - {0, 0, 0, 0} - }; - - opt = getopt_long(argc, argv, "n", long_options, &option_index); - - if (opt == EOF) - break; - - switch (opt) { - case 'n': - opt_range_check = 1; - break; - - default: - rrd_set_error("usage rrdtool %s [--no-header|-n] " - "file.rrd [file.xml]", argv[0]); - return (-1); - break; - } - } /* while (42) */ - - if ((argc - optind) < 2) { - rrd_set_error("usage rrdtool %s [--no-header|-n] " - "file.rrd [file.xml]", argv[0]); - return (-1); - } - - if (argc == 3) { - rc = rrd_dump_opt_r(argv[1], argv[2],opt_noheader); - } else { - rc = rrd_dump_opt_r(argv[1], NULL,opt_noheader); - } - - return rc; -} - int rrd_dump_opt_r( const char *filename, @@ -133,7 +81,7 @@ int rrd_dump_opt_r( out_file = stdout; } - if (opt_noheader){ + if (!opt_noheader){ fputs("\n", out_file); fputs ("\n", @@ -485,5 +433,58 @@ int rrd_dump_r( const char *filename, char *outname) { - rrd_dump_opt_r(filename,outname,0); + return rrd_dump_opt_r(filename,outname,0); } + +int rrd_dump( + int argc, + char **argv) +{ + int rc; + int opt_noheader = 0; + /* init rrd clean */ + + optind = 0; + opterr = 0; /* initialize getopt */ + + while (42) { + int opt; + int option_index = 0; + static struct option long_options[] = { + {"no-header", no_argument, 0, 'n'}, + {0, 0, 0, 0} + }; + + opt = getopt_long(argc, argv, "n", long_options, &option_index); + + if (opt == EOF) + break; + + switch (opt) { + case 'n': + opt_noheader = 1; + break; + + default: + rrd_set_error("usage rrdtool %s [--no-header|-n] " + "file.rrd [file.xml]", argv[0]); + return (-1); + break; + } + } /* while (42) */ + + if ((argc - optind) < 1 || (argc - optind) > 2) { + rrd_set_error("usage rrdtool %s [--no-header|-n] " + "file.rrd [file.xml]", argv[0]); + return (-1); + } + + if ((argc - optind) == 2) { + rc = rrd_dump_opt_r(argv[optind], argv[optind+1],opt_noheader); + } else { + rc = rrd_dump_opt_r(argv[optind], NULL,opt_noheader); + } + + return rc; +} +