X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_dump.c;h=0f69e4f93731efd0e96148311d445cd240537eb7;hb=6396ef12edf2fb8fc5364ae5a8b782e6ef77d64b;hp=08fa87cb72130d28847f2a898da823d07ad2188a;hpb=9bfe76a20fbf12791dc1c6f68f5a5558d4baaf25;p=rrdtool.git diff --git a/src/rrd_dump.c b/src/rrd_dump.c index 08fa87c..0f69e4f 100644 --- a/src/rrd_dump.c +++ b/src/rrd_dump.c @@ -1,5 +1,5 @@ /***************************************************************************** - * RRDtool 1.2.99907080300 Copyright by Tobi Oetiker, 1997-2007 + * RRDtool 1.3rc2 Copyright by Tobi Oetiker, 1997-2008 ***************************************************************************** * rrd_dump Display a RRD ***************************************************************************** @@ -48,29 +48,12 @@ extern char *tzname[2]; #endif -int rrd_dump( - int argc, - char **argv) -{ - int rc; - - if (argc < 2) { - rrd_set_error("Not enough arguments"); - return -1; - } - if (argc == 3) { - rc = rrd_dump_r(argv[1], argv[2]); - } else { - rc = rrd_dump_r(argv[1], NULL); - } - - return rc; -} - -int rrd_dump_r( +int rrd_dump_opt_r( const char *filename, - char *outname) + char *outname, + int opt_noheader +) { unsigned int i, ii, ix, iii = 0; time_t now; @@ -98,10 +81,12 @@ int rrd_dump_r( out_file = stdout; } - fputs("", out_file); - fputs - ("", + if (opt_noheader){ + fputs("\n", out_file); + fputs + ("\n", out_file); + } fputs("", out_file); fputs("", out_file); if (atoi(rrd.stat_head->version) <= 3) { @@ -442,3 +427,64 @@ int rrd_dump_r( } return rrd_close(rrd_file); } + +/* backward compatibility with 1.2.x */ +int rrd_dump_r( + const char *filename, + char *outname) +{ + 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) < 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; +} +