replaced mrw::Shared by std::shared_ptr; refs #28
This commit is contained in:
		@@ -10,6 +10,7 @@
 | 
				
			|||||||
// #include <openssl.hxx>
 | 
					// #include <openssl.hxx>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
 | 
					#include <mrw/checkcxx11.hxx>
 | 
				
			||||||
#include <memory>
 | 
					#include <memory>
 | 
				
			||||||
#include <cctype>
 | 
					#include <cctype>
 | 
				
			||||||
#include <stdexcept>
 | 
					#include <stdexcept>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,7 @@
 | 
				
			|||||||
#include <mrw/args.hxx>
 | 
					#include <mrw/args.hxx>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
 | 
					#include <mrw/checkcxx11.hxx>
 | 
				
			||||||
#include <memory>
 | 
					#include <memory>
 | 
				
			||||||
#include <cctype>
 | 
					#include <cctype>
 | 
				
			||||||
#include <stdexcept>
 | 
					#include <stdexcept>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,7 +18,7 @@ class TextualCycle: public suisseid::StatusCycle {
 | 
				
			|||||||
  public:
 | 
					  public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // just pass the card to parent
 | 
					    // just pass the card to parent
 | 
				
			||||||
    TextualCycle(mrw::Shared<suisseid::Card> card):
 | 
					    TextualCycle(std::shared_ptr<suisseid::Card> card):
 | 
				
			||||||
        StatusCycle(card) {
 | 
					        StatusCycle(card) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -424,12 +424,12 @@ namespace cardos {
 | 
				
			|||||||
      Commands() {}
 | 
					      Commands() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /// Initialize with given smart card reader.
 | 
					      /// Initialize with given smart card reader.
 | 
				
			||||||
      Commands(pcsc::shared_ptr<pcsc::Connection::Reader>::t r):
 | 
					      Commands(std::shared_ptr<pcsc::Connection::Reader> r):
 | 
				
			||||||
          _reader(r) {
 | 
					          _reader(r) {
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /// Set smart card reader.
 | 
					      /// Set smart card reader.
 | 
				
			||||||
      void reader(pcsc::shared_ptr<pcsc::Connection::Reader>::t r) {
 | 
					      void reader(std::shared_ptr<pcsc::Connection::Reader> r) {
 | 
				
			||||||
        _reader = r;
 | 
					        _reader = r;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1549,7 +1549,7 @@ namespace cardos {
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    protected:
 | 
					    protected:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      pcsc::shared_ptr<pcsc::Connection::Reader>::t _reader;
 | 
					      std::shared_ptr<pcsc::Connection::Reader> _reader;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
@@ -1557,7 +1557,7 @@ namespace cardos {
 | 
				
			|||||||
  /// Represents a CardOS Filesystem Object
 | 
					  /// Represents a CardOS Filesystem Object
 | 
				
			||||||
  class Object {
 | 
					  class Object {
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
      typedef pcsc::shared_ptr<Object>::t Child;
 | 
					      typedef std::shared_ptr<Object> Child;
 | 
				
			||||||
      typedef std::vector<Child> Children;
 | 
					      typedef std::vector<Child> Children;
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
      Object(const std::string& p): _path(p) {}
 | 
					      Object(const std::string& p): _path(p) {}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,7 @@
 | 
				
			|||||||
#include <cryptoki.hxx>
 | 
					#include <cryptoki.hxx>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <sstream>
 | 
					#include <sstream>
 | 
				
			||||||
 | 
					#include <mrw/checkcxx11.hxx>
 | 
				
			||||||
#include <memory>
 | 
					#include <memory>
 | 
				
			||||||
#ifndef WIN32
 | 
					#ifndef WIN32
 | 
				
			||||||
#include <dlfcn.h>
 | 
					#include <dlfcn.h>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,7 +18,8 @@
 | 
				
			|||||||
#include <vector>
 | 
					#include <vector>
 | 
				
			||||||
#include <map>
 | 
					#include <map>
 | 
				
			||||||
#include <set>
 | 
					#include <set>
 | 
				
			||||||
#include <mrw/shared.hxx>
 | 
					#include <mrw/checkcxx11.hxx>
 | 
				
			||||||
 | 
					#include <memory>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// for inline implementations only
 | 
					// for inline implementations only
 | 
				
			||||||
#include <cryptaux.hxx>
 | 
					#include <cryptaux.hxx>
 | 
				
			||||||
@@ -27,7 +28,6 @@
 | 
				
			|||||||
#include <cstring> // memset
 | 
					#include <cstring> // memset
 | 
				
			||||||
#include <cassert> // assert
 | 
					#include <cassert> // assert
 | 
				
			||||||
#include <iomanip>
 | 
					#include <iomanip>
 | 
				
			||||||
#include <memory>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*! @defgroup gcryptoki C++ Wrapper around Cryptoki API
 | 
					/*! @defgroup gcryptoki C++ Wrapper around Cryptoki API
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
@@ -1903,7 +1903,7 @@ namespace cryptoki {
 | 
				
			|||||||
      void login(const std::string& pin,
 | 
					      void login(const std::string& pin,
 | 
				
			||||||
                 CK_USER_TYPE userType=CKU_USER) {
 | 
					                 CK_USER_TYPE userType=CKU_USER) {
 | 
				
			||||||
        CRYPTOLOG("log");
 | 
					        CRYPTOLOG("log");
 | 
				
			||||||
        _login = new Login(*this, pin, userType);
 | 
					        _login = std::shared_ptr<Login>(new Login(*this, pin, userType));
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /// Logout from card
 | 
					      /// Logout from card
 | 
				
			||||||
@@ -1913,7 +1913,7 @@ namespace cryptoki {
 | 
				
			|||||||
        _login.reset();
 | 
					        _login.reset();
 | 
				
			||||||
       }
 | 
					       }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
       mrw::Shared<Login> _login;
 | 
					       std::shared_ptr<Login> _login;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      //@}
 | 
					      //@}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										31
									
								
								src/pcsc.hxx
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								src/pcsc.hxx
									
									
									
									
									
								
							@@ -56,27 +56,12 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <vector>
 | 
					#include <vector>
 | 
				
			||||||
#include <map>
 | 
					#include <map>
 | 
				
			||||||
 | 
					#include <mrw/checkcxx11.hxx>
 | 
				
			||||||
#include <memory>
 | 
					#include <memory>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <sstream>
 | 
					#include <sstream>
 | 
				
			||||||
#include <iomanip>
 | 
					#include <iomanip>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if __cplusplus > 199711L
 | 
					 | 
				
			||||||
  namespace pcsc {
 | 
					 | 
				
			||||||
    template<typename T> struct shared_ptr {
 | 
					 | 
				
			||||||
        typedef std::shared_ptr<T> t;
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
  #warning Old compiler (pre 2011): using boost as replacement for std
 | 
					 | 
				
			||||||
  #include <boost/shared_ptr.hpp>
 | 
					 | 
				
			||||||
  namespace pcsc {
 | 
					 | 
				
			||||||
    template<typename T> struct shared_ptr {
 | 
					 | 
				
			||||||
        typedef boost::shared_ptr<T> t;
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! @defgroup gpcsc C++ Wrapper around pcsc-lite API
 | 
					/*! @defgroup gpcsc C++ Wrapper around pcsc-lite API
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This library is a C++ wrapper to the awful pcsc-lite interface.
 | 
					    This library is a C++ wrapper to the awful pcsc-lite interface.
 | 
				
			||||||
@@ -200,7 +185,7 @@ namespace pcsc {
 | 
				
			|||||||
              /*! @note Please note that the Reader is required in the
 | 
					              /*! @note Please note that the Reader is required in the
 | 
				
			||||||
                  destructor und must therefore live longer than the
 | 
					                  destructor und must therefore live longer than the
 | 
				
			||||||
                  Transaction instance. */
 | 
					                  Transaction instance. */
 | 
				
			||||||
              Transaction(shared_ptr<Reader>::t r):
 | 
					              Transaction(std::shared_ptr<Reader> r):
 | 
				
			||||||
                  _reader(r), _running(true) {
 | 
					                  _reader(r), _running(true) {
 | 
				
			||||||
                CRYPTOLOG("log");
 | 
					                CRYPTOLOG("log");
 | 
				
			||||||
                _reader->beginTransaction();
 | 
					                _reader->beginTransaction();
 | 
				
			||||||
@@ -218,7 +203,7 @@ namespace pcsc {
 | 
				
			|||||||
                _running = false;
 | 
					                _running = false;
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
            private:
 | 
					            private:
 | 
				
			||||||
              shared_ptr<Reader>::t _reader;
 | 
					              std::shared_ptr<Reader> _reader;
 | 
				
			||||||
              bool _running;
 | 
					              bool _running;
 | 
				
			||||||
          };
 | 
					          };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -422,7 +407,7 @@ namespace pcsc {
 | 
				
			|||||||
          friend class Connection;
 | 
					          friend class Connection;
 | 
				
			||||||
          
 | 
					          
 | 
				
			||||||
          //! Establishes a connection to the given named cardreader
 | 
					          //! Establishes a connection to the given named cardreader
 | 
				
			||||||
          Reader(const std::string& nm, shared_ptr<Connection>::t c,
 | 
					          Reader(const std::string& nm, std::shared_ptr<Connection> c,
 | 
				
			||||||
                 DWORD mode=SCARD_SHARE_SHARED,
 | 
					                 DWORD mode=SCARD_SHARE_SHARED,
 | 
				
			||||||
                 DWORD protocol=SCARD_PROTOCOL_T1):
 | 
					                 DWORD protocol=SCARD_PROTOCOL_T1):
 | 
				
			||||||
              name(nm), _connection(c) {
 | 
					              name(nm), _connection(c) {
 | 
				
			||||||
@@ -439,7 +424,7 @@ namespace pcsc {
 | 
				
			|||||||
          //...........................................................variables
 | 
					          //...........................................................variables
 | 
				
			||||||
        private:
 | 
					        private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          shared_ptr<Connection>::t _connection;
 | 
					          std::shared_ptr<Connection> _connection;
 | 
				
			||||||
          SCARDHANDLE _id;
 | 
					          SCARDHANDLE _id;
 | 
				
			||||||
          DWORD _state;
 | 
					          DWORD _state;
 | 
				
			||||||
          DWORD _protocol;
 | 
					          DWORD _protocol;
 | 
				
			||||||
@@ -514,12 +499,12 @@ namespace pcsc {
 | 
				
			|||||||
      //! Get a reader, open a connection if not already open.
 | 
					      //! Get a reader, open a connection if not already open.
 | 
				
			||||||
      /*! First use scan() to get a list of readers, then open a
 | 
					      /*! First use scan() to get a list of readers, then open a
 | 
				
			||||||
          connection to the reader, then access it. */
 | 
					          connection to the reader, then access it. */
 | 
				
			||||||
      static shared_ptr<Reader>::t reader(const std::string& name,
 | 
					      static std::shared_ptr<Reader> reader(const std::string& name,
 | 
				
			||||||
                                          Scope s=USER, bool exceptions=true) {
 | 
					                                          Scope s=USER, bool exceptions=true) {
 | 
				
			||||||
        CRYPTOLOG("get reader: "<<name);
 | 
					        CRYPTOLOG("get reader: "<<name);
 | 
				
			||||||
        return shared_ptr<Reader>::t
 | 
					        return std::shared_ptr<Reader>
 | 
				
			||||||
          (new Reader(name,
 | 
					          (new Reader(name,
 | 
				
			||||||
                      shared_ptr<Connection>::t
 | 
					                      std::shared_ptr<Connection>
 | 
				
			||||||
                      (new Connection(s, exceptions))));
 | 
					                      (new Connection(s, exceptions))));
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,8 @@
 | 
				
			|||||||
#include <cryptoki.hxx>
 | 
					#include <cryptoki.hxx>
 | 
				
			||||||
#include <pcsc.hxx>
 | 
					#include <pcsc.hxx>
 | 
				
			||||||
#include <mrw/vector.hxx>
 | 
					#include <mrw/vector.hxx>
 | 
				
			||||||
#include <mrw/shared.hxx>
 | 
					#include <mrw/checkcxx11.hxx>
 | 
				
			||||||
 | 
					#include <memory>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*! @defgroup gsuisseid C++ library to access SuisseID smart cards
 | 
					/*! @defgroup gsuisseid C++ library to access SuisseID smart cards
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -185,7 +186,7 @@ namespace suisseid {
 | 
				
			|||||||
      /** Instance requires a connenction to the reader an a cryptoky
 | 
					      /** Instance requires a connenction to the reader an a cryptoky
 | 
				
			||||||
          library. This is passes automatically when this class is
 | 
					          library. This is passes automatically when this class is
 | 
				
			||||||
          instanciated through suisseid::Scanner. */
 | 
					          instanciated through suisseid::Scanner. */
 | 
				
			||||||
      Card(mrw::Shared<pcsc::Connection::Reader> reader,
 | 
					      Card(std::shared_ptr<pcsc::Connection::Reader> reader,
 | 
				
			||||||
           const cryptoki::Library& cryptoki):
 | 
					           const cryptoki::Library& cryptoki):
 | 
				
			||||||
          cardos::Commands(reader),
 | 
					          cardos::Commands(reader),
 | 
				
			||||||
          _cryptoki(cryptoki) {
 | 
					          _cryptoki(cryptoki) {
 | 
				
			||||||
@@ -205,7 +206,7 @@ namespace suisseid {
 | 
				
			|||||||
          pcsc::Connection::Reader::Transaction lock(card.reader());
 | 
					          pcsc::Connection::Reader::Transaction lock(card.reader());
 | 
				
			||||||
          [... do some low level stuff ...]
 | 
					          [... do some low level stuff ...]
 | 
				
			||||||
          @endcode */
 | 
					          @endcode */
 | 
				
			||||||
      mrw::Shared<pcsc::Connection::Reader> reader() {
 | 
					      std::shared_ptr<pcsc::Connection::Reader> reader() {
 | 
				
			||||||
        return _reader;
 | 
					        return _reader;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
@@ -290,7 +291,7 @@ namespace suisseid {
 | 
				
			|||||||
    public:
 | 
					    public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /// @copydoc Card::Card
 | 
					      /// @copydoc Card::Card
 | 
				
			||||||
      Post(mrw::Shared<pcsc::Connection::Reader> reader,
 | 
					      Post(std::shared_ptr<pcsc::Connection::Reader> reader,
 | 
				
			||||||
           const cryptoki::Library& cryptoki):
 | 
					           const cryptoki::Library& cryptoki):
 | 
				
			||||||
          Card(reader, cryptoki), _minPinLen(0), _maxPinLen(0) {
 | 
					          Card(reader, cryptoki), _minPinLen(0), _maxPinLen(0) {
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@@ -368,7 +369,7 @@ namespace suisseid {
 | 
				
			|||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //! List of cards, returned by @ref suisseid::Scanner::scan.
 | 
					  //! List of cards, returned by @ref suisseid::Scanner::scan.
 | 
				
			||||||
  typedef std::vector<mrw::Shared<Card> > Cards;
 | 
					  typedef std::vector<std::shared_ptr<Card> > Cards;
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
  //! Auxiliary SuisseID card manager.
 | 
					  //! Auxiliary SuisseID card manager.
 | 
				
			||||||
  /** Use this manager to scan your system for SuisseID cards.
 | 
					  /** Use this manager to scan your system for SuisseID cards.
 | 
				
			||||||
@@ -418,7 +419,7 @@ namespace suisseid {
 | 
				
			|||||||
          CRYPTOLOG("number of cryptoki-readers for "<<*reader
 | 
					          CRYPTOLOG("number of cryptoki-readers for "<<*reader
 | 
				
			||||||
                    <<": "<<slots.size());
 | 
					                    <<": "<<slots.size());
 | 
				
			||||||
          if (slots.size()==1)
 | 
					          if (slots.size()==1)
 | 
				
			||||||
            res.push_back(dynamic_cast<Card*>
 | 
					            res.push_back(std::shared_ptr<Card>
 | 
				
			||||||
                          (new Post(pcsc::Connection::reader(*reader),
 | 
					                          (new Post(pcsc::Connection::reader(*reader),
 | 
				
			||||||
                                    _cryptoki)));
 | 
					                                    _cryptoki)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -435,7 +436,7 @@ namespace suisseid {
 | 
				
			|||||||
      
 | 
					      
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      StatusCycle(mrw::Shared<Card> card, unsigned int maxRetries = 20):
 | 
					      StatusCycle(std::shared_ptr<Card> card, unsigned int maxRetries = 20):
 | 
				
			||||||
          _card(card), _maxRetries(maxRetries), _counter(0) {
 | 
					          _card(card), _maxRetries(maxRetries), _counter(0) {
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -449,7 +450,7 @@ namespace suisseid {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    protected:
 | 
					    protected:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      mrw::Shared<Card> card() {
 | 
					      std::shared_ptr<Card> card() {
 | 
				
			||||||
        return _card;
 | 
					        return _card;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -595,7 +596,7 @@ namespace suisseid {
 | 
				
			|||||||
        return start();
 | 
					        return start();
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      mrw::Shared<Card> _card;
 | 
					      std::shared_ptr<Card> _card;
 | 
				
			||||||
      unsigned int _maxRetries;
 | 
					      unsigned int _maxRetries;
 | 
				
			||||||
      unsigned int _counter;
 | 
					      unsigned int _counter;
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user