3 * disabled: check to see if registration is enabled right now. Most of this
4 * code is stolen from the cron daemon.
6 * (c) Copyright 1988 by the Massachusetts Institute of Technology.
7 * For copying and distribution information, please see the file
11 #include <mit-copyright.h>
14 #include <sys/types.h>
18 #endif /* _AUX_SOURCE */
22 #define LISTS (2*BUFSIZ)
33 struct tm *localtime();
42 int number(register char c, FILE *f);
44 /* This routine will determine if registration is enabled at this time. If
45 * NULL is returned, registration is OK. Otherwise, the string returned
46 * will indicate the time that registration will be re-enabled.
62 itime -= localtime(&itime)->tm_sec;
63 loct = localtime(&itime);
64 loct->tm_mon++; /* 1-12 for month */
65 if (loct->tm_wday == 0)
66 loct->tm_wday = 7; /* sunday is 7, not 0 */
68 for(cp = list; *cp != EOS;) {
70 cp = cmp(cp, loct->tm_min);
71 cp = cmp(cp, loct->tm_hour);
72 cp = cmp(cp, loct->tm_mday);
73 cp = cmp(cp, loct->tm_mon);
74 cp = cmp(cp, loct->tm_wday);
86 itime += 60; /* add a minute */
87 loct = localtime(&itime);
88 loct->tm_mon++; /* 1-12 for month */
89 if (loct->tm_wday == 0)
90 loct->tm_wday = 7; /* sunday is 7, not 0 */
92 for(cp = list; *cp != EOS;) {
94 cp = cmp(cp, loct->tm_min);
95 cp = cmp(cp, loct->tm_hour);
96 cp = cmp(cp, loct->tm_mday);
97 cp = cmp(cp, loct->tm_mon);
98 cp = cmp(cp, loct->tm_wday);
107 return(ctime(&itime));
138 if(*cp > v || cp[1] < v)
150 * Don't free in case was longer than LISTS. Trades off
151 * the rare case of crontab shrinking vs. the common case of
152 * extra realloc's needed in append() for a large crontab.
155 list = malloc(LISTS);
170 if ((f = fopen(fn, "r")) == (FILE *) NULL)
174 if(cp > list+listsize-MAXLIN) {
175 int length = cp - list;
178 list = realloc(list, listsize);
185 while(c == ' ' || c == '\t')
187 if(c == EOF || c == '\n')
195 if ((n = number(c, f)) < 0)
202 if(c != '\t' && c != ' ')
212 if ((n = number(getc(f), f)) < 0)
217 if(c != '\t' && c != ' ')
225 if ((n = number(getc(f), f)) < 0)
228 if(c != '\t' && c != ' ')