OpenPGP: allow calling -d multiple times

Put the arguments passed to option -d into an array instead of only
storing the latest value.
During output, iterate over the values passed in via the option.
This commit is contained in:
Peter Marschall 2018-05-20 16:01:34 +02:00 committed by Frank Morgner
parent 1da7da5e99
commit 85f4ba6c5f
1 changed files with 11 additions and 5 deletions

View File

@ -88,8 +88,8 @@ static int opt_pin = 0;
static const char *pin = NULL;
static int opt_erase = 0;
static int opt_delkey = 0;
static int opt_dump_do = 0;
static unsigned int do_dump_idx;
static size_t opt_dump_do = 0;
static unsigned int do_dump_idx[200]; /* large enough and checked on input */
static const char *app_name = "openpgp-tool";
@ -327,8 +327,10 @@ static int decode_options(int argc, char **argv)
printf("Unable to parse DO identifier\n");
return 1;
}
do_dump_idx = (unsigned int) (val | 0x100);
opt_dump_do++;
if (opt_dump_do < sizeof(do_dump_idx) / sizeof(*do_dump_idx)) {
do_dump_idx[opt_dump_do] = (unsigned int) (val | 0x100);
opt_dump_do++;
}
actions++;
break;
default:
@ -654,7 +656,11 @@ int main(int argc, char **argv)
}
if (opt_dump_do) {
exit_status |= do_dump_do(card, do_dump_idx);
size_t n;
for (n = 0; n < opt_dump_do; n++) {
exit_status |= do_dump_do(card, do_dump_idx[n]);
}
}
if (opt_genkey)