From f9913fa28a27f23fde2d4956c62cbb2fb2bc2ee8 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Thu, 21 Nov 2013 22:16:57 +0100 Subject: Boost/C++11 shared pointers. --- src/net/tls/openssl/OpenSSLInitializer.cpp | 4 ++-- src/net/tls/openssl/TLSProperties_OpenSSL.cpp | 10 ++++----- src/net/tls/openssl/TLSSession_OpenSSL.cpp | 12 +++++----- src/net/tls/openssl/TLSSocket_OpenSSL.cpp | 32 +++++++++++++-------------- 4 files changed, 29 insertions(+), 29 deletions(-) (limited to 'src/net/tls/openssl') diff --git a/src/net/tls/openssl/OpenSSLInitializer.cpp b/src/net/tls/openssl/OpenSSLInitializer.cpp index 8238b864..1bbb9ee5 100644 --- a/src/net/tls/openssl/OpenSSLInitializer.cpp +++ b/src/net/tls/openssl/OpenSSLInitializer.cpp @@ -49,7 +49,7 @@ namespace net { namespace tls { -ref * OpenSSLInitializer::sm_mutexes; +shared_ptr * OpenSSLInitializer::sm_mutexes; OpenSSLInitializer::autoInitializer::autoInitializer() @@ -93,7 +93,7 @@ void OpenSSLInitializer::initialize() RAND_seed(seed, SEEDSIZE); int numMutexes = CRYPTO_num_locks(); - sm_mutexes = new ref [numMutexes]; + sm_mutexes = new shared_ptr [numMutexes]; for (int i = 0 ; i < numMutexes ; ++i) sm_mutexes[i] = vmime::platform::getHandler()->createCriticalSection(); diff --git a/src/net/tls/openssl/TLSProperties_OpenSSL.cpp b/src/net/tls/openssl/TLSProperties_OpenSSL.cpp index 34e31cf1..932477df 100644 --- a/src/net/tls/openssl/TLSProperties_OpenSSL.cpp +++ b/src/net/tls/openssl/TLSProperties_OpenSSL.cpp @@ -40,7 +40,7 @@ namespace tls { TLSProperties::TLSProperties() - : m_data(vmime::create ()) + : m_data(make_shared ()) { setCipherSuite(CIPHERSUITE_DEFAULT); } @@ -48,9 +48,9 @@ TLSProperties::TLSProperties() TLSProperties::TLSProperties(const TLSProperties& props) : object(), - m_data(vmime::create ()) + m_data(make_shared ()) { - *m_data.dynamicCast () = *props.m_data.dynamicCast (); + *dynamicCast (m_data) = *dynamicCast (props.m_data); } @@ -84,13 +84,13 @@ void TLSProperties::setCipherSuite(const GenericCipherSuite cipherSuite) void TLSProperties::setCipherSuite(const string& cipherSuite) { - m_data.dynamicCast ()->cipherSuite = cipherSuite; + dynamicCast (m_data)->cipherSuite = cipherSuite; } const string TLSProperties::getCipherSuite() const { - return m_data.dynamicCast ()->cipherSuite; + return dynamicCast (m_data)->cipherSuite; } diff --git a/src/net/tls/openssl/TLSSession_OpenSSL.cpp b/src/net/tls/openssl/TLSSession_OpenSSL.cpp index 953e4ebc..cf600a63 100644 --- a/src/net/tls/openssl/TLSSession_OpenSSL.cpp +++ b/src/net/tls/openssl/TLSSession_OpenSSL.cpp @@ -46,13 +46,13 @@ static OpenSSLInitializer::autoInitializer openSSLInitializer; // static -ref TLSSession::create(ref cv, ref props) +shared_ptr TLSSession::create(shared_ptr cv, shared_ptr props) { - return vmime::create (cv, props); + return make_shared (cv, props); } -TLSSession_OpenSSL::TLSSession_OpenSSL(ref cv, ref props) +TLSSession_OpenSSL::TLSSession_OpenSSL(shared_ptr cv, shared_ptr props) : m_sslctx(0), m_certVerifier(cv), m_props(props) { m_sslctx = SSL_CTX_new(SSLv23_client_method()); @@ -76,13 +76,13 @@ TLSSession_OpenSSL::~TLSSession_OpenSSL() } -ref TLSSession_OpenSSL::getSocket(ref sok) +shared_ptr TLSSession_OpenSSL::getSocket(shared_ptr sok) { - return TLSSocket::wrap(thisRef().dynamicCast (), sok); + return TLSSocket::wrap(dynamicCast (shared_from_this()), sok); } -ref TLSSession_OpenSSL::getCertificateVerifier() +shared_ptr TLSSession_OpenSSL::getCertificateVerifier() { return m_certVerifier; } diff --git a/src/net/tls/openssl/TLSSocket_OpenSSL.cpp b/src/net/tls/openssl/TLSSocket_OpenSSL.cpp index 7fda1f15..9aec43e5 100644 --- a/src/net/tls/openssl/TLSSocket_OpenSSL.cpp +++ b/src/net/tls/openssl/TLSSocket_OpenSSL.cpp @@ -65,14 +65,14 @@ BIO_METHOD TLSSocket_OpenSSL::sm_customBIOMethod = // static -ref TLSSocket::wrap(ref session, ref sok) +shared_ptr TLSSocket::wrap(shared_ptr session, shared_ptr sok) { - return vmime::create - (session.dynamicCast (), sok); + return make_shared + (dynamicCast (session), sok); } -TLSSocket_OpenSSL::TLSSocket_OpenSSL(ref session, ref sok) +TLSSocket_OpenSSL::TLSSocket_OpenSSL(shared_ptr session, shared_ptr sok) : m_session(session), m_wrapped(sok), m_connected(false), m_ssl(0), m_ex(NULL) { } @@ -128,7 +128,7 @@ void TLSSocket_OpenSSL::connect(const string& address, const port_t port) createSSLHandle(); - handshake(NULL); + handshake(null); m_connected = true; } @@ -224,7 +224,7 @@ TLSSocket_OpenSSL::size_type TLSSocket_OpenSSL::sendRawNonBlocking(const char* b } -void TLSSocket_OpenSSL::handshake(ref toHandler) +void TLSSocket_OpenSSL::handshake(shared_ptr toHandler) { if (toHandler) toHandler->resetTimeOut(); @@ -245,14 +245,14 @@ void TLSSocket_OpenSSL::handshake(ref toHandler) { SSL_free(m_ssl); m_ssl = 0; - m_toHandler = NULL; + m_toHandler = null; throw; } - m_toHandler = NULL; + m_toHandler = null; // Verify server's certificate(s) - ref certs = getPeerCertificates(); + shared_ptr certs = getPeerCertificates(); if (certs == NULL) throw exceptions::tls_exception("No peer certificate."); @@ -263,24 +263,24 @@ void TLSSocket_OpenSSL::handshake(ref toHandler) } -ref TLSSocket_OpenSSL::getPeerCertificates() const +shared_ptr TLSSocket_OpenSSL::getPeerCertificates() const { STACK_OF(X509)* chain = SSL_get_peer_cert_chain(m_ssl); if (chain == NULL) - return NULL; + return null; int certCount = sk_X509_num(chain); if (certCount == 0) - return NULL; + return null; bool error = false; - std::vector > certs; + std::vector > certs; for (int i = 0; i < certCount && !error; i++) { - ref cert = + shared_ptr cert = vmime::security::cert::X509Certificate_OpenSSL::importInternal(sk_X509_value(chain, i)); if (cert) @@ -290,9 +290,9 @@ ref TLSSocket_OpenSSL::getPeerCertificates() } if (error) - return NULL; + return null; - return vmime::create (certs); + return make_shared (certs); } -- cgit v1.2.3