* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: convert-fcrontab.c,v 1.12 2002-10-05 14:27:22 thib Exp $ */
+ /* $Id: convert-fcrontab.c,v 1.13 2002-10-06 17:10:37 thib Exp $ */
#include "global.h"
#include "log.h"
#include "subs.h"
-char rcs_info[] = "$Id: convert-fcrontab.c,v 1.12 2002-10-05 14:27:22 thib Exp $";
+char rcs_info[] = "$Id: convert-fcrontab.c,v 1.13 2002-10-06 17:10:37 thib Exp $";
void info(void);
void usage(void);
void convert_file(char *file_name);
char *read_str(FILE *f, char *buf, int max);
-void delete_file(CF *file);
+void delete_file(cf_t *file);
char *cdir = FCRONTABS; /* the dir where are stored users' fcrontabs */
void
-delete_file(CF *file)
+delete_file(cf_t *file)
/* free a file if user_name is not null
* otherwise free all files */
{
- CL *line = NULL;
- CL *cur_line = NULL;
+ cl_t *line = NULL;
+ cl_t *cur_line = NULL;
env_t *env = NULL;
env_t *cur_env = NULL;
/* this functions is a mix of read_file() from version 1.0.3 and save_file(),
* so you can read more comments there */
{
- CF *file = NULL;
- CL *line = NULL;
+ cf_t *file = NULL;
+ cl_t *line = NULL;
env_t *env = NULL;
FILE *f = NULL;
int fd;
explain("Converting %s's fcrontab ...", file_name);
- Alloc(file, CF);
+ Alloc(file, cf_t);
/* open file */
if ( (f = fopen(file_name, "r")) == NULL )
die_e("Could not read %s", file_name);
free(env);
/* read lines */
- Alloc(line, CL);
- while ( fread(line, sizeof(CL), 1, f) == 1 ) {
+ Alloc(line, cl_t);
+ while ( fread(line, sizeof(cl_t), 1, f) == 1 ) {
if ((line->cl_shell = read_str(f, buf, sizeof(buf))) == NULL) {
error("Line is not valid (empty shell command) : ignored");
line->cl_next = file->cf_line_base;
file->cf_line_base = line;
- Alloc(line, CL);
+ Alloc(line, cl_t);
}
-
/*
* FCRON - periodic command scheduler
*
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: database.c,v 1.65 2002-08-29 17:34:03 thib Exp $ */
+ /* $Id: database.c,v 1.66 2002-10-06 17:10:11 thib Exp $ */
#include "fcron.h"
int is_leap_year(int year);
int get_nb_mdays(int year, int mon);
void set_wday(struct tm *date);
-void goto_non_matching(CL *line, struct tm *tm, char option);
+void goto_non_matching(cl_t *line, struct tm *tm, char option);
#define END_OF_INTERVAL 1 /* goto_non_matching() : option */
-void run_normal_job(CL *line);
+void run_normal_job(cl_t *line);
void run_serial_job(void);
void run_lavg_job(int i);
-void run_queue_job(CL *line);
+void run_queue_job(cl_t *line);
void resize_exe_array(void);
void
test_jobs(void)
/* determine which jobs need to be run, and run them. */
{
- struct job *j;
+ struct job_t *j;
/* // */
debug("Looking for jobs to execute ...");
void
-run_normal_job(CL *line)
+run_normal_job(cl_t *line)
{
if (line->cl_numexe <= 0 ||
resize_exe_array(void)
/* make exe_array bigger */
{
- struct exe *ptr = NULL;
+ struct exe_t *ptr = NULL;
short int old_size = exe_array_size;
debug("Resizing exe_array");
exe_array_size = (exe_array_size + EXE_GROW_SIZE);
- if ( (ptr = calloc(exe_array_size, sizeof(struct exe))) == NULL )
+ if ( (ptr = calloc(exe_array_size, sizeof(struct exe_t))) == NULL )
die_e("could not calloc exe_array");
- memcpy(ptr, exe_array, (sizeof(struct exe) * old_size));
+ memcpy(ptr, exe_array, (sizeof(struct exe_t) * old_size));
free(exe_array);
exe_array = ptr;
}
void
-run_queue_job(CL *line)
+run_queue_job(cl_t *line)
/* run a job */
{
void
-insert_nextexe(CL *line)
+insert_nextexe(cl_t *line)
/* insert a job the queue list */
{
- struct job *newjob;
+ struct job_t *newjob;
if (queue_base != NULL) {
- struct job *j;
- struct job *jprev = NULL;
- struct job *old_entry = NULL;
+ struct job_t *j;
+ struct job_t *jprev = NULL;
+ struct job_t *old_entry = NULL;
/* find the job in the list */
for (j = queue_base; j != NULL ; j = j->j_next)
if (old_entry == NULL) {
/* this job wasn't in the queue : we append it */
- Alloc(newjob, job);
+ Alloc(newjob, job_t);
newjob->j_line = line;
}
else
}
else {
/* no job in queue */
- Alloc(newjob, job);
+ Alloc(newjob, job_t);
newjob->j_line = line;
queue_base = newjob;
}
}
void
-add_serial_job(CL *line)
+add_serial_job(cl_t *line)
/* add the next queued job in serial queue */
{
short int i;
return;
}
else {
- CL **ptr = NULL;
+ cl_t **ptr = NULL;
short int old_size = serial_array_size;
debug("Resizing serial_array");
serial_array_size = (serial_array_size + SERIAL_GROW_SIZE);
- if ( (ptr = calloc(serial_array_size, sizeof(CL *))) == NULL )
+ if ( (ptr = calloc(serial_array_size, sizeof(cl_t *))) == NULL )
die_e("could not calloc serial_array");
/* copy lines in order to have the first line at the index 0 */
memcpy(ptr + serial_array_index, serial_array,
- (sizeof(CL*) * (old_size - serial_array_index)) );
+ (sizeof(cl_t*) * (old_size - serial_array_index)) );
memcpy(ptr, serial_array + (old_size - serial_array_index),
- (sizeof(CL*) * serial_array_index));
+ (sizeof(cl_t*) * serial_array_index));
serial_array_index = 0;
free(serial_array);
serial_array = ptr;
void
-add_lavg_job(CL *line)
+add_lavg_job(cl_t *line)
/* add the next queued job in lavg queue */
/* WARNING : must be run before a set_next_exe() to get the strict option
* working correctly */
return;
}
else {
- struct lavg *ptr = NULL;
+ struct lavg_t *ptr = NULL;
short int old_size = lavg_array_size;
debug("Resizing lavg_array");
lavg_array_size = (lavg_array_size + LAVG_GROW_SIZE);
- if ( (ptr = calloc(lavg_array_size, sizeof(lavg))) == NULL )
+ if ( (ptr = calloc(lavg_array_size, sizeof(lavg_t))) == NULL )
die_e("could not calloc lavg_array");
- memcpy(ptr, lavg_array, (sizeof(lavg) * old_size));
+ memcpy(ptr, lavg_array, (sizeof(lavg_t) * old_size));
free(lavg_array);
lavg_array = ptr;
}
{
short int i = 0;
int pid;
- CL *line = NULL;
+ cl_t *line = NULL;
/* // */
while ( (pid = wait3(NULL, WNOHANG, NULL)) > 0 ) {
i = 0;
while ( i < exe_num ) {
- if (pid == exe_array[i].e_pid) {
+ if (pid == exe_array[i].e_ctrl_pid) {
if ( exe_array[i].e_line == NULL ) {
/* the corresponding file has been removed from memory */
debug("job finished: pid %d", pid);
while ( (*counter > 0) && (pid = wait3(NULL, 0, NULL)) > 0 ) {
i = 0;
while ( i < exe_num ) {
- if (pid == exe_array[i].e_pid) {
+ if (pid == exe_array[i].e_ctrl_pid) {
if ( exe_array[i].e_line == NULL ) {
/* the corresponding file has been removed from memory */
debug("job finished: pid %d", pid);
void
-goto_non_matching(CL *line, struct tm *ftime, char option)
+goto_non_matching(cl_t *line, struct tm *ftime, char option)
/* search the first the nearest time and date that does
* not match the line */
{
void
-set_next_exe(CL *line, char option)
- /* set the cl_nextexe of a given CL and insert it in the queue */
+set_next_exe(cl_t *line, char option)
+ /* set the cl_nextexe of a given cl_t and insert it in the queue */
{
if ( is_td(line->cl_option) ) {
void
-set_next_exe_notrun(CL *line, char context)
+set_next_exe_notrun(cl_t *line, char context)
/* set the time of the next execution and send a mail to tell user his job
* has not run if necessary */
{
}
void
-mail_notrun(CL *line, char context, struct tm *since)
+mail_notrun(cl_t *line, char context, struct tm *since)
/* send a mail to tell user a job has not run (and why) */
{
int pid = 0;
resize_exe_array();
/* set line to NULL as this is not a line ... */
exe_array[exe_num].e_line = NULL;
- exe_array[exe_num].e_pid = pid;
+ exe_array[exe_num].e_ctrl_pid = pid;
exe_num++;
return;
}
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: database.h,v 1.4 2001-12-23 22:05:01 thib Exp $ */
+ /* $Id: database.h,v 1.5 2002-10-06 17:10:30 thib Exp $ */
#ifndef __DATABASE_H__
#define __DATABASE_H__
extern void wait_all(int *counter);
extern time_t time_to_sleep(time_t lim);
extern time_t check_lavg(time_t lim);
-extern void set_next_exe(struct CL *line, char option);
+extern void set_next_exe(struct cl_t *line, char option);
#define NO_GOTO 1 /* set_next_exe() : no goto_non_matching() */
#define NO_GOTO_LOG 2 /* set_next_exe() : NO_GOTO but also log nextexe time */
-extern void set_next_exe_notrun(struct CL *line, char context);
+extern void set_next_exe_notrun(struct cl_t *line, char context);
#define LAVG 1 /* set_next_exe_notrun() : context */
#define SYSDOWN 2 /* set_next_exe_notrun() : context */
#define QUEUE_FULL 3 /* set_next_exe_notrun() : context */
-extern void mail_notrun(struct CL *line, char context, struct tm *since);
-extern void insert_nextexe(struct CL *line);
-extern void add_serial_job(struct CL *line);
-extern void add_lavg_job(struct CL *line);
+extern void mail_notrun(struct cl_t *line, char context, struct tm *since);
+extern void insert_nextexe(struct cl_t *line);
+extern void add_serial_job(struct cl_t *line);
+extern void add_lavg_job(struct cl_t *line);
extern void run_serial_job(void);
#endif /* __DATABASE_H__ */