diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-22 08:44:58 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-22 08:44:58 +0000 |
commit | cb1ba865077720087d47895d4125474ccbf366cc (patch) | |
tree | 50a16e3d6dc052f48e6be13b4886a572d2fb2bd4 | |
parent | f47ff100cc7d7009da6186c7ceec609f211156c8 (diff) | |
download | busybox-w32-cb1ba865077720087d47895d4125474ccbf366cc.tar.gz busybox-w32-cb1ba865077720087d47895d4125474ccbf366cc.tar.bz2 busybox-w32-cb1ba865077720087d47895d4125474ccbf366cc.zip |
logger: getopt_ulflags'isation
-rw-r--r-- | sysklogd/logger.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/sysklogd/logger.c b/sysklogd/logger.c index 762e70ff7..a78cf77b9 100644 --- a/sysklogd/logger.c +++ b/sysklogd/logger.c | |||
@@ -89,30 +89,21 @@ static int pencode(char *s) | |||
89 | 89 | ||
90 | int logger_main(int argc, char **argv) | 90 | int logger_main(int argc, char **argv) |
91 | { | 91 | { |
92 | unsigned long opt; | ||
93 | char *opt_p, *opt_t; | ||
92 | int pri = LOG_USER | LOG_NOTICE; | 94 | int pri = LOG_USER | LOG_NOTICE; |
93 | int option = 0; | 95 | int option = 0; |
94 | int c, i, opt; | 96 | int c, i; |
95 | char buf[1024], name[128]; | 97 | char buf[1024], name[128]; |
96 | 98 | ||
97 | /* Fill out the name string early (may be overwritten later) */ | 99 | /* Fill out the name string early (may be overwritten later) */ |
98 | bb_getpwuid(name, geteuid(), sizeof(name)); | 100 | bb_getpwuid(name, geteuid(), sizeof(name)); |
99 | 101 | ||
100 | /* Parse any options */ | 102 | /* Parse any options */ |
101 | while ((opt = getopt(argc, argv, "p:st:")) > 0) { | 103 | opt = bb_getopt_ulflags(argc, argv, "p:st:", &opt_p, &opt_t); |
102 | switch (opt) { | 104 | if (opt & 0x1) pri = pencode(opt_p); // -p |
103 | case 's': | 105 | if (opt & 0x2) option |= LOG_PERROR; // -s |
104 | option |= LOG_PERROR; | 106 | if (opt & 0x4) safe_strncpy(name, opt_t, sizeof(name)); // -t |
105 | break; | ||
106 | case 'p': | ||
107 | pri = pencode(optarg); | ||
108 | break; | ||
109 | case 't': | ||
110 | safe_strncpy(name, optarg, sizeof(name)); | ||
111 | break; | ||
112 | default: | ||
113 | bb_show_usage(); | ||
114 | } | ||
115 | } | ||
116 | 107 | ||
117 | openlog(name, option, 0); | 108 | openlog(name, option, 0); |
118 | if (optind == argc) { | 109 | if (optind == argc) { |