pcsc-lite 2.3.0
readerfactory.c File Reference

This keeps track of a list of currently available reader structures. More...

#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdatomic.h>
#include <stdbool.h>
#include "misc.h"
#include "pcscd.h"
#include "debuglog.h"
#include "readerfactory.h"
#include "dyn_generic.h"
#include "sys_generic.h"
#include "eventhandler.h"
#include "ifdwrapper.h"
#include "hotplug.h"
#include "configfile.h"
#include "utils.h"

Go to the source code of this file.

Macros

#define GET_ADDRESS_OPTIONALv2(s, code)
 
#define GET_ADDRESSv2(s)
 
#define GET_ADDRESS_OPTIONALv3(s, code)
 
#define GET_ADDRESSv3(s)
 

Functions

static LONG removeReader (READER_CONTEXT *sReader)
 
static int RDR_CLIHANDLES_seeker (const void *el, const void *key)
 
LONG _RefReader (READER_CONTEXT *sReader)
 
LONG _UnrefReader (READER_CONTEXT *sReader)
 
LONG RFAllocateReaderSpace (unsigned int customMaxReaderHandles)
 
LONG RFAddReader (const char *readerNameLong, int port, const char *library, const char *device)
 
LONG RFRemoveReader (const char *readerName, int port, int flags)
 
LONG RFSetReaderName (READER_CONTEXT *rContext, const char *readerName, const char *libraryName, int port)
 
LONG RFReaderInfo (const char *readerName, READER_CONTEXT **sReader)
 
LONG RFReaderInfoById (SCARDHANDLE hCard, READER_CONTEXT **sReader)
 
LONG RFLoadReader (READER_CONTEXT *rContext)
 
LONG RFBindFunctions (READER_CONTEXT *rContext)
 
LONG RFUnBindFunctions (READER_CONTEXT *rContext)
 
LONG RFUnloadReader (READER_CONTEXT *rContext)
 
LONG RFCheckSharing (SCARDHANDLE hCard, READER_CONTEXT *rContext)
 
LONG RFLockSharing (SCARDHANDLE hCard, READER_CONTEXT *rContext)
 
LONG RFUnlockSharing (SCARDHANDLE hCard, READER_CONTEXT *rContext)
 
LONG RFUnlockAllSharing (SCARDHANDLE hCard, READER_CONTEXT *rContext)
 
LONG RFInitializeReader (READER_CONTEXT *rContext)
 
void RFUnInitializeReader (READER_CONTEXT *rContext)
 
SCARDHANDLE RFCreateReaderHandle (READER_CONTEXT *rContext)
 
LONG RFAddReaderHandle (READER_CONTEXT *rContext, SCARDHANDLE hCard)
 
LONG RFRemoveReaderHandle (READER_CONTEXT *rContext, SCARDHANDLE hCard)
 
void RFSetReaderEventState (READER_CONTEXT *rContext, DWORD dwEvent)
 
LONG RFCheckReaderEventState (READER_CONTEXT *rContext, SCARDHANDLE hCard)
 
LONG RFClearReaderEventState (READER_CONTEXT *rContext, SCARDHANDLE hCard)
 
LONG RFCheckReaderStatus (READER_CONTEXT *rContext)
 
void RFCleanupReaders (void)
 
int RFGetPowerState (READER_CONTEXT *rContext)
 Wait until all connected readers have a chance to power up a possibly inserted card.
 
void RFSetPowerState (READER_CONTEXT *rContext, int value)
 

Variables

static READER_CONTEXTsReadersContexts [PCSCLITE_MAX_READERS_CONTEXTS]
 
READER_STATE readerStates [PCSCLITE_MAX_READERS_CONTEXTS]
 
static int maxReaderHandles = PCSC_MAX_READER_HANDLES
 
static DWORD dwNumReadersContexts = 0
 
static pthread_mutex_t LockMutex = PTHREAD_MUTEX_INITIALIZER
 
int16_t ReaderEvents = 1
 

Detailed Description

This keeps track of a list of currently available reader structures.

Definition in file readerfactory.c.

Macro Definition Documentation

◆ GET_ADDRESS_OPTIONALv2

#define GET_ADDRESS_OPTIONALv2 ( s,
code )
Value:
{ \
void *f1 = NULL; \
int rvl = DYN_GetAddress(rContext->vHandle, &f1, "IFDH" #s, false); \
if (SCARD_S_SUCCESS != rvl) \
{ \
code \
} \
rContext->psFunctions.psFunctions_v2.pvf ## s = f1; \
}
#define SCARD_S_SUCCESS
No error was encountered.
Definition pcsclite.h:107

◆ GET_ADDRESS_OPTIONALv3

#define GET_ADDRESS_OPTIONALv3 ( s,
code )
Value:
{ \
void *f1 = NULL; \
int rvl = DYN_GetAddress(rContext->vHandle, &f1, "IFDH" #s, false); \
if (SCARD_S_SUCCESS != rvl) \
{ \
code \
} \
rContext->psFunctions.psFunctions_v3.pvf ## s = f1; \
}

◆ GET_ADDRESSv2

#define GET_ADDRESSv2 ( s)
Value:
GET_ADDRESS_OPTIONALv2(s, \
Log1(PCSC_LOG_CRITICAL, "IFDHandler functions missing: " #s ); \
return(rv); )

◆ GET_ADDRESSv3

#define GET_ADDRESSv3 ( s)
Value:
GET_ADDRESS_OPTIONALv3(s, \
Log1(PCSC_LOG_CRITICAL, "IFDHandler functions missing: " #s ); \
return(rv); )

Function Documentation

◆ _RefReader()

LONG _RefReader ( READER_CONTEXT * sReader)

Definition at line 99 of file readerfactory.c.

◆ _UnrefReader()

LONG _UnrefReader ( READER_CONTEXT * sReader)

Definition at line 109 of file readerfactory.c.

◆ RDR_CLIHANDLES_seeker()

static int RDR_CLIHANDLES_seeker ( const void * el,
const void * key )
static

Definition at line 80 of file readerfactory.c.

◆ removeReader()

LONG removeReader ( READER_CONTEXT * sReader)
static

Definition at line 641 of file readerfactory.c.

◆ RFAddReader()

LONG RFAddReader ( const char * readerNameLong,
int port,
const char * library,
const char * device )

Definition at line 154 of file readerfactory.c.

◆ RFAddReaderHandle()

LONG RFAddReaderHandle ( READER_CONTEXT * rContext,
SCARDHANDLE hCard )

Definition at line 1214 of file readerfactory.c.

◆ RFAllocateReaderSpace()

LONG RFAllocateReaderSpace ( unsigned int customMaxReaderHandles)

Definition at line 122 of file readerfactory.c.

◆ RFBindFunctions()

LONG RFBindFunctions ( READER_CONTEXT * rContext)

Definition at line 899 of file readerfactory.c.

◆ RFCheckReaderEventState()

LONG RFCheckReaderEventState ( READER_CONTEXT * rContext,
SCARDHANDLE hCard )

Definition at line 1319 of file readerfactory.c.

◆ RFCheckReaderStatus()

LONG RFCheckReaderStatus ( READER_CONTEXT * rContext)

Definition at line 1376 of file readerfactory.c.

◆ RFCheckSharing()

LONG RFCheckSharing ( SCARDHANDLE hCard,
READER_CONTEXT * rContext )

Definition at line 1024 of file readerfactory.c.

◆ RFCleanupReaders()

void RFCleanupReaders ( void )

Definition at line 1384 of file readerfactory.c.

◆ RFClearReaderEventState()

LONG RFClearReaderEventState ( READER_CONTEXT * rContext,
SCARDHANDLE hCard )

Definition at line 1357 of file readerfactory.c.

◆ RFCreateReaderHandle()

SCARDHANDLE RFCreateReaderHandle ( READER_CONTEXT * rContext)

Definition at line 1184 of file readerfactory.c.

◆ RFGetPowerState()

int RFGetPowerState ( READER_CONTEXT * rContext)

Wait until all connected readers have a chance to power up a possibly inserted card.

Definition at line 1594 of file readerfactory.c.

◆ RFInitializeReader()

LONG RFInitializeReader ( READER_CONTEXT * rContext)

Definition at line 1097 of file readerfactory.c.

◆ RFLoadReader()

LONG RFLoadReader ( READER_CONTEXT * rContext)

Definition at line 882 of file readerfactory.c.

◆ RFLockSharing()

LONG RFLockSharing ( SCARDHANDLE hCard,
READER_CONTEXT * rContext )

Definition at line 1032 of file readerfactory.c.

◆ RFReaderInfo()

LONG RFReaderInfo ( const char * readerName,
READER_CONTEXT ** sReader )

Definition at line 829 of file readerfactory.c.

◆ RFReaderInfoById()

LONG RFReaderInfoById ( SCARDHANDLE hCard,
READER_CONTEXT ** sReader )

Definition at line 855 of file readerfactory.c.

◆ RFRemoveReader()

LONG RFRemoveReader ( const char * readerName,
int port,
int flags )

Definition at line 577 of file readerfactory.c.

◆ RFRemoveReaderHandle()

LONG RFRemoveReaderHandle ( READER_CONTEXT * rContext,
SCARDHANDLE hCard )

Definition at line 1257 of file readerfactory.c.

◆ RFSetPowerState()

void RFSetPowerState ( READER_CONTEXT * rContext,
int value )

Definition at line 1602 of file readerfactory.c.

◆ RFSetReaderEventState()

void RFSetReaderEventState ( READER_CONTEXT * rContext,
DWORD dwEvent )

Definition at line 1286 of file readerfactory.c.

◆ RFSetReaderName()

LONG RFSetReaderName ( READER_CONTEXT * rContext,
const char * readerName,
const char * libraryName,
int port )

Definition at line 713 of file readerfactory.c.

◆ RFUnBindFunctions()

LONG RFUnBindFunctions ( READER_CONTEXT * rContext)

Definition at line 1001 of file readerfactory.c.

◆ RFUnInitializeReader()

void RFUnInitializeReader ( READER_CONTEXT * rContext)

Definition at line 1155 of file readerfactory.c.

◆ RFUnloadReader()

LONG RFUnloadReader ( READER_CONTEXT * rContext)

Definition at line 1009 of file readerfactory.c.

◆ RFUnlockAllSharing()

LONG RFUnlockAllSharing ( SCARDHANDLE hCard,
READER_CONTEXT * rContext )

Definition at line 1081 of file readerfactory.c.

◆ RFUnlockSharing()

LONG RFUnlockSharing ( SCARDHANDLE hCard,
READER_CONTEXT * rContext )

Definition at line 1048 of file readerfactory.c.

Variable Documentation

◆ dwNumReadersContexts

DWORD dwNumReadersContexts = 0
static

Definition at line 70 of file readerfactory.c.

◆ LockMutex

pthread_mutex_t LockMutex = PTHREAD_MUTEX_INITIALIZER
static

Definition at line 75 of file readerfactory.c.

◆ maxReaderHandles

int maxReaderHandles = PCSC_MAX_READER_HANDLES
static

Definition at line 69 of file readerfactory.c.

◆ ReaderEvents

int16_t ReaderEvents = 1

Definition at line 76 of file readerfactory.c.

◆ readerStates

Definition at line 68 of file readerfactory.c.

◆ sReadersContexts

READER_CONTEXT* sReadersContexts[PCSCLITE_MAX_READERS_CONTEXTS]
static

Definition at line 67 of file readerfactory.c.