From 1348ea90142bb2b3ac542343b5c78ea1a56dcd41 Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Wed, 11 Apr 2012 10:49:10 +0200 Subject: [PATCH] rules for combinations with -n --- ykpers-args.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/ykpers-args.c b/ykpers-args.c index 5ff61a6..4b64899 100644 --- a/ykpers-args.c +++ b/ykpers-args.c @@ -301,16 +301,21 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, switch (c) { case 'u': - if(slot_chosen) { + if (slot_chosen) { fprintf(stderr, "You must use update before slot (-1 / -2).\n"); *exit_code = 1; return 0; } - if(swap_seen) { + if (swap_seen) { fprintf(stderr, "Update (-u) and swap (-x) can't be combined.\n"); *exit_code = 1; return 0; } + if (ndef_seen) { + fprintf(stderr, "Update (-u) can not be combined with ndef (-n).\n"); + *exit_code = 1; + return 0; + } update_seen = true; break; case '1': @@ -330,6 +335,11 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, *exit_code = 1; return 0; } + if (ndef_seen) { + fprintf(stderr, "Slot (-1 / -2) can not be combined with ndef (-n)\n"); + *exit_code = 1; + return 0; + } int command; if (update_seen) { memcpy(ycfg, &default_update, sizeof(default_update)); @@ -366,6 +376,11 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, *exit_code = 1; return 0; } + if (ndef_seen) { + fprintf(stderr, "Swap (-x) can not be combined with ndef (-n).\n"); + *exit_code = 1; + return 0; + } if (!ykp_configure_command(cfg, SLOT_SWAP)) { return 0; } @@ -401,7 +416,7 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, break; } case 'n': - if (slot_chosen || swap_seen || update_seen) { + if (slot_chosen || swap_seen || update_seen || option_seen) { fprintf(stderr, "Ndef (-n) must be used on it's own.\n"); *exit_code = 1; return 0; -- 2.39.5