From 876164283217f7280f861556297330f95d211666 Mon Sep 17 00:00:00 2001 From: thib Date: Sun, 6 Oct 2002 17:08:56 +0000 Subject: [PATCH] changed type name : CL->cl_t CF->cf_t exe->exe_t lavg->lavg_t job->job_t --- conf.h | 4 +-- convert-fcrontab.c | 24 ++++++++-------- database.c | 71 +++++++++++++++++++++++----------------------- database.h | 14 ++++----- 4 files changed, 56 insertions(+), 57 deletions(-) diff --git a/conf.h b/conf.h index 4edcd13..719e4c6 100644 --- a/conf.h +++ b/conf.h @@ -21,7 +21,7 @@ * `LICENSE' that comes with the fcron source distribution. */ - /* $Id: conf.h,v 1.4 2001-12-23 22:04:54 thib Exp $ */ + /* $Id: conf.h,v 1.5 2002-10-06 17:08:56 thib Exp $ */ #ifndef __CONF_H__ #define __CONF_H__ @@ -30,6 +30,6 @@ extern void reload_all(const char *dir_name); extern void synchronize_dir(const char *dir_name); extern void delete_file(const char *user_name); -extern void save_file(struct CF *file_name); +extern void save_file(struct cf_t *file_name); #endif /* __CONF_H__ */ diff --git a/convert-fcrontab.c b/convert-fcrontab.c index 02745ff..d08d26f 100644 --- a/convert-fcrontab.c +++ b/convert-fcrontab.c @@ -22,7 +22,7 @@ * `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" @@ -30,13 +30,13 @@ #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 */ @@ -100,12 +100,12 @@ read_str(FILE *f, char *buf, int max) 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; @@ -180,8 +180,8 @@ convert_file(char *file_name) /* 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; @@ -191,7 +191,7 @@ convert_file(char *file_name) 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); @@ -231,8 +231,8 @@ convert_file(char *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"); @@ -249,7 +249,7 @@ convert_file(char *file_name) line->cl_next = file->cf_line_base; file->cf_line_base = line; - Alloc(line, CL); + Alloc(line, cl_t); } diff --git a/database.c b/database.c index dacaddc..76407a6 100644 --- a/database.c +++ b/database.c @@ -1,4 +1,3 @@ - /* * FCRON - periodic command scheduler * @@ -22,7 +21,7 @@ * `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" @@ -32,19 +31,19 @@ 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 ..."); @@ -73,7 +72,7 @@ test_jobs(void) void -run_normal_job(CL *line) +run_normal_job(cl_t *line) { if (line->cl_numexe <= 0 || @@ -136,23 +135,23 @@ void 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 */ { @@ -173,15 +172,15 @@ run_queue_job(CL *line) 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) @@ -211,7 +210,7 @@ insert_nextexe(CL *line) 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 @@ -228,7 +227,7 @@ insert_nextexe(CL *line) } else { /* no job in queue */ - Alloc(newjob, job); + Alloc(newjob, job_t); newjob->j_line = line; queue_base = newjob; } @@ -236,7 +235,7 @@ insert_nextexe(CL *line) } void -add_serial_job(CL *line) +add_serial_job(cl_t *line) /* add the next queued job in serial queue */ { short int i; @@ -261,20 +260,20 @@ add_serial_job(CL *line) 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; @@ -298,7 +297,7 @@ add_serial_job(CL *line) 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 */ @@ -326,16 +325,16 @@ add_lavg_job(CL *line) 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; } @@ -384,7 +383,7 @@ wait_chld(void) { short int i = 0; int pid; - CL *line = NULL; + cl_t *line = NULL; /* // */ @@ -394,7 +393,7 @@ wait_chld(void) 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); @@ -448,7 +447,7 @@ wait_all(int *counter) 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); @@ -546,7 +545,7 @@ set_wday(struct tm *date) 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 */ { @@ -785,8 +784,8 @@ goto_non_matching(CL *line, struct tm *ftime, char option) 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) ) { @@ -999,7 +998,7 @@ set_next_exe(CL *line, char 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 */ { @@ -1043,7 +1042,7 @@ set_next_exe_notrun(CL *line, char context) } 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; @@ -1070,7 +1069,7 @@ mail_notrun(CL *line, char context, struct tm *since) 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; } diff --git a/database.h b/database.h index 4d780d5..043c2b6 100644 --- a/database.h +++ b/database.h @@ -21,7 +21,7 @@ * `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__ @@ -32,17 +32,17 @@ extern void wait_chld(void); 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__ */ -- 2.40.0