pcsc-lite  2.5.0
libredirect.c File Reference

Redirect PC/SC calls to the delegate library. More...

#include <dlfcn.h>
#include <stdio.h>
#include <stdarg.h>
#include <fcntl.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <pthread.h>
#include "misc.h"
#include <winscard.h>
#include "sys_generic.h"

Go to the source code of this file.

Macros

#define DEBUG
 
#define DLSYM_DECLARE(symbol)    typeof(symbol)* symbol
 
#define DLSYM_SET_VALUE(symbol)    .symbol = (typeof(symbol)(*))internal_error
 
#define LIBPCSC   "libpcsclite_real.so.1"
 
#define get_symbol(s)   do { redirect.s = dlsym(Lib_handle, #s); if (NULL == redirect.s) { log_line("%s", dlerror()); return; } } while (0)
 

Functions

static LONG internal_error (void)
 
static void log_line (const char *fmt,...)
 
static void load_lib (void)
 
PCSC_API LONG SCardEstablishContext (DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
 
PCSC_API LONG SCardReleaseContext (SCARDCONTEXT hContext)
 
PCSC_API LONG SCardIsValidContext (SCARDCONTEXT hContext)
 
PCSC_API LONG SCardConnect (SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode, DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol)
 
PCSC_API LONG SCardReconnect (SCARDHANDLE hCard, DWORD dwShareMode, DWORD dwPreferredProtocols, DWORD dwInitialization, LPDWORD pdwActiveProtocol)
 
PCSC_API LONG SCardDisconnect (SCARDHANDLE hCard, DWORD dwDisposition)
 
PCSC_API LONG SCardBeginTransaction (SCARDHANDLE hCard)
 
PCSC_API LONG SCardEndTransaction (SCARDHANDLE hCard, DWORD dwDisposition)
 
PCSC_API LONG SCardStatus (SCARDHANDLE hCard, LPSTR mszReaderName, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen)
 
PCSC_API LONG SCardGetStatusChange (SCARDCONTEXT hContext, DWORD dwTimeout, SCARD_READERSTATE *rgReaderStates, DWORD cReaders)
 
PCSC_API LONG SCardControl (SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned)
 
PCSC_API LONG SCardTransmit (SCARDHANDLE hCard, const SCARD_IO_REQUEST *pioSendPci, LPCBYTE pbSendBuffer, DWORD cbSendLength, SCARD_IO_REQUEST *pioRecvPci, LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength)
 
PCSC_API LONG SCardListReaderGroups (SCARDCONTEXT hContext, LPSTR mszGroups, LPDWORD pcchGroups)
 
PCSC_API LONG SCardListReaders (SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders, LPDWORD pcchReaders)
 
PCSC_API LONG SCardFreeMemory (SCARDCONTEXT hContext, LPCVOID pvMem)
 
PCSC_API LONG SCardCancel (SCARDCONTEXT hContext)
 
PCSC_API LONG SCardGetAttrib (SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr, LPDWORD pcbAttrLen)
 
PCSC_API LONG SCardSetAttrib (SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr, DWORD cbAttrLen)
 

Variables

struct {
redirect
 
static void * Lib_handle = NULL
 

Detailed Description

Redirect PC/SC calls to the delegate library.

Definition in file libredirect.c.

Variable Documentation

struct { ... } redirect
Initial value:
= {
DLSYM_SET_VALUE(SCardEstablishContext),
DLSYM_SET_VALUE(SCardReleaseContext),
DLSYM_SET_VALUE(SCardIsValidContext),
DLSYM_SET_VALUE(SCardConnect),
DLSYM_SET_VALUE(SCardReconnect),
DLSYM_SET_VALUE(SCardDisconnect),
DLSYM_SET_VALUE(SCardBeginTransaction),
DLSYM_SET_VALUE(SCardEndTransaction),
DLSYM_SET_VALUE(SCardStatus),
DLSYM_SET_VALUE(SCardGetStatusChange),
DLSYM_SET_VALUE(SCardControl),
DLSYM_SET_VALUE(SCardTransmit),
DLSYM_SET_VALUE(SCardListReaderGroups),
DLSYM_SET_VALUE(SCardListReaders),
DLSYM_SET_VALUE(SCardFreeMemory),
DLSYM_SET_VALUE(SCardCancel),
DLSYM_SET_VALUE(SCardGetAttrib),
}