20#if defined(__has_include) 21#if __has_include(<PCSC/winscard.h>) 22#include <PCSC/winscard.h> 23#include <PCSC/wintypes.h> 24#elif __has_include(<winscard.h>) 27#error "FUN_WITH_PCSC is enabled but PCSC headers were not found" 30#include <PCSC/winscard.h> 31#include <PCSC/wintypes.h> 46static pcsc_ctx_entry g_pcsc_ctx[8];
47static pcsc_card_entry g_pcsc_card[32];
54static int pcsc_alloc_ctx_slot(
void) {
55 for (
int i = 0; i < (int)(
sizeof(g_pcsc_ctx) /
sizeof(g_pcsc_ctx[0])); ++i) {
56 if (!g_pcsc_ctx[i].in_use) {
57 g_pcsc_ctx[i].in_use = 1;
58 g_pcsc_ctx[i].ctx = 0;
70static int pcsc_alloc_card_slot(
void) {
71 for (
int i = 0; i < (int)(
sizeof(g_pcsc_card) /
sizeof(g_pcsc_card[0])); ++i) {
72 if (!g_pcsc_card[i].in_use) {
73 g_pcsc_card[i].in_use = 1;
75 g_pcsc_card[i].proto = 0;
88static pcsc_ctx_entry *pcsc_get_ctx(
int id) {
89 if (
id <= 0)
return NULL;
91 if (
idx < 0 || idx >= (
int)(
sizeof(g_pcsc_ctx) /
sizeof(g_pcsc_ctx[0])))
return NULL;
92 if (!g_pcsc_ctx[
idx].in_use)
return NULL;
93 return &g_pcsc_ctx[
idx];
102static pcsc_card_entry *pcsc_get_card(
int id) {
103 if (
id <= 0)
return NULL;
105 if (
idx < 0 || idx >= (
int)(
sizeof(g_pcsc_card) /
sizeof(g_pcsc_card[0])))
return NULL;
106 if (!g_pcsc_card[
idx].in_use)
return NULL;
107 return &g_pcsc_card[
idx];