123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- //
- // Created by robin on 6/28/15.
- //
-
- #ifndef LIBPCSC_CPPTOOLS_SCREADER_H
- # define LIBPCSC_CPPTOOLS_SCREADER_H
-
- # include <wintypes.h>
- # include <pcsclite.h>
- # include <memory>
- #include <bits/stl_bvector.h>
- # include "ScCommand.h"
- # include "ScResult.h"
-
- class ScReader
- {
- public:
- inline ScReader(std::string name);
-
- virtual ~ScReader();
-
- static std::vector<std::shared_ptr<ScReader>> getReaders();
-
- static LONG getLastStaticResult();
-
- static std::string getLastStaticResultString();
-
- static std::string getResultString(const LONG& result);
-
- LONG getLastResult();
-
- std::string getLastResultString();
-
- static bool establishContext();
-
- static bool freeContext();
-
- bool connect(DWORD shareMode = SCARD_SHARE_SHARED, DWORD protocols =
- SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, DWORD disposition = SCARD_LEAVE_CARD);
-
- bool disconnect(DWORD disposition = SCARD_LEAVE_CARD);
-
- std::shared_ptr<ScResult> transmit(const ScCommand& command, DWORD size = 2048);
-
- inline const std::string getName() const;
-
- std::string getAttribute(DWORD attr);
-
- std::string getAtr();
-
- private:
- std::string _name;
-
- static thread_local LPSCARDCONTEXT _context;
-
- static thread_local LONG _lastStaticResult;
-
- LPSCARDHANDLE _card;
-
- LPDWORD _proto;
-
- SCARD_IO_REQUEST _sendPci;
-
- LONG _lastResult;
- };
-
- # include "ScReader.hxx"
-
- #endif //LIBPCSC_CPPTOOLS_SCREADER_H
|