diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2019-09-06 06:19:50 +0200 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2019-09-11 03:11:18 +0200 |
commit | f44aa290c1368a3119b2323664c0f356195c4206 (patch) | |
tree | 4286673a75d234fe2d719728dbb189c0294b77e3 /scd | |
parent | doc: Fix distchek for generated eps file (diff) | |
download | gnupg2-f44aa290c1368a3119b2323664c0f356195c4206.tar.xz gnupg2-f44aa290c1368a3119b2323664c0f356195c4206.zip |
scd: Clean up the structure for future fix of PC/SC.
* scd/apdu.c (struct dev_list): Rename from ccid_table, with void*.
(open_ccid_reader): Follow the change.
(apdu_dev_list_start, apdu_dev_list_finish): Likewise.
(apdu_open_reader): Likewise.
* scd/ccid-driver.c (ccid_dev_scan): Use void *.
(ccid_dev_scan_finish, ccid_get_BAI, ccid_open_usb_reader): Likewise.
* scd/ccid-driver.h: Change the APIs.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'scd')
-rw-r--r-- | scd/apdu.c | 18 | ||||
-rw-r--r-- | scd/ccid-driver.c | 15 | ||||
-rw-r--r-- | scd/ccid-driver.h | 8 |
3 files changed, 23 insertions, 18 deletions
diff --git a/scd/apdu.c b/scd/apdu.c index 37becb287..9c5f15eea 100644 --- a/scd/apdu.c +++ b/scd/apdu.c @@ -55,7 +55,7 @@ #include "ccid-driver.h" struct dev_list { - struct ccid_dev_table *ccid_table; + void *table; const char *portstr; int idx; int idx_max; @@ -1520,7 +1520,7 @@ open_ccid_reader (struct dev_list *dl) return -1; slotp = reader_table + slot; - err = ccid_open_reader (dl->portstr, dl->idx, dl->ccid_table, + err = ccid_open_reader (dl->portstr, dl->idx, dl->table, &slotp->ccid.handle, &slotp->rdrname); if (!err) { @@ -1879,14 +1879,14 @@ apdu_dev_list_start (const char *portstr, struct dev_list **l_p) #ifdef HAVE_LIBUSB if (opt.disable_ccid) { - dl->ccid_table = NULL; + dl->table = NULL; dl->idx_max = 1; } else { gpg_error_t err; - err = ccid_dev_scan (&dl->idx_max, &dl->ccid_table); + err = ccid_dev_scan (&dl->idx_max, &dl->table); if (err) return err; @@ -1908,7 +1908,7 @@ apdu_dev_list_start (const char *portstr, struct dev_list **l_p) } } #else - dl->ccid_table = NULL; + dl->table = NULL; dl->idx_max = 1; #endif /* HAVE_LIBUSB */ @@ -1920,8 +1920,8 @@ void apdu_dev_list_finish (struct dev_list *dl) { #ifdef HAVE_LIBUSB - if (dl->ccid_table) - ccid_dev_scan_finish (dl->ccid_table, dl->idx_max); + if (dl->table) + ccid_dev_scan_finish (dl->table, dl->idx_max); #endif xfree (dl); npth_mutex_unlock (&reader_table_lock); @@ -2037,7 +2037,7 @@ apdu_open_reader (struct dev_list *dl, int app_empty) int slot; #ifdef HAVE_LIBUSB - if (dl->ccid_table) + if (dl->table) { /* CCID readers. */ int readerno; @@ -2074,7 +2074,7 @@ apdu_open_reader (struct dev_list *dl, int app_empty) while (dl->idx < dl->idx_max) { - unsigned int bai = ccid_get_BAI (dl->idx, dl->ccid_table); + unsigned int bai = ccid_get_BAI (dl->idx, dl->table); if (DBG_READER) log_debug ("apdu_open_reader: BAI=%x\n", bai); diff --git a/scd/ccid-driver.c b/scd/ccid-driver.c index 170f36641..d3e9ef024 100644 --- a/scd/ccid-driver.c +++ b/scd/ccid-driver.c @@ -1276,7 +1276,7 @@ static libusb_device **ccid_usb_dev_list; static struct ccid_dev_table ccid_dev_table[MAX_DEVICE]; gpg_error_t -ccid_dev_scan (int *idx_max_p, struct ccid_dev_table **t_p) +ccid_dev_scan (int *idx_max_p, void **t_p) { ssize_t n; libusb_device *dev; @@ -1403,9 +1403,10 @@ ccid_dev_scan (int *idx_max_p, struct ccid_dev_table **t_p) } void -ccid_dev_scan_finish (struct ccid_dev_table *tbl, int max) +ccid_dev_scan_finish (void *tbl0, int max) { int i; + struct ccid_dev_table *tbl = tbl0; for (i = 0; i < max; i++) { @@ -1424,12 +1425,13 @@ ccid_dev_scan_finish (struct ccid_dev_table *tbl, int max) } unsigned int -ccid_get_BAI (int idx, struct ccid_dev_table *tbl) +ccid_get_BAI (int idx, void *tbl0) { int n; int bus, addr, intf; unsigned int bai; libusb_device *dev; + struct ccid_dev_table *tbl = tbl0; n = tbl[idx].n; dev = ccid_usb_dev_list[n]; @@ -1537,7 +1539,7 @@ ccid_usb_thread (void *arg) static int ccid_open_usb_reader (const char *spec_reader_name, - int idx, struct ccid_dev_table *ccid_table, + int idx, void *ccid_table0, ccid_driver_t *handle, char **rdrname_p) { libusb_device *dev; @@ -1549,6 +1551,7 @@ ccid_open_usb_reader (const char *spec_reader_name, int n; int bus, addr; unsigned int bai; + struct ccid_dev_table *ccid_table = ccid_table0; n = ccid_table[idx].n; ifc_no = ccid_table[idx].interface_number; @@ -1678,9 +1681,11 @@ ccid_open_usb_reader (const char *spec_reader_name, pointer to be used as handle in HANDLE. Returns 0 on success. */ int ccid_open_reader (const char *spec_reader_name, int idx, - struct ccid_dev_table *ccid_table, + void *ccid_table0, ccid_driver_t *handle, char **rdrname_p) { + struct ccid_dev_table *ccid_table = ccid_table0; + *handle = calloc (1, sizeof **handle); if (!*handle) { diff --git a/scd/ccid-driver.h b/scd/ccid-driver.h index 1550b3eba..8e7ff4482 100644 --- a/scd/ccid-driver.h +++ b/scd/ccid-driver.h @@ -116,12 +116,12 @@ struct ccid_dev_table; int ccid_set_debug_level (int level); char *ccid_get_reader_list (void); -gpg_error_t ccid_dev_scan (int *idx_max, struct ccid_dev_table **t_p); -void ccid_dev_scan_finish (struct ccid_dev_table *tbl, int max); -unsigned int ccid_get_BAI (int, struct ccid_dev_table *tbl); +gpg_error_t ccid_dev_scan (int *idx_max, void **t_p); +void ccid_dev_scan_finish (void *tbl0, int max); +unsigned int ccid_get_BAI (int, void *tbl0); int ccid_compare_BAI (ccid_driver_t handle, unsigned int); int ccid_open_reader (const char *spec_reader_name, - int idx, struct ccid_dev_table *ccid_table, + int idx, void *ccid_table0, ccid_driver_t *handle, char **rdrname_p); int ccid_set_progress_cb (ccid_driver_t handle, void (*cb)(void *, const char *, int, int, int), |