diff options
author | Eric Andersen | 2003-06-20 09:01:58 +0000 |
---|---|---|
committer | Eric Andersen | 2003-06-20 09:01:58 +0000 |
commit | 8876fb2f59a0b515b3121d5894933eef88ce566a (patch) | |
tree | f67de9320202043aca8ded20fb80d668c3b0c2d8 /miscutils | |
parent | dfce3536ace2bcd38bdd3731841998ce344d786e (diff) | |
download | busybox-8876fb2f59a0b515b3121d5894933eef88ce566a.zip busybox-8876fb2f59a0b515b3121d5894933eef88ce566a.tar.gz |
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
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/crond.c | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c index cbb4ffc..9d9ecc2 100644 --- a/miscutils/crond.c +++ b/miscutils/crond.c @@ -117,46 +117,40 @@ static CronFile *FileBase; int crond_main(int ac, char **av) { - int i; + unsigned long opt; + char *lopt, *Lopt, *copt; +#ifdef FEATURE_DEBUG_OPT + char *dopt; + bb_opt_complementaly = "f-b:b-f:S-L:L-S:d-l"; +#else + bb_opt_complementaly = "f-b:b-f:S-L:L-S"; +#endif opterr = 0; /* disable getopt 'errors' message.*/ - - while ((i = getopt(ac,av, + opt = bb_getopt_ulflags(ac, av, "l:L:fbSc:" #ifdef FEATURE_DEBUG_OPT "d:" #endif - "l:L:fbSc:")) != EOF){ - - switch (i){ - case 'l': - LogLevel = atoi(optarg); - break; + , &lopt, &Lopt, &copt #ifdef FEATURE_DEBUG_OPT - case 'd': - DebugOpt = atoi(optarg); - LogLevel = 0; - break; + , &dopt #endif - case 'f': - ForegroundOpt = 1; - break; - case 'b': - ForegroundOpt = 0; - break; - case 'S': /* select logging to syslog */ - LoggerOpt = 0; - break; - case 'L': /* select internal file logger */ - LoggerOpt = 1; - if (*optarg != 0) LogFile = optarg; - break; - case 'c': - if (*optarg != 0) CDir = optarg; - break; - default: /* parse error */ - bb_show_usage(); + ); + if(opt & 1) + LogLevel = atoi(lopt); + LoggerOpt = opt & 2; + if(LoggerOpt) + if (*Lopt != 0) LogFile = Lopt; + ForegroundOpt = opt & 4; + if(opt & 32) { + if (*copt != 0) CDir = copt; } +#ifdef FEATURE_DEBUG_OPT + if(opt & 64) { + DebugOpt = atoi(dopt); + LogLevel = 0; } +#endif /* * change directory @@ -165,6 +159,9 @@ crond_main(int ac, char **av) if (chdir(CDir) != 0) bb_perror_msg_and_die("chdir"); + signal(SIGHUP,SIG_IGN); /* hmm.. but, if kill -HUP original + * version - his died. ;( + */ /* * close stdin and stdout, stderr. * close unused descriptors - don't need. @@ -177,9 +174,6 @@ crond_main(int ac, char **av) } (void)startlogger(); /* need if syslog mode selected */ - signal(SIGHUP,SIG_IGN); /* hmm.. but, if kill -HUP original - * version - his died. ;( - */ /* * main loop - synchronize to 1 second after the minute, minimum sleep |