* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: fileconf.c,v 1.13 2000-08-22 18:01:34 thib Exp $ */
+ /* $Id: fileconf.c,v 1.14 2000-08-28 17:59:26 thib Exp $ */
#include "fcrontab.h"
/* append env variable list.
* (remove blanks) */
{
- char name[ENV_LEN];
+ char name[LINE_LEN];
env_t *env = NULL;
int j=0;
char *val = NULL;
Alloc(env, env_t);
- env->e_name = strdup2(name);
- env->e_val = val;
+ strcat(name, "=");
+ env->e_val = strdup2( strcat(name, val) );
env->e_next = cf->cf_env_base;
cf->cf_env_base = env;
}
#define Handle_err \
{ \
- fprintf(stderr, "%s:%d: Argument for option '%s' is not valid: " \
+ fprintf(stderr, "%s:%d: Argument(s) for option '%s' not valid: " \
"skipping end of line.\n", file_name, line, opt_name); \
need_correction = 1; \
return NULL; \
else if( strcmp(opt_name, "reset")==0 ) {
if ( in_brackets && (ptr = get_bool(ptr, &i)) == NULL )
Handle_err;
- if ( i == 1 )
+ if ( i == 1 ) {
bzero(cl, sizeof(cl));
+ default_line.cl_runas = uid;
+ default_line.cl_mailto = uid;
+ }
if (debug_opt)
fprintf(stderr, " Opt : '%s'\n", opt_name);
}
+
else if(strcmp(opt_name, "f") == 0 || strcmp(opt_name, "first") == 0){
if( ! in_brackets || (ptr=get_time(ptr, &(cl->cl_nextexe)))==NULL)
Handle_err;
fprintf(stderr, " Opt : '%s' %d\n", opt_name, i);
}
+ else if( strcmp(opt_name, "lavg") == 0 ) {
+ if( ! in_brackets || (ptr=get_num(ptr, &i, 256, NULL)) == NULL )
+ Handle_err;
+ cl->cl_lavg[0] = i;
+ if (debug_opt)
+ fprintf(stderr, " Opt : 'lavg1' %d\n", i);
+ if ( *ptr++ != ',' )
+ Handle_err;
+ if( ! in_brackets || (ptr=get_num(ptr, &i, 256, NULL)) == NULL )
+ Handle_err;
+ cl->cl_lavg[1] = i;
+ if (debug_opt)
+ fprintf(stderr, " Opt : 'lavg5' %d\n", i);
+ if ( *ptr++ != ',' )
+ Handle_err;
+ if( ! in_brackets || (ptr=get_num(ptr, &i, 256, NULL)) == NULL )
+ Handle_err;
+ cl->cl_lavg[2] = i;
+ set_lavg(cl->cl_option);
+ if (debug_opt)
+ fprintf(stderr, " Opt : 'lavg15' %d\n", i);
+ }
+
+ else if( strcmp(opt_name, "lavg1") == 0 ) {
+ if( ! in_brackets || (ptr=get_num(ptr, &i, 256, NULL)) == NULL )
+ Handle_err;
+ cl->cl_lavg[0] = i;
+ set_lavg(cl->cl_option);
+ if (debug_opt)
+ fprintf(stderr, " Opt : 'lavg1' %d\n", i);
+ }
+
+ else if( strcmp(opt_name, "lavg5") == 0 ) {
+ if( ! in_brackets || (ptr=get_num(ptr, &i, 256, NULL)) == NULL )
+ Handle_err;
+ cl->cl_lavg[1] = i;
+ set_lavg(cl->cl_option);
+ if (debug_opt)
+ fprintf(stderr, " Opt : 'lavg5' %d\n", i);
+ }
+
+ else if( strcmp(opt_name, "lavg15") == 0 ) {
+ if( ! in_brackets || (ptr=get_num(ptr, &i, 256, NULL)) == NULL )
+ Handle_err;
+ cl->cl_lavg[2] = i;
+ set_lavg(cl->cl_option);
+ if (debug_opt)
+ fprintf(stderr, " Opt : 'lavg15' %d\n", i);
+ }
+
+ else if( strcmp(opt_name, "lavgand") == 0 ) {
+ if ( in_brackets && (ptr = get_bool(ptr, &i)) == NULL )
+ Handle_err;
+ if ( i == 0 )
+ set_lor(cl->cl_option);
+ else
+ set_land(cl->cl_option);
+ if (debug_opt)
+ fprintf(stderr, " Opt : '%s' %d\n", opt_name, i);
+ }
+
+ else if( strcmp(opt_name, "lavgor") == 0 ) {
+ if ( in_brackets && (ptr = get_bool(ptr, &i)) == NULL )
+ Handle_err;
+ if ( i == 0 )
+ set_land(cl->cl_option);
+ else
+ set_lor(cl->cl_option);
+ if (debug_opt)
+ fprintf(stderr, " Opt : '%s' %d\n", opt_name, i);
+ }
+
+ else if(strcmp(opt_name, "u") == 0 || strcmp(opt_name, "until") == 0){
+ if( ! in_brackets || (ptr=get_time(ptr, &(cl->cl_until)))==NULL)
+ Handle_err;
+ if (debug_opt)
+ fprintf(stderr, " Opt : '%s' %ld\n",opt_name,cl->cl_until);
+ }
+
else if(strcmp(opt_name, "m")==0 || strcmp(opt_name, "mail")==0){
if ( in_brackets && (ptr = get_bool(ptr, &i)) == NULL )
Handle_err;
cur_env = file->cf_env_base;
while ( (env = cur_env) != NULL ) {
cur_env = env->e_next;
- free(env->e_name);
free(env->e_val);
free(env);
}
fprintf(f, "%d", 0);
/* env variables, */
- for (env = file->cf_env_base; env; env = env->e_next) {
- fprintf(f, "%s%c", env->e_name, '\0');
+ for (env = file->cf_env_base; env; env = env->e_next)
fprintf(f, "%s%c", env->e_val, '\0');
- }
+
fprintf(f, "%c", '\0');
/* then, lines. */
fprintf(f, "%s%c", line->cl_shell, '\0');
}
-// /* finally, write the number of lines to permit to check if the file
-// * is complete (i.e. fcron may has been interrupted during
-// * save process */
-// fprintf(f, "eof\n");
+ /* finally, write the number of lines to permit to check if the file
+ * is complete (i.e. fcron may has been interrupted during
+ * save process */
+/* // fprintf(f, "eof\n"); */
fclose(f);
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: global.h,v 1.16 2000-08-22 18:01:37 thib Exp $ */
+ /* $Id: global.h,v 1.17 2000-08-28 17:59:40 thib Exp $ */
/*
#include "option.h"
-#define FILEVERSION "010" /* syntax's version of fcrontabs :
+#define FILEVERSION "012" /* syntax's version of fcrontabs :
* must have a length of 3 characters */
+/* you should not change this (nor need to do it) */
#define ERR -1
#define OK 0
#define debug if(debug_opt) Debug
typedef struct env_t {
- char *e_name; /* env name */
char *e_val; /* env value */
struct env_t *e_next;
} env_t ;
struct CF *cl_file; /* the file in which the line is */
unsigned short cl_option; /* options for that line (see option.h) */
char *cl_shell; /* shell command */
+ char cl_lavg[3]; /* 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 */
uid_t cl_runas; /* determine permissions of the job */
uid_t cl_mailto; /* mail output to cl_mailto */
struct job *j_next;
} job;
+typedef struct lavg {
+ struct CL *l_line;
+ time_t l_since; /* the time of the line admission in the queue */
+} lavg;
#endif /* __GLOBALH__ */