66LONG EHRegisterClientForEvent(int32_t filedes)
72 (void)MSGSendReaderStates(filedes);
108 Log2(PCSC_LOG_ERROR,
"Can't remove client: %d", filedes);
135LONG EHInitializeEventStructures(
void)
150LONG EHDeinitializeEventStructures(
void)
166 Log1(PCSC_LOG_INFO,
"Thread already stomped.");
175 Log1(PCSC_LOG_INFO,
"Stomping thread.");
178 dwGetSize =
sizeof(ucGetData);
180 &dwGetSize, ucGetData);
182#ifdef HAVE_PTHREAD_CANCEL
183 if ((
IFD_SUCCESS == rv) && (1 == dwGetSize) && ucGetData[0])
185 Log1(PCSC_LOG_INFO,
"Killing polling thread");
186 (void)pthread_cancel(rContext->
pthThread);
192 RESPONSECODE (*fct)(DWORD) = NULL;
194 dwGetSize =
sizeof(fct);
196 &dwGetSize, (PUCHAR)&fct);
198 if ((
IFD_SUCCESS == rv) && (dwGetSize ==
sizeof(fct)))
200 Log1(PCSC_LOG_INFO,
"Request stopping of polling thread");
204 Log1(PCSC_LOG_INFO,
"Waiting polling thread");
208 rv = pthread_join(rContext->
pthThread, NULL);
210 Log2(PCSC_LOG_ERROR,
"pthread_join failed: %s", strerror(rv));
215 Log1(PCSC_LOG_INFO,
"Thread stomped.");
228 Log2(PCSC_LOG_ERROR,
"Initial Check Failed on %s",
233 rv = ThreadCreate(&rContext->
pthThread, 0,
234 (PCSCLITE_THREAD_FUNCTION( ))EHStatusHandlerThread, (LPVOID) rContext);
237 Log2(PCSC_LOG_ERROR,
"ThreadCreate failed: %s", strerror(rv));
248 const char *readerName;
251 uint32_t readerState;
252 int32_t readerSharing;
253 DWORD dwCurrentState;
254#ifndef DISABLE_AUTO_POWER_ON
271#ifdef DISABLE_AUTO_POWER_ON
275 Log1(PCSC_LOG_INFO,
"Skip card power on");
289 Log1(PCSC_LOG_DEBUG,
"powerState: POWER_STATE_POWERED");
293 LogXxd(PCSC_LOG_INFO,
"Card ATR: ",
298 Log1(PCSC_LOG_INFO,
"Card ATR: (NULL)");
304 Log1(PCSC_LOG_DEBUG,
"powerState: POWER_STATE_UNPOWERED");
305 Log2(PCSC_LOG_ERROR,
"Error powering up card: %s", rv2text(rv));
336 Log2(PCSC_LOG_ERROR,
"Error communicating to: %s", readerName);
358 Log2(PCSC_LOG_INFO,
"Card Removed From %s", readerName);
382#ifdef DISABLE_AUTO_POWER_ON
387 Log1(PCSC_LOG_DEBUG,
"powerState: POWER_STATE_UNPOWERED");
389 Log1(PCSC_LOG_INFO,
"Skip card power on");
406 Log1(PCSC_LOG_DEBUG,
"powerState: POWER_STATE_POWERED");
412 Log1(PCSC_LOG_DEBUG,
"powerState: POWER_STATE_UNPOWERED");
423 Log2(PCSC_LOG_INFO,
"Card inserted into %s", readerName);
431 LogXxd(PCSC_LOG_INFO,
"Card ATR: ",
436 Log1(PCSC_LOG_INFO,
"Card ATR: (NULL)");
439 Log1(PCSC_LOG_ERROR,
"Error powering up card.");
446 if (readerSharing != rContext->
contexts)
458#ifndef DISABLE_ON_DEMAND_POWER_ON
474#ifndef DISABLE_ON_DEMAND_POWER_ON
482 Log1(PCSC_LOG_DEBUG,
"powerState: POWER_STATE_UNPOWERED");
494 Log1(PCSC_LOG_DEBUG,
"powerState: POWER_STATE_POWERED");
499 if (rContext->
hLockId == 0xFFFF)
504 Log1(PCSC_LOG_INFO,
"Die");
506 (void)pthread_exit(NULL);
This abstracts dynamic library loading functions.
static list_t ClientsWaitingForEvent
list of client file descriptors
LONG EHTryToUnregisterClientForEvent(int32_t filedes)
Try to unregister a client If no client is found then do not log an error.
void EHSignalEventToClients(void)
Sends an asynchronous event to any waiting client.
pthread_mutex_t ClientsWaitingForEvent_lock
lock for the above list
LONG EHUnregisterClientForEvent(int32_t filedes)
Unregister a client and log an error if the client is not found.
This handles card insertion/removal events, updates ATR, protocol, and status information.
#define SCARD_F_INTERNAL_ERROR
An internal consistency check failed.
#define SCARD_F_UNKNOWN_ERROR
An internal error has been detected, but the source is unknown.
#define SCARD_S_SUCCESS
No error was encountered.
#define SCARD_E_NO_MEMORY
Not enough memory available to complete this command.
#define IFD_POWER_UP
power up the card
#define TAG_IFD_STOP_POLLING_THREAD
method used to stop the polling thread (instead of just pthread_kill())
#define IFD_POWER_DOWN
power down the card
#define TAG_IFD_POLLING_THREAD_KILLABLE
the polling thread can be killed
#define IFD_SUCCESS
no error
RESPONSECODE IFDGetCapabilities(READER_CONTEXT *rContext, DWORD dwTag, PDWORD pdwLength, PUCHAR pucValue)
Gets capabilities in the reader.
LONG IFDStatusICC(READER_CONTEXT *rContext, PDWORD pdwStatus)
Provide statistical information about the IFD and ICC including insertions, atr, powering status/etc.
RESPONSECODE IFDPowerICC(READER_CONTEXT *rContext, DWORD dwAction, PUCHAR pucAtr, PDWORD pdwAtrLen)
Power up/down or reset's an ICC located in the IFD.
This wraps the dynamic ifdhandler functions.
This keeps a list of defines for pcsc-lite.
#define PCSCLITE_STATUS_EVENT_TIMEOUT
normal timeout for pthCardEvent driver function when no card or card in use
#define PCSCLITE_STATUS_POLL_RATE
Status polling rate.
#define PCSCLITE_POWER_OFF_GRACE_PERIOD
time to wait before powering down an unused card
@ POWER_STATE_UNPOWERED
auto power off
@ POWER_STATE_POWERED
powered
@ POWER_STATE_GRACE_PERIOD
card was in use
#define SCARD_REMOVED
Card was removed.
#define SCARD_SWALLOWED
Card not powered.
#define SCARD_PROTOCOL_UNDEFINED
protocol not set
#define SCARD_PRESENT
Card is present.
#define SCARD_POWERED
Card is powered.
#define SCARD_ABSENT
Card is absent.
#define SCARD_UNKNOWN
Unknown state.
#define SCARD_NEGOTIABLE
Ready for PTS.
This handles protocol defaults, PTS, etc.
int RFGetPowerState(READER_CONTEXT *rContext)
Wait until all connected readers have a chance to power up a possibly inserted card.
This keeps track of a list of currently available reader structures.
RESPONSECODE(* pthCardEvent)(DWORD, int)
Card Event sync.
pthread_mutex_t powerState_lock
powerState mutex
pthread_t pthThread
Event polling thread.
_Atomic int32_t contexts
Number of open contexts.
int slot
Current Reader Slot.
_Atomic SCARDHANDLE hLockId
Lock Id.
struct pubReaderStatesList * readerState
link to the reader state
int powerState
auto power off state
char readerName[MAX_READERNAME]
reader name
int32_t readerSharing
PCSCLITE_SHARING_* sharing status.
uint32_t cardProtocol
SCARD_PROTOCOL_* value.
UCHAR cardAtr[MAX_ATR_SIZE]
ATR.
uint32_t eventCounter
number of card events
uint32_t readerState
SCARD_* bit field.
uint32_t cardAtrLength
ATR length.
This handles abstract system level calls.
int SYS_USleep(int)
Makes the current process sleep for some microseconds.
This demarshalls functions over the message queue and keeps track of clients and their handles.