]> granicus.if.org Git - fcron/blob - global.h
Updated to-do list
[fcron] / global.h
1 /*
2  * FCRON - periodic command scheduler 
3  *
4  *  Copyright 2000-2012 Thibault Godouet <fcron@free.fr>
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  * 
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  * 
20  *  The GNU General Public License can also be found in the file
21  *  `LICENSE' that comes with the fcron source distribution.
22  */
23
24
25
26 /* 
27    WARNING : this file should not be modified.
28    Compilation's options are in config.h
29 */
30
31 #ifndef __GLOBAL_H__
32 #define __GLOBAL_H__
33
34 /* config.h must be included before every other includes 
35  * (contains the compilation options) */
36 #include "config.h"
37
38
39 #include <ctype.h>
40
41 #ifdef HAVE_ERRNO_H
42 #include <errno.h>
43 #endif
44
45 #ifdef WITH_SELINUX
46 #include <selinux.h>
47 #include <get_context_list.h>
48 #include <selinux/flask.h>
49 #include <selinux/av_permissions.h>
50 #endif
51
52 #ifdef HAVE_GETOPT_H
53 #include <getopt.h>
54 #endif
55
56 #ifdef HAVE_GRP_H
57 #include <grp.h>
58 #endif
59
60 #ifdef HAVE_LIMITS_H
61 #include <limits.h>
62 #endif
63
64 #include <locale.h>
65 #include <nl_types.h>
66 #include <langinfo.h>
67 #include <pwd.h>
68 #include <signal.h>
69
70 #ifdef HAVE_STDARG_H
71 #include <stdarg.h>
72 #endif
73
74 #include <stdio.h>
75 #include <stdlib.h>
76 #include <string.h>
77
78 #ifdef HAVE_STRINGS_H
79 #include <strings.h>
80 #endif
81
82 #ifdef HAVE_SYS_FILE_H
83 #include <sys/file.h>
84 #endif
85
86 #include <sys/stat.h>
87 #include <sys/types.h>
88
89 #ifdef HAVE_SYS_WAIT_H
90 #include <sys/wait.h>
91 #endif
92
93 #ifdef HAVE_SYSLOG_H
94 #include <syslog.h>
95 #endif
96
97 #ifdef TIME_WITH_SYS_TIME
98 #include <time.h>
99 #elif HAVE_SYS_TIME_H
100 #include <sys/time.h>
101 #endif
102
103 #ifdef HAVE_TERMIOS_H
104 #include <termios.h>
105 #endif
106
107 #ifdef HAVE_UNISTD_H
108 #include <unistd.h>
109 #endif
110
111 #ifdef HAVE_FCNTL_H
112 #include <fcntl.h>
113 #elif HAVE_SYS_FCNTL_H
114 #include <sys/fcntl.h>
115 #endif
116
117 #ifdef HAVE_CRED_H
118 #include <cred.h>
119 #endif
120 #ifdef HAVE_UCRED_H
121 #include <ucred.h>
122 #endif
123 #ifdef HAVE_SYS_CRED_H
124 #include <sys/cred.h>
125 #endif
126 #ifdef HAVE_SYS_UCRED_H
127 #include <sys/ucred.h>
128 #endif
129
130 #ifdef WITH_AUDIT
131 #include <libaudit.h>
132 #endif
133
134 #ifdef HAVE_LIBPAM
135 #include "pam.h"
136 #endif
137
138 #include "bitstring.h"     /* bit arrays */
139 #include "option.h"        /* manage fcrontab's options */
140 #include "env_list.h"      /* manage fcrontab's environment variable lists */
141 #include "cl.h"            /* Cron Line cl_t type and associated functions */
142
143 /* you should not change this (nor need to do it) */
144 #define ERR     -1           
145 #define OK       0
146
147 /* options for local functions */
148 #define STD 0
149
150 /* macros */
151 #ifndef HAVE_SETEUID
152 #define seteuid(arg) setresuid(-1,(arg),-1)
153 #endif
154
155 #ifndef HAVE_SETEGID
156 #define setegid(arg) setresgid(-1,(arg),-1)
157 #endif
158
159 #define Skip_blanks(PTR) \
160         while((*(PTR) == ' ') || (*(PTR) == '\t')) \
161             (PTR)++;
162
163 #define Overwrite(x) \
164         do {                     \
165           register char *__xx__; \
166           if ((__xx__=(x)))      \
167             while (*__xx__)      \
168               *__xx__++ = '\0';  \
169         } while (0)
170
171 #define debug if(debug_opt) Debug
172
173 typedef struct cf_t {
174     struct cf_t  *cf_next;
175     struct cl_t  *cf_line_base;
176     char         *cf_user;      /* user-name                                 */
177     env_list_t   *cf_env_list;  /* list of all parsed env var                */
178     int           cf_running;   /* number of jobs running                    */
179     signed char   cf_tzdiff;    /* time diff between system and local hour   */
180 #ifdef WITH_SELINUX
181     security_context_t cf_user_context;
182     security_context_t cf_file_context;
183 #endif
184 } cf_t;
185
186
187 typedef struct job_t {
188     struct cl_t  *j_line;
189     struct job_t   *j_next;
190 } job_t;
191
192
193 #if SIZEOF_TIME_T == SIZEOF_SHORT_INT
194 #define ATTR_SIZE_TIMET "h"
195 #define CAST_TIMET_PTR (short int *)
196 #elif SIZEOF_TIME_T == SIZEOF_INT
197 #define ATTR_SIZE_TIMET ""
198 #define CAST_TIMET_PTR (int *)
199 #elif SIZEOF_TIME_T == SIZEOF_LONG_INT
200 #define ATTR_SIZE_TIMET "l"
201 #define CAST_TIMET_PTR (long int *)
202 #elif SIZEOF_TIME_T == SIZEOF_LONG_LONG_INT
203 #define ATTR_SIZE_TIMET "ll"
204 #define CAST_TIMET_PTR (long long int *)
205 #else
206 #error "SIZEOF_TIME_T does not correspond with a known format."
207 #endif
208
209 #if SIZEOF_PID_T == SIZEOF_SHORT_INT
210 #define ATTR_SIZE_PIDT "h"
211 #define CAST_PIDT_PTR (short int *)
212 #elif SIZEOF_PID_T == SIZEOF_INT
213 #define ATTR_SIZE_PIDT ""
214 #define CAST_PIDT_PTR (int *)
215 #elif SIZEOF_PID_T == SIZEOF_LONG_INT
216 #define ATTR_SIZE_PIDT "l"
217 #define CAST_PIDT_PTR (long int *)
218 #elif SIZEOF_PID_T == SIZEOF_LONG_LONG_INT
219 #define ATTR_SIZE_PIDT "ll"
220 #define CAST_PIDT_PTR (long long int *)
221 #else
222 #error "SIZEOF_PID_T does not correspond with a known format."
223 #endif
224
225
226 /* local header files : we include here the headers which may use some types defined
227  *                      above. */
228
229 /* constants for fcrontabs needed to load and save the fcrontabs to disk */
230 #include "save.h"
231 /* log part */
232 #include "log.h"
233 /* functions used by fcrontab, fcrondyn, and fcron */
234 #include "subs.h"
235
236
237 #endif /* __GLOBAL_H__ */
238