X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Frrd_create.c;fp=src%2Frrd_create.c;h=f221c99d535491fa511bbfa0eae2b55b13834aff;hb=bb124879717bdb65640cd50ce99e3569cb0a9a3f;hp=707e6013756851e65e8f18b7bef9237303cf838c;hpb=96b0f4aace0deef034a792a08dc2d426cd2b61a4;p=rrdtool.git diff --git a/src/rrd_create.c b/src/rrd_create.c index 707e601..f221c99 100644 --- a/src/rrd_create.c +++ b/src/rrd_create.c @@ -14,7 +14,6 @@ #include "rrd_client.h" #include "rrd_is_thread_safe.h" -static int opt_no_overwrite = 0; #ifdef WIN32 # include @@ -34,12 +33,6 @@ void parseGENERIC_DS( static void rrd_free2( rrd_t *rrd); /* our onwn copy, immmune to mmap */ -void rrd_create_set_no_overwrite( - int opt ) -{ - opt_no_overwrite = (opt?1:0); -} - int rrd_create( int argc, char **argv) @@ -60,6 +53,7 @@ int rrd_create( long long_tmp; int rc; char * opt_daemon = NULL; + int opt_no_overwrite = 0; optind = 0; opterr = 0; /* initialize getopt */ @@ -135,8 +129,8 @@ int rrd_create( pdp_step, last_up, opt_no_overwrite, argc - optind - 1, (const char **) (argv + optind + 1)); } else { - rc = rrd_create_r(argv[optind], - pdp_step, last_up, + rc = rrd_create_r2(argv[optind], + pdp_step, last_up, opt_no_overwrite, argc - optind - 1, (const char **) (argv + optind + 1)); } @@ -144,6 +138,8 @@ int rrd_create( } /* #define DEBUG */ +/* For backwards compatibility with previous API. Use rrd_create_r2 if you + need to have the no_overwrite parameter. */ int rrd_create_r( const char *filename, unsigned long pdp_step, @@ -151,6 +147,16 @@ int rrd_create_r( int argc, const char **argv) { + return rrd_create_r2(filename,pdp_step,last_up,0,argc,argv); +} +int rrd_create_r2( + const char *filename, + unsigned long pdp_step, + time_t last_up, + int no_overwrite, + int argc, + const char **argv) +{ rrd_t rrd; long i; int offset; @@ -584,7 +590,7 @@ int rrd_create_r( rrd_free2(&rrd); return (-1); } - return rrd_create_fn(filename, &rrd); + return rrd_create_fn(filename, &rrd, no_overwrite); } void parseGENERIC_DS( @@ -708,7 +714,8 @@ int create_hw_contingent_rras( int rrd_create_fn( const char *file_name, - rrd_t *rrd) + rrd_t *rrd, + int no_overwrite ) { unsigned long i, ii; rrd_value_t *unknown; @@ -717,7 +724,7 @@ int rrd_create_fn( rrd_t rrd_dn; unsigned rrd_flags = RRD_READWRITE | RRD_CREAT; - if (opt_no_overwrite) { + if (no_overwrite) { rrd_flags |= RRD_EXCL ; }