summaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu.c
diff options
context:
space:
mode:
authorSami Kerola2012-06-15 23:16:21 +0200
committerSami Kerola2012-06-17 17:59:59 +0200
commit41a8940d430bf119196ecc27b4dc10c41f7c34a9 (patch)
tree3eaee7afefadb4952a6869b20c537b1b890c99d5 /sys-utils/lscpu.c
parentlosetup: use exclusive_option() (diff)
downloadkernel-qcow2-util-linux-41a8940d430bf119196ecc27b4dc10c41f7c34a9.tar.gz
kernel-qcow2-util-linux-41a8940d430bf119196ecc27b4dc10c41f7c34a9.tar.xz
kernel-qcow2-util-linux-41a8940d430bf119196ecc27b4dc10c41f7c34a9.zip
lscpu: use exclusive_option()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r--sys-utils/lscpu.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 1adc92bad..05a5fb43a 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -42,6 +42,7 @@
#include "tt.h"
#include "path.h"
#include "closestream.h"
+#include "optutils.h"
#define CACHE_MAX 100
@@ -1242,6 +1243,19 @@ int main(int argc, char *argv[])
int c, i;
int columns[ARRAY_SIZE(coldescs)], ncolumns = 0;
+ enum {
+ EXCL_NONE,
+
+ EXCL_ALL,
+ EXCL_ONLINE,
+ EXCL_OFFLINE,
+
+ EXCL_EXTENDED,
+ EXCL_PARSE
+ };
+ int excl_ep = EXCL_NONE;
+ int excl_abc = EXCL_NONE;
+
static const struct option longopts[] = {
{ "all", no_argument, 0, 'a' },
{ "online", no_argument, 0, 'b' },
@@ -1261,28 +1275,27 @@ int main(int argc, char *argv[])
atexit(close_stdout);
while ((c = getopt_long(argc, argv, "abce::hp::s:xV", longopts, NULL)) != -1) {
-
- if (mod->mode != OUTPUT_SUMMARY && strchr("ep", c))
- errx(EXIT_FAILURE,
- _("extended and parsable formats are mutually exclusive"));
- if ((mod->online || mod->offline) && strchr("abc", c))
- errx(EXIT_FAILURE,
- _("--all, --online and --offline options are mutually exclusive"));
-
switch (c) {
case 'a':
+ exclusive_option(&excl_abc, EXCL_ALL, "--{all,online,offline}");
mod->online = mod->offline = 1;
break;
case 'b':
+ exclusive_option(&excl_abc, EXCL_ONLINE, "--{all,online,offline}");
mod->online = 1;
break;
case 'c':
+ exclusive_option(&excl_abc, EXCL_OFFLINE, "--{all,online,offline}");
mod->offline = 1;
break;
case 'h':
usage(stdout);
case 'p':
+ exclusive_option(&excl_ep, EXCL_PARSE, "--{extended,parse}");
+ goto hop_over;
case 'e':
+ exclusive_option(&excl_ep, EXCL_EXTENDED, "--{extended,parse}");
+ hop_over:
if (optarg) {
if (*optarg == '=')
optarg++;