X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_fetch.c;h=e6590ec74c98dab7388486ba536903523d4c9669;hb=cffc3b561fbc7bafbde87b10edf18013df3da531;hp=d5c5709450a1febd6e3c7522a0d4f2e0e3de5260;hpb=f036173fecfbe93f8f8c9296c791f5dcdaa391ba;p=rrdtool.git diff --git a/src/rrd_fetch.c b/src/rrd_fetch.c index d5c5709..e6590ec 100644 --- a/src/rrd_fetch.c +++ b/src/rrd_fetch.c @@ -1,10 +1,16 @@ /***************************************************************************** - * RRDtool 1.1.x Copyright Tobias Oetiker, 1997 - 2002 + * RRDtool 1.2.11 Copyright by Tobi Oetiker, 1997-2005 ***************************************************************************** * rrd_fetch.c read date from an rrd to use for further processing ***************************************************************************** * $Id$ * $Log$ + * Revision 1.8 2004/05/18 18:53:03 oetiker + * big spell checking patch -- slif@bellsouth.net + * + * Revision 1.7 2003/11/11 19:46:21 oetiker + * replaced time_value with rrd_time_value as MacOS X introduced a struct of that name in their standard headers + * * Revision 1.6 2003/01/16 23:27:54 oetiker * fix border condition in rra selection of rrd_fetch * -- Stanislav Sinyagin @@ -67,8 +73,9 @@ rrd_fetch(int argc, time_t start_tmp=0, end_tmp=0; enum cf_en cf_idx; - struct time_value start_tv, end_tv; + struct rrd_time_value start_tv, end_tv; char *parsetime_error = NULL; + optind = 0; opterr = 0; /* initialize getopt */ /* init start and end time */ parsetime("end-24h", &start_tv); @@ -175,18 +182,18 @@ rrd_fetch_fn( int first_part = 1; rrd_t rrd; rrd_value_t *data_ptr; - unsigned long rows = (*end - *start) / *step; + unsigned long rows; #ifdef DEBUG fprintf(stderr,"Entered rrd_fetch_fn() searching for the best match\n"); -fprintf(stderr,"Looking for: start %10lu end %10lu step %5lu rows %lu\n", - *start,*end,*step,rows); +fprintf(stderr,"Looking for: start %10lu end %10lu step %5lu\n", + *start,*end,*step); #endif if(rrd_open(filename,&in_file,&rrd, RRD_READONLY)==-1) return(-1); - /* when was the realy last update of this file ? */ + /* when was the really last update of this file ? */ if (((*ds_namv) = (char **) malloc(rrd.stat_head->ds_cnt * sizeof(char*)))==NULL){ rrd_set_error("malloc fetch ds_namv array"); @@ -288,7 +295,7 @@ fprintf(stderr,"partial match, not best\n"); *step = rrd.stat_head->pdp_step * rrd.rra_def[chosen_rra].pdp_cnt; *start -= (*start % *step); if (*end % *step) *end += (*step - *end % *step); - rows = (*end - *start) / *step; + rows = (*end - *start) / *step + 1; #ifdef DEBUG fprintf(stderr,"We found: start %10lu end %10lu step %5lu rows %lu\n",