]> granicus.if.org Git - fcron/blob - global.h
*** empty log message ***
[fcron] / global.h
1 /*
2  * FCRON - periodic command scheduler 
3  *
4  *  Copyright 2000-2001 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  /* $Id: global.h,v 1.22 2001-01-12 21:43:35 thib Exp $ */
25
26
27 /* 
28    WARNING : this file should not be modified.
29    Compilation's options are in config.h
30 */
31
32 #ifndef __GLOBALH__
33 #define __GLOBALH__
34
35 /* config.h must be included before every other includes */
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 HAVE_GETOPT_H
46 #include <getopt.h>
47 #endif
48
49 #include <pwd.h>
50 #include <signal.h>
51
52 #ifdef HAVE_STDARG_H
53 #include <stdarg.h>
54 #endif
55
56 #include <stdio.h>
57 #include <stdlib.h>
58 #include <string.h>
59
60 #ifdef HAVE_SYS_FILE_H
61 #include <sys/file.h>
62 #endif
63
64 #include <sys/stat.h>
65 #include <sys/types.h>
66
67 #ifdef HAVE_SYS_WAIT_H
68 #include <sys/wait.h>
69 #endif
70
71 #ifdef HAVE_SYSLOG_H
72 #include <syslog.h>
73 #endif
74
75 #ifdef TIME_WITH_SYS_TIME
76 #include <time.h>
77 #elif HAVE_SYS_TIME_H
78 #include <sys/time.h>
79 #endif
80
81 #ifdef HAVE_UNISTD_H
82 #include <unistd.h>
83 #endif
84
85 #ifdef HAVE_FCNTL_H
86 #include <fcntl.h>
87 #elif HAVE_SYS_FCNTL_H
88 #include <sys/fcntl.h>
89 #endif
90
91 #ifdef HAVE_LIMITS_H
92 #include <limits.h>
93 #endif
94
95 #include "bitstring.h"         
96 #include "option.h"
97
98
99 #define FILEVERSION "016"  /* syntax's version of fcrontabs : 
100                             * must have a length of 3 characters */
101
102 /* you should not change this (nor need to do it) */
103 #define ERR     -1           
104 #define OK       0
105
106
107 /* macros */
108 #define Alloc(ptr, type) \
109         if( (ptr = calloc(1, sizeof(type))) == NULL ) \
110             die_e("Could not calloc.");
111
112 #define debug if(debug_opt) Debug
113
114 typedef struct env_t {
115     char         *e_val;        /* env value                            */
116     struct env_t *e_next;
117 } env_t ;
118
119 typedef struct CF {
120     struct CF    *cf_next;
121     struct CL    *cf_line_base;
122     char         *cf_user;      /* user-name                            */
123     struct env_t *cf_env_base;  /* list of all env variables to set     */
124     int          cf_running;    /* number of jobs running               */
125 } CF;
126
127 /* warning : do not change the order of the members of this structure
128  *   because some tests made are dependent to that order */
129 typedef struct CL {
130     struct CL     *cl_next;
131     struct CF     *cl_file;       /* the file in which the line is        */
132     unsigned char  cl_option[3];  /* options for that line (see option.h) */
133     char          *cl_shell;      /* shell command                        */
134     unsigned char  cl_numexe;     /* num of entries in lavg/serial queue  */
135     unsigned char  cl_lavg[3];    /* load averages needed (1, 5, 15 mins) */
136     time_t         cl_until;      /* timeout of the wait for a lavg value */
137     char           cl_nice;       /* nice value to control priority       */
138     uid_t          cl_runas;      /* determine permissions of the job     */
139     uid_t          cl_mailto;     /* mail output to cl_mailto             */
140     time_t         cl_nextexe;    /* time and date of the next execution  */
141     unsigned short cl_remain;     /* remaining until next execution       */
142     time_t         cl_timefreq;   /* Run every n seconds                  */
143     unsigned short cl_runfreq;    /* Run once every n matches             */
144     /* see bitstring(3) man page for more details */
145     bitstr_t       bit_decl(cl_mins, 60); /* 0-59                         */
146     bitstr_t       bit_decl(cl_hrs, 24);  /* 0-23                         */
147     bitstr_t       bit_decl(cl_days, 32); /* 1-31                         */
148     bitstr_t       bit_decl(cl_mons, 12); /* 0-11                         */
149     bitstr_t       bit_decl(cl_dow, 8);   /* 0-7, 0 and 7 are both Sunday */
150 } CL;
151
152 typedef struct job {
153     struct CL    *j_line;
154     struct job   *j_next;
155 } job;
156
157 typedef struct lavg {
158     struct CL  *l_line;  
159     time_t      l_until;   /* the timeout of the wait for load averages */
160 } lavg;
161
162 typedef struct exe {
163     struct CL  *e_line;
164     pid_t       e_pid;
165 } exe;
166
167 #endif /* __GLOBALH__ */
168