* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: conf.c,v 1.43 2001-05-15 00:46:00 thib Exp $ */
+ /* $Id: conf.c,v 1.44 2001-05-24 19:59:35 thib Exp $ */
#include "fcron.h"
#include "conf.h"
if ( new_l->cl_runfreq == old_l->cl_runfreq )
new_l->cl_remain = old_l->cl_remain;
- new_l->cl_nextexe = old_l->cl_nextexe;
+ /* check if there is a change about the tz diff */
+ if ( (new_l->cl_file->cf_tzdiff !=
+ old_l->cl_file->cf_tzdiff) &&
+ (old_l->cl_nextexe - old_l->cl_file->cf_tzdiff
+ + new_l->cl_file->cf_tzdiff > now) )
+ new_l->cl_nextexe = old_l->cl_nextexe
+ - old_l->cl_file->cf_tzdiff
+ + new_l->cl_file->cf_tzdiff;
+ else
+ new_l->cl_nextexe = old_l->cl_nextexe;
insert_nextexe(new_l);
if (debug_opt) {
}
break;
+ case S_TZDIFF_T:
+ /* time diff between local (real) and system hour */
+ if ( read(fileno(ff), &bufi, size) < size ) {
+ error_e("Error while reading tzdiff field");
+ goto err;
+ }
+ cf->cf_tzdiff = (signed char) bufi;
+ break;
+
case S_SHELL_T:
if ( read_strn(fileno(ff), &cl->cl_shell, size) != OK ) {
error_e("Error while reading shell field");
/* S_USER_T *must* be the 3rd field of a binary fcrontab */
Save_lint(f, S_TIMEDATE_T, now);
+ /* Save the time diff between local (real) and system hour (if any) */
+ if ( file->cf_tzdiff != 0 )
+ Save_lint(f, S_TZDIFF_T, file->cf_tzdiff);
+
/* env variables, */
for (env = file->cf_env_base; env; env = env->e_next)
Save_str(f, S_ENVVAR_T, env->e_val);
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: database.c,v 1.51 2001-05-15 00:46:54 thib Exp $ */
+ /* $Id: database.c,v 1.52 2001-05-24 19:59:47 thib Exp $ */
#include "fcron.h"
#include "database.h"
if ( is_strict(line->cl_option) && line->cl_runfreq == 1) {
struct tm *ft;
struct tm ftime;
- time_t end_of_cur_int = 0;
+ time_t begin_of_cur_int, end_of_cur_int = 0;
- ft = localtime(&line->cl_nextexe);
+ /* handle timezone differences */
+ begin_of_cur_int = line->cl_nextexe - (line->cl_file->cf_tzdiff*3600);
+
+ ft = localtime( &begin_of_cur_int );
/* localtime() function seem to return every time the same pointer :
it resets our previous changes, so we need to prevent it
goto_non_matching(line, &ftime, END_OF_INTERVAL);
- end_of_cur_int = mktime(&ftime);
+ end_of_cur_int = mktime(&ftime) + (line->cl_file->cf_tzdiff * 3600);
if ((line->cl_until > 0) && (line->cl_until + now < end_of_cur_int))
lavg_array[lavg_num].l_until = line->cl_until + now;
if (option != END_OF_INTERVAL) {
if (debug_opt)
set_wday(ftime);
- debug(" %s beginning of next period %d/%d/%d wday:%d %02d:%02d",
- line->cl_shell, (ftime->tm_mon + 1), ftime->tm_mday,
- (ftime->tm_year + 1900), ftime->tm_wday,
- ftime->tm_hour, ftime->tm_min);
+ debug(" %s beginning of next period %d/%d/%d wday:%d %02d:%02d "
+ "(tzdiff=%d)", line->cl_shell, (ftime->tm_mon + 1),
+ ftime->tm_mday, (ftime->tm_year + 1900), ftime->tm_wday,
+ ftime->tm_hour, ftime->tm_min, line->cl_file->cf_tzdiff);
return;
}
}
}
- debug(" %s %s %d/%d/%d wday:%d %02d:%02d", line->cl_shell,
+ debug(" %s %s %d/%d/%d wday:%d %02d:%02d (tzdiff=%d)",line->cl_shell,
(option == STD) ? "first non matching" : "end of interval",
- (ftime->tm_mon + 1), ftime->tm_mday,
- (ftime->tm_year + 1900), ftime->tm_wday,
- ftime->tm_hour, ftime->tm_min);
+ (ftime->tm_mon + 1), ftime->tm_mday, (ftime->tm_year + 1900),
+ ftime->tm_wday, ftime->tm_hour, ftime->tm_min,
+ line->cl_file->cf_tzdiff);
return;
}
}
register char has_changed = 0;
/* to prevent from invinite loop with unvalid lines : */
short int year_limit = MAXYEAR_SCHEDULE_TIME;
+ /* timezone difference */
+ time_t now_tz = now - (line->cl_file->cf_tzdiff * 3600);
- ft = localtime(&now);
+ ft = localtime(&now_tz);
/* localtime() function seem to return every time the same pointer :
it resets our previous changes, so we need to prevent it
}
ftime.tm_min = i;
- set_cl_nextexe:
- line->cl_nextexe = mktime(&ftime);
+ set_cl_nextexe:
+ /* set cl_nextexe (handle the timezone differences) */
+ line->cl_nextexe = mktime(&ftime) + (line->cl_file->cf_tzdiff * 3600);
if ( option != NO_GOTO )
- debug(" cmd: %s next exec %d/%d/%d wday:%d %02d:%02d",
- line->cl_shell, (ftime.tm_mon + 1), ftime.tm_mday,
- (ftime.tm_year + 1900), ftime.tm_wday,
- ftime.tm_hour, ftime.tm_min);
+ debug(" cmd: %s next exec %d/%d/%d wday:%d %02d:%02d "
+ "(tzdiff=%d)", line->cl_shell, (ftime.tm_mon + 1),
+ ftime.tm_mday, (ftime.tm_year + 1900), ftime.tm_wday,
+ ftime.tm_hour, ftime.tm_min, line->cl_file->cf_tzdiff);
}
else {
/* set the time of the next execution and send a mail to tell user his job
* has not run if necessary */
{
- time_t next_period = 0;
+ time_t previous_period = 0, next_period = 0;
struct tm *ft = NULL;
struct tm ftime, last_nextexe;
char set_next_exe_opt = 0;
/* // */
if (context == SYSDOWN) {
- ft = localtime(&line->cl_nextexe);
+ /* handle timezone differences */
+ previous_period = line->cl_nextexe - (line->cl_file->cf_tzdiff * 3600);
set_next_exe_opt = NO_GOTO;
}
else {
- ft = localtime(&now);
+ previous_period = now - (line->cl_file->cf_tzdiff * 3600);
set_next_exe_opt = NO_GOTO_LOG;
}
-
+ ft = localtime(&previous_period);
+
/* localtime() function seem to return every time the same pointer :
it resets our previous changes, so we need to prevent it
( localtime() is used in the debug() function) */
ftime.tm_sec = 0;
goto_non_matching(line, &ftime, STD);
- next_period = mktime(&ftime);
+ next_period = mktime(&ftime) + (line->cl_file->cf_tzdiff * 3600);
set_next_exe(line, set_next_exe_opt);
if ( line->cl_nextexe >= next_period ) {
lavg_array[i].l_line->cl_shell);
/* set time of the next execution and send a mail if needed */
- if ( is_notice_notrun(lavg_array[i].l_line->cl_option) )
+ if ( is_td(lavg_array[i].l_line->cl_option) &&
+ is_notice_notrun(lavg_array[i].l_line->cl_option) )
set_next_exe_notrun(lavg_array[i].l_line, LAVG);
else
set_next_exe(lavg_array[i].l_line, NO_GOTO_LOG);
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: fileconf.c,v 1.45 2001-05-17 00:53:29 thib Exp $ */
+ /* $Id: fileconf.c,v 1.46 2001-05-24 19:57:10 thib Exp $ */
#include "fcrontab.h"
#include "fileconf.h"
ptr++;
}
- if ( strcmp(opt_name, "s") == 0 || strcmp(opt_name, "serial") == 0 ) {
+ /* global options for a file */
+ if ( strcmp(opt_name, "tzdiff") == 0 ) {
+ char negative = 0;
+
+ if ( ! in_brackets )
+ Handle_err;
+ if ( *ptr == '-' ) {
+ negative = 1;
+ ptr++;
+ }
+ if ( (ptr = get_num(ptr, &i, 24, 0, NULL)) == NULL )
+ Handle_err;
+ if ( negative )
+ cl->cl_file->cf_tzdiff = (- i);
+ else
+ cl->cl_file->cf_tzdiff = i;
+
+ if (debug_opt)
+ fprintf(stderr, " Opt : \"%s\" (-)%d\n", opt_name, i);
+ }
+
+
+ /* options related to a line (or a set of lines) */
+ else if(strcmp(opt_name, "s") == 0 || strcmp(opt_name, "serial") == 0){
if ( in_brackets && (ptr = get_bool(ptr, &i)) == NULL )
Handle_err;
if (i == 0 )
Handle_err;
i = 0;
- while ( isalnum(*ptr) )
+ while ( isalnum(*ptr) && i + 1 < sizeof(buf) )
buf[i++] = *ptr++;
if ( strcmp(buf, "\0") == 0 )
clear_mail(cl->cl_option);
Handle_err;
cl->cl_nice = (char)i;
if (debug_opt)
- fprintf(stderr, " Opt : \"%s\" %d\n", opt_name, i);
+ fprintf(stderr, " Opt : \"%s\" (-)%d\n", opt_name, i);
}
else if(strcmp(opt_name, "runas") == 0) {
/* S_USER_T *must* be the 3rd field of a binary fcrontab */
Save_lint(f, S_TIMEDATE_T, 0);
+ /* Save the time diff between local (real) and system hour (if any) */
+ if ( file->cf_tzdiff != 0 )
+ Save_lint(f, S_TZDIFF_T, file->cf_tzdiff);
+
/* env variables, */
for (env = file->cf_env_base; env; env = env->e_next)
Save_str(f, S_ENVVAR_T, env->e_val);
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: global.h,v 1.26 2001-05-17 00:57:26 thib Exp $ */
+ /* $Id: global.h,v 1.27 2001-05-24 19:59:12 thib Exp $ */
/*
typedef struct CF {
struct CF *cf_next;
struct CL *cf_line_base;
- char *cf_user; /* user-name */
- struct env_t *cf_env_base; /* list of all env variables to set */
- int cf_running; /* number of jobs running */
+ char *cf_user; /* user-name */
+ struct env_t *cf_env_base; /* list of all env variables to set */
+ int cf_running; /* number of jobs running */
+ signed char cf_tzdiff; /* time diff between system and local hour */
} CF;
* in the save/load binary fcrontab functions */
typedef struct CL {
struct CL *cl_next;
- struct CF *cl_file; /* the file in which the line is */
- unsigned char cl_option[OPTION_SIZE]; /* line's option (see option.h)*/
- char *cl_shell; /* shell command */
- unsigned char cl_numexe; /* num of entries in lavg/serial queue */
- unsigned char cl_lavg[LAVG_SIZE];/*load averages needed (1,5,15 mins)*/
- time_t cl_until; /* timeout of the wait for a lavg value */
- char cl_nice; /* nice value to control priority */
- char *cl_runas; /* determine permissions of the job */
- char *cl_mailto; /* mail output to cl_mailto */
- time_t cl_nextexe; /* time and date of the next execution */
- unsigned short cl_remain; /* remaining until next execution */
- time_t cl_timefreq; /* Run every n seconds */
- unsigned short cl_runfreq; /* Run once every n matches */
+ struct CF *cl_file; /* the file in which the line is */
+ unsigned char cl_option[OPTION_SIZE]; /* line's option (see option.h) */
+ char *cl_shell; /* shell command */
+ unsigned char cl_numexe; /* num of entries in lavg/serial queue */
+ unsigned char cl_lavg[LAVG_SIZE];/*load averages needed (1,5,15 mins) */
+ time_t cl_until; /* timeout of the wait for a lavg value */
+ char cl_nice; /* nice value to control priority */
+ char *cl_runas; /* determine permissions of the job */
+ char *cl_mailto; /* mail output to cl_mailto */
+ time_t cl_nextexe; /* time and date of the next execution */
+ unsigned short cl_remain; /* remaining until next execution */
+ long int cl_timefreq; /* Run every n seconds */
+ unsigned short cl_runfreq; /* Run once every n matches */
/* see bitstring(3) man page for more details */
- bitstr_t bit_decl(cl_mins, 60); /* 0-59 */
- bitstr_t bit_decl(cl_hrs, 24); /* 0-23 */
- bitstr_t bit_decl(cl_days, 32); /* 1-31 */
- bitstr_t bit_decl(cl_mons, 12); /* 0-11 */
- bitstr_t bit_decl(cl_dow, 8); /* 0-7, 0 and 7 are both Sunday */
+ bitstr_t bit_decl(cl_mins, 60); /* 0-59 */
+ bitstr_t bit_decl(cl_hrs, 24); /* 0-23 */
+ bitstr_t bit_decl(cl_days, 32); /* 1-31 */
+ bitstr_t bit_decl(cl_mons, 12); /* 0-11 */
+ bitstr_t bit_decl(cl_dow, 8); /* 0-7, 0 and 7 are both Sunday */
} CL;
typedef struct job {
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: save.h,v 1.1 2001-04-21 08:52:16 thib Exp $ */
+ /* $Id: save.h,v 1.2 2001-05-24 19:59:58 thib Exp $ */
/* here is the format fcron(tab) uses to save the fcrontabs :
#define S_HEADER_T 1 /* file version */
#define S_USER_T 2 /* name of the fcrontab's owner */
#define S_TIMEDATE_T 3 /* time and date of saving */
+#define S_TZDIFF_T 4 /* time diff between the local and system hour */
/* env var */
#define S_ENVVAR_T 1000 /* an environment variable */