1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-05-27 21:41:23 +02:00

2006-09-01 Marcus Brinkmann <marcus@g10code.de>

* command.c (cmd_getinfo): Handle status command.
This commit is contained in:
Marcus Brinkmann 2006-09-01 13:57:33 +00:00
parent 9bdb549dc4
commit 59a5681e63
2 changed files with 35 additions and 3 deletions

View File

@ -1,3 +1,7 @@
2006-09-01 Marcus Brinkmann <marcus@g10code.de>
* command.c (cmd_getinfo): Handle status command.
2006-08-30 Marcus Brinkmann <marcus@g10code.de>
* command.c (do_reset): Delay resetting CTRL->reader_slot until

View File

@ -295,7 +295,7 @@ get_reader_slot (void)
/* If the card has not yet been opened, do it. Note that this
function returns an Assuan error, so don't map the error a second
time */
time. */
static assuan_error_t
open_card (ctrl_t ctrl, const char *apptype)
{
@ -1355,7 +1355,12 @@ cmd_unlock (assuan_context_t ctx, char *line)
Supported values of WHAT are:
socket_name - Return the name of the socket.
status - Return the status of the current slot (in the future, may
also return the status of all slots). The status is a list of
one-character flags. The following flags are currently defined:
'u' Usable card present. This is the normal state during operation.
'r' Card removed. A reset is necessary.
These flags are exclusive.
*/
static int
@ -1372,6 +1377,29 @@ cmd_getinfo (assuan_context_t ctx, char *line)
else
rc = gpg_error (GPG_ERR_NO_DATA);
}
else if (!strcmp (line, "status"))
{
ctrl_t ctrl = assuan_get_pointer (ctx);
int slot = ctrl->reader_slot;
char flag = 'r';
if (!ctrl->server_local->card_removed && slot != -1)
{
struct slot_status_s *ss;
if (!(slot >= 0 && slot < DIM(slot_table)))
BUG ();
ss = &slot_table[slot];
if (!ss->valid)
BUG ();
if (ss->any && (ss->status & 1))
flag = 'u';
}
rc = assuan_send_data (ctx, &flag, 1);
}
else
rc = set_error (Parameter_Error, "unknown value for WHAT");
return rc;
@ -1752,7 +1780,7 @@ update_reader_status_file (void)
will set this on any card change because a reset or
SERIALNO request must be done in any case. */
if (ss->any)
update_card_removed (ss->slot, 1);
update_card_removed (ss->slot, 1); /* XXX: MB: Should be idx? */
ss->any = 1;
ss->status = status;