00001 /* tab.h - in-core crontab data Author: Kees J. Bot 00002 * 7 Dec 1996 00003 */ 00004 #ifndef TAB__H 00005 #define TAB__H 00006 00007 #include <sys/types.h> 00008 #include <limits.h> 00009 00010 struct crontab; 00011 00012 typedef unsigned char bitmap_t[8]; 00013 00014 typedef struct cronjob { /* One entry in a crontab file */ 00015 struct cronjob *next; 00016 struct crontab *tab; /* Associated table file. */ 00017 bitmap_t min; /* Minute (0-59) */ 00018 bitmap_t hour; /* Hour (0-23) */ 00019 bitmap_t mday; /* Day of the month (1-31) */ 00020 bitmap_t mon; /* Month (1-12) */ 00021 bitmap_t wday; /* Weekday (0-7 with 0 = 7 = Sunday) */ 00022 char *user; /* User to run it as (nil = root) */ 00023 char *cmd; /* Command to run */ 00024 time_t rtime; /* When next to run */ 00025 char do_mday; /* True iff mon or mday is not '*' */ 00026 char do_wday; /* True iff wday is not '*' */ 00027 char late; /* True iff the job is late */ 00028 char atjob; /* True iff it is an AT job */ 00029 pid_t pid; /* Process-id of job if nonzero */ 00030 } cronjob_t; 00031 00032 typedef struct crontab { 00033 struct crontab *next; 00034 char *file; /* Crontab name */ 00035 char *user; /* Owner if non-null */ 00036 time_t mtime; /* Last modified time */ 00037 cronjob_t *jobs; /* List of jobs in the file */ 00038 char *data; /* File data */ 00039 int current; /* True if current, i.e. file exists */ 00040 } crontab_t; 00041 00042 crontab_t *crontabs; /* All crontabs. */ 00043 00044 /* A time as far in the future as possible. */ 00045 #define NEVER ((time_t) ((time_t) -1 < 0 ? LONG_MAX : ULONG_MAX)) 00046 00047 /* Don't trust crontabs bigger than this: */ 00048 #define TAB_MAX ((sizeof(int) == 2 ? 8 : 128) * 1024) 00049 00050 /* Pid if no process running, or a pid value you'll never see. */ 00051 #define IDLE_PID ((pid_t) 0) 00052 #define NO_PID ((pid_t) -1) 00053 00054 /* Bitmap operations. */ 00055 #define bit_set(map, n) ((void) ((map)[(n) >> 3] |= (1 << ((n) & 7)))) 00056 #define bit_clr(map, n) ((void) ((map)[(n) >> 3] &= ~(1 << ((n) & 7)))) 00057 #define bit_isset(map, n) (!!((map)[(n) >> 3] & (1 << ((n) & 7)))) 00058 00059 /* Functions. */ 00060 void tab_parse(char *file, char *user); 00061 void tab_find_atjob(char *atdir); 00062 void tab_purge(void); 00063 void tab_reap_job(pid_t pid); 00064 void tab_reschedule(cronjob_t *job); 00065 cronjob_t *tab_nextjob(void); 00066 void tab_print(FILE *fp); 00067 00068 #endif /* TAB__H */ 00069 00070 /* 00071 * $PchId: tab.h,v 1.3 2000/07/17 07:57:27 philip Exp $ 00072 */
1.5.8