#include "config.h"
#include <stdlib.h>
#include <sys/time.h>
#include <string.h>
#include "pcsclite.h"
#include "winscard.h"
#include "ifdhandler.h"
#include "debuglog.h"
#include "readerfactory.h"
#include "prothandler.h"
#include "ifdwrapper.h"
#include "atrhandler.h"
#include "sys_generic.h"
#include "eventhandler.h"
Go to the source code of this file.
Defines | |
#define | SCARD_PROTOCOL_ANY_OLD 0x1000 |
used for backward compatibility. | |
#define | SCARD_LAST_CONTEXT 1 |
Some defines for context stack. | |
#define | SCARD_NO_CONTEXT 0 |
Some defines for context stack. | |
#define | SCARD_EXCLUSIVE_CONTEXT -1 |
Some defines for context stack. | |
#define | SCARD_NO_LOCK 0 |
Some defines for context stack. | |
Functions | |
LONG | SCardEstablishContext (DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext) |
Creates an Application Context for a client. More... | |
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. More... | |
LONG | SCardSetTimeout (SCARDCONTEXT hContext, DWORD dwTimeout) |
LONG | SCardConnect (SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode, DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol) |
This function establishes a connection to the friendly name of the reader specified in szReader. More... | |
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(). More... | |
LONG | SCardDisconnect (SCARDHANDLE hCard, DWORD dwDisposition) |
This function terminates a connection to the connection made through SCardConnect(). More... | |
LONG | SCardBeginTransaction (SCARDHANDLE hCard) |
This function establishes a temporary exclusive access mode for doing a series of commands or transaction. More... | |
LONG | SCardEndTransaction (SCARDHANDLE hCard, DWORD dwDisposition) |
This function ends a previously begun transaction. More... | |
LONG | SCardCancelTransaction (SCARDHANDLE hCard) |
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. More... | |
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. More... | |
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. More... | |
LONG | SCardGetAttrib (SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr, LPDWORD pcbAttrLen) |
This function get an attribute from the IFD Handler. More... | |
LONG | SCardSetAttrib (SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr, DWORD cbAttrLen) |
This function set an attribute of the IFD Handler. More... | |
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(). More... | |
LONG | SCardListReaders (SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders, LPDWORD pcchReaders) |
This function returns a list of currently available readers on the system. More... | |
LONG | SCardCancel (SCARDCONTEXT hContext) |
This function cancels all pending blocking requests on the SCardGetStatusChange() function. More... | |
Variables | |
SCARD_IO_REQUEST | g_rgSCardT0Pci = { SCARD_PROTOCOL_T0, 8 } |
SCARD_IO_REQUEST | g_rgSCardT1Pci = { SCARD_PROTOCOL_T1, 8 } |
SCARD_IO_REQUEST | g_rgSCardRawPci = { SCARD_PROTOCOL_RAW, 8 } |
Here are the main server-side functions which execute the requests from the clients.
Definition in file winscard.c.
|
This function establishes a temporary exclusive access mode for doing a series of commands or transaction. You might want to use this when you are selecting a few files and then writing a large file so you can make sure that another application will not change the current file. If another application has a lock on this reader or this application is in SCARD_SHARE_EXCLUSIVE there will be no action taken.
Definition at line 874 of file winscard.c. References SCardBeginTransaction. |
|
This function cancels all pending blocking requests on the SCardGetStatusChange() function.
|
|
Definition at line 1062 of file winscard.c. References SCardCancelTransaction. |
|
This function establishes a connection to the friendly name of the reader specified in szReader. The first connection will power up and perform a reset on the card.
|
|
This function sends a command directly to the IFD Handler to be processed by the reader. This is useful for creating client side reader drivers for functions like PIN pads, biometrics, or other extensions to the normal smart card reader that are not normally handled by PC/SC.
|
|
This function terminates a connection to the connection made through SCardConnect(). dwDisposition can have the following values:
|
|
This function ends a previously begun transaction. The calling application must be the owner of the previously begun transaction or an error will occur.
|
|
Creates an Application Context for a client. This must be the first function called in a PC/SC application.
Definition at line 135 of file winscard.c. References SCardEstablishContext. |
|
This function get an attribute from the IFD Handler.
The list of possible attributes is available in the file
|
|
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. The new event state will be contained in dwEventState. A status change might be a card insertion or removal event, a change in ATR, etc. This function will block for reader availability if cReaders is equal to zero and rgReaderStates is NULL.
typedef struct { LPCSTR szReader; // Reader name LPVOID pvUserData; // User defined data DWORD dwCurrentState; // Current state of reader DWORD dwEventState; // Reader state after a state change DWORD cbAtr; // ATR Length, usually MAX_ATR_SIZE BYTE rgbAtr[MAX_ATR_SIZE]; // ATR Value } SCARD_READERSTATE; ... typedef SCARD_READERSTATE *PSCARD_READERSTATE, **LPSCARD_READERSTATE; ... Value of dwCurrentState and dwEventState:
|
|
This function returns a list of currently available readers on the system.
|
|
This function reestablishes a connection to a reader that was previously connected to using SCardConnect(). In a multi application environment it is possible for an application to reset the card in shared mode. When this occurs any other application trying to access certain commands will be returned the value SCARD_W_RESET_CARD. When this occurs SCardReconnect() must be called in order to acknowledge that the card was reset and allow it to change it's state accordingly.
|
|
This function destroys a communication context to the PC/SC Resource Manager. This must be the last function called in a PC/SC application.
|
|
This function set an attribute of the IFD Handler. The list of attributes you can set is dependent on the IFD Handler you are using.
|
|
Definition at line 175 of file winscard.c. |
|
This function returns the current status of the reader connected to by hCard. It's friendly name will be stored in szReaderName. pcchReaderLen will be the size of the allocated buffer for szReaderName, while pcbAtrLen will be the size of the allocated buffer for pbAtr. If either of these is too small, the function will return with SCARD_E_INSUFFICIENT_BUFFER and the necessary size in pcchReaderLen and pcbAtrLen. The current state, and protocol will be stored in pdwState and pdwProtocol respectively.
|
|
This function sends an APDU to the smart card contained in the reader connected to by SCardConnect(). The card responds from the APDU and stores this response in pbRecvBuffer and it's length in SpcbRecvLength. SSendPci and SRecvPci are structures containing the following: typedef struct { DWORD dwProtocol; // SCARD_PROTOCOL_T0 or SCARD_PROTOCOL_T1 DWORD cbPciLength; // Length of this structure - not used } SCARD_IO_REQUEST;
|