summaryrefslogtreecommitdiffstats
path: root/sys-utils/dmesg.c
diff options
context:
space:
mode:
authorKarel Zak2012-07-26 09:25:35 +0200
committerKarel Zak2012-07-26 09:25:35 +0200
commit43d2eeef5dd3a64c372dbf60e4a32aa9e97b4645 (patch)
treec7e4b20c7dad50355165d26dd0bcd901bdaf1a6f /sys-utils/dmesg.c
parentchcpu: use err_exclusive_options() (diff)
downloadkernel-qcow2-util-linux-43d2eeef5dd3a64c372dbf60e4a32aa9e97b4645.tar.gz
kernel-qcow2-util-linux-43d2eeef5dd3a64c372dbf60e4a32aa9e97b4645.tar.xz
kernel-qcow2-util-linux-43d2eeef5dd3a64c372dbf60e4a32aa9e97b4645.zip
dmesg: use err_exclusive_options()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/dmesg.c')
-rw-r--r--sys-utils/dmesg.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index 1819c7c64..c4d1f9f38 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -995,19 +995,6 @@ int main(int argc, char *argv[])
.kmsg = -1,
};
- enum {
- EXCL_NONE,
- EXCL_CLEAR,
- EXCL_READ_CLEAR,
- EXCL_CONSOLE_LEVEL,
- EXCL_CONSOLE_ON,
- EXCL_CONSOLE_OFF,
- EXCL_FOLLOW,
- EXCL_SYSLOG
- };
-
- int excl_act = EXCL_NONE, excl_sys = EXCL_NONE;
-
static const struct option longopts[] = {
{ "buffer-size", required_argument, NULL, 's' },
{ "clear", no_argument, NULL, 'C' },
@@ -1033,6 +1020,13 @@ int main(int argc, char *argv[])
{ NULL, 0, NULL, 0 }
};
+ static const ul_excl_t excl[] = { /* rows and cols in in ASCII order */
+ { 'C','D','E','c','n' }, /* clear,off,on,read-clear,level*/
+ { 'S','w' }, /* syslog,follow */
+ { 0 }
+ };
+ int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
+
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
@@ -1040,24 +1034,23 @@ int main(int argc, char *argv[])
while ((c = getopt_long(argc, argv, "CcDdEeF:f:hkl:n:rSs:TtuVwx",
longopts, NULL)) != -1) {
+
+ err_exclusive_options(c, longopts, excl, excl_st);
+
switch (c) {
case 'C':
- exclusive_option(&excl_act, EXCL_CLEAR, EXCL_ACT_ERR);
ctl.action = SYSLOG_ACTION_CLEAR;
break;
case 'c':
- exclusive_option(&excl_act, EXCL_READ_CLEAR, EXCL_ACT_ERR);
ctl.action = SYSLOG_ACTION_READ_CLEAR;
break;
case 'D':
- exclusive_option(&excl_act, EXCL_CONSOLE_OFF, EXCL_ACT_ERR);
ctl.action = SYSLOG_ACTION_CONSOLE_OFF;
break;
case 'd':
ctl.delta = 1;
break;
case 'E':
- exclusive_option(&excl_act, EXCL_CONSOLE_ON, EXCL_ACT_ERR);
ctl.action = SYSLOG_ACTION_CONSOLE_ON;
break;
case 'e':
@@ -1089,7 +1082,6 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
break;
case 'n':
- exclusive_option(&excl_act, EXCL_CONSOLE_LEVEL, EXCL_ACT_ERR);
ctl.action = SYSLOG_ACTION_CONSOLE_LEVEL;
console_level = parse_level(optarg, 0);
break;
@@ -1097,7 +1089,6 @@ int main(int argc, char *argv[])
ctl.raw = 1;
break;
case 'S':
- exclusive_option(&excl_sys, EXCL_SYSLOG, EXCL_SYS_ERR);
ctl.method = DMESG_METHOD_SYSLOG;
break;
case 's':
@@ -1124,7 +1115,6 @@ int main(int argc, char *argv[])
PACKAGE_STRING);
return EXIT_SUCCESS;
case 'w':
- exclusive_option(&excl_sys, EXCL_FOLLOW, EXCL_SYS_ERR);
ctl.follow = 1;
break;
case 'x':