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();
43 /* This routine will determine if registration is enabled at this time. If
44 * NULL is returned, registration is OK. Otherwise, the string returned
45 * will indicate the time that registration will be re-enabled.
61 itime -= localtime(&itime)->tm_sec;
62 loct = localtime(&itime);
63 loct->tm_mon++; /* 1-12 for month */
64 if (loct->tm_wday == 0)
65 loct->tm_wday = 7; /* sunday is 7, not 0 */
67 for(cp = list; *cp != EOS;) {
69 cp = cmp(cp, loct->tm_min);
70 cp = cmp(cp, loct->tm_hour);
71 cp = cmp(cp, loct->tm_mday);
72 cp = cmp(cp, loct->tm_mon);
73 cp = cmp(cp, loct->tm_wday);
85 itime += 60; /* add a minute */
86 loct = localtime(&itime);
87 loct->tm_mon++; /* 1-12 for month */
88 if (loct->tm_wday == 0)
89 loct->tm_wday = 7; /* sunday is 7, not 0 */
91 for(cp = list; *cp != EOS;) {
93 cp = cmp(cp, loct->tm_min);
94 cp = cmp(cp, loct->tm_hour);
95 cp = cmp(cp, loct->tm_mday);
96 cp = cmp(cp, loct->tm_mon);
97 cp = cmp(cp, loct->tm_wday);
106 return(ctime(&itime));
137 if(*cp > v || cp[1] < v)
149 * Don't free in case was longer than LISTS. Trades off
150 * the rare case of crontab shrinking vs. the common case of
151 * extra realloc's needed in append() for a large crontab.
154 list = malloc(LISTS);
169 if ((f = fopen(fn, "r")) == (FILE *) NULL)
173 if(cp > list+listsize-MAXLIN) {
174 int length = cp - list;
177 list = realloc(list, listsize);
184 while(c == ' ' || c == '\t')
186 if(c == EOF || c == '\n')
194 if ((n = number(c, f)) < 0)
201 if(c != '\t' && c != ' ')
211 if ((n = number(getc(f), f)) < 0)
216 if(c != '\t' && c != ' ')
224 if ((n = number(getc(f), f)) < 0)
227 if(c != '\t' && c != ' ')