X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fparsetime.c;h=df93284f304b07c09b1553a773f4ab1013c2e06d;hb=88ec7a41d5ba332d0a902a17c0ef0cb01d133a30;hp=a081d58507ed975e0f739be5c89bc5c10871ec2e;hpb=1f6180d370e99a278608310bb74a0502f346a583;p=rrdtool.git diff --git a/src/parsetime.c b/src/parsetime.c index a081d58..df93284 100644 --- a/src/parsetime.c +++ b/src/parsetime.c @@ -32,6 +32,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* NOTE: nothing in here is thread-safe!!!! Not even the localtime + calls ... */ + /* * The BNF-like specification of the time syntax parsed is below: * @@ -450,10 +453,10 @@ token() /* - * expect() gets a token and complins if it's not the token we want + * expect2() gets a token and complins if it's not the token we want */ static char * -expect(int desired, char *complain_fmt, ...) +expect2(int desired, char *complain_fmt, ...) { va_list ap; va_start( ap, complain_fmt ); @@ -463,7 +466,7 @@ expect(int desired, char *complain_fmt, ...) va_end( ap ); return TIME_OK; -} /* expect */ +} /* expect2 */ /* @@ -472,7 +475,7 @@ expect(int desired, char *complain_fmt, ...) * It allso applies those m-guessing euristics. */ static char * -plus_minus(struct time_value *ptv, int doop) +plus_minus(struct rrd_time_value *ptv, int doop) { static int op = PLUS; static int prev_multiplier = -1; @@ -481,7 +484,7 @@ plus_minus(struct time_value *ptv, int doop) if( doop >= 0 ) { op = doop; - try(expect(NUMBER,"There should be number after '%c'", op == PLUS ? '+' : '-')); + try(expect2(NUMBER,"There should be number after '%c'", op == PLUS ? '+' : '-')); prev_multiplier = -1; /* reset months-minutes guessing mechanics */ } /* if doop is < 0 then we repeat the previous op @@ -552,7 +555,7 @@ plus_minus(struct time_value *ptv, int doop) * tod() computes the time of day (TIME-OF-DAY-SPEC) */ static char * -tod(struct time_value *ptv) +tod(struct rrd_time_value *ptv) { int hour, minute = 0; int tlen; @@ -581,7 +584,7 @@ tod(struct time_value *ptv) return TIME_OK; } if (sc_tokid == COLON ) { - try(expect(NUMBER, + try(expect2(NUMBER, "Parsing HH:MM syntax, expecting MM as number, got none")); minute = atoi(sc_token); if (minute > 59) { @@ -628,7 +631,7 @@ tod(struct time_value *ptv) * assign_date() assigns a date, adjusting year as appropriate */ static char * -assign_date(struct time_value *ptv, long mday, long mon, long year) +assign_date(struct rrd_time_value *ptv, long mday, long mon, long year) { if (year > 138) { if (year > 1970) @@ -656,7 +659,7 @@ assign_date(struct time_value *ptv, long mday, long mon, long year) * day() picks apart DAY-SPEC-[12] */ static char * -day(struct time_value *ptv) +day(struct rrd_time_value *ptv) { long mday=0, wday, mon, year = ptv->tm.tm_year; int tlen; @@ -678,7 +681,7 @@ day(struct time_value *ptv) /* do month mday [year] */ mon = (sc_tokid-JAN); - try(expect(NUMBER, + try(expect2(NUMBER, "the day of the month should follow month name")); mday = atol(sc_token); if (token() == NUMBER) { @@ -734,11 +737,11 @@ day(struct time_value *ptv) if (mon <= 31 && (sc_tokid == SLASH || sc_tokid == DOT)) { int sep; sep = sc_tokid; - try(expect(NUMBER,"there should be %s number after '%c'", + try(expect2(NUMBER,"there should be %s number after '%c'", sep == DOT ? "month" : "day", sep == DOT ? '.' : '/')); mday = atol(sc_token); if (token() == sep) { - try(expect(NUMBER,"there should be year number after '%c'", + try(expect2(NUMBER,"there should be year number after '%c'", sep == DOT ? '.' : '/')); year = atol(sc_token); token(); @@ -774,7 +777,7 @@ day(struct time_value *ptv) /* * parsetime() is the external interface that takes tspec, parses - * it and puts the result in the time_value structure *ptv. + * it and puts the result in the rrd_time_value structure *ptv. * It can return either absolute times (these are ensured to be * correct) or relative time references that are expected to be * added to some absolute time value and then normalized by @@ -782,7 +785,7 @@ day(struct time_value *ptv) * the pointer to the error message in the case of problems */ char * -parsetime(char *tspec, struct time_value *ptv) +parsetime(char *tspec, struct rrd_time_value *ptv) { time_t now = time(NULL); int hr = 0; @@ -910,8 +913,8 @@ parsetime(char *tspec, struct time_value *ptv) } /* parsetime */ -int proc_start_end (struct time_value *start_tv, - struct time_value *end_tv, +int proc_start_end (struct rrd_time_value *start_tv, + struct rrd_time_value *end_tv, time_t *start, time_t *end){ if (start_tv->type == RELATIVE_TO_END_TIME && /* same as the line above */