mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-21 14:47:03 +01:00
scd: Add "card_list" sub command for GETINFO.
* scd/app.c (app_send_card_list): New. * scd/command.c (cmd_getinfo): Fix "status" sub command. Add "card_list" sub command. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
a09f258b14
commit
8b1f24a29e
@ -123,6 +123,7 @@ size_t app_help_read_length_of_cert (int slot, int fid, size_t *r_certoff);
|
||||
/*-- app.c --*/
|
||||
app_t app_list_start (void);
|
||||
void app_list_finish (void);
|
||||
void app_send_card_list (ctrl_t ctrl);
|
||||
|
||||
void app_dump_state (void);
|
||||
void application_notify_card_reset (int slot);
|
||||
|
18
scd/app.c
18
scd/app.c
@ -1103,3 +1103,21 @@ app_list_finish (void)
|
||||
{
|
||||
npth_mutex_unlock (&app_list_lock);
|
||||
}
|
||||
|
||||
void
|
||||
app_send_card_list (ctrl_t ctrl)
|
||||
{
|
||||
app_t a;
|
||||
char buf[65];
|
||||
|
||||
npth_mutex_lock (&app_list_lock);
|
||||
for (a = app_top; a; a = a->next)
|
||||
{
|
||||
if (DIM (buf) < 2 * a->serialnolen + 1)
|
||||
continue;
|
||||
|
||||
bin2hex (a->serialno, a->serialnolen, buf);
|
||||
send_status_direct (ctrl, "SERIALNO", buf);
|
||||
}
|
||||
npth_mutex_unlock (&app_list_lock);
|
||||
}
|
||||
|
@ -1392,7 +1392,10 @@ static const char hlp_getinfo[] =
|
||||
"\n"
|
||||
"app_list - Return a list of supported applications. One\n"
|
||||
" application per line, fields delimited by colons,\n"
|
||||
" first field is the name.";
|
||||
" first field is the name.\n"
|
||||
"\n"
|
||||
"card_list - Return a list of serial numbers of active cards,\n"
|
||||
" using a status response.";
|
||||
static gpg_error_t
|
||||
cmd_getinfo (assuan_context_t ctx, char *line)
|
||||
{
|
||||
@ -1422,10 +1425,11 @@ cmd_getinfo (assuan_context_t ctx, char *line)
|
||||
else if (!strcmp (line, "status"))
|
||||
{
|
||||
ctrl_t ctrl = assuan_get_pointer (ctx);
|
||||
app_t app = ctrl->app_ctx;
|
||||
char flag = 'r';
|
||||
char flag;
|
||||
|
||||
if (!ctrl->server_local->card_removed && app)
|
||||
if (open_card (ctrl))
|
||||
flag = 'r';
|
||||
else
|
||||
flag = 'u';
|
||||
|
||||
rc = assuan_send_data (ctx, &flag, 1);
|
||||
@ -1455,6 +1459,12 @@ cmd_getinfo (assuan_context_t ctx, char *line)
|
||||
rc = 0;
|
||||
xfree (s);
|
||||
}
|
||||
else if (!strcmp (line, "card_list"))
|
||||
{
|
||||
ctrl_t ctrl = assuan_get_pointer (ctx);
|
||||
|
||||
app_send_card_list (ctrl);
|
||||
}
|
||||
else
|
||||
rc = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT");
|
||||
return rc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user