diff options
author | Sami Kerola | 2012-06-16 11:31:47 +0200 |
---|---|---|
committer | Sami Kerola | 2012-06-17 17:59:59 +0200 |
commit | 9492013429d0d9fd6e3bbe7cf5fe6f3ee37e4abe (patch) | |
tree | e80ef3715ec3fec21a9283c4075d57eb6c039417 /sys-utils | |
parent | wipefs: use exclusive_option() (diff) | |
download | kernel-qcow2-util-linux-9492013429d0d9fd6e3bbe7cf5fe6f3ee37e4abe.tar.gz kernel-qcow2-util-linux-9492013429d0d9fd6e3bbe7cf5fe6f3ee37e4abe.tar.xz kernel-qcow2-util-linux-9492013429d0d9fd6e3bbe7cf5fe6f3ee37e4abe.zip |
dmesg: use exclusive_option()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils')
-rw-r--r-- | sys-utils/dmesg.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index 854990361..9fc7982a1 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -30,6 +30,7 @@ #include "all-io.h" #include "bitops.h" #include "closestream.h" +#include "optutils.h" /* Close the log. Currently a NOP. */ #define SYSLOG_ACTION_CLOSE 0 @@ -54,6 +55,8 @@ /* Return size of the log buffer */ #define SYSLOG_ACTION_SIZE_BUFFER 10 +#define EXCL_ERROR "--{clear,read-clear,console-level,console-on,console-off}" + /* * Priority and facility names */ @@ -664,6 +667,16 @@ int main(int argc, char *argv[]) int cmd = -1; static struct dmesg_control ctl; + enum { + EXCL_NONE, + EXCL_CLEAR, + EXCL_READ_CLEAR, + EXCL_CONSOLE_LEVEL, + EXCL_CONSOLE_ON, + EXCL_CONSOLE_OFF + }; + int excl_any = EXCL_NONE; + static const struct option longopts[] = { { "buffer-size", required_argument, NULL, 's' }, { "clear", no_argument, NULL, 'C' }, @@ -693,26 +706,24 @@ int main(int argc, char *argv[]) while ((c = getopt_long(argc, argv, "CcDdEF:f:hkl:n:rs:TtuVx", longopts, NULL)) != -1) { - - if (cmd != -1 && strchr("CcnDE", c)) - errx(EXIT_FAILURE, _("clear, read-clear, console-level, " - "console-on, and console-off options are mutually " - "exclusive")); - switch (c) { case 'C': + exclusive_option(&excl_any, EXCL_CLEAR, EXCL_ERROR); cmd = SYSLOG_ACTION_CLEAR; break; case 'c': + exclusive_option(&excl_any, EXCL_READ_CLEAR, EXCL_ERROR); cmd = SYSLOG_ACTION_READ_CLEAR; break; case 'D': + exclusive_option(&excl_any, EXCL_CONSOLE_OFF, EXCL_ERROR); cmd = SYSLOG_ACTION_CONSOLE_OFF; break; case 'd': ctl.delta = 1; break; case 'E': + exclusive_option(&excl_any, EXCL_CONSOLE_ON, EXCL_ERROR); cmd = SYSLOG_ACTION_CONSOLE_ON; break; case 'F': @@ -738,6 +749,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; break; case 'n': + exclusive_option(&excl_any, EXCL_CONSOLE_LEVEL, EXCL_ERROR); cmd = SYSLOG_ACTION_CONSOLE_LEVEL; console_level = parse_level(optarg, 0); break; |