Logo Search packages:      
Sourcecode: pcsc-lite version File versions  Download package

winscard_clnt.c File Reference


Detailed Description

This handles smartcard reader communications and forwarding requests over message queues.

Here is exposed the API for client applications.

Definition in file winscard_clnt.c.

#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/un.h>
#include <errno.h>
#include "misc.h"
#include "pcsclite.h"
#include "winscard.h"
#include "debug.h"
#include "thread_generic.h"
#include "readerfactory.h"
#include "eventhandler.h"
#include "sys_generic.h"
#include "winscard_msg.h"

Go to the source code of this file.

Classes

struct  _psChannelMap
struct  _psContextMap
 Represents the an Application Context on the Client side. More...

Defines

#define FALSE   0
#define min(a, b)   (((a) < (b)) ? (a) : (b))
#define PROFILE_END
#define PROFILE_START
#define SCARD_PROTOCOL_ANY_OLD   0x1000
#define TRUE   1

Typedefs

typedef struct _psChannelMap CHANNEL_MAP
typedef struct _psChannelMapPCHANNEL_MAP

Functions

static LONG SCardAddContext (SCARDCONTEXT hContext, DWORD dwClientID)
 Adds an Application Context to the vector psContextMap.
static LONG SCardAddHandle (SCARDHANDLE, DWORD, LPSTR)
LONG SCardBeginTransaction (SCARDHANDLE hCard)
 This function establishes a temporary exclusive access mode for doing a series of commands or transaction.
LONG SCardCancel (SCARDCONTEXT hContext)
LONG SCardCancelTransaction (SCARDHANDLE hCard)
static LONG SCardCheckDaemonAvailability (void)
 Checks if the Server is running.
LONG SCardConnect (SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode, DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol)
LONG SCardControl (SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned)
 This function sends a command directly to the IFD Handler to be processed by the reader.
LONG SCardDisconnect (SCARDHANDLE hCard, DWORD dwDisposition)
LONG SCardEndTransaction (SCARDHANDLE hCard, DWORD dwDisposition)
 This function ends a previously begun transaction.
LONG SCardEstablishContext (DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
 Creates an Application Context to the PC/SC Resource Manager.
static LONG SCardEstablishContextTH (DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
 Creates a communication context to the PC/SC Resource Manager.
LONG SCardGetAttrib (SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr, LPDWORD pcbAttrLen)
static LONG SCardGetContextIndice (SCARDCONTEXT hContext)
 Get the index from the Application Context vector psContextMap for the passed context.
static LONG SCardGetContextIndiceTH (SCARDCONTEXT hContext)
 Get the index from the Application Context vector psContextMap for the passed context.
static LONG SCardGetIndicesFromHandle (SCARDHANDLE, PDWORD, PDWORD)
static LONG SCardGetIndicesFromHandleTH (SCARDHANDLE, PDWORD, PDWORD)
static LONG SCardGetSetAttrib (SCARDHANDLE hCard, int command, DWORD dwAttrId, LPBYTE pbAttr, LPDWORD pcbAttrLen)
LONG SCardGetStatusChange (SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATE_A rgReaderStates, DWORD cReaders)
 This function receives a structure or list of structures containing reader names. It then blocks for a change in state to occur on any of the OR'd values contained in dwCurrentState for a maximum blocking time of dwTimeout or forever if INFINITE is used.
LONG SCardListReaderGroups (SCARDCONTEXT hContext, LPSTR mszGroups, LPDWORD pcchGroups)
 This function returns a list of currently available reader groups on the system. mszGroups is a pointer to a character string that is allocated by the application. If the application sends mszGroups as NULL then this function will return the size of the buffer needed to allocate in pcchGroups.
LONG SCardListReaders (SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders, LPDWORD pcchReaders)
static LONG SCardLockThread (void)
 This function locks a mutex so another thread must wait to use this function.
LONG SCardReconnect (SCARDHANDLE hCard, DWORD dwShareMode, DWORD dwPreferredProtocols, DWORD dwInitialization, LPDWORD pdwActiveProtocol)
 This function reestablishes a connection to a reader that was previously connected to using SCardConnect().
LONG SCardReleaseContext (SCARDCONTEXT hContext)
 This function destroys a communication context to the PC/SC Resource Manager. This must be the last function called in a PC/SC application.
static LONG SCardRemoveContext (SCARDCONTEXT hContext)
 Removes an Application Context from a control vector.
static LONG SCardRemoveHandle (SCARDHANDLE)
LONG SCardSetAttrib (SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr, DWORD cbAttrLen)
 This function set an attribute of the IFD Handler.
LONG SCardSetTimeout (SCARDCONTEXT hContext, DWORD dwTimeout)
LONG SCardStatus (SCARDHANDLE hCard, LPSTR mszReaderNames, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen)
 This function returns the current status of the reader connected to by hCard.
LONG SCardTransmit (SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, LPCBYTE pbSendBuffer, DWORD cbSendLength, LPSCARD_IO_REQUEST pioRecvPci, LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength)
 This function sends an APDU to the smart card contained in the reader connected to by SCardConnect().
void DESTRUCTOR SCardUnload (void)
static LONG SCardUnlockThread (void)
 This function unlocks a mutex so another thread may use the client.

Variables

static PCSCLITE_MUTEX clientMutex = PTHREAD_MUTEX_INITIALIZER
PCSC_API SCARD_IO_REQUEST g_rgSCardRawPci = { SCARD_PROTOCOL_RAW, 8 }
PCSC_API SCARD_IO_REQUEST g_rgSCardT0Pci = { SCARD_PROTOCOL_T0, 8 }
PCSC_API SCARD_IO_REQUEST g_rgSCardT1Pci = { SCARD_PROTOCOL_T1, 8 }
static short isExecuted = 0
static int mapAddr = 0
static struct _psContextMap psContextMap [PCSCLITE_MAX_APPLICATION_CONTEXTS]
 Represents the an Application Context on the Client side.
static PREADER_STATE readerStates [PCSCLITE_MAX_READERS_CONTEXTS]


Generated by  Doxygen 1.6.0   Back to index