Changeset View
Changeset View
Standalone View
Standalone View
scd/apdu.c
Context not available. | |||||
#define PCSC_E_READER_UNAVAILABLE 0x80100017 | #define PCSC_E_READER_UNAVAILABLE 0x80100017 | ||||
#define PCSC_W_REMOVED_CARD 0x80100069 | #define PCSC_W_REMOVED_CARD 0x80100069 | ||||
/* The PC/SC error is defined as a long as per specs. Due to left | |||||
shifts bit 31 will get sign extended. We use this mask to fix | |||||
it. */ | |||||
#define PCSC_ERR_MASK(a) ((a) & 0xffffffff) | |||||
struct pcsc_io_request_s | struct pcsc_io_request_s | ||||
{ | { | ||||
unsigned long protocol; | unsigned long protocol; | ||||
Context not available. | |||||
{ | { | ||||
int rc; | int rc; | ||||
switch (ec) | switch ( PCSC_ERR_MASK (ec) ) | ||||
{ | { | ||||
case 0: rc = 0; break; | case 0: rc = 0; break; | ||||
Context not available. | |||||
sw = SW_HOST_GENERAL_ERROR; | sw = SW_HOST_GENERAL_ERROR; | ||||
goto command_failed; | goto command_failed; | ||||
} | } | ||||
err = (msgbuf[5] << 24) | (msgbuf[6] << 16) | (msgbuf[7] << 8 ) | msgbuf[8]; | err = PCSC_ERR_MASK ((msgbuf[5] << 24) | (msgbuf[6] << 16) | ||||
| (msgbuf[7] << 8 ) | msgbuf[8]); | |||||
if (err) | if (err) | ||||
{ | { | ||||
log_error ("PC/SC RESET failed: %s (0x%lx)\n", | log_error ("PC/SC RESET failed: %s (0x%lx)\n", | ||||
Context not available. | |||||
goto command_failed; | goto command_failed; | ||||
} | } | ||||
len -= 4; /* Already read the error code. */ | len -= 4; /* Already read the error code. */ | ||||
err = (msgbuf[5] << 24) | (msgbuf[6] << 16) | (msgbuf[7] << 8 ) | msgbuf[8]; | err = PCSC_ERR_MASK ((msgbuf[5] << 24) | (msgbuf[6] << 16) | ||||
| (msgbuf[7] << 8 ) | msgbuf[8]); | |||||
if (err) | if (err) | ||||
{ | { | ||||
log_error ("pcsc_status failed: %s (0x%lx)\n", | log_error ("pcsc_status failed: %s (0x%lx)\n", | ||||
Context not available. | |||||
goto command_failed; | goto command_failed; | ||||
} | } | ||||
len -= 4; /* Already read the error code. */ | len -= 4; /* Already read the error code. */ | ||||
err = (msgbuf[5] << 24) | (msgbuf[6] << 16) | (msgbuf[7] << 8 ) | msgbuf[8]; | err = PCSC_ERR_MASK ((msgbuf[5] << 24) | (msgbuf[6] << 16) | ||||
| (msgbuf[7] << 8 ) | msgbuf[8]); | |||||
if (err) | if (err) | ||||
{ | { | ||||
log_error ("pcsc_transmit failed: %s (0x%lx)\n", | log_error ("pcsc_transmit failed: %s (0x%lx)\n", | ||||
Context not available. | |||||
goto command_failed; | goto command_failed; | ||||
} | } | ||||
len -= 4; /* Already read the error code. */ | len -= 4; /* Already read the error code. */ | ||||
err = (msgbuf[5] << 24) | (msgbuf[6] << 16) | (msgbuf[7] << 8 ) | msgbuf[8]; | err = PCSC_ERR_MASK ((msgbuf[5] << 24) | (msgbuf[6] << 16) | ||||
| (msgbuf[7] << 8 ) | msgbuf[8]); | |||||
if (err) | if (err) | ||||
log_error ("pcsc_close failed: %s (0x%lx)\n", | log_error ("pcsc_close failed: %s (0x%lx)\n", | ||||
pcsc_error_string (err), err); | pcsc_error_string (err), err); | ||||
Context not available. | |||||
(unsigned long)len); | (unsigned long)len); | ||||
goto command_failed; | goto command_failed; | ||||
} | } | ||||
err = (msgbuf[5] << 24) | (msgbuf[6] << 16) | (msgbuf[7] << 8 ) | msgbuf[8]; | err = PCSC_ERR_MASK ((msgbuf[5] << 24) | (msgbuf[6] << 16) | ||||
| (msgbuf[7] << 8 ) | msgbuf[8]); | |||||
if (err) | if (err) | ||||
{ | { | ||||
log_error ("PC/SC OPEN failed: %s\n", pcsc_error_string (err)); | log_error ("PC/SC OPEN failed: %s\n", pcsc_error_string (err)); | ||||
Context not available. |