From: Thibault Godouet Date: Sat, 2 Mar 2002 17:29:03 +0000 (+0000) Subject: added fifofile support X-Git-Tag: ver2_9_4~174 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=552f6e6aea10b5bbd9a69869f2dc8a3693480b9e;p=thirdparty%2Ffcron.git added fifofile support --- diff --git a/subs.c b/subs.c index ead5756..526f876 100644 --- a/subs.c +++ b/subs.c @@ -22,7 +22,7 @@ * `LICENSE' that comes with the fcron source distribution. */ - /* $Id: subs.c,v 1.17 2002-02-25 18:46:14 thib Exp $ */ + /* $Id: subs.c,v 1.18 2002-03-02 17:29:03 thib Exp $ */ #include "global.h" #include "subs.h" @@ -35,6 +35,7 @@ extern char debug_opt; char *fcronconf = NULL; char *fcrontabs = NULL; char *pidfile = NULL; +char *fifofile = NULL; char *fcronallow = NULL; char *fcrondeny = NULL; char *shell = NULL; @@ -83,6 +84,22 @@ strdup2(const char *str) } +int +get_word(char **str) + /* make str point the next word and return word length */ +{ + char *ptr; + + Skip_blanks(*str); + ptr = *str; + + while ( (isalnum( (int) *ptr) || *ptr == '_' || *ptr == '-') + && *ptr != '=' && ! isspace( (int) *ptr) ) + ptr++; + + return (ptr - *str); +} + void init_conf(void) /* initialises config with compiled in constants */ @@ -92,6 +109,7 @@ init_conf(void) fcronconf = strdup2(ETC "/" FCRON_CONF); fcrontabs = strdup2(FCRONTABS); pidfile = strdup2(PIDFILE); + fifofile = strdup2(FIFOFILE); fcronallow = strdup2(ETC "/" FCRON_ALLOW); fcrondeny = strdup2(ETC "/" FCRON_DENY); shell = strdup2(SHELL); @@ -152,36 +170,34 @@ read_conf(void) remove_blanks(ptr1); /* at the end of the line */ - ptr2 = ptr1; - /* get the name of the var */ - while ( (isalnum( (int) *ptr2) || *ptr2 == '_') - && *ptr2 != '=' && ! isspace( (int) *ptr2) ) - ptr2++; - - if ( (namesize = ptr2 - ptr1) == 0 ) + if ( ( namesize = get_word(&ptr1) ) == 0 ) /* name is zero-length */ error("Zero-length var name at line %s : line ignored", buf); + ptr2 = ptr1 + namesize; + /* skip the blanks and the "=" and go to the value */ while ( isspace( (int) *ptr2 ) ) ptr2++; if ( *ptr2 == '=' ) ptr2++; while ( isspace( (int) *ptr2 ) ) ptr2++; /* find which var the line refers to and update it */ - if ( strncmp(ptr1, "fcrontabs", 9) == 0 ) + if ( strncmp(ptr1, "fcrontabs", namesize) == 0 ) fcrontabs = strdup2(ptr2); - else if ( strncmp(ptr1, "pidfile", 7) == 0 ) + else if ( strncmp(ptr1, "pidfile", namesize) == 0 ) pidfile = strdup2(ptr2); - else if ( strncmp(ptr1, "fcronallow", 10) == 0 ) + else if ( strncmp(ptr1, "fifofile", namesize) == 0 ) + fifofile = strdup2(ptr2); + else if ( strncmp(ptr1, "fcronallow", namesize) == 0 ) fcronallow = strdup2(ptr2); - else if ( strncmp(ptr1, "fcrondeny", 9) == 0 ) + else if ( strncmp(ptr1, "fcrondeny", namesize) == 0 ) fcrondeny = strdup2(ptr2); - else if ( strncmp(ptr1, "shell", 5) == 0 ) + else if ( strncmp(ptr1, "shell", namesize) == 0 ) shell = strdup2(ptr2); - else if ( strncmp(ptr1, "sendmail", 8) == 0 ) + else if ( strncmp(ptr1, "sendmail", namesize) == 0 ) sendmail = strdup2(ptr2); - else if ( strncmp(ptr1, "editor", 6) == 0 ) + else if ( strncmp(ptr1, "editor", namesize) == 0 ) editor = strdup2(ptr2); else error("Unknown var name at line %s : line ignored", buf); @@ -194,6 +210,7 @@ read_conf(void) /* debug(" fcrondeny=%s", fcrondeny); */ /* debug(" fcrontabs=%s", fcrontabs); */ /* debug(" pidfile=%s", pidfile); */ + debug(" fifofile=%s", fifofile); /* debug(" editor=%s", editor); */ /* debug(" shell=%s", shell); */ /* debug(" sendmail=%s", sendmail); */ diff --git a/subs.h b/subs.h index 474b9b9..934c049 100644 --- a/subs.h +++ b/subs.h @@ -21,7 +21,7 @@ * `LICENSE' that comes with the fcron source distribution. */ - /* $Id: subs.h,v 1.5 2002-02-25 18:46:31 thib Exp $ */ + /* $Id: subs.h,v 1.6 2002-03-02 17:29:31 thib Exp $ */ #ifndef __SUBS_H__ #define __SUBS_H__ @@ -35,6 +35,7 @@ extern char *fcronallow; extern char *fcrondeny; extern char *fcrontabs; extern char *pidfile; +extern char *fifofile; extern char *editor; extern char *shell; extern char *sendmail; @@ -43,6 +44,7 @@ extern char *sendmail; /* functions prototypes */ extern int remove_blanks(char *str); extern char *strdup2(const char *); +extern int get_word(char **str); extern int temp_file(char **name); extern void read_conf(void);