aboutsummaryrefslogtreecommitdiff
path: root/miscutils/crond.c
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-05-20 14:14:05 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-05-20 14:14:05 +0000
commitef21629a6b23201c48bf5acad058420ea68984f0 (patch)
tree5769dadac11d4d0c9cb31d63ae3d82c6e7d8ed5e /miscutils/crond.c
parent9b5a99ad2109abdb0fcf7303a57c20500dad3e9c (diff)
downloadbusybox-w32-ef21629a6b23201c48bf5acad058420ea68984f0.tar.gz
busybox-w32-ef21629a6b23201c48bf5acad058420ea68984f0.tar.bz2
busybox-w32-ef21629a6b23201c48bf5acad058420ea68984f0.zip
- silence warning about no return in function returning non-void
- put CONFIG_DEBUG_CROND_OPTION into config no changes in size when debugging is disabled.
Diffstat (limited to 'miscutils/crond.c')
-rw-r--r--miscutils/crond.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c
index f0b475389..9b194d13a 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -12,9 +12,6 @@
12 12
13#define VERSION "2.3.2" 13#define VERSION "2.3.2"
14 14
15#undef FEATURE_DEBUG_OPT
16
17
18#include <stdio.h> 15#include <stdio.h>
19#include <stdlib.h> 16#include <stdlib.h>
20#include <stdarg.h> 17#include <stdarg.h>
@@ -83,7 +80,7 @@ typedef struct CronLine {
83 80
84#define DaemonUid 0 81#define DaemonUid 0
85 82
86#ifdef FEATURE_DEBUG_OPT 83#if ENABLE_DEBUG_CROND_OPTION
87static short DebugOpt; 84static short DebugOpt;
88#endif 85#endif
89 86
@@ -101,7 +98,7 @@ static int CheckJobs(void);
101 98
102static void RunJob(const char *user, CronLine * line); 99static void RunJob(const char *user, CronLine * line);
103 100
104#ifdef CONFIG_FEATURE_CROND_CALL_SENDMAIL 101#if ENABLE_FEATURE_CROND_CALL_SENDMAIL
105static void EndJob(const char *user, CronLine * line); 102static void EndJob(const char *user, CronLine * line);
106#else 103#else
107#define EndJob(user, line) line->cl_Pid = 0 104#define EndJob(user, line) line->cl_Pid = 0
@@ -125,7 +122,7 @@ static void crondlog(const char *ctl, ...)
125 fmt = ctl + 1; 122 fmt = ctl + 1;
126 if (level >= LogLevel) { 123 if (level >= LogLevel) {
127 124
128#ifdef FEATURE_DEBUG_OPT 125#if ENABLE_DEBUG_CROND_OPTION
129 if (DebugOpt) { 126 if (DebugOpt) {
130 vfprintf(stderr, fmt, va); 127 vfprintf(stderr, fmt, va);
131 } else 128 } else
@@ -137,7 +134,7 @@ static void crondlog(const char *ctl, ...)
137 if (logfd >= 0) { 134 if (logfd >= 0) {
138 vdprintf(logfd, fmt, va); 135 vdprintf(logfd, fmt, va);
139 close(logfd); 136 close(logfd);
140#ifdef FEATURE_DEBUG_OPT 137#if ENABLE_DEBUG_CROND_OPTION
141 } else { 138 } else {
142 bb_perror_msg("Can't open log file"); 139 bb_perror_msg("Can't open log file");
143#endif 140#endif
@@ -155,7 +152,7 @@ int crond_main(int ac, char **av)
155 unsigned long opt; 152 unsigned long opt;
156 char *lopt, *Lopt, *copt; 153 char *lopt, *Lopt, *copt;
157 154
158#ifdef FEATURE_DEBUG_OPT 155#if ENABLE_DEBUG_CROND_OPTION
159 char *dopt; 156 char *dopt;
160 157
161 bb_opt_complementally = "f-b:b-f:S-L:L-S:d-l"; 158 bb_opt_complementally = "f-b:b-f:S-L:L-S:d-l";
@@ -165,11 +162,11 @@ int crond_main(int ac, char **av)
165 162
166 opterr = 0; /* disable getopt 'errors' message. */ 163 opterr = 0; /* disable getopt 'errors' message. */
167 opt = bb_getopt_ulflags(ac, av, "l:L:fbSc:" 164 opt = bb_getopt_ulflags(ac, av, "l:L:fbSc:"
168#ifdef FEATURE_DEBUG_OPT 165#if ENABLE_DEBUG_CROND_OPTION
169 "d:" 166 "d:"
170#endif 167#endif
171 , &lopt, &Lopt, &copt 168 , &lopt, &Lopt, &copt
172#ifdef FEATURE_DEBUG_OPT 169#if ENABLE_DEBUG_CROND_OPTION
173 , &dopt 170 , &dopt
174#endif 171#endif
175 ); 172 );
@@ -186,7 +183,7 @@ int crond_main(int ac, char **av)
186 CDir = copt; 183 CDir = copt;
187 } 184 }
188 } 185 }
189#ifdef FEATURE_DEBUG_OPT 186#if ENABLE_DEBUG_CROND_OPTION
190 if (opt & 64) { 187 if (opt & 64) {
191 DebugOpt = atoi(dopt); 188 DebugOpt = atoi(dopt);
192 LogLevel = 0; 189 LogLevel = 0;
@@ -263,7 +260,7 @@ int crond_main(int ac, char **av)
263 SynchronizeDir(); 260 SynchronizeDir();
264 } 261 }
265 CheckUpdates(); 262 CheckUpdates();
266#ifdef FEATURE_DEBUG_OPT 263#if ENABLE_DEBUG_CROND_OPTION
267 if (DebugOpt) 264 if (DebugOpt)
268 crondlog("\005Wakeup dt=%d\n", dt); 265 crondlog("\005Wakeup dt=%d\n", dt);
269#endif 266#endif
@@ -283,10 +280,10 @@ int crond_main(int ac, char **av)
283 } 280 }
284 } 281 }
285 } 282 }
286 /* not reached */ 283 bb_fflush_stdout_and_exit(EXIT_SUCCESS); /* not reached */
287} 284}
288 285
289#if defined(FEATURE_DEBUG_OPT) || defined(CONFIG_FEATURE_CROND_CALL_SENDMAIL) 286#if ENABLE_DEBUG_CROND_OPTION || ENABLE_FEATURE_CROND_CALL_SENDMAIL
290/* 287/*
291 write to temp file.. 288 write to temp file..
292*/ 289*/
@@ -341,7 +338,7 @@ static void startlogger(void)
341 if (LogFile == 0) { 338 if (LogFile == 0) {
342 openlog(bb_applet_name, LOG_CONS | LOG_PID, LOG_CRON); 339 openlog(bb_applet_name, LOG_CONS | LOG_PID, LOG_CRON);
343 } 340 }
344#ifdef FEATURE_DEBUG_OPT 341#if ENABLE_DEBUG_CROND_OPTION
345 else { /* test logfile */ 342 else { /* test logfile */
346 int logfd; 343 int logfd;
347 344
@@ -513,7 +510,7 @@ static char *ParseField(char *user, char *ary, int modvalue, int off,
513 while (*ptr == ' ' || *ptr == '\t' || *ptr == '\n') { 510 while (*ptr == ' ' || *ptr == '\t' || *ptr == '\n') {
514 ++ptr; 511 ++ptr;
515 } 512 }
516#ifdef FEATURE_DEBUG_OPT 513#if ENABLE_DEBUG_CROND_OPTION
517 if (DebugOpt) { 514 if (DebugOpt) {
518 int i; 515 int i;
519 516
@@ -595,7 +592,7 @@ static void SynchronizeFile(const char *fileName)
595 } 592 }
596 memset(&line, 0, sizeof(line)); 593 memset(&line, 0, sizeof(line));
597 594
598#ifdef FEATURE_DEBUG_OPT 595#if ENABLE_DEBUG_CROND_OPTION
599 if (DebugOpt) { 596 if (DebugOpt) {
600 crondlog("\111User %s Entry %s\n", fileName, buf); 597 crondlog("\111User %s Entry %s\n", fileName, buf);
601 } 598 }
@@ -626,7 +623,7 @@ static void SynchronizeFile(const char *fileName)
626 /* copy command */ 623 /* copy command */
627 (*pline)->cl_Shell = strdup(ptr); 624 (*pline)->cl_Shell = strdup(ptr);
628 625
629#ifdef FEATURE_DEBUG_OPT 626#if ENABLE_DEBUG_CROND_OPTION
630 if (DebugOpt) { 627 if (DebugOpt) {
631 crondlog("\111 Command %s\n", ptr); 628 crondlog("\111 Command %s\n", ptr);
632 } 629 }
@@ -778,21 +775,21 @@ static int TestJobs(time_t t1, time_t t2)
778 CronLine *line; 775 CronLine *line;
779 776
780 for (file = FileBase; file; file = file->cf_Next) { 777 for (file = FileBase; file; file = file->cf_Next) {
781#ifdef FEATURE_DEBUG_OPT 778#if ENABLE_DEBUG_CROND_OPTION
782 if (DebugOpt) 779 if (DebugOpt)
783 crondlog("\005FILE %s:\n", file->cf_User); 780 crondlog("\005FILE %s:\n", file->cf_User);
784#endif 781#endif
785 if (file->cf_Deleted) 782 if (file->cf_Deleted)
786 continue; 783 continue;
787 for (line = file->cf_LineBase; line; line = line->cl_Next) { 784 for (line = file->cf_LineBase; line; line = line->cl_Next) {
788#ifdef FEATURE_DEBUG_OPT 785#if ENABLE_DEBUG_CROND_OPTION
789 if (DebugOpt) 786 if (DebugOpt)
790 crondlog("\005 LINE %s\n", line->cl_Shell); 787 crondlog("\005 LINE %s\n", line->cl_Shell);
791#endif 788#endif
792 if (line->cl_Mins[tp->tm_min] && line->cl_Hrs[tp->tm_hour] && 789 if (line->cl_Mins[tp->tm_min] && line->cl_Hrs[tp->tm_hour] &&
793 (line->cl_Days[tp->tm_mday] || line->cl_Dow[tp->tm_wday]) 790 (line->cl_Days[tp->tm_mday] || line->cl_Dow[tp->tm_wday])
794 && line->cl_Mons[tp->tm_mon]) { 791 && line->cl_Mons[tp->tm_mon]) {
795#ifdef FEATURE_DEBUG_OPT 792#if ENABLE_DEBUG_CROND_OPTION
796 if (DebugOpt) { 793 if (DebugOpt) {
797 crondlog("\005 JobToDo: %d %s\n", 794 crondlog("\005 JobToDo: %d %s\n",
798 line->cl_Pid, line->cl_Shell); 795 line->cl_Pid, line->cl_Shell);
@@ -881,7 +878,7 @@ static int CheckJobs(void)
881} 878}
882 879
883 880
884#ifdef CONFIG_FEATURE_CROND_CALL_SENDMAIL 881#if ENABLE_FEATURE_CROND_CALL_SENDMAIL
885static void 882static void
886ForkJob(const char *user, CronLine * line, int mailFd, 883ForkJob(const char *user, CronLine * line, int mailFd,
887 const char *prog, const char *cmd, const char *arg, const char *mailf) 884 const char *prog, const char *cmd, const char *arg, const char *mailf)
@@ -898,7 +895,7 @@ ForkJob(const char *user, CronLine * line, int mailFd,
898 if (ChangeUser(user) < 0) { 895 if (ChangeUser(user) < 0) {
899 exit(0); 896 exit(0);
900 } 897 }
901#ifdef FEATURE_DEBUG_OPT 898#if ENABLE_DEBUG_CROND_OPTION
902 if (DebugOpt) { 899 if (DebugOpt) {
903 crondlog("\005Child Running %s\n", prog); 900 crondlog("\005Child Running %s\n", prog);
904 } 901 }
@@ -1030,7 +1027,7 @@ static void RunJob(const char *user, CronLine * line)
1030 if (ChangeUser(user) < 0) { 1027 if (ChangeUser(user) < 0) {
1031 exit(0); 1028 exit(0);
1032 } 1029 }
1033#ifdef FEATURE_DEBUG_OPT 1030#if ENABLE_DEBUG_CROND_OPTION
1034 if (DebugOpt) { 1031 if (DebugOpt) {
1035 crondlog("\005Child Running %s\n", DEFAULT_SHELL); 1032 crondlog("\005Child Running %s\n", DEFAULT_SHELL);
1036 } 1033 }
@@ -1047,4 +1044,4 @@ static void RunJob(const char *user, CronLine * line)
1047 } 1044 }
1048 line->cl_Pid = pid; 1045 line->cl_Pid = pid;
1049} 1046}
1050#endif /* CONFIG_FEATURE_CROND_CALL_SENDMAIL */ 1047#endif /* ENABLE_FEATURE_CROND_CALL_SENDMAIL */