diff options
author | Werner Koch <[email protected]> | 2004-04-20 16:42:55 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2004-04-20 16:42:55 +0000 |
commit | 78f797d11d9201b3561b921b69b6de50df7160e8 (patch) | |
tree | 59d64e297d9d465fc9ab3f4b10907372afadbda5 /scd/command.c | |
parent | 2004-04-20 Marcus Brinkmann <[email protected]> (diff) | |
download | gnupg-78f797d11d9201b3561b921b69b6de50df7160e8.tar.gz gnupg-78f797d11d9201b3561b921b69b6de50df7160e8.zip |
* command.c (scd_update_reader_status_file): Write status files.
* app-help.c (app_help_read_length_of_cert): Fixed calculation of
R_CERTOFF.
* pcsc-wrapper.c: New.
* Makefile.am (pkglib_PROGRAMS): Install it here.
* apdu.c (writen, readn): New.
(open_pcsc_reader, pcsc_send_apdu, close_pcsc_reader): Use the
pcsc-wrapper if we are using Pth.
(apdu_send_le): Reinitialize RESULTLEN. Handle SW_EOF_REACHED
like SW_SUCCESS.
Diffstat (limited to 'scd/command.c')
-rw-r--r-- | scd/command.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/scd/command.c b/scd/command.c index 06ff6d2e2..9e77cbe0f 100644 --- a/scd/command.c +++ b/scd/command.c @@ -1179,6 +1179,11 @@ send_status_info (CTRL ctrl, const char *keyword, ...) void scd_update_reader_status_file (void) { + static struct { + int any; + unsigned int status; + unsigned int changed; + } last[10]; int slot; int used; unsigned int status, changed; @@ -1187,9 +1192,35 @@ scd_update_reader_status_file (void) make sense to wait here for a operation to complete. If we are so busy working with the card, delays in the status file updated are should be acceptable. */ - for (slot=0; !apdu_enum_reader (slot, &used); slot++) + for (slot=0; (slot < DIM(last) + &&!apdu_enum_reader (slot, &used)); slot++) if (used && !apdu_get_status (slot, 0, &status, &changed)) { - log_info ("status of slot %d is %u\n", slot, status); + if (!last[slot].any || last[slot].status != status + || last[slot].changed != changed ) + { + char *fname; + char templ[50]; + FILE *fp; + + last[slot].any = 1; + last[slot].status = status; + last[slot].changed = changed; + + log_info ("updating status of slot %d to 0x%04X\n", slot, status); + + sprintf (templ, "reader_%d.status", slot); + fname = make_filename (opt.homedir, templ, NULL ); + fp = fopen (fname, "w"); + if (fp) + { + fprintf (fp, "%s\n", + (status & 1)? "USABLE": + (status & 4)? "ACTIVE": + (status & 2)? "PRESENT": "NOCARD"); + fclose (fp); + } + xfree (fname); + } } } |