Changeset View
Changeset View
Standalone View
Standalone View
scd/apdu.c
| Context not available. | |||||
| dl->idx = 0; | dl->idx = 0; | ||||
| dl->idx_max = 0; | dl->idx_max = 0; | ||||
| npth_mutex_lock (&reader_table_lock); | |||||
| #ifdef HAVE_LIBUSB | #ifdef HAVE_LIBUSB | ||||
| if (!opt.disable_ccid) | if (!opt.disable_ccid) | ||||
| { | { | ||||
| Context not available. | |||||
| if (err) | if (err) | ||||
| { | { | ||||
| xfree (dl); | xfree (dl); | ||||
| npth_mutex_unlock (&reader_table_lock); | |||||
| return err; | return err; | ||||
| } | } | ||||
| Context not available. | |||||
| log_debug ("leave: apdu_open_reader => slot=-1 (no ccid)\n"); | log_debug ("leave: apdu_open_reader => slot=-1 (no ccid)\n"); | ||||
| xfree (dl); | xfree (dl); | ||||
| npth_mutex_unlock (&reader_table_lock); | |||||
| return gpg_error (GPG_ERR_ENODEV); | return gpg_error (GPG_ERR_ENODEV); | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| if (pcsc_init () < 0) | if (pcsc_init () < 0) | ||||
| { | { | ||||
| xfree (dl); | xfree (dl); | ||||
| npth_mutex_unlock (&reader_table_lock); | |||||
| return gpg_error (GPG_ERR_NO_SERVICE); | return gpg_error (GPG_ERR_NO_SERVICE); | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| log_error ("error allocating memory for reader list\n"); | log_error ("error allocating memory for reader list\n"); | ||||
| if (pcsc.count == 0) | if (pcsc.count == 0) | ||||
| release_pcsc_context (); | release_pcsc_context (); | ||||
| npth_mutex_unlock (&reader_table_lock); | |||||
| xfree (dl); | xfree (dl); | ||||
| return err; | return err; | ||||
| } | } | ||||
| Context not available. | |||||
| xfree (p); | xfree (p); | ||||
| if (pcsc.count == 0) | if (pcsc.count == 0) | ||||
| release_pcsc_context (); | release_pcsc_context (); | ||||
| npth_mutex_unlock (&reader_table_lock); | |||||
| xfree (dl); | xfree (dl); | ||||
| return iso7816_map_sw (pcsc_error_to_sw (r)); | return iso7816_map_sw (pcsc_error_to_sw (r)); | ||||
| } | } | ||||
| Context not available. | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| pcsc.count++; | |||||
| } | } | ||||
| npth_mutex_unlock (&reader_table_lock); | |||||
| *l_p = dl; | *l_p = dl; | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| Context not available. | |||||
| pcsc.rdrname[i] = NULL; | pcsc.rdrname[i] = NULL; | ||||
| log_assert (pcsc.count > 0); | log_assert (pcsc.count > 0); | ||||
| if (--pcsc.count == 0) | if (pcsc.count == 0) | ||||
| release_pcsc_context (); | release_pcsc_context (); | ||||
| } | } | ||||
| xfree (dl); | xfree (dl); | ||||
| Context not available. | |||||
| if (readerno < 0 || readerno >= dl->idx_max) | if (readerno < 0 || readerno >= dl->idx_max) | ||||
| return -1; | return -1; | ||||
| npth_mutex_lock (&reader_table_lock); | |||||
| /* If already opened HANDLE, return -1. */ | /* If already opened HANDLE, return -1. */ | ||||
| for (slot = 0; slot < MAX_READER; slot++) | for (slot = 0; slot < MAX_READER; slot++) | ||||
| if (reader_table[slot].used) | if (reader_table[slot].used) | ||||
| return -1; | { | ||||
| npth_mutex_unlock (&reader_table_lock); | |||||
| return -1; | |||||
| } | |||||
| npth_mutex_unlock (&reader_table_lock); | |||||
| dl->idx = readerno; | dl->idx = readerno; | ||||
| dl->portstr = NULL; | dl->portstr = NULL; | ||||
| Context not available. | |||||
| return slot; | return slot; | ||||
| } | } | ||||
| npth_mutex_lock (&reader_table_lock); | |||||
| while (dl->idx < dl->idx_max) | while (dl->idx < dl->idx_max) | ||||
| { | { | ||||
| unsigned int bai = ccid_get_BAI (dl->idx, dl->table); | unsigned int bai = ccid_get_BAI (dl->idx, dl->table); | ||||
| Context not available. | |||||
| dl->idx++; | dl->idx++; | ||||
| if (slot >= 0) | if (slot >= 0) | ||||
| return slot; | { | ||||
| npth_mutex_unlock (&reader_table_lock); | |||||
| return slot; | |||||
| } | |||||
| else | else | ||||
| { | { | ||||
| /* Skip this reader. */ | /* Skip this reader. */ | ||||
| Context not available. | |||||
| else | else | ||||
| dl->idx++; | dl->idx++; | ||||
| } | } | ||||
| npth_mutex_unlock (&reader_table_lock); | |||||
| /* Not found. */ | /* Not found. */ | ||||
| slot = -1; | slot = -1; | ||||
| Context not available. | |||||
| return slot; | return slot; | ||||
| } | } | ||||
| npth_mutex_lock (&reader_table_lock); | |||||
| while (dl->idx < dl->idx_max) | while (dl->idx < dl->idx_max) | ||||
| { | { | ||||
| const char *rdrname = pcsc.rdrname[dl->idx]; | const char *rdrname = pcsc.rdrname[dl->idx]; | ||||
| Context not available. | |||||
| dl->idx++; | dl->idx++; | ||||
| if (slot >= 0) | if (slot >= 0) | ||||
| return slot; | { | ||||
| npth_mutex_unlock (&reader_table_lock); | |||||
| return slot; | |||||
| } | |||||
| else | else | ||||
| { | { | ||||
| /* Skip this reader. */ | /* Skip this reader. */ | ||||
| Context not available. | |||||
| dl->idx++; | dl->idx++; | ||||
| } | } | ||||
| npth_mutex_unlock (&reader_table_lock); | |||||
| /* Not found. */ | /* Not found. */ | ||||
| slot = -1; | slot = -1; | ||||
| } | } | ||||
| Context not available. | |||||