]> granicus.if.org Git - fcron/blob - global.h
support of lavg
[fcron] / global.h
1 /*
2  * FCRON - periodic command scheduler 
3  *
4  *  Copyright 2000 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.17 2000-08-28 17:59:40 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 #include <ctype.h>
36 #include <errno.h>
37 #ifdef __linux__
38 #include <getopt.h>
39 #endif
40 #include <pwd.h>
41 #include <signal.h>
42 #include <stdarg.h>
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <string.h>
46 #include <sys/file.h>
47 #include <sys/stat.h>
48 #include <sys/types.h>
49 #include <sys/wait.h>
50 #include <syslog.h>
51 #include <time.h>
52 #include <unistd.h>
53 #include <fcntl.h>
54
55 #include "config.h"
56 #include "bitstring.h"         
57 #include "option.h"
58
59
60 #define FILEVERSION "012"  /* syntax's version of fcrontabs : 
61                             * must have a length of 3 characters */
62
63 /* you should not change this (nor need to do it) */
64 #define ERR     -1           
65 #define OK       0
66
67
68 /* macros */
69 #define Alloc(ptr, type) \
70         if( (ptr = calloc(1, sizeof(type))) == NULL ) \
71             die_e("Could not calloc.");
72
73 #define debug if(debug_opt) Debug
74
75 typedef struct env_t {
76     char         *e_val;        /* env value                            */
77     struct env_t *e_next;
78 } env_t ;
79
80 typedef struct CF {
81     struct CF    *cf_next;
82     struct CL    *cf_line_base;
83     char         *cf_user;      /* user-name                            */
84     struct env_t *cf_env_base;  /* list of all env variables to set     */
85     int          cf_running;    /* number of jobs running               */
86 } CF;
87
88 /* warning : do not change the order of the members of this structure
89  *   because some tests made are dependent to that order */
90 typedef struct CL {
91     struct CL     *cl_next;
92     struct CF     *cl_file;       /* the file in which the line is        */
93     unsigned short cl_option;     /* options for that line (see option.h) */
94     char          *cl_shell;      /* shell command                        */
95     char           cl_lavg[3];    /* load averages needed (1, 5, 15 mins) */
96     time_t         cl_until;      /* timeout of the wait for a lavg value */
97     char           cl_nice;       /* nice value to control priority       */
98     uid_t          cl_runas;      /* determine permissions of the job     */
99     uid_t          cl_mailto;     /* mail output to cl_mailto             */
100     pid_t          cl_pid;        /* running pid, 0, or armed (-1)        */
101     time_t         cl_nextexe;    /* time and date of the next execution  */
102     short int      cl_remain;     /* remaining until next execution       */
103     time_t         cl_timefreq;   /* Run every n seconds                  */
104     short int      cl_runfreq;    /* Run once every n matches             */
105     /* see bitstring(3) man page for more details */
106     bitstr_t       bit_decl(cl_mins, 60); /* 0-59                         */
107     bitstr_t       bit_decl(cl_hrs, 24);  /* 0-23                         */
108     bitstr_t       bit_decl(cl_days, 32); /* 1-31                         */
109     bitstr_t       bit_decl(cl_mons, 12); /* 0-11                         */
110     bitstr_t       bit_decl(cl_dow, 8);   /* 0-7, 0 and 7 are both Sunday */
111 } CL;
112
113 typedef struct job {
114     struct CL    *j_line;
115     struct job   *j_next;
116 } job;
117
118 typedef struct lavg {
119     struct CL  *l_line;  
120     time_t      l_since;   /* the time of the line admission in the queue */
121 } lavg;
122
123 #endif /* __GLOBALH__ */
124