Cleanup patch from tito: migrate option parsing to the bb_ functions and fix

types.
This commit is contained in:
Rob Landley 2005-09-14 15:36:52 +00:00
parent b7285001c9
commit 570f655ee4

View File

@ -113,37 +113,24 @@ static void doKlogd(const int console_log_level)
} }
} }
#define OPT_LEVEL 1
#define OPT_FOREGROUND 2
extern int klogd_main(int argc, char **argv) extern int klogd_main(int argc, char **argv)
{ {
/* no options, no getopt */ unsigned long opt;
int opt; char *c_arg;
int doFork = TRUE; int console_log_level = -1;
unsigned char console_log_level = -1;
/* do normal option parsing */ /* do normal option parsing */
while ((opt = getopt(argc, argv, "c:n")) > 0) { opt = bb_getopt_ulflags (argc, argv, "c:n", &c_arg);
switch (opt) {
case 'c':
if ((optarg == NULL) || (optarg[1] != '\0')) {
bb_show_usage();
}
/* Valid levels are between 1 and 8 */
console_log_level = *optarg - '1';
if (console_log_level > 7) {
bb_show_usage();
}
console_log_level++;
break; if (opt & OPT_LEVEL) {
case 'n': /* Valid levels are between 1 and 8 */
doFork = FALSE; console_log_level = bb_xgetlarg(c_arg, 10, 1, 8);
break;
default:
bb_show_usage();
}
} }
if (doFork) { if (!(opt & OPT_FOREGROUND)) {
#if defined(__uClinux__) #if defined(__uClinux__)
vfork_daemon_rexec(0, 1, argc, argv, "-n"); vfork_daemon_rexec(0, 1, argc, argv, "-n");
#else /* __uClinux__ */ #else /* __uClinux__ */