ifeq ($(FCRONDYN), 1)
LIBOBJS := socket.o $(LIBOBJS)
endif
-OBJSD := fcron.o subs.o mem.o save.o temp_file.o log.o database.o job.o conf.o u_list.o exe_list.o lavg_list.o env_list.o fcronconf.o $(LIBOBJS)
-OBJSTAB := fcrontab.o subs.o mem.o save.o temp_file.o log.o fileconf.o allow.o read_string.o u_list.o env_list.o fcronconf.o
+OBJSD := fcron.o cl.o subs.o mem.o save.o temp_file.o log.o database.o job.o conf.o u_list.o exe_list.o lavg_list.o env_list.o fcronconf.o $(LIBOBJS)
+OBJSTAB := fcrontab.o cl.o subs.o mem.o save.o temp_file.o log.o fileconf.o allow.o read_string.o u_list.o env_list.o fcronconf.o
OBJSDYN := fcrondyn.o subs.o mem.o log.o allow.o read_string.o fcronconf.o
-OBJCONV := convert-fcrontab.o subs.o mem.o save.o log.o u_list.o env_list.o
+OBJCONV := convert-fcrontab.o cl.o subs.o mem.o save.o log.o u_list.o env_list.o
OBJSIG := fcronsighup.o subs.o mem.o log.o allow.o fcronconf.o
-HEADERSALL := config.h $(SRCDIR)/global.h $(SRCDIR)/log.h $(SRCDIR)/subs.h $(SRCDIR)/mem.h $(SRCDIR)/save.h $(SRCDIR)/option.h $(SRCDIR)/dyncom.h
+HEADERSALL := config.h $(SRCDIR)/global.h $(SRCDIR)/cl.h $(SRCDIR)/log.h $(SRCDIR)/subs.h $(SRCDIR)/mem.h $(SRCDIR)/save.h $(SRCDIR)/option.h $(SRCDIR)/dyncom.h
# this is a regular expression :
# do not ci automaticaly generated files and doc (done by doc's Makefile)
--- /dev/null
+/*
+ * FCRON - periodic command scheduler
+ *
+ * Copyright 2000-2012 Thibault Godouet <fcron@free.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * The GNU General Public License can also be found in the file
+ * `LICENSE' that comes with the fcron source distribution.
+ */
+
+#include "global.h"
+#include "cl.h"
+#include "mem.h"
+
+cl_t*
+dups_cl(cl_t *orig)
+ /* Duplicate a line, including the strings it points to. */
+{
+ cl_t *cl = NULL;
+
+ Alloc(cl, cl_t);
+
+ /* copy the structure */
+ *cl = *orig;
+
+ /* don't assume any link to a file or belonging to a list */
+ cl->cl_file = NULL;
+ cl->cl_next = NULL;
+
+ /* we just copied the pointers of orig to cl, but we didn't
+ * make a copy of the strings yet.
+ * Reset the pointers, then copy the strings */
+ cl->cl_shell = NULL;
+ Set(cl->cl_shell, orig->cl_shell);
+
+ cl->cl_runas = NULL;
+ Set(cl->cl_runas, orig->cl_runas);
+ debug("%s: Set cl->cl_runas=%s", __func__, (cl->cl_runas == NULL) ? "null" : cl->cl_runas);
+
+ cl->cl_mailto = NULL;
+ Set(cl->cl_mailto, orig->cl_mailto);
+
+ cl->cl_tz = NULL;
+ Set(cl->cl_tz, orig->cl_tz);
+
+ return cl;
+}
+
+void
+free_line(cl_t *cl)
+ /* free a line, including its fields */
+{
+ if (cl != NULL) {
+ Free_safe(cl->cl_shell);
+ Free_safe(cl->cl_runas);
+ Free_safe(cl->cl_mailto);
+ Free_safe(cl->cl_tz);
+ Free_safe(cl);
+ }
+}
+
+
--- /dev/null
+/*
+ * FCRON - periodic command scheduler
+ *
+ * Copyright 2000-2012 Thibault Godouet <fcron@free.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * The GNU General Public License can also be found in the file
+ * `LICENSE' that comes with the fcron source distribution.
+ */
+
+/* cl: Cron Line type and associated functions */
+
+#ifndef __CL_H__
+#define __CL_H__
+
+/*
+ * TYPES
+ */
+
+#define OPTION_SIZE 4 /* number of bytes to hold the cl_option bit array */
+#define LAVG_SIZE 3
+/* warning : do not change the order of the members of this structure
+ * because some tests made are dependent to that order */
+/* warning : if you change a field type, you may have to also make some changes
+ * in the save/load binary fcrontab functions */
+typedef struct cl_t {
+ struct cl_t *cl_next;
+ struct cf_t *cl_file; /* the file in which the line is */
+ char *cl_shell; /* shell command */
+ char *cl_runas; /* determine permissions of the job */
+ char *cl_mailto; /* mail output to cl_mailto */
+ char *cl_tz; /* time zone of the line */
+ unsigned long cl_id; /* line's unique id number */
+ time_t cl_until; /* timeout of the wait for a lavg value */
+ time_t cl_first; /* initial delay preserved for volatile entries */
+ time_t cl_nextexe; /* time and date of the next execution */
+ long int cl_timefreq; /* Run every n seconds */
+ unsigned short cl_remain; /* remaining until next execution */
+ unsigned short cl_runfreq; /* Run once every n matches(=1 for %-lines)*/
+ unsigned char cl_option[OPTION_SIZE]; /* line's option (see option.h) */
+ unsigned char cl_lavg[LAVG_SIZE];/*load averages needed (1,5,15 mins) */
+ unsigned char cl_numexe; /* entries in queues & running processes */
+ char cl_nice; /* nice value to control priority */
+ unsigned char cl_jitter; /* run randomly late up to jitter seconds */
+ /* 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 */
+} cl_t;
+
+
+/*
+ * functions prototypes
+ */
+
+/* duplicate a line, including strings it points to */
+cl_t* dups_cl(cl_t *orig);
+void free_line(cl_t *cl);
+
+#endif /* __CL_H__ */
int read_strn(int fd, char **str, short int size);
int read_type(int fd, short int *type, short int *size);
void synchronize_file(char *file_name, int is_system_startup);
-void free_line(cl_t *cl);
/* this is used to create a list of files to remove, to add */
return 0;
}
-void
-free_line(cl_t *cl)
- /* free a line, including its fields */
-{
- if (cl != NULL) {
- Free_safe(cl->cl_shell);
- Free_safe(cl->cl_runas);
- Free_safe(cl->cl_mailto);
- Free_safe(cl->cl_tz);
- Free_safe(cl);
- }
-}
-
void
delete_file(const char *user_name)
/* free a file if user_name is not null
void read_env(char *ptr, cf_t *cf);
char *read_opt(char *ptr, cl_t *cl);
char *check_username(char *ptr, cf_t *cf, cl_t *cl);
-void free_line(cl_t *cl);
char need_correction;
return ptr;
}
-void
-free_line(cl_t *cl)
- /* free a line, including its fields */
-{
- if (cl != NULL) {
- Free_safe(cl->cl_shell);
- Free_safe(cl->cl_runas);
- Free_safe(cl->cl_mailto);
- Free_safe(cl->cl_tz);
- Free_safe(cl);
- }
-}
-
void
delete_file(const char *user_name)
/* free a file if user_name is not null
#include "bitstring.h" /* bit arrays */
#include "option.h" /* manage fcrontab's options */
#include "env_list.h" /* manage fcrontab's environment variable lists */
+#include "cl.h" /* Cron Line cl_t type and associated functions */
/* you should not change this (nor need to do it) */
#define ERR -1
} cf_t;
-#define OPTION_SIZE 4 /* number of bytes to hold the cl_option bit array */
-#define LAVG_SIZE 3
-/* warning : do not change the order of the members of this structure
- * because some tests made are dependent to that order */
-/* warning : if you change a field type, you may have to also make some changes
- * in the save/load binary fcrontab functions */
-typedef struct cl_t {
- struct cl_t *cl_next;
- struct cf_t *cl_file; /* the file in which the line is */
- char *cl_shell; /* shell command */
- char *cl_runas; /* determine permissions of the job */
- char *cl_mailto; /* mail output to cl_mailto */
- char *cl_tz; /* time zone of the line */
- unsigned long cl_id; /* line's unique id number */
- time_t cl_until; /* timeout of the wait for a lavg value */
- time_t cl_first; /* initial delay preserved for volatile entries */
- time_t cl_nextexe; /* time and date of the next execution */
- long int cl_timefreq; /* Run every n seconds */
- unsigned short cl_remain; /* remaining until next execution */
- unsigned short cl_runfreq; /* Run once every n matches(=1 for %-lines)*/
- unsigned char cl_option[OPTION_SIZE]; /* line's option (see option.h) */
- unsigned char cl_lavg[LAVG_SIZE];/*load averages needed (1,5,15 mins) */
- unsigned char cl_numexe; /* entries in queues & running processes */
- char cl_nice; /* nice value to control priority */
- unsigned char cl_jitter; /* run randomly late up to jitter seconds */
- /* 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 */
-} cl_t;
-
typedef struct job_t {
struct cl_t *j_line;
struct job_t *j_next;