1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 #ifndef _ANACRON_GLOBAL_H
26 #define _ANACRON_GLOBAL_H
27
28
29
30 #define SYSLOG_FACILITY LOG_CRON
31 #define EXPLAIN_LEVEL LOG_NOTICE
32 #define COMPLAIN_LEVEL LOG_ERR
33 #define DEBUG_LEVEL LOG_DEBUG
34
35
36 #define SENDMAIL "/usr/sbin/sendmail"
37
38
39
40
41 #define FAILURE_EXIT 1
42 #define MAX_MSG 150
43
44 #include <signal.h>
45 #include <time.h>
46 #include "anacron-paths.h"
47 #include "cronie_common.h"
48
49
50
51 struct env_rec1 {
52 char *assign;
53
54 struct env_rec1 *next;
55 };
56 typedef struct env_rec1 env_rec;
57
58 struct job_rec1 {
59 int period;
60 int named_period;
61 int delay;
62 char *ident;
63 char *command;
64 char *mailto;
65
66 int tab_line;
67 int arg_num;
68 int timestamp_fd;
69 int input_fd;
70 int output_fd;
71 off_t mail_header_size;
72 pid_t job_pid;
73 pid_t mailer_pid;
74 int drop_job;
75
76 struct job_rec1 *next;
77 env_rec *prev_env_rec;
78 };
79 typedef struct job_rec1 job_rec;
80
81
82
83 extern pid_t primary_pid;
84 extern char *program_name;
85 extern char *anacrontab;
86 extern char *spooldir;
87 extern int old_umask;
88 extern sigset_t old_sigmask;
89 extern int serialize,force,update_only,now,no_daemon,quiet,testing_only;
90 extern int day_now;
91 extern int year,month,day_of_month;
92 extern int in_background;
93
94 extern job_rec *first_job_rec;
95 extern env_rec *first_env_rec;
96
97 extern char **job_args;
98 extern int job_nargs;
99
100 extern int njobs;
101 extern job_rec **job_array;
102
103 extern int running_jobs,running_mailers;
104
105 extern int complaints;
106
107 extern time_t start_sec;
108
109
110 extern int range_start;
111 extern int range_stop;
112
113
114 extern int preferred_hour;
115
116
117
118
119 int xopen(int fd, const char *file_name, int flags);
120 void xclose(int fd);
121 pid_t xfork(void);
122
123 #ifdef __GNUC__
124 #define PRINTF_FORMAT(n, m) \
125 __attribute__ ((format (printf, n, m)))
126 #else
127 #define PRINTF_FORMAT(n, m)
128 #endif
129
130
131 void explain(const char *fmt, ...)PRINTF_FORMAT(1,2);
132 void explain_e(const char *fmt, ...)PRINTF_FORMAT(1,2);
133 void complain(const char *fmt, ...)PRINTF_FORMAT(1,2);
134 void complain_e(const char *fmt, ...)PRINTF_FORMAT(1,2);
135 void die(const char *fmt, ...)PRINTF_FORMAT(1,2) ATTRIBUTE_NORETURN;
136 void die_e(const char *fmt, ...)PRINTF_FORMAT(1,2) ATTRIBUTE_NORETURN;
137 void xdebug(const char *fmt, ...)PRINTF_FORMAT(1,2);
138 void xdebug_e(const char *fmt, ...)PRINTF_FORMAT(1,2);
139 void xcloselog(void);
140
141 #ifdef DEBUG
142 #define Debug(args) xdebug args
143 #define Debug_e(args) xdebug_e args
144 #else
145 #define Debug(args) (void)(0)
146 #define Debug_e(args) (void)(0)
147 #endif
148
149
150 void read_tab(int cwd);
151 void arrange_jobs(void);
152
153
154 int consider_job(job_rec *jr);
155 void unlock(job_rec *jr);
156 void update_timestamp(job_rec *jr);
157 void fake_job(job_rec *jr);
158
159
160 void tend_children();
161 void launch_job(job_rec *jr);
162
163 #endif