pcsc-lite 2.5.0
readers.h
Go to the documentation of this file.
1/*
2 * MUSCLE SmartCard Development ( https://pcsclite.apdu.fr/ )
3 *
4 * Copyright (C) 2026-2026
5 * Ludovic Rousseau <ludovic.rousseau@free.fr>
6 *
7Redistribution and use in source and binary forms, with or without
8modification, are permitted provided that the following conditions
9are met:
10
111. Redistributions of source code must retain the above copyright
12 notice, this list of conditions and the following disclaimer.
132. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
163. The name of the author may not be used to endorse or promote products
17 derived from this software without specific prior written permission.
18
19THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
35
36#ifndef __READERS_H__
37#define __READERS_H__
38
39#include <inttypes.h>
40#include <pthread.h>
41
42#include "ifdhandler.h"
43#include "simclist.h"
44
49typedef struct pubReaderState
50{
51 char readerName[MAX_READERNAME];
52 uint32_t eventCounter;
53 uint32_t readerState;
54 _Atomic int32_t readerSharing;
55
57 _Atomic uint32_t cardAtrLength;
58 uint32_t cardProtocol;
59}
61
63{
64 /* shared with API 3.0 */
65 RESPONSECODE (*pvfCreateChannel)(DWORD, DWORD);
66 RESPONSECODE (*pvfCloseChannel)(DWORD);
67 RESPONSECODE (*pvfGetCapabilities)(DWORD, DWORD, PDWORD, PUCHAR);
68 RESPONSECODE (*pvfSetCapabilities)(DWORD, DWORD, DWORD, PUCHAR);
69 RESPONSECODE (*pvfSetProtocolParameters)(DWORD, DWORD, UCHAR, UCHAR,
70 UCHAR, UCHAR);
71 RESPONSECODE (*pvfPowerICC)(DWORD, DWORD, PUCHAR, PDWORD);
72 RESPONSECODE (*pvfTransmitToICC)(DWORD, SCARD_IO_HEADER, PUCHAR,
73 DWORD, PUCHAR, PDWORD, PSCARD_IO_HEADER);
74 RESPONSECODE (*pvfICCPresence)(DWORD);
75
76 /* API v2.0 only */
77 RESPONSECODE (*pvfControl)(DWORD, PUCHAR, DWORD, PUCHAR, PDWORD);
78};
79
80typedef struct FctMap_V2 FCT_MAP_V2;
81
83{
84 /* the common fields SHALL be in the same order as in FctMap_V2 */
85 RESPONSECODE (*pvfCreateChannel)(DWORD, DWORD);
86 RESPONSECODE (*pvfCloseChannel)(DWORD);
87 RESPONSECODE (*pvfGetCapabilities)(DWORD, DWORD, PDWORD, PUCHAR);
88 RESPONSECODE (*pvfSetCapabilities)(DWORD, DWORD, DWORD, PUCHAR);
89 RESPONSECODE (*pvfSetProtocolParameters)(DWORD, DWORD, UCHAR, UCHAR,
90 UCHAR, UCHAR);
91 RESPONSECODE (*pvfPowerICC)(DWORD, DWORD, PUCHAR, PDWORD);
92 RESPONSECODE (*pvfTransmitToICC)(DWORD, SCARD_IO_HEADER, PUCHAR,
93 DWORD, PUCHAR, PDWORD, PSCARD_IO_HEADER);
94 RESPONSECODE (*pvfICCPresence)(DWORD);
95
96 /* API V3.0 only */
97 RESPONSECODE (*pvfControl)(DWORD, DWORD, LPCVOID, DWORD, LPVOID,
98 DWORD, LPDWORD);
99 RESPONSECODE (*pvfCreateChannelByName)(DWORD, LPSTR);
100};
101
102typedef struct FctMap_V3 FCT_MAP_V3;
103
105{
106 char *library;
107 char *device;
108 pthread_t pthThread;
109 RESPONSECODE (*pthCardEvent)(DWORD, int);
110 pthread_mutex_t *mMutex;
111 list_t handlesList;
112 pthread_mutex_t handlesList_lock;
114 union
115 {
116 FCT_MAP_V2 psFunctions_v2;
117 FCT_MAP_V3 psFunctions_v3;
119
120 _Atomic LPVOID vHandle;
122 int port;
123 int slot;
125 _Atomic int LockCount;
126 _Atomic int32_t contexts;
127 int * pFeeds;
128 int * pMutex;
130 pthread_mutex_t powerState_lock;
131 _Atomic int reference;
132
134};
135
136typedef struct ReaderContext READER_CONTEXT;
137
138#endif
struct _SCARD_IO_HEADER SCARD_IO_HEADER
Use by SCardTransmit().
#define MAX_ATR_SIZE
Maximum ATR size.
Definition pcsclite.h:59
LONG SCARDHANDLE
hCard returned by SCardConnect()
Definition pcsclite.h:55
struct pubReaderState READER_STATE
Define an exported public reader state structure so each application gets instant notification of cha...
READER_STATE readerState
reader state
Definition readers.h:133
RESPONSECODE(* pthCardEvent)(DWORD, int)
Card Event sync.
Definition readers.h:109
pthread_mutex_t * mMutex
Mutex for this connection.
Definition readers.h:110
FCT_MAP_V3 psFunctions_v3
API V3.0.
Definition readers.h:117
pthread_mutex_t powerState_lock
powerState mutex
Definition readers.h:130
int port
Port ID.
Definition readers.h:122
pthread_t pthThread
Event polling thread.
Definition readers.h:108
_Atomic int32_t contexts
Number of open contexts.
Definition readers.h:126
int slot
Current Reader Slot.
Definition readers.h:123
int * pFeeds
Number of shared client to lib.
Definition readers.h:127
_Atomic SCARDHANDLE hLockId
Lock Id.
Definition readers.h:124
int * pMutex
Number of client to mutex.
Definition readers.h:128
int version
IFD Handler version number.
Definition readers.h:121
FCT_MAP_V2 psFunctions_v2
API V2.0.
Definition readers.h:116
union ReaderContext::@114326376151332066361210111067242353223333322260 psFunctions
driver functions
pthread_mutex_t handlesList_lock
lock for the above list
Definition readers.h:112
_Atomic int LockCount
number of recursive locks
Definition readers.h:125
char * library
Library Path.
Definition readers.h:106
_Atomic int reference
number of users of the structure
Definition readers.h:131
int powerState
auto power off state
Definition readers.h:129
char * device
Device Name.
Definition readers.h:107
_Atomic LPVOID vHandle
Dlopen handle.
Definition readers.h:120
list object
Definition simclist.h:181
Define an exported public reader state structure so each application gets instant notification of cha...
Definition readers.h:50
_Atomic int32_t readerSharing
PCSCLITE_SHARING_* sharing status.
Definition readers.h:54
char readerName[MAX_READERNAME]
reader name
Definition readers.h:51
uint32_t cardProtocol
SCARD_PROTOCOL_* value.
Definition readers.h:58
UCHAR cardAtr[MAX_ATR_SIZE]
ATR.
Definition readers.h:56
uint32_t eventCounter
number of card events
Definition readers.h:52
_Atomic uint32_t cardAtrLength
ATR length.
Definition readers.h:57
uint32_t readerState
SCARD_* bit field.
Definition readers.h:53