X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_dump.c;h=a8887ee82ab8ff4b0a6b5ed802c72f9f3b181c68;hb=110ae8b7e4893e9c641a8fcf9e787e2a0d4988ea;hp=32b227fa117b293156bc7ae99062dc9f31d87fff;hpb=a278779cdf2ded56b89fc404d6914bff7ad7dcbd;p=rrdtool.git diff --git a/src/rrd_dump.c b/src/rrd_dump.c index 32b227f..a8887ee 100644 --- a/src/rrd_dump.c +++ b/src/rrd_dump.c @@ -1,10 +1,32 @@ /***************************************************************************** - * RRDtool 1.0.33 Copyright Tobias Oetiker, 1997 - 2000 + * RRDtool 1.1.x Copyright Tobias Oetiker, 1997 - 2004 ***************************************************************************** * rrd_dump Display a RRD ***************************************************************************** * $Id$ * $Log$ + * Revision 1.7 2004/05/25 20:53:21 oetiker + * prevent small leak when resources are exhausted -- Mike Slifcak + * + * Revision 1.6 2004/05/25 20:51:49 oetiker + * Update displayed copyright messages to be consistent. -- Mike Slifcak + * + * Revision 1.5 2003/02/13 07:05:27 oetiker + * Find attached the patch I promised to send to you. Please note that there + * are three new source files (src/rrd_is_thread_safe.h, src/rrd_thread_safe.c + * and src/rrd_not_thread_safe.c) and the introduction of librrd_th. This + * library is identical to librrd, but it contains support code for per-thread + * global variables currently used for error information only. This is similar + * to how errno per-thread variables are implemented. librrd_th must be linked + * alongside of libpthred + * + * There is also a new file "THREADS", holding some documentation. + * + * -- Peter Stamfest + * + * Revision 1.4 2002/02/01 20:34:49 oetiker + * fixed version number and date/time + * * Revision 1.3 2001/03/10 23:54:39 oetiker * Support for COMPUTE data sources (CDEF data sources). Removes the RPN * parser and calculator from rrd_graph and puts then in a new file, @@ -26,18 +48,34 @@ extern char *tzname[2]; int -rrd_dump(int argc, char **argv) +rrd_dump(int argc, char **argv) +{ + int rc; + + if (argc < 2) { + rrd_set_error("Not enough arguments"); + return -1; + } + + rc = rrd_dump_r(argv[1]); + + return rc; +} + +int +rrd_dump_r(char *filename) { - int i,ii,ix,iii=0; + unsigned int i,ii,ix,iii=0; time_t now; char somestring[255]; rrd_value_t my_cdp; long rra_base, rra_start, rra_next; - FILE *in_file; - rrd_t rrd; + FILE *in_file; + rrd_t rrd; rrd_value_t value; - - if(rrd_open(argv[1],&in_file,&rrd, RRD_READONLY)==-1){ + struct tm tm; + if(rrd_open(filename, &in_file,&rrd, RRD_READONLY)==-1){ + rrd_free(&rrd); return(-1); } @@ -46,8 +84,9 @@ rrd_dump(int argc, char **argv) printf("\t %s \n",RRD_VERSION); printf("\t %lu \n",rrd.stat_head->pdp_step); #if HAVE_STRFTIME + localtime_r(&rrd.live_head->last_up, &tm); strftime(somestring,200,"%Y-%m-%d %H:%M:%S %Z", - localtime(&rrd.live_head->last_up)); + &tm); #else # error "Need strftime" #endif @@ -222,7 +261,7 @@ rrd_dump(int argc, char **argv) break; case CF_FAILURES: { - short vidx; + unsigned short vidx; char *violations_array = (char *) ((void*) rrd.cdp_prep[i*rrd.stat_head->ds_cnt+ii].scratch); printf("\t\t\t "); @@ -272,7 +311,8 @@ rrd_dump(int argc, char **argv) timer++; #if HAVE_STRFTIME - strftime(somestring,200,"%Y-%m-%d %H:%M:%S %Z", localtime(&now)); + localtime_r(&now, &tm); + strftime(somestring,200,"%Y-%m-%d %H:%M:%S %Z", &tm); #else # error "Need strftime" #endif