aboutsummaryrefslogtreecommitdiff
path: root/sysklogd/klogd.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2005-09-14 15:36:52 +0000
committerRob Landley <rob@landley.net>2005-09-14 15:36:52 +0000
commit570f655ee4bf56972a91873dee4bb9ef7bc48513 (patch)
tree12bbcc4c2928657dbaea8594f1ff79b2ed1d00bf /sysklogd/klogd.c
parentb7285001c9f21bd2971f9fd511b229e1f0da541c (diff)
downloadbusybox-w32-570f655ee4bf56972a91873dee4bb9ef7bc48513.tar.gz
busybox-w32-570f655ee4bf56972a91873dee4bb9ef7bc48513.tar.bz2
busybox-w32-570f655ee4bf56972a91873dee4bb9ef7bc48513.zip
Cleanup patch from tito: migrate option parsing to the bb_ functions and fix
types.
Diffstat (limited to 'sysklogd/klogd.c')
-rw-r--r--sysklogd/klogd.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/sysklogd/klogd.c b/sysklogd/klogd.c
index c908b593c..e4c8a630e 100644
--- a/sysklogd/klogd.c
+++ b/sysklogd/klogd.c
@@ -113,37 +113,24 @@ static void doKlogd(const int console_log_level)
113 } 113 }
114} 114}
115 115
116#define OPT_LEVEL 1
117#define OPT_FOREGROUND 2
118
116extern int klogd_main(int argc, char **argv) 119extern int klogd_main(int argc, char **argv)
117{ 120{
118 /* no options, no getopt */ 121 unsigned long opt;
119 int opt; 122 char *c_arg;
120 int doFork = TRUE; 123 int console_log_level = -1;
121 unsigned char console_log_level = -1;
122 124
123 /* do normal option parsing */ 125 /* do normal option parsing */
124 while ((opt = getopt(argc, argv, "c:n")) > 0) { 126 opt = bb_getopt_ulflags (argc, argv, "c:n", &c_arg);
125 switch (opt) { 127
126 case 'c': 128 if (opt & OPT_LEVEL) {
127 if ((optarg == NULL) || (optarg[1] != '\0')) { 129 /* Valid levels are between 1 and 8 */
128 bb_show_usage(); 130 console_log_level = bb_xgetlarg(c_arg, 10, 1, 8);
129 }
130 /* Valid levels are between 1 and 8 */
131 console_log_level = *optarg - '1';
132 if (console_log_level > 7) {
133 bb_show_usage();
134 }
135 console_log_level++;
136
137 break;
138 case 'n':
139 doFork = FALSE;
140 break;
141 default:
142 bb_show_usage();
143 }
144 } 131 }
145 132
146 if (doFork) { 133 if (!(opt & OPT_FOREGROUND)) {
147#if defined(__uClinux__) 134#if defined(__uClinux__)
148 vfork_daemon_rexec(0, 1, argc, argv, "-n"); 135 vfork_daemon_rexec(0, 1, argc, argv, "-n");
149#else /* __uClinux__ */ 136#else /* __uClinux__ */