diff options
author | Denis Vlasenko | 2006-09-19 17:40:31 +0000 |
---|---|---|
committer | Denis Vlasenko | 2006-09-19 17:40:31 +0000 |
commit | c7b9bad519c56e5d4437cf954ac61d8bace64636 (patch) | |
tree | f4ad664c136653eddcdf6b13656659321f1bd7d4 /util-linux/ipcs.c | |
parent | 79deb66c357c45d2237e755efb13cc912805a9cd (diff) | |
download | busybox-c7b9bad519c56e5d4437cf954ac61d8bace64636.zip busybox-c7b9bad519c56e5d4437cf954ac61d8bace64636.tar.gz |
ipcs: getopt_ulflag'ification, -170 bytes
Diffstat (limited to 'util-linux/ipcs.c')
-rw-r--r-- | util-linux/ipcs.c | 55 |
1 files changed, 16 insertions, 39 deletions
diff --git a/util-linux/ipcs.c b/util-linux/ipcs.c index c54f535..78c0ce9 100644 --- a/util-linux/ipcs.c +++ b/util-linux/ipcs.c @@ -570,52 +570,29 @@ static void print_sem(int semid) int ipcs_main(int argc, char **argv) { - int opt, id = 0; + int id = 0; unsigned flags = 0; + unsigned long opt; + char *opt_i; #define flag_print (1<<0) #define flag_msg (1<<1) #define flag_sem (1<<2) #define flag_shm (1<<3) - const char *const options = "atclupsmqi:ih?"; - while ((opt = getopt(argc, argv, options)) != -1) { - switch (opt) { - case 'i': - id = atoi(optarg); - flags |= flag_print; - break; - case 'a': - flags |= flag_msg | flag_sem | flag_shm; - break; - case 'q': - flags |= flag_msg; - break; - case 's': - flags |= flag_sem; - break; - case 'm': - flags |= flag_shm; - break; - case 't': - format = TIME; - break; - case 'c': - format = CREATOR; - break; - case 'p': - format = PID; - break; - case 'l': - format = LIMITS; - break; - case 'u': - format = STATUS; - break; - case 'h': - case '?': - bb_show_usage(); - } + opt = bb_getopt_ulflags(argc, argv, "i:aqsmtcplu", &opt_i); + if (opt & 0x1) { // -i + id = atoi(optarg); + flags |= flag_print; } + if (opt & 0x2) flags |= flag_msg | flag_sem | flag_shm; // -a + if (opt & 0x4) flags |= flag_msg; // -q + if (opt & 0x8) flags |= flag_sem; // -s + if (opt & 0x10) flags |= flag_shm; // -m + if (opt & 0x20) format = TIME; // -t + if (opt & 0x40) format = CREATOR; // -c + if (opt & 0x80) format = PID; // -p + if (opt & 0x100) format = LIMITS; // -l + if (opt & 0x200) format = STATUS; // -u if (flags & flag_print) { if (flags & flag_shm) { |