FreeCalypso > hg > fc-sim-tools
view pcsc/connect.c @ 53:fbedb67d234f
serial: fix parity for inverse coding convention
Important note: it is my (Mother Mychaela's) understanding that
SIM cards with inverse coding convention are extremely rare,
and I have never seen such a card. Therefore, our support for
the inverse coding convention will likely remain forever untested.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 21 Mar 2021 20:46:09 +0000 |
parents | f7a03e53bb2c |
children |
line wrap: on
line source
#include <string.h> #include <strings.h> #include <stdio.h> #include <stdlib.h> #include <pcsclite.h> #include <winscard.h> extern SCARDCONTEXT hContext; extern char *reader_list; extern unsigned select_reader_num; SCARDHANDLE hCard; char *selected_reader; select_reader_by_num() { char *cp; unsigned num; for (cp = reader_list, num = 0; *cp; num++) { if (num == select_reader_num) { selected_reader = cp; return(0); } cp += strlen(cp) + 1; } fprintf(stderr, "error: requested reader #%u, but only %u reader(s) found\n", select_reader_num, num); SCardReleaseContext(hContext); exit(1); } connect_to_card() { LONG rv; DWORD dwActiveProtocol; rv = SCardConnect(hContext, selected_reader, SCARD_SHARE_EXCLUSIVE, SCARD_PROTOCOL_T0, &hCard, &dwActiveProtocol); if (rv != SCARD_S_SUCCESS) { fprintf(stderr, "SCardConnect: %s\n", pcsc_stringify_error(rv)); SCardReleaseContext(hContext); exit(1); } return(0); }