scron

simple cron daemon
git clone git://git.2f30.org/scron
Log | Files | Refs | README | LICENSE

commit db6ec83bdf9dbb6730b756af71c82805b2312009
parent e7e716fd488599c57ee08fc35fa779679c668649
Author: Ari Malinen <ari.malinen@gmail.com>
Date:   Wed, 11 Jun 2014 19:16:57 +0300

cleaned code

Diffstat:
MREADME | 8++++----
Mdcron.c | 15+++++++--------
2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/README b/README @@ -5,10 +5,10 @@ Single daemon, config and initscript. Logs to stdout and syslog. usage: -usage: dcron [options] --h help --d daemon --f <file> config file +usage: ./dcron [options] +-h help +-d daemon +-f <file> config file config: # min,hour,mday,mon,wday,command diff --git a/dcron.c b/dcron.c @@ -9,25 +9,24 @@ #define MAXLEN 100 -char config[MAXLEN+1] = "/etc/dcron.conf"; - int main(int argc, char *argv[]) { - FILE *fp; - char *argv0, *col; + char config[MAXLEN+1] = "/etc/dcron.conf"; char line[MAXLEN+1]; char cmd[MAXLEN+1]; + char *argv0, *col; int i, l, date[5]; time_t t; struct tm *tm; + FILE *fp; openlog(argv[0], LOG_CONS | LOG_PID, LOG_LOCAL1); for (argv0 = argv[0]; argc > 0; argc--, argv++) { if (!strcmp("-h", argv[0])) { fprintf(stderr, "usage: %s [options]\n", argv0); - fprintf(stderr, "-h help\n"); - fprintf(stderr, "-d daemon\n"); - fprintf(stderr, "-f <file> config file\n"); + fprintf(stderr, "-h help\n"); + fprintf(stderr, "-d daemon\n"); + fprintf(stderr, "-f <file> config file\n"); return 1; } else if (!strcmp("-d", argv[0])) { if (daemon(1, 0) != 0) { @@ -61,7 +60,7 @@ int main(int argc, char *argv[]) { return 1; } - for (l = 0; fgets(line, MAXLEN, fp) != NULL; l++) { + for (l = 0; fgets(line, MAXLEN+1, fp) != NULL; l++) { if (line[1] == '\0' || line[0] == '\043') continue;