ArmJob: fixed comparison btw MaxWait and NotUntil
[yacron.git] / defs.h
blob1fd065070f5a87739518c6dc6eefe84ec3302702
2 /*
3 * DEFS.H
5 * Copyright 1994-1998 Matthew Dillon (dillon@backplane.com)
6 * Copyright 2009 James Pryor <profjim@jimpryor.net>
7 * May be distributed under the GNU General Public License
8 */
10 #include <sys/types.h>
11 #include <sys/stat.h>
12 #include <sys/ioctl.h>
13 #include <sys/wait.h>
14 #include <sys/resource.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <stdarg.h>
18 #include <string.h>
19 #include <errno.h>
20 #define __USE_XOPEN
21 #include <time.h>
22 #include <dirent.h>
23 #include <fcntl.h>
24 #include <pwd.h>
25 #include <unistd.h>
26 #include <grp.h>
27 #include <syslog.h>
28 #include <signal.h>
29 #include <getopt.h>
30 #include <err.h>
31 #include <limits.h>
33 #define Prototype extern
34 #define arysize(ary) (sizeof(ary)/sizeof((ary)[0]))
36 #ifndef CRONTABS
37 #define CRONTABS "/var/spool/cron/crontabs"
38 #endif
39 #ifndef TIMESTAMPS
40 #define TIMESTAMPS "/var/spool/cron/timestamps"
41 #endif
42 #ifndef TIMESTAMP_FMT
43 #define TIMESTAMP_FMT "%Y-%m-%d %H:%M"
44 #endif
45 #ifndef SCRONTABS
46 #define SCRONTABS "/etc/cron.d"
47 #endif
48 #ifndef TMPDIR
49 #define TMPDIR "/tmp"
50 #endif
51 #ifndef LOG_FILE
52 #define LOG_FILE "/var/log/crond.log"
53 #endif
54 #ifndef LOG_IDENT
55 #define LOG_IDENT "crond"
56 #endif
57 #ifndef LOG_DATE_FMT
58 #define LOG_DATE_FMT "%b %e %H:%M:%S %%s " LOG_IDENT ": "
59 #endif
60 #ifndef OPEN_MAX
61 #define OPEN_MAX 256
62 #endif
64 #ifndef SENDMAIL
65 #define SENDMAIL "/usr/sbin/sendmail"
66 #endif
67 #ifndef SENDMAIL_ARGS
68 #define SENDMAIL_ARGS "-t", "-oem", "-i"
69 #endif
70 #ifndef CRONUPDATE
71 #define CRONUPDATE "cron.update"
72 #endif
73 #ifndef MAXLINES
74 #define MAXLINES 256 /* max lines in non-root crontabs */
75 #endif
76 #ifndef PATH_VI
77 #define PATH_VI "/usr/bin/vi" /* location of vi */
78 #endif
80 #define HOURLY_FREQ 60 * 60
81 #define DAILY_FREQ 24 * HOURLY_FREQ
82 #define WEEKLY_FREQ 7 * DAILY_FREQ
83 #define MONTHLY_FREQ 30 * DAILY_FREQ
84 #define YEARLY_FREQ 365 * DAILY_FREQ
86 #define ID_TAG "ID="
87 #define WAIT_TAG "AFTER="
88 #define FREQ_TAG "FREQ="
90 #define VERSION "V4.0pre"
92 typedef struct CronFile {
93 struct CronFile *cf_Next;
94 struct CronLine *cf_LineBase;
95 char *cf_DPath; /* Directory path to cronfile */
96 char *cf_FileName; /* Name of cronfile */
97 char *cf_UserName; /* username to execute jobs as */
98 int cf_Ready; /* bool: one or more jobs ready */
99 int cf_Running; /* bool: one or more jobs running */
100 int cf_Deleted; /* marked for deletion, ignore */
101 } CronFile;
103 typedef struct CronLine {
104 struct CronLine *cl_Next;
105 char *cl_Shell; /* shell command */
106 char *cl_Description; /* either "<cl_Shell>" or "job <cl_JobName>" */
107 char *cl_JobName; /* job name, if any */
108 char *cl_Timestamp; /* path to timestamp file, if cl_Freq defined */
109 struct CronWaiter *cl_Waiters;
110 struct CronNotifier *cl_Notifs;
111 int cl_Freq; /* 0 (use arrays), minutes, -1 (noauto), -2 (startup) */
112 int cl_Delay; /* defaults to cl_Freq or hourly */
113 time_t cl_LastRan;
114 time_t cl_NotUntil;
115 int cl_Pid; /* running pid, 0, or armed (-1), or waiting (-2) */
116 int cl_MailFlag; /* running pid is for mail */
117 int cl_MailPos; /* 'empty file' size */
118 char cl_Mins[60]; /* 0-59 */
119 char cl_Hrs[24]; /* 0-23 */
120 char cl_Days[32]; /* 1-31 */
121 char cl_Mons[12]; /* 0-11 */
122 char cl_Dow[7]; /* 0-6, beginning sunday */
123 } CronLine;
125 typedef struct CronWaiter {
126 struct CronWaiter *cw_Next;
127 struct CronNotifier *cw_Notifier;
128 struct CronLine *cw_NotifLine;
129 short cw_Flag;
130 int cw_MaxWait;
131 } CronWaiter;
133 typedef struct CronNotifier {
134 struct CronNotifier *cn_Next;
135 struct CronWaiter *cn_Waiter;
136 } CronNotifier;
138 // #define RUN_RANOUT 1
139 // #define RUN_RUNNING 2
140 // #define RUN_FAILED 3
142 #include "protos.h"