diff options
author | Werner Koch <wk@gnupg.org> | 2020-11-27 11:14:30 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2020-11-27 11:14:30 +0100 |
commit | 0e34683a6c4b037aa50ca0f97ddb9d5c4e499084 (patch) | |
tree | 9ed6e896bfe1f0c9bb1fd4bca4529668f74980a5 /scd/command.c | |
parent | card: Netkey improvement for passwd. (diff) | |
download | gnupg2-0e34683a6c4b037aa50ca0f97ddb9d5c4e499084.tar.xz gnupg2-0e34683a6c4b037aa50ca0f97ddb9d5c4e499084.zip |
scd: New getinfo sub-command apdu_strerror.
* scd/apdu.c (apdu_strerror): Add missing status codes.
* scd/command.c (cmd_getinfo): New sub-command apdu_strerror.
--
This is quite handy for gpg-card's APDU command and avoids that we
need to duplicate the mapping table or put it into a shared file.
Diffstat (limited to '')
-rw-r--r-- | scd/command.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/scd/command.c b/scd/command.c index 457347121..5bb52246b 100644 --- a/scd/command.c +++ b/scd/command.c @@ -1728,15 +1728,18 @@ static const char hlp_getinfo[] = " all_active_apps\n" " - Return a list of active apps on all inserted cards.\n" " cmd_has_option CMD OPT\n" - " - Returns OK if command CMD has option OPT.\n"; + " - Returns OK if command CMD has option OPT.\n" + " apdu_strerror NUMBER\n" + " - Return a string for a status word.\n"; static gpg_error_t cmd_getinfo (assuan_context_t ctx, char *line) { int rc = 0; + const char *s; if (!strcmp (line, "version")) { - const char *s = VERSION; + s = VERSION; rc = assuan_send_data (ctx, s, strlen (s)); } else if (!strcmp (line, "pid")) @@ -1780,8 +1783,7 @@ cmd_getinfo (assuan_context_t ctx, char *line) } else if (!strcmp (line, "socket_name")) { - const char *s = scd_get_socket_name (); - + s = scd_get_socket_name (); if (s) rc = assuan_send_data (ctx, s, strlen (s)); else @@ -1809,27 +1811,27 @@ cmd_getinfo (assuan_context_t ctx, char *line) else if (!strcmp (line, "reader_list")) { #ifdef HAVE_LIBUSB - char *s = ccid_get_reader_list (); + char *p = ccid_get_reader_list (); #else - char *s = NULL; + char *p = NULL; #endif - if (s) - rc = assuan_send_data (ctx, s, strlen (s)); + if (p) + rc = assuan_send_data (ctx, p, strlen (p)); else rc = gpg_error (GPG_ERR_NO_DATA); - xfree (s); + xfree (p); } else if (!strcmp (line, "deny_admin")) rc = opt.allow_admin? gpg_error (GPG_ERR_GENERAL) : 0; else if (!strcmp (line, "app_list")) { - char *s = get_supported_applications (); - if (s) - rc = assuan_send_data (ctx, s, strlen (s)); + char *p = get_supported_applications (); + if (p) + rc = assuan_send_data (ctx, p, strlen (p)); else rc = 0; - xfree (s); + xfree (p); } else if (!strcmp (line, "card_list")) { @@ -1850,6 +1852,12 @@ cmd_getinfo (assuan_context_t ctx, char *line) ctrl_t ctrl = assuan_get_pointer (ctx); rc = app_send_active_apps (NULL, ctrl); } + else if ((s=has_leading_keyword (line, "apdu_strerror"))) + { + unsigned long ul = strtoul (s, NULL, 0); + s = apdu_strerror (ul); + rc = assuan_send_data (ctx, s, strlen (s)); + } else rc = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT"); return rc; |