aboutsummaryrefslogtreecommitdiff
path: root/miscutils/crond.c
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-06-20 09:01:58 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-06-20 09:01:58 +0000
commit3b4406c151cabd47b24d309dbbd9c5b19e9d6b33 (patch)
treef67de9320202043aca8ded20fb80d668c3b0c2d8 /miscutils/crond.c
parent90e9e2c71f1e3ed8031334106594ef7fa9e0173b (diff)
downloadbusybox-w32-3b4406c151cabd47b24d309dbbd9c5b19e9d6b33.tar.gz
busybox-w32-3b4406c151cabd47b24d309dbbd9c5b19e9d6b33.tar.bz2
busybox-w32-3b4406c151cabd47b24d309dbbd9c5b19e9d6b33.zip
last_patch89 from vodz:
Manuel, I rewrite bb_getopt_ulflags() function for more universal usage. My version support now: - options with arguments (optional arg as GNU extension also) - complementaly and/or incomplementaly and/or incongruously and/or list options - long_opt (all applets may have long option, add supporting is trivial) This realisation full compatibile from your version. Code size grow 480 bytes, but only coreutils/* over compensate this size after using new function. Last patch reduced over 800 bytes and not full applied to all. "mkdir" and "mv" applets have long_opt now for demonstrate trivial addition support long_opt with usage new bb_getopt_ulflags(). Complementaly and/or incomplementaly and/or incongruously and/or list options logic is not trivial, but new "cut" and "grep" applets using this logic for examples with full demostrating. New "grep" applet reduced over 300 bytes. Mark, Also. I removed bug from "grep" applet. $ echo a b | busybox grep -e a b a b a b But right is printing one only. --w vodz git-svn-id: svn://busybox.net/trunk/busybox@6939 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'miscutils/crond.c')
-rw-r--r--miscutils/crond.c62
1 files changed, 28 insertions, 34 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c
index cbb4ffc58..9d9ecc290 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -117,46 +117,40 @@ static CronFile *FileBase;
117int 117int
118crond_main(int ac, char **av) 118crond_main(int ac, char **av)
119{ 119{
120 int i; 120 unsigned long opt;
121 char *lopt, *Lopt, *copt;
122#ifdef FEATURE_DEBUG_OPT
123 char *dopt;
124 bb_opt_complementaly = "f-b:b-f:S-L:L-S:d-l";
125#else
126 bb_opt_complementaly = "f-b:b-f:S-L:L-S";
127#endif
121 128
122 opterr = 0; /* disable getopt 'errors' message.*/ 129 opterr = 0; /* disable getopt 'errors' message.*/
123 130 opt = bb_getopt_ulflags(ac, av, "l:L:fbSc:"
124 while ((i = getopt(ac,av,
125#ifdef FEATURE_DEBUG_OPT 131#ifdef FEATURE_DEBUG_OPT
126 "d:" 132 "d:"
127#endif 133#endif
128 "l:L:fbSc:")) != EOF){ 134 , &lopt, &Lopt, &copt
129
130 switch (i){
131 case 'l':
132 LogLevel = atoi(optarg);
133 break;
134#ifdef FEATURE_DEBUG_OPT 135#ifdef FEATURE_DEBUG_OPT
135 case 'd': 136 , &dopt
136 DebugOpt = atoi(optarg);
137 LogLevel = 0;
138 break;
139#endif 137#endif
140 case 'f': 138 );
141 ForegroundOpt = 1; 139 if(opt & 1)
142 break; 140 LogLevel = atoi(lopt);
143 case 'b': 141 LoggerOpt = opt & 2;
144 ForegroundOpt = 0; 142 if(LoggerOpt)
145 break; 143 if (*Lopt != 0) LogFile = Lopt;
146 case 'S': /* select logging to syslog */ 144 ForegroundOpt = opt & 4;
147 LoggerOpt = 0; 145 if(opt & 32) {
148 break; 146 if (*copt != 0) CDir = copt;
149 case 'L': /* select internal file logger */
150 LoggerOpt = 1;
151 if (*optarg != 0) LogFile = optarg;
152 break;
153 case 'c':
154 if (*optarg != 0) CDir = optarg;
155 break;
156 default: /* parse error */
157 bb_show_usage();
158 } 147 }
148#ifdef FEATURE_DEBUG_OPT
149 if(opt & 64) {
150 DebugOpt = atoi(dopt);
151 LogLevel = 0;
159 } 152 }
153#endif
160 154
161 /* 155 /*
162 * change directory 156 * change directory
@@ -165,6 +159,9 @@ crond_main(int ac, char **av)
165 if (chdir(CDir) != 0) 159 if (chdir(CDir) != 0)
166 bb_perror_msg_and_die("chdir"); 160 bb_perror_msg_and_die("chdir");
167 161
162 signal(SIGHUP,SIG_IGN); /* hmm.. but, if kill -HUP original
163 * version - his died. ;(
164 */
168 /* 165 /*
169 * close stdin and stdout, stderr. 166 * close stdin and stdout, stderr.
170 * close unused descriptors - don't need. 167 * close unused descriptors - don't need.
@@ -177,9 +174,6 @@ crond_main(int ac, char **av)
177 } 174 }
178 175
179 (void)startlogger(); /* need if syslog mode selected */ 176 (void)startlogger(); /* need if syslog mode selected */
180 signal(SIGHUP,SIG_IGN); /* hmm.. but, if kill -HUP original
181 * version - his died. ;(
182 */
183 177
184 /* 178 /*
185 * main loop - synchronize to 1 second after the minute, minimum sleep 179 * main loop - synchronize to 1 second after the minute, minimum sleep