*tptr++ = 0;
ttok = malloc(sizeof(struct token));
ttok->next = NULL;
- ttok->key = malloc(strlen(tbuffer) + 1);
- strcpy(ttok->key, tbuffer);
+ ttok->key = strdup(tbuffer);
if (last) {
last->next = ttok;
last = ttok;
/* handle some special cases */
if (tmask & KTIME_NEVER)
- return 0x7fffffff;
+ return KTIME_NEVERTIME;
if (tmask & KTIME_NOW)
- return 0;
+ return KTIME_NOWTIME;
/* Use probe to fill in members of *tsp. Add 23 hours each iteration until
* time_next is correct. Only add 23 hrs to avoid skipping spring
* daylight savings time day */
for (probe = start;; probe += (23 * 3600)) {
tsp = localtime(&probe); /* find out what UTC time "probe" is */
+ if (!tsp)
+ return KTIME_NEVERTIME;
tdate.year = tsp->tm_year;
tdate.month = tsp->tm_mon + 1;
continue; /* "probe" time is already past */
if ((tmask & KTIME_DAY) == 0) /* don't care about day, we're done */
break;
+
tsp = localtime(&time_next);
+ if (!tsp)
+ return KTIME_NEVERTIME;
if (tsp->tm_wday == aktime->day)
break; /* day matches, we're done */
}
/* compare date in both formats, and return as in strcmp */
-#ifdef undef
-static int
-KTimeCmp(struct ktime *aktime, struct tm *atm)
-{
- afs_int32 tmask;
-
- /* don't compare day of the week, since we can't tell the
- * order in a cyclical set. Caller must check for equality, if
- * she cares */
- tmask = aktime->mask;
- if (tmask & KTIME_HOUR) {
- if (aktime->hour > atm->tm_hour)
- return 1;
- if (aktime->hour < atm->tm_hour)
- return -1;
- }
- if (tmask & KTIME_MIN) {
- if (aktime->min > atm->tm_min)
- return 1;
- if (aktime->min < atm->tm_min)
- return -1;
- }
- if (tmask & KTIME_SEC) {
- if (aktime->sec > atm->tm_sec)
- return 1;
- if (aktime->sec < atm->tm_sec)
- return -1;
- }
- return 0;
-}
-#endif
-
-/* compare date in both formats, and return as in strcmp */
static int
KDateCmp(struct ktime_date *akdate, struct tm *atm)
{
while (tbit > 0) {
temp = tresult + tbit; /* see if adding this bit keeps us < akdate */
tsp = localtime(&temp);
+ if (!tsp)
+ return KTIMEDATE_NEVERDATE;
tsp->tm_mon++;
-#ifdef notdef
- if (tsp->tm_mon == 0) {
- tsp->tm_mon = 12;
- tsp->tm_year--;
- }
-#endif
if (KDateCmp(akdate, tsp) >= 0) {
/* if temp still represents earlier than date than we're searching
* for, add in bit as increment, otherwise use old value and look