aboutsummaryrefslogtreecommitdiffstats
path: root/g10/apdu.c
diff options
context:
space:
mode:
Diffstat (limited to 'g10/apdu.c')
-rw-r--r--g10/apdu.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/g10/apdu.c b/g10/apdu.c
index d5b93de6e..1587bfe5b 100644
--- a/g10/apdu.c
+++ b/g10/apdu.c
@@ -347,6 +347,14 @@ open_ct_reader (int port)
return reader;
}
+static int
+close_ct_reader (int slot)
+{
+ /* FIXME: Implement. */
+ reader_table[slot].used = 0;
+ return 0;
+}
+
/* Actually send the APDU of length APDULEN to SLOT and return a
maximum of *BUFLEN data in BUFFER, the actual retruned size will be
@@ -570,6 +578,17 @@ pcsc_send_apdu (int slot, unsigned char *apdu, size_t apdulen,
return err? -1:0; /* FIXME: Return appropriate error code. */
}
+static int
+close_pcsc_reader (int slot)
+{
+ /* FIXME: Implement. */
+ reader_table[slot].used = 0;
+ return 0;
+}
+
+
+
+
#ifdef HAVE_LIBUSB
/*
@@ -609,6 +628,15 @@ open_ccid_reader (void)
return slot;
}
+static int
+close_ccid_reader (int slot)
+{
+ ccid_close_reader (reader_table[slot].ccid.handle);
+ reader_table[slot].used = 0;
+ return 0;
+}
+
+
/* Actually send the APDU of length APDULEN to SLOT and return a
maximum of *BUFLEN data in BUFFER, the actual returned size will be
@@ -738,6 +766,16 @@ open_osc_reader (int portno)
}
+static int
+close_osc_reader (int slot)
+{
+ /* FIXME: Implement. */
+ reader_table[slot].used = 0;
+ return 0;
+}
+
+
+
/* Actually send the APDU of length APDULEN to SLOT and return a
maximum of *BUFLEN data in BUFFER, the actual returned size will be
set to BUFLEN. Returns: OpenSC error code. */
@@ -940,6 +978,26 @@ apdu_open_reader (const char *portstr)
}
+int
+apdu_close_reader (int slot)
+{
+ if (slot < 0 || slot >= MAX_READER || !reader_table[slot].used )
+ return SW_HOST_NO_DRIVER;
+ if (reader_table[slot].is_ctapi)
+ return close_ct_reader (slot);
+#ifdef HAVE_LIBUSB
+ else if (reader_table[slot].is_ccid)
+ return close_ccid_reader (slot);
+#endif
+#ifdef HAVE_OPENSC
+ else if (reader_table[slot].is_osc)
+ return close_osc_reader (slot);
+#endif
+ else
+ return close_pcsc_reader (slot);
+}
+
+
unsigned char *
apdu_get_atr (int slot, size_t *atrlen)
{