opensc-tool: make '--card-driver ?' list all available drivers
Extend opensc-tool the same way opensc-explorer was extended. I.e. treat the question mark given as argument to option '--card-driver' special: list all available drivers instead of stupidly bailing out.
This commit is contained in:
parent
5da40bf027
commit
94288b438e
|
@ -52,8 +52,12 @@
|
|||
<option>--card-driver</option> <replaceable>driver</replaceable>,
|
||||
<option>-c</option> <replaceable>driver</replaceable>
|
||||
</term>
|
||||
<listitem><para>Use the given card driver.
|
||||
The default is auto-detected.</para></listitem>
|
||||
<listitem><para>
|
||||
Use the given card driver.
|
||||
The default is to auto-detect the correct card driver.
|
||||
The literal value <literal>?</literal> lists
|
||||
all available card drivers.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
|
|
|
@ -90,7 +90,7 @@ static const char *option_help[] = {
|
|||
"Sends an APDU in format AA:BB:CC:DD:EE:FF...",
|
||||
"Uses reader number <arg> [0]",
|
||||
"Does card reset of type <cold|warm> [cold]",
|
||||
"Forces the use of driver <arg> [auto-detect]",
|
||||
"Forces the use of driver <arg> [auto-detect; '?' for list]",
|
||||
"Lists algorithms supported by card",
|
||||
"Wait for a card to be inserted",
|
||||
"Verbose operation. Use several times to enable debug output.",
|
||||
|
@ -300,22 +300,6 @@ static int list_readers(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int list_drivers(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (ctx->card_drivers[0] == NULL) {
|
||||
printf("No card drivers installed!\n");
|
||||
return 0;
|
||||
}
|
||||
printf("Configured card drivers:\n");
|
||||
for (i = 0; ctx->card_drivers[i] != NULL; i++) {
|
||||
printf(" %-16s %s\n", ctx->card_drivers[i]->short_name,
|
||||
ctx->card_drivers[i]->name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int print_file(sc_card_t *in_card, const sc_file_t *file,
|
||||
const sc_path_t *path, int depth)
|
||||
{
|
||||
|
@ -784,6 +768,13 @@ int main(int argc, char *argv[])
|
|||
break;
|
||||
case 'c':
|
||||
opt_driver = optarg;
|
||||
|
||||
/* treat argument "?" as request to list drivers */
|
||||
if (opt_driver && strncmp("?", opt_driver, sizeof("?")) == 0) {
|
||||
opt_driver = NULL;
|
||||
do_list_drivers = 1;
|
||||
action_count++;
|
||||
}
|
||||
break;
|
||||
case 'w':
|
||||
opt_wait = 1;
|
||||
|
@ -844,7 +835,7 @@ int main(int argc, char *argv[])
|
|||
action_count--;
|
||||
}
|
||||
if (do_list_drivers) {
|
||||
if ((err = list_drivers()))
|
||||
if ((err = util_list_card_drivers(ctx)))
|
||||
goto end;
|
||||
action_count--;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue