cardos-tool: make '--card-driver ?' list all available drivers
Extend cardos-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. In contrast to opensc-tool and opensc-explorer, which are card-agnostic, I am not sure whether the option '--card-driver' makes sense on this card-specific tool.
This commit is contained in:
parent
30fdc7de4a
commit
a10368769c
|
@ -36,9 +36,15 @@ smart cards and similar security tokens based on Siemens Card/OS M4.
|
|||
<varlistentry>
|
||||
<term>
|
||||
<option>--card-driver</option> <replaceable>name</replaceable>,
|
||||
<option>-c</option> <replaceable>name</replaceable></term>
|
||||
<listitem><para>Use the card driver specified by <replaceable>name</replaceable>.
|
||||
The default is to auto-detect the correct card driver.</para></listitem>
|
||||
<option>-c</option> <replaceable>name</replaceable>
|
||||
</term>
|
||||
<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 and terminates
|
||||
<command>cardos-tool</command>.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
|
|
|
@ -67,7 +67,7 @@ static const char *option_help[] = {
|
|||
"Specify startkey for format",
|
||||
"Change Startkey with given APDU command",
|
||||
"Uses reader number <arg> [0]",
|
||||
"Forces the use of driver <arg> [auto-detect]",
|
||||
"Forces the use of driver <arg> [auto-detect; '?' for list]",
|
||||
"Wait for a card to be inserted",
|
||||
"Verbose operation. Use several times to enable debug output.",
|
||||
};
|
||||
|
@ -1038,6 +1038,7 @@ int main(int argc, char *argv[])
|
|||
int do_info = 0;
|
||||
int do_format = 0;
|
||||
int do_change_startkey = 0;
|
||||
int do_list_card_drivers = 0;
|
||||
int action_count = 0;
|
||||
const char *opt_driver = NULL;
|
||||
const char *opt_startkey = NULL;
|
||||
|
@ -1077,6 +1078,13 @@ int main(int argc, char *argv[])
|
|||
break;
|
||||
case 'c':
|
||||
opt_driver = optarg;
|
||||
|
||||
/* special card driver value "?" means: list available drivers */
|
||||
if (opt_driver != NULL && strncmp("?", opt_driver, sizeof("?")) == 0) {
|
||||
opt_driver = NULL;
|
||||
do_list_card_drivers = 1;
|
||||
action_count++;
|
||||
}
|
||||
break;
|
||||
case 'w':
|
||||
opt_wait = 1;
|
||||
|
@ -1095,6 +1103,11 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (do_list_card_drivers) {
|
||||
err = util_list_card_drivers(ctx);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (opt_driver != NULL) {
|
||||
err = sc_set_card_driver(ctx, opt_driver);
|
||||
if (err) {
|
||||
|
|
Loading…
Reference in New Issue