#include <afsconfig.h>
#include <afs/param.h>
+#include <roken.h>
+#include <afs/opr.h>
-#include <sys/types.h>
-#include <stdio.h>
-#include <time.h>
#include <ctype.h>
-#ifdef AFS_NT40_ENV
-#include <malloc.h>
-#endif
-#include <string.h>
-#include <stdlib.h>
-#include "afsutil.h"
+#include <afs/opr.h>
+#include "afsutil.h"
#include "ktime.h"
/* some date parsing routines */
};
/* free token list returned by parseLine */
-#ifdef undef
-static
-LocalFreeTokens(alist)
- struct token *alist;
+static void
+LocalFreeTokens(struct token *alist)
{
struct token *nlist;
for (; alist; alist = nlist) {
free(alist->key);
free(alist);
}
- return 0;
+ return;
}
-#endif
static int
space(int x)
if (inToken) {
inToken = 0; /* end of this token */
*tptr++ = 0;
- ttok = (struct token *)malloc(sizeof(struct token));
+ ttok = malloc(sizeof(struct token));
ttok->next = NULL;
- ttok->key = (char *)malloc(strlen(tbuffer) + 1);
- strcpy(ttok->key, tbuffer);
+ ttok->key = strdup(tbuffer);
if (last) {
last->next = ttok;
last = ttok;
/* look at each token */
if (strcmp(tt->key, "now") == 0) {
ak->mask |= KTIME_NOW;
- return 0;
+ goto out;
}
if (strcmp(tt->key, "never") == 0) {
ak->mask |= KTIME_NEVER;
- return 0;
+ goto out;
}
if (strcmp(tt->key, "at") == 0)
continue;
if (isdigit(tt->key[0])) {
/* parse a time */
code = ParseTime(ak, tt->key);
- if (code)
- return -1;
+ if (code) {
+ code = -1;
+ goto out;
+ }
continue;
}
/* otherwise use keyword table */
for (tp = ptkeys;; tp++) {
if (tp->key == NULL) {
- return -1;
+ code = -1;
+ goto out;
}
if (strcmp(tp->key, tt->key) == 0)
break;
/* am or pm token */
if ((tp->value & 0xff) == 1) {
/* pm */
- if (!(ak->mask & KTIME_HOUR))
- return -1;
- if (ak->hour < 12)
+ if (!(ak->mask & KTIME_HOUR)) {
+ code = -1;
+ goto out;
+ }
+ if (ak->hour < 12) {
ak->hour += 12;
/* 12 is 12 PM */
- else if (ak->hour != 12)
- return -1;
+ } else if (ak->hour != 12) {
+ code = -1;
+ goto out;
+ }
} else {
/* am is almost a noop, except that we map 12:01 am to 0:01 */
- if (ak->hour > 12)
- return -1;
+ if (ak->hour > 12) {
+ code = -1;
+ goto out;
+ }
if (ak->hour == 12)
ak->hour = 0;
}
}
}
- return 0;
+out:
+ LocalFreeTokens(tt);
+ return code;
}
/* ktime_DisplayString
/* 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