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 #define LISTS (2*BUFSIZ)
27 #define FILENAME "disabled.times"
31 struct tm *localtime();
41 /* This routine will determine if registration is enabled at this time. If
42 * NULL is returned, registration is OK. Otherwise, the string returned
43 * will indicate the time that registration will be re-enabled.
59 itime -= localtime(&itime)->tm_sec;
60 loct = localtime(&itime);
61 loct->tm_mon++; /* 1-12 for month */
62 if (loct->tm_wday == 0)
63 loct->tm_wday = 7; /* sunday is 7, not 0 */
65 for(cp = list; *cp != EOS;) {
67 cp = cmp(cp, loct->tm_min);
68 cp = cmp(cp, loct->tm_hour);
69 cp = cmp(cp, loct->tm_mday);
70 cp = cmp(cp, loct->tm_mon);
71 cp = cmp(cp, loct->tm_wday);
83 itime += 60; /* add a minute */
84 loct = localtime(&itime);
85 loct->tm_mon++; /* 1-12 for month */
86 if (loct->tm_wday == 0)
87 loct->tm_wday = 7; /* sunday is 7, not 0 */
89 for(cp = list; *cp != EOS;) {
91 cp = cmp(cp, loct->tm_min);
92 cp = cmp(cp, loct->tm_hour);
93 cp = cmp(cp, loct->tm_mday);
94 cp = cmp(cp, loct->tm_mon);
95 cp = cmp(cp, loct->tm_wday);
104 return(ctime(&itime));
135 if(*cp > v || cp[1] < v)
147 * Don't free in case was longer than LISTS. Trades off
148 * the rare case of crontab shrinking vs. the common case of
149 * extra realloc's needed in append() for a large crontab.
152 list = malloc(LISTS);
167 if ((f = fopen(fn, "r")) == (FILE *) NULL)
171 if(cp > list+listsize-MAXLIN) {
172 int length = cp - list;
175 list = realloc(list, listsize);
182 while(c == ' ' || c == '\t')
184 if(c == EOF || c == '\n')
192 if ((n = number(c, f)) < 0)
199 if(c != '\t' && c != ' ')
209 if ((n = number(getc(f), f)) < 0)
214 if(c != '\t' && c != ' ')
222 if ((n = number(getc(f), f)) < 0)
225 if(c != '\t' && c != ' ')