commit 473121943104e281fecb03707a8d6e03e90a3016 Author: Peter Åstrand (astrand) Date: 2019-02-24 11:58:18 +0100 Allow build with both modern and old versions of pcsc-lite * Part of bug 5846. * _A datatypes should no longer be used, see https://ludovicrousseau.blogspot.com/2010/08/pcsc-lite-16x-breaks-some-programs-at.html * Unfortunately, osx64 still uses pcsc-lite 1.4.0, which lacks LPSCARD_READERSTATE. But the LP/NP concept is obsolete anyway. * g_rgSCard* constants needs to be "const" * pcsc_stringify_error is present in both new and old pcsc-lite; do not define. diff --git client/pcsctun/src/hooks.c client/pcsctun/src/hooks.c index 8e9ea60..37ac65c 100644 --- client/pcsctun/src/hooks.c +++ client/pcsctun/src/hooks.c @@ -78,9 +78,18 @@ struct card static GSList *ctxlist = NULL; /* Protocol constants */ + +/* In pcsc-lite 1.7.3, g_rgSCard* was made constant. + FEATURE_EXECUTE_PACE was defined in 1.8.0; close enough. */ +#ifdef FEATURE_EXECUTE_PACE +const SCARD_IO_REQUEST g_rgSCardT0Pci = { SCARD_PROTOCOL_T0, sizeof(SCARD_IO_REQUEST) }; +const SCARD_IO_REQUEST g_rgSCardT1Pci = { SCARD_PROTOCOL_T1, sizeof(SCARD_IO_REQUEST) }; +const SCARD_IO_REQUEST g_rgSCardRawPci = { SCARD_PROTOCOL_RAW, sizeof(SCARD_IO_REQUEST) }; +#else SCARD_IO_REQUEST g_rgSCardT0Pci = { SCARD_PROTOCOL_T0, sizeof(SCARD_IO_REQUEST) }; SCARD_IO_REQUEST g_rgSCardT1Pci = { SCARD_PROTOCOL_T1, sizeof(SCARD_IO_REQUEST) }; SCARD_IO_REQUEST g_rgSCardRawPci = { SCARD_PROTOCOL_RAW, sizeof(SCARD_IO_REQUEST) }; +#endif static LONG SCardAllocMemory(SCARDCONTEXT hContext, void **ppvMem, DWORD cbLength); @@ -736,7 +745,7 @@ SCardStatus(SCARDHANDLE hCard, LPTSTR mszReaderName, LONG SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, - LPSCARD_READERSTATE_A rgReaderStates, DWORD cReaders) + SCARD_READERSTATE *rgReaderStates, DWORD cReaders) { struct session *s; int ret, i, size; @@ -1418,13 +1427,3 @@ SCardSetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr, DWORD cbAttrLe return translate_errno(ret); } -#ifdef __APPLE__ -char * -pcsc_stringify_error(int32_t code) -#else -char * -pcsc_stringify_error(long code) -#endif -{ - return "(UNKNOWN ERROR)"; -} diff --git client/pcsctun/src/main.c client/pcsctun/src/main.c index bf2435d..42f5959 100644 --- client/pcsctun/src/main.c +++ client/pcsctun/src/main.c @@ -143,7 +143,7 @@ struct async_params /* For SCardGetStatusChange */ DWORD timeout; DWORD readers; - LPSCARD_READERSTATE_A states; + SCARD_READERSTATE *states; /* For SCardDisconnect and SCardBeginTransaction */ struct card *card; @@ -1051,7 +1051,7 @@ cb_SCardGetStatusChange(struct client *c, struct packet *p) int ret, i, size; uint32_t timeout, readers, state, event; struct async_params *params; - LPSCARD_READERSTATE_A states; + SCARD_READERSTATE *states; ret = demarshall(p, "UU", &timeout, &readers); if (ret) @@ -1063,13 +1063,13 @@ cb_SCardGetStatusChange(struct client *c, struct packet *p) memset(params, 0, sizeof(struct async_params)); - states = malloc(sizeof(SCARD_READERSTATE_A) * readers); + states = malloc(sizeof(SCARD_READERSTATE) * readers); if (!states) { free(params); return -ENOMEM; } - memset(states, 0, sizeof(SCARD_READERSTATE_A) * readers); + memset(states, 0, sizeof(SCARD_READERSTATE) * readers); params->readers = readers; params->states = states;