aboutsummaryrefslogtreecommitdiffstats
path: root/scd/ccid-driver.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2009-07-13 09:59:22 +0000
committerWerner Koch <[email protected]>2009-07-13 09:59:22 +0000
commitd0d4931e00ef1ff55c247ef85cc79ae005767b9d (patch)
tree2b885f646b77cde42334f5b9d008ed04fdadefb5 /scd/ccid-driver.c
parentBetter reset the PIN verification stati after changing the key attributes. (diff)
downloadgnupg-d0d4931e00ef1ff55c247ef85cc79ae005767b9d.tar.gz
gnupg-d0d4931e00ef1ff55c247ef85cc79ae005767b9d.zip
* ccid-driver.c (struct ccid_driver_s): Add fields last_progress,
progress_cb and progress_cb_arg. (ccid_set_progress_cb): New. (print_progress): New. (ccid_transceive): Call print_progress for wait time extensions. * apdu.c (struct reader_table_s): Add field set_progress_cb. (new_reader_slot): Clear that field. (open_ccid_reader): Set it to .. (set_progress_cb_ccid_reader): ... new fucntion. * app.c (print_progress_line): New. (lock_reader): Add arg CTRL to set a progress callback and change all callers to provide it. (unlock_reader): Remove the progress callback.
Diffstat (limited to 'scd/ccid-driver.c')
-rw-r--r--scd/ccid-driver.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/scd/ccid-driver.c b/scd/ccid-driver.c
index 8428d8536..f9b0bb599 100644
--- a/scd/ccid-driver.c
+++ b/scd/ccid-driver.c
@@ -254,6 +254,12 @@ struct ccid_driver_s
int apdu_level; /* Reader supports short APDU level exchange.
With a value of 2 short and extended level is
supported.*/
+ time_t last_progress; /* Last time we sent progress line. */
+
+ /* The progress callback and its first arg as supplied to
+ ccid_set_progress_cb. */
+ void (*progress_cb)(void *, const char *, int, int, int);
+ void *progress_cb_arg;
};
@@ -302,6 +308,23 @@ set_msg_len (unsigned char *msg, unsigned int length)
}
+static void
+print_progress (ccid_driver_t handle)
+{
+ time_t ct = time (NULL);
+
+ /* We don't want to print progress lines too often. */
+ if (ct == handle->last_progress)
+ return;
+
+ if (handle->progress_cb)
+ handle->progress_cb (handle->progress_cb_arg, "card_busy", 'w', 0, 0);
+
+ handle->last_progress = ct;
+}
+
+
+
/* Pint an error message for a failed CCID command including a textual
error code. MSG shall be the CCID message at a minimum of 10 bytes. */
static void
@@ -1670,6 +1693,20 @@ ccid_shutdown_reader (ccid_driver_t handle)
}
+int
+ccid_set_progress_cb (ccid_driver_t handle,
+ void (*cb)(void *, const char *, int, int, int),
+ void *cb_arg)
+{
+ if (!handle || !handle->rid)
+ return CCID_DRIVER_ERR_INV_VALUE;
+
+ handle->progress_cb = cb;
+ handle->progress_cb_arg = cb_arg;
+ return 0;
+}
+
+
/* Close the reader HANDLE. */
int
ccid_close_reader (ccid_driver_t handle)
@@ -2894,6 +2931,7 @@ ccid_transceive (ccid_driver_t handle,
tpdu[tpdulen++] = (edc >> 8);
tpdu[tpdulen++] = edc;
DEBUGOUT_1 ("T=1: waittime extension of bwi=%d\n", bwi);
+ print_progress (handle);
}
else if ( (tpdu[1] & 0x20) && (tpdu[1] & 0x1f) == 0 && !tpdu[2])
{