summaryrefslogtreecommitdiff
path: root/dmiopt.c
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2008-10-26 08:26:51 +0000
committerJean Delvare <jdelvare@suse.de>2008-10-26 08:26:51 +0000
commit06d4ef0cd74b23b69fea5e17295e90f11a38f333 (patch)
tree11ca6dbae4d4f7e99ca43fa546ae1f7ccc9aa613 /dmiopt.c
parent6543db2a0902be71e929aacde28bd70acbf3df40 (diff)
downloaddmidecode-git-06d4ef0cd74b23b69fea5e17295e90f11a38f333.tar.gz
Simplify the handling and documentation of mutually exclusive output
format options.
Diffstat (limited to 'dmiopt.c')
-rw-r--r--dmiopt.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/dmiopt.c b/dmiopt.c
index 5d5cad1..4b35666 100644
--- a/dmiopt.c
+++ b/dmiopt.c
@@ -280,28 +280,16 @@ int parse_command_line(int argc, char * const argv[])
return -1;
}
- if(opt.type!=NULL && opt.string!=NULL)
+ /* Check for mutually exclusive output format options */
+ if((opt.string!=NULL)+(opt.type!=NULL)
+ +!!(opt.flags & FLAG_DUMP)+!!(opt.flags & FLAG_DUMP_BIN)>1)
{
- fprintf(stderr, "Options --string and --type are mutually exclusive\n");
+ fprintf(stderr, "Options --string, --type, --dump and --dump-bin are mutually exclusive\n");
return -1;
}
+ if(opt.flags & (FLAG_DUMP | FLAG_DUMP_BIN))
+ opt.flags&=~FLAG_QUIET;
- if((opt.flags & FLAG_DUMP) && opt.string!=NULL)
- {
- fprintf(stderr, "Options --string and --dump are mutually exclusive\n");
- return -1;
- }
-
- if((opt.flags & FLAG_DUMP) && (opt.flags & FLAG_QUIET))
- {
- fprintf(stderr, "Options --quiet and --dump are mutually exclusive\n");
- return -1;
- }
- if((opt.flags & FLAG_DUMP_BIN) && (opt.type!=NULL || opt.string!=NULL))
- {
- fprintf(stderr, "Options --dump-bin, --string and --type are mutually exclusive\n");
- return -1;
- }
if((opt.flags & FLAG_FROM_DUMP) && (opt.flags & FLAG_DUMP_BIN))
{
fprintf(stderr, "Options --from-dump and --dump-bin are mutually exclusive\n");