]> granicus.if.org Git - fcron/blob - global.h
Initial revision
[fcron] / global.h
1 /*
2  * FCRON - periodic command scheduler 
3  *
4  *  Copyright 2000 Thibault Godouet <sphawk@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 /* global.h */
25
26
27 #ifndef __GLOBALH__
28 #define __GLOBALH__
29
30 #include <ctype.h>
31 #include <errno.h>
32 #include <getopt.h>
33 #include <pwd.h>
34 #include <signal.h>
35 #include <stdarg.h>
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <string.h>
39 #include <sys/file.h>
40 #include <sys/stat.h>
41 #include <sys/types.h>
42 #include <sys/wait.h>
43 #include <syslog.h>
44 #include <time.h>
45 #include <unistd.h>
46 #include <fcntl.h>
47
48 #include "bitstring.h"         
49
50 #include "config.h"
51
52
53
54 /* none configurable constants */
55 #define FILEVERSION "001"  /* syntax's version of fcrontabs : 
56                             * must have a length of 3 characters */
57
58
59
60 /* macros */
61 #define arysize(ary)    (sizeof(ary)/sizeof((ary)[0]))
62
63 #define Alloc(ptr, type) \
64         if( (ptr = calloc(1, sizeof(type))) == NULL ) { \
65             fprintf(stderr, "Could not calloc."); \
66             exit(EXIT_ERR); \
67         }
68
69 #define debug if(debug_opt) Debug
70
71 typedef struct env_t {
72     char         *e_name;       /* env name                             */
73     char         *e_val;        /* env value                            */
74     struct env_t *e_next;
75 } env_t ;
76
77 typedef struct CF {
78     struct CF    *cf_next;
79     struct CL    *cf_line_base;
80     char         *cf_user;      /* user-name                            */
81     char         *cf_mailto;    /* mail output's to mail_user           */
82     struct env_t *cf_env_base;  /* list of all env variables to set     */
83     int          cf_running;    /* number of jobs running               */
84 } CF;
85
86 /* warning : do not change the order of the members of this structure
87  *   because some tests made are dependent to that order */
88 typedef struct CL {
89     struct CL    *cl_next;
90     char         *cl_shell;     /* shell command                        */
91     pid_t        cl_pid;        /* running pid, 0, or armed (-1)        */
92     pid_t        cl_mailpid;    /* mailer pid or 0                      */
93     int          cl_mailfd;     /* running pid is for mail              */
94     int          cl_mailpos;    /* 'empty file' size                    */
95     /* see bitstring(3) man page for more details */
96     bitstr_t     bit_decl(cl_mins, 60);  /* 0-59                        */
97     bitstr_t     bit_decl(cl_hrs, 24);  /* 0-23                         */
98     bitstr_t     bit_decl(cl_days, 32); /* 1-31                         */
99     bitstr_t     bit_decl(cl_mons, 12); /* 0-11                         */
100     bitstr_t     bit_decl(cl_dow, 8);   /* 0-7, 0 and 7 are both Sunday */
101     time_t       cl_timefreq;    /* Run every n min                     */
102     short int    cl_runfreq;     /* Run once every n matches            */
103     time_t       cl_remain;      /* remaining until next execution      */
104     time_t       cl_nextexe;     /* time and date of the next execution */
105 } CL;
106
107
108
109 #endif /* __GLOBALH__ */
110