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

readerfactory.h

Go to the documentation of this file.
/*
 * MUSCLE SmartCard Development ( http://www.linuxnet.com )
 *
 * Copyright (C) 1999
 *  David Corcoran <corcoran@linuxnet.com>
 * Copyright (C) 2004
 *  Ludovic Rousseau <ludovic.rousseau@free.fr>
 *
 * $Id: readerfactory.h 2900 2008-04-22 13:12:50Z rousseau $
 */

/**
 * @file
 * @brief This keeps track of a list of currently available reader structures.
 */

#ifndef __readerfactory_h__
#define __readerfactory_h__

#include <inttypes.h>

#include "thread_generic.h"
#include "ifdhandler.h"

#ifdef __cplusplus
extern "C"
{
#endif

00030       typedef struct
      {
00032             char *pcFriendlyname;   /**< FRIENDLYNAME */
00033             char *pcDevicename;           /**< DEVICENAME */
00034             char *pcLibpath;        /**< LIBPATH */
00035             int dwChannelId;        /**< CHANNELID */
      } SerialReader;

00038       struct FctMap_V1
      {
            RESPONSECODE (*pvfCreateChannel)(DWORD);
            RESPONSECODE (*pvfCloseChannel)(void);
            RESPONSECODE (*pvfGetCapabilities)(DWORD, PUCHAR);
            RESPONSECODE (*pvfSetCapabilities)(DWORD, PUCHAR);
            RESPONSECODE (*pvfSetProtocolParameters)(DWORD, UCHAR, UCHAR, UCHAR,
                  UCHAR);
            RESPONSECODE (*pvfPowerICC)(DWORD);
            RESPONSECODE (*pvfTransmitToICC)(SCARD_IO_HEADER, PUCHAR, DWORD,
                  PUCHAR, PDWORD, PSCARD_IO_HEADER);
            RESPONSECODE (*pvfICCPresence)(void);
      };

      typedef struct FctMap_V1 FCT_MAP_V1, *PFCT_MAP_V1;

00054       struct FctMap_V2
      {
            /* shared with API 3.0 */
            RESPONSECODE (*pvfCreateChannel)(DWORD, DWORD);
            RESPONSECODE (*pvfCloseChannel)(DWORD);
            RESPONSECODE (*pvfGetCapabilities)(DWORD, DWORD, PDWORD, PUCHAR);
            RESPONSECODE (*pvfSetCapabilities)(DWORD, DWORD, DWORD, PUCHAR);
            RESPONSECODE (*pvfSetProtocolParameters)(DWORD, DWORD, UCHAR, UCHAR,
                  UCHAR, UCHAR);
            RESPONSECODE (*pvfPowerICC)(DWORD, DWORD, PUCHAR, PDWORD);
            RESPONSECODE (*pvfTransmitToICC)(DWORD, SCARD_IO_HEADER, PUCHAR,
                  DWORD, PUCHAR, PDWORD, PSCARD_IO_HEADER);
            RESPONSECODE (*pvfICCPresence)(DWORD);

            /* API v2.0 only */
            RESPONSECODE (*pvfControl)(DWORD, PUCHAR, DWORD, PUCHAR, PDWORD);
      };

      typedef struct FctMap_V2 FCT_MAP_V2, *PFCT_MAP_V2;

00074       struct FctMap_V3
      {
            /* the common fields SHALL be in the same order as in FctMap_V2 */
            RESPONSECODE (*pvfCreateChannel)(DWORD, DWORD);
            RESPONSECODE (*pvfCloseChannel)(DWORD);
            RESPONSECODE (*pvfGetCapabilities)(DWORD, DWORD, PDWORD, PUCHAR);
            RESPONSECODE (*pvfSetCapabilities)(DWORD, DWORD, DWORD, PUCHAR);
            RESPONSECODE (*pvfSetProtocolParameters)(DWORD, DWORD, UCHAR, UCHAR,
                        UCHAR, UCHAR);
            RESPONSECODE (*pvfPowerICC)(DWORD, DWORD, PUCHAR, PDWORD);
            RESPONSECODE (*pvfTransmitToICC)(DWORD, SCARD_IO_HEADER, PUCHAR,
                  DWORD, PUCHAR, PDWORD, PSCARD_IO_HEADER);
            RESPONSECODE (*pvfICCPresence)(DWORD);

            /* API V3.0 only */
            RESPONSECODE (*pvfControl)(DWORD, DWORD, LPCVOID, DWORD, LPVOID,
                  DWORD, LPDWORD);
            RESPONSECODE (*pvfCreateChannelByName)(DWORD, LPSTR);
      };

      typedef struct FctMap_V3 FCT_MAP_V3, *PFCT_MAP_V3;

00096       struct RdrCliHandles
      {
00098             SCARDHANDLE hCard;            /**< hCard for this connection */
00099             DWORD dwEventStatus;    /**< Recent event that must be sent */
      };

      typedef struct RdrCliHandles RDR_CLIHANDLES, *PRDR_CLIHANDLES;

00104       struct ReaderContext
      {
00106             char lpcReader[MAX_READERNAME];     /**< Reader Name */
00107             char lpcLibrary[MAX_LIBNAME]; /**< Library Path */
00108             char lpcDevice[MAX_DEVICENAME];     /**< Device Name */
00109             PCSCLITE_THREAD_T pthThread;  /**< Event polling thread */
00110             RESPONSECODE (*pthCardEvent)(DWORD);      /**< Card Event sync */
00111             PCSCLITE_MUTEX_T mMutex;      /**< Mutex for this connection */
            RDR_CLIHANDLES psHandles[PCSCLITE_MAX_READER_CONTEXT_CHANNELS];
00113                                          /**< Structure of connected handles */
            union
            {
00116                   FCT_MAP_V1 psFunctions_v1;    /**< API V1.0 */
00117                   FCT_MAP_V2 psFunctions_v2;    /**< API V2.0 */
00118                   FCT_MAP_V3 psFunctions_v3;    /**< API V3.0 */
            } psFunctions;    /**< driver functions */

00121             LPVOID vHandle;               /**< Dlopen handle */
00122             DWORD dwVersion;        /**< IFD Handler version number */
00123             DWORD dwPort;                 /**< Port ID */
00124             DWORD dwSlot;                 /**< Current Reader Slot */
00125             DWORD dwBlockStatus;    /**< Current blocking status */
00126             DWORD dwLockId;               /**< Lock Id */
00127             int LockCount;                /**< number of recursive locks */
00128             DWORD dwIdentity;       /**< Shared ID High Nibble */
00129             int32_t dwContexts;           /**< Number of open contexts */
00130             PDWORD pdwFeeds;        /**< Number of shared client to lib */
00131             PDWORD pdwMutex;        /**< Number of client to mutex */

00133             struct pubReaderStatesList *readerState; /**< link to the reader state */
            /* we can't use PREADER_STATE here since eventhandler.h can't be
             * included because of circular dependencies */
      };

      typedef struct ReaderContext READER_CONTEXT, *PREADER_CONTEXT;

      LONG RFAllocateReaderSpace(void);
      LONG RFAddReader(LPSTR, DWORD, LPSTR, LPSTR);
      LONG RFRemoveReader(LPSTR, DWORD);
      LONG RFSetReaderName(PREADER_CONTEXT, LPSTR, LPSTR, DWORD, DWORD);
      LONG RFListReaders(LPSTR, LPDWORD);
      LONG RFReaderInfo(LPSTR, struct ReaderContext **);
      LONG RFReaderInfoNamePort(DWORD, LPSTR, struct ReaderContext **);
      LONG RFReaderInfoById(DWORD, struct ReaderContext **);
      LONG RFCheckSharing(DWORD);
      LONG RFLockSharing(DWORD);
      LONG RFUnlockSharing(DWORD);
      LONG RFUnblockReader(PREADER_CONTEXT);
      LONG RFUnblockContext(SCARDCONTEXT);
      LONG RFLoadReader(PREADER_CONTEXT);
      LONG RFBindFunctions(PREADER_CONTEXT);
      LONG RFUnBindFunctions(PREADER_CONTEXT);
      LONG RFUnloadReader(PREADER_CONTEXT);
      LONG RFInitializeReader(PREADER_CONTEXT);
      LONG RFUnInitializeReader(PREADER_CONTEXT);
      SCARDHANDLE RFCreateReaderHandle(PREADER_CONTEXT);
      LONG RFDestroyReaderHandle(SCARDHANDLE hCard);
      LONG RFAddReaderHandle(PREADER_CONTEXT, SCARDHANDLE);
      LONG RFFindReaderHandle(SCARDHANDLE);
      LONG RFRemoveReaderHandle(PREADER_CONTEXT, SCARDHANDLE);
      LONG RFSetReaderEventState(PREADER_CONTEXT, DWORD);
      LONG RFCheckReaderEventState(PREADER_CONTEXT, SCARDHANDLE);
      LONG RFClearReaderEventState(PREADER_CONTEXT, SCARDHANDLE);
      LONG RFCheckReaderStatus(PREADER_CONTEXT);
      void RFCleanupReaders(int);
      int RFStartSerialReaders(const char *readerconf);
      void RFReCheckReaderConf(void);
      void RFSuspendAllReaders(void);
      void RFAwakeAllReaders(void);

#ifdef __cplusplus
}
#endif

#endif

Generated by  Doxygen 1.6.0   Back to index