activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
Subject svn commit: r589358 [1/2] - in /activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq: exceptions/ network/ support/ transport/filters/
Date Sun, 28 Oct 2007 14:17:05 GMT
Author: nmittler
Date: Sun Oct 28 07:17:03 2007
New Revision: 589358

URL: http://svn.apache.org/viewvc?rev=589358&view=rev
Log:
[AMQCPP-140] Changing calls to vector.data() to &vector.front() for compiler compatibility.

Modified:
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/exceptions/ActiveMQException.cpp
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLError.cpp
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLError.h
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocket.cpp
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocket.h
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketFactory.cpp
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketFactory.h
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketInputStream.cpp
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketInputStream.h
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketOutputStream.cpp
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketOutputStream.h
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketError.cpp
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketFactory.h
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketInputStream.cpp
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketInputStream.h
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketOutputStream.cpp
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketOutputStream.h
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/TcpSocket.cpp
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/TcpSocket.h
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/TcpSocketFactory.cpp
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/TcpSocketFactory.h
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/support/InitDirector.cpp
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/transport/filters/SSLTransportFactory.cpp
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/transport/filters/SSLTransportFactory.h
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/transport/filters/TcpTransport.cpp
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/transport/filters/TcpTransport.h
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/transport/filters/TcpTransportFactory.cpp
    activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/transport/filters/TcpTransportFactory.h

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/exceptions/ActiveMQException.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/exceptions/ActiveMQException.cpp?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/exceptions/ActiveMQException.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/exceptions/ActiveMQException.cpp Sun Oct 28 07:17:03 2007
@@ -28,128 +28,125 @@
 #endif
 
 ////////////////////////////////////////////////////////////////////////////////
-ActiveMQException::ActiveMQException() throw(){
+ActiveMQException::ActiveMQException() throw() {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-ActiveMQException::ActiveMQException( const ActiveMQException& ex ) throw()
-: cms::CMSException()
-{
+ActiveMQException::ActiveMQException(const ActiveMQException& ex) throw() :
+    cms::CMSException() {
     *this = ex;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-ActiveMQException::ActiveMQException( const char* file, const int lineNumber, 
-                   const char* msg, ... ) throw()
-{
+ActiveMQException::ActiveMQException(const char* file, const int lineNumber,
+        const char* msg, ...) throw() {
     va_list vargs;
-    va_start( vargs, msg ) ;
-    buildMessage( msg, vargs );
-    
+    va_start( vargs, msg );
+    buildMessage(msg, vargs);
+
     // Set the first mark for this exception.
-    setMark( file, lineNumber );
+    setMark(file, lineNumber);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-ActiveMQException::~ActiveMQException() throw(){
+ActiveMQException::~ActiveMQException() throw() {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQException::setMessage( const char* msg, ... ){
+void ActiveMQException::setMessage(const char* msg, ...) {
     va_list vargs;
     va_start(vargs, msg);
     buildMessage(msg, vargs);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQException::buildMessage(const char* format, va_list& vargs)
-{
+void ActiveMQException::buildMessage(const char* format, va_list& vargs) {
     // Allocate buffer with a guess of it's size
     int size = 256;
-    
+
     // Format string
-    while( true ){
-    	
-    	// Allocate a buffer of the specified size.
-    	char* buffer = new char[size];
-    	
+    while ( true) {
+
+        // Allocate a buffer of the specified size.
+        char* buffer = new char[size];
+
         int written = vsnprintf(buffer, size, format, vargs);
         if (written > -1 && written < size-1) {
-            
+
             // Guessed size was enough. Assign the string.
-            message.assign (buffer, written);
-            
+            message.assign(buffer, written);
+
             // assign isn't passing ownership, just copying, delete
             // the allocated buffer.
             delete [] buffer;
-            
+
             break;
         }
-                
+
         // Our buffer wasn't big enough - destroy the old buffer,
         // double the size and try again.
         delete [] buffer;
         size *= 2;
     }
-    
+
     //activemq::logger::SimpleLogger logger("com.yadda1");
     //logger.log( message );   
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQException::setMark( const char* file, const int lineNumber ){
-    
+void ActiveMQException::setMark(const char* file, const int lineNumber) {
+
     // Add this mark to the end of the stack trace.
-    stackTrace.push_back( std::make_pair( (std::string)file, (int)lineNumber ) );
-    
+    stackTrace.push_back(std::make_pair( (std::string)file, (int)lineNumber ) );
+
     ostringstream stream;
     stream << "\tFILE: " << stackTrace[stackTrace.size()-1].first;
     stream << ", LINE: " << stackTrace[stackTrace.size()-1].second;
-                 
+
     //activemq::logger::SimpleLogger logger("com.yadda2");
     //logger.log( stream.str() );    
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-ActiveMQException* ActiveMQException::clone() const{
+ActiveMQException* ActiveMQException::clone() const {
     return new ActiveMQException( *this );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::vector< std::pair< std::string, int> > ActiveMQException::getStackTrace() const{ 
-    return stackTrace; 
+std::vector< std::pair< std::string, int> > ActiveMQException::getStackTrace() const {
+    return stackTrace;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQException::printStackTrace() const{
-    printStackTrace( std::cerr );
+void ActiveMQException::printStackTrace() const {
+    printStackTrace(std::cerr);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQException::printStackTrace( std::ostream& stream ) const{
+void ActiveMQException::printStackTrace(std::ostream& stream) const {
     stream << getStackTraceString();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string ActiveMQException::getStackTraceString() const{
-    
+std::string ActiveMQException::getStackTraceString() const {
+
     // Create the output stream.
     std::ostringstream stream;
-    
+
     // Write the message and each stack entry.
     stream << message << std::endl;
-    for( unsigned int ix=0; ix<stackTrace.size(); ++ix ){
+    for (unsigned int ix=0; ix<stackTrace.size(); ++ix) {
         stream << "\tFILE: " << stackTrace[ix].first;
         stream << ", LINE: " << stackTrace[ix].second;
-        stream << std::endl;                    
+        stream << std::endl;
     }
-    
+
     // Return the string from the output stream.
     return stream.str();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-ActiveMQException& ActiveMQException::operator =( const ActiveMQException& ex ){
+ActiveMQException& ActiveMQException::operator =( const ActiveMQException& ex ) {
     this->message = ex.message;
     this->stackTrace = ex.stackTrace;
     return *this;

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLError.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLError.cpp?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLError.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLError.cpp Sun Oct 28 07:17:03 2007
@@ -31,16 +31,16 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 std::string SSLError::getErrorString() {
-    
+
     std::string returnValue;
-    
+
     for (unsigned long e = ERR_get_error(); e; e = ERR_get_error()) {
-	char msg[256];
-	ERR_error_string_n(e, msg, sizeof msg);
-	returnValue += "\n";
-	returnValue += msg;
+        char msg[256];
+        ERR_error_string_n(e, msg, sizeof msg);
+        returnValue += "\n";
+        returnValue += msg;
     }
-    
+
     return returnValue;
 }
 

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLError.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLError.h?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLError.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLError.h Sun Oct 28 07:17:03 2007
@@ -23,26 +23,27 @@
 
 #ifdef AMQ_HAVE_SSL
 
-namespace activemq{
-namespace network{
-    
+namespace activemq {
+namespace network {
+
     /**
      * Static utility class to simplify handling of error codes
      * for SSL operations.
      */
     class SSLError {
     public:
-    
+
         /**
          * Gets the last error appropriate for the platform.
          */
         static unsigned long getErrorCode();
-        
+
         /**
          * Gets the string description for the last error.
          */
         static std::string getErrorString();
     };
+    
 }}
 
 #endif /* AMQ_HAVE_SSL */

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocket.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocket.cpp?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocket.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocket.cpp Sun Oct 28 07:17:03 2007
@@ -30,35 +30,35 @@
 ///////////////////////////////////////////////////////////////////////////////
 SSLSocket::SSLSocket() throw (SocketException)
 :
-    TcpSocket(),
-    ctx( SSL_CTX_new( SSLv3_client_method() )),
-    ssl( 0 ),
-    verify_peer( false )
+TcpSocket(),
+ctx( SSL_CTX_new( SSLv3_client_method() )),
+ssl( 0 ),
+verify_peer( false )
 {
     if( !ctx )
-        throw SocketException( __FILE__, __LINE__,
-			       "Failed to allocate SSL context");
+    throw SocketException( __FILE__, __LINE__,
+            "Failed to allocate SSL context");
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 SSLSocket::SSLSocket( SocketHandle socketHandle ) throw (SocketException)
 :
-    TcpSocket(),
-    ctx( SSL_CTX_new( SSLv3_client_method() )),
-    ssl( 0 ),
-    verify_peer( false )
+TcpSocket(),
+ctx( SSL_CTX_new( SSLv3_client_method() )),
+ssl( 0 ),
+verify_peer( false )
 {
     if( !ctx )
-        throw SocketException( __FILE__, __LINE__,
-			       "Failed to allocate SSL context - %s",
-			       SSLError::getErrorString().c_str());
+    throw SocketException( __FILE__, __LINE__,
+            "Failed to allocate SSL context - %s",
+            SSLError::getErrorString().c_str());
 
     initializeSSL( socketHandle );
 
     try {
-	this->socketHandle = socketHandle;
-	this->inputStream = new SSLSocketInputStream( socketHandle, ssl );
-	this->outputStream = new SSLSocketOutputStream( socketHandle, ssl );
+        this->socketHandle = socketHandle;
+        this->inputStream = new SSLSocketInputStream( socketHandle, ssl );
+        this->outputStream = new SSLSocketOutputStream( socketHandle, ssl );
     }
     AMQ_CATCH_RETHROW( SocketException )
     AMQ_CATCHALL_THROW( SocketException )
@@ -71,112 +71,113 @@
     TcpSocket::close();
 
     if( ssl != 0 ) {
-	if( SSL_get_shutdown( ssl ) == 0 )
-	    SSL_set_shutdown( ssl, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN );
-	SSL_shutdown( ssl );
+        if( SSL_get_shutdown( ssl ) == 0 )
+        SSL_set_shutdown( ssl, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN );
+        SSL_shutdown( ssl );
     }
 
     if( ssl ) SSL_free( ssl );
     if( ctx ) SSL_CTX_free( ctx );
 }
 
+///////////////////////////////////////////////////////////////////////////////
 void SSLSocket::connect(const char* host, int port) throw ( SocketException )
 {
     if( ssl ) {
-	throw SocketException( __FILE__, __LINE__,
-			       "SSLSocket::connect - Socket already connected."
-			       " host: %s, port: %d", host, port );
+        throw SocketException( __FILE__, __LINE__,
+                "SSLSocket::connect - Socket already connected."
+                " host: %s, port: %d", host, port );
     }
 
     TcpSocket::connect (host, port);
     if( isConnected() ) {
-	while( true ){
+        while( true ) {
 
-	    int result = SSL_connect(ssl);
+            int result = SSL_connect(ssl);
 
-	    switch (SSL_get_error (ssl, result))
-		{
-		case SSL_ERROR_NONE:
-		    // Apart from verification we are done.
-		    verifyPeerCertificate( host );
-		    return;
-
-		case SSL_ERROR_SSL:
-		case SSL_ERROR_ZERO_RETURN:
-		    TcpSocket::close();
-		    throw SocketException( __FILE__, __LINE__,
-					   SSLError::getErrorString().c_str());
-
-		case SSL_ERROR_WANT_READ:
-		case SSL_ERROR_WANT_WRITE:
-		    // Repeat the operation.
-		    break;
-
-		case SSL_ERROR_SYSCALL:
-		    TcpSocket::close();
-		    throw SocketException( __FILE__, __LINE__,
-					   SocketError::getErrorString().c_str() );
-		}
-	}
+            switch (SSL_get_error (ssl, result))
+            {
+                case SSL_ERROR_NONE:
+                // Apart from verification we are done.
+                verifyPeerCertificate( host );
+                return;
+
+                case SSL_ERROR_SSL:
+                case SSL_ERROR_ZERO_RETURN:
+                TcpSocket::close();
+                throw SocketException( __FILE__, __LINE__,
+                        SSLError::getErrorString().c_str());
+
+                case SSL_ERROR_WANT_READ:
+                case SSL_ERROR_WANT_WRITE:
+                // Repeat the operation.
+                break;
+
+                case SSL_ERROR_SYSCALL:
+                TcpSocket::close();
+                throw SocketException( __FILE__, __LINE__,
+                        SocketError::getErrorString().c_str() );
+            }
+        }
     }
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 void SSLSocket::verifyPeerCertificate( const char* host )
-    throw( SocketException )
+throw( SocketException )
 {
     // Verify the certificate name.
     if( verify_peer ) {
-	X509 *peer_cert = SSL_get_peer_certificate( ssl );
+        X509 *peer_cert = SSL_get_peer_certificate( ssl );
 
-	if( !peer_cert ) {
-	    TcpSocket::close();
-	    throw SocketException( __FILE__, __LINE__,
-				   "No peer certificate for verify");
-	}
-
-	X509_NAME *subject = X509_get_subject_name( peer_cert );
-
-	std::string need_name (verify_name);
-	if( need_name.empty() ){
-	    need_name = host;
-	}
-
-	bool match = false;
-	std::string peer_name;
-
-	int i = -1;
-	do {
-	    i = X509_NAME_get_index_by_NID( subject, NID_commonName, i );
-	    if( i >= 0 ) {
-		X509_NAME_ENTRY *name = X509_NAME_get_entry( subject, i );
-
-		unsigned char *cn;
-		if( ASN1_STRING_to_UTF8( &cn, name->value ) >= 0 ){
-		    peer_name = reinterpret_cast<char*> (cn);
-		    std::free( cn );
-
-		    if( peer_name == need_name ){
-			match = true;
-		    }
-		}
-	    }
-	} while( i >= 0 && !match );
-
-	if( !match ){
-	    TcpSocket::close();
-
-	    if( peer_name.length() ){
-		throw SocketException( __FILE__, __LINE__,
-				       "Peer certificate mismatch for %s"
-				       " - peer name %s",
-				       verify_name.c_str(),
-				       peer_name.c_str() );
-	    } else {
-		throw SocketException( __FILE__, __LINE__,
-				       "Unable to find certificate CN");
-	    }
-	}
+        if( !peer_cert ) {
+            TcpSocket::close();
+            throw SocketException( __FILE__, __LINE__,
+                    "No peer certificate for verify");
+        }
+
+        X509_NAME *subject = X509_get_subject_name( peer_cert );
+
+        std::string need_name (verify_name);
+        if( need_name.empty() ) {
+            need_name = host;
+        }
+
+        bool match = false;
+        std::string peer_name;
+
+        int i = -1;
+        do {
+            i = X509_NAME_get_index_by_NID( subject, NID_commonName, i );
+            if( i >= 0 ) {
+                X509_NAME_ENTRY *name = X509_NAME_get_entry( subject, i );
+
+                unsigned char *cn;
+                if( ASN1_STRING_to_UTF8( &cn, name->value ) >= 0 ) {
+                    peer_name = reinterpret_cast<char*> (cn);
+                    std::free( cn );
+
+                    if( peer_name == need_name ) {
+                        match = true;
+                    }
+                }
+            }
+        }while( i >= 0 && !match );
+
+        if( !match ) {
+            TcpSocket::close();
+
+            if( peer_name.length() ) {
+                throw SocketException( __FILE__, __LINE__,
+                        "Peer certificate mismatch for %s"
+                        " - peer name %s",
+                        verify_name.c_str(),
+                        peer_name.c_str() );
+            } else {
+                throw SocketException( __FILE__, __LINE__,
+                        "Unable to find certificate CN");
+            }
+        }
     }
 }
 
@@ -184,20 +185,20 @@
 void SSLSocket::initialize() throw( SocketException )
 {
     // Destroy the input stream.
-    if( inputStream != NULL ){
-	delete inputStream;
-	inputStream = NULL;
+    if( inputStream != NULL ) {
+        delete inputStream;
+        inputStream = NULL;
     }
 
     // Destroy the output stream.
-    if( outputStream != NULL ){
-	delete outputStream;
-	outputStream = NULL;
+    if( outputStream != NULL ) {
+        delete outputStream;
+        outputStream = NULL;
     }
 
     if( ssl ) {
-	SSL_free( ssl );
-	ssl = 0;
+        SSL_free( ssl );
+        ssl = 0;
     }
     initializeSSL( socketHandle );
 
@@ -208,19 +209,19 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 void SSLSocket::initializeSSL( SocketHandle handle )
-    throw (SocketException)
+throw (SocketException)
 {
     ssl = SSL_new( ctx );
-    if( !ssl ){
+    if( !ssl ) {
         throw SocketException( __FILE__, __LINE__,
-			       "Failed to allocate SSL - %s",
-			       SSLError::getErrorString().c_str());
+                "Failed to allocate SSL - %s",
+                SSLError::getErrorString().c_str());
     }
 
     BIO* bio = BIO_new( BIO_s_socket() );
-    if( !bio ){
-	throw SocketException( __FILE__, __LINE__,
-			       "Failed to create BIO for SSL");
+    if( !bio ) {
+        throw SocketException( __FILE__, __LINE__,
+                "Failed to create BIO for SSL");
     }
 
     BIO_set_fd( bio, handle, BIO_NOCLOSE );
@@ -231,84 +232,84 @@
 void SSLSocket::close() throw( cms::CMSException )
 {
     // Close the input stream.
-    if( inputStream != NULL ){
+    if( inputStream != NULL ) {
         inputStream->close();
     }
 
     // Close the output stream.
-    if( outputStream != NULL ){
+    if( outputStream != NULL ) {
         outputStream->close();
     }
 
     if( ssl ) {
-	// The ssl can not yet be free'd, it is still use in the streams.
-	SSL_shutdown(ssl);
+        // The ssl can not yet be free'd, it is still use in the streams.
+        SSL_shutdown(ssl);
     }
     TcpSocket::close ();
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 void SSLSocket::setCAFilePath( std::string const& file,
-			       std::string const& path )
-    throw( SocketException )
+        std::string const& path )
+throw( SocketException )
 {
     if( file.length() || path.length() ) {
 
-	const char *c_file = file.length() ? file.c_str() : 0;
-	const char *c_path = path.length() ? path.c_str() : 0;
+        const char *c_file = file.length() ? file.c_str() : 0;
+        const char *c_path = path.length() ? path.c_str() : 0;
 
-	if( !SSL_CTX_load_verify_locations( ctx, c_file, c_path )) {
-	    throw SocketException( __FILE__, __LINE__,
-				   "Failed to load verify locations - %s",
-				   SSLError::getErrorString().c_str());
-	}
+        if( !SSL_CTX_load_verify_locations( ctx, c_file, c_path )) {
+            throw SocketException( __FILE__, __LINE__,
+                    "Failed to load verify locations - %s",
+                    SSLError::getErrorString().c_str());
+        }
     }
 
     // Should we do this automatically? 
     if( !SSL_CTX_set_default_verify_paths( ctx )) {
-	throw SocketException( __FILE__, __LINE__,
-			       "Failed to load default verify locations - %s",
-			       SSLError::getErrorString().c_str());
+        throw SocketException( __FILE__, __LINE__,
+                "Failed to load default verify locations - %s",
+                SSLError::getErrorString().c_str());
     }
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 void SSLSocket::setCertFile( std::string const& cert_file,
-			     std::string const& key_file )
-    throw( SocketException )
+        std::string const& key_file )
+throw( SocketException )
 {
     if( cert_file.length() ) {
-	if( !SSL_CTX_use_certificate_file( ctx, cert_file.c_str (),
-					   SSL_FILETYPE_PEM )) {
-	    throw SocketException( __FILE__, __LINE__,
-				   "Failed to load certificate %s - %s",
-				   cert_file.c_str(),
-				   SSLError::getErrorString().c_str());
-	}
-
-	const char *c_key_file
-	    = key_file.length() ? key_file.c_str() : cert_file.c_str();
-	    
-	if( !SSL_CTX_use_PrivateKey_file( ctx, c_key_file,
-					  SSL_FILETYPE_PEM )) {
-	    throw SocketException( __FILE__, __LINE__,
-				   "Failed to load private key %s - %s",
-				   c_key_file,
-				   SSLError::getErrorString().c_str());
-	}
+        if( !SSL_CTX_use_certificate_file( ctx, cert_file.c_str (),
+                        SSL_FILETYPE_PEM )) {
+            throw SocketException( __FILE__, __LINE__,
+                    "Failed to load certificate %s - %s",
+                    cert_file.c_str(),
+                    SSLError::getErrorString().c_str());
+        }
+
+        const char *c_key_file
+        = key_file.length() ? key_file.c_str() : cert_file.c_str();
+
+        if( !SSL_CTX_use_PrivateKey_file( ctx, c_key_file,
+                        SSL_FILETYPE_PEM )) {
+            throw SocketException( __FILE__, __LINE__,
+                    "Failed to load private key %s - %s",
+                    c_key_file,
+                    SSLError::getErrorString().c_str());
+        }
     }
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 void SSLSocket::setPassword( std::string const& password )
-    throw( SocketException )
+throw( SocketException )
 {
     if( password.length() ) {
-	this->password = password;
-	void* data = static_cast<void*> (&this->password);
+        this->password = password;
+        void* data = static_cast<void*> (&this->password);
 
-	SSL_CTX_set_default_passwd_cb( ctx, password_cb );
-	SSL_CTX_set_default_passwd_cb_userdata( ctx, data );
+        SSL_CTX_set_default_passwd_cb( ctx, password_cb );
+        SSL_CTX_set_default_passwd_cb_userdata( ctx, data );
     }
 }
 
@@ -322,26 +323,26 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 void SSLSocket::setVerifyPeer( bool value, std::string const& name )
-    throw( SocketException )
+throw( SocketException )
 {
     verify_peer = value;
-    if( verify_peer ){
-	verify_name = name;
-	SSL_CTX_set_verify( ctx, SSL_VERIFY_PEER, 0);
+    if( verify_peer ) {
+        verify_name = name;
+        SSL_CTX_set_verify( ctx, SSL_VERIFY_PEER, 0);
     }
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 void SSLSocket::setCiphers( std::string const& ciphers )
-    throw( SocketException )
+throw( SocketException )
 {
-    if( ciphers.length() ){
-	if( SSL_CTX_set_cipher_list( ctx, ciphers.c_str() ) == 0){
-	    throw SocketException( __FILE__, __LINE__,
-				   "Failed to set ciphers %s - %s",
-				   ciphers.c_str(),
-				   SSLError::getErrorString().c_str());
-	}
+    if( ciphers.length() ) {
+        if( SSL_CTX_set_cipher_list( ctx, ciphers.c_str() ) == 0) {
+            throw SocketException( __FILE__, __LINE__,
+                    "Failed to set ciphers %s - %s",
+                    ciphers.c_str(),
+                    SSLError::getErrorString().c_str());
+        }
     }
 }
 

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocket.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocket.h?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocket.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocket.h Sun Oct 28 07:17:03 2007
@@ -23,8 +23,8 @@
 #ifdef AMQ_HAVE_OPENSSL
 #include <openssl/ssl.h>
 
-namespace activemq{
-namespace network{
+namespace activemq {
+namespace network {
 
     /**
      * Platform-independent implementation of the SSL socket interface.
@@ -32,46 +32,46 @@
     class SSLSocket : public TcpSocket
     {
     private:
-	SSL_CTX *ctx;
-	SSL *ssl;
+        SSL_CTX *ctx;
+        SSL *ssl;
 
-	/**
-	 * Password for certificate and key files.
-	 */
-	std::string password;
-
-	/**
-	 * If peer certificate needs to be verified.
-	 */
-	bool verify_peer;
-
-	/**
-	 * Additional peer name that is accepted.
-	 */
-	std::string verify_name;
+        /**
+         * Password for certificate and key files.
+         */
+        std::string password;
+
+        /**
+         * If peer certificate needs to be verified.
+         */
+        bool verify_peer;
+
+        /**
+         * Additional peer name that is accepted.
+         */
+        std::string verify_name;
 
     protected:
-	/**
-	 * Internal initialize for TcpSocket.
-	 */
-	virtual void initialize () throw (SocketException);
-
-	/**
-	 * Verify peer certificate if needed.
-	 */
-	virtual void verifyPeerCertificate( const char* host)
-	    throw (SocketException);
-
-	/**
-	 * Initialize SSL connection structure.
-	 */
-	virtual void initializeSSL( SocketHandle handle )
-	    throw (SocketException);
-
-	/**
-	 * OpenSSL password callback.
-	 */
-	static int password_cb( char* buffer, int size, int rw, void* data);
+        /**
+         * Internal initialize for TcpSocket.
+         */
+        virtual void initialize () throw (SocketException);
+
+        /**
+         * Verify peer certificate if needed.
+         */
+        virtual void verifyPeerCertificate( const char* host)
+        throw (SocketException);
+
+        /**
+         * Initialize SSL connection structure.
+         */
+        virtual void initializeSSL( SocketHandle handle )
+        throw (SocketException);
+
+        /**
+         * OpenSSL password callback.
+         */
+        static int password_cb( char* buffer, int size, int rw, void* data);
 
     public:
 
@@ -109,7 +109,7 @@
          * Indicates whether or not this socket is connected to a destination.
          * @return true if connected
          */
-        bool isConnected() const{
+        bool isConnected() const {
             return TcpSocket::isConnected() && ssl != 0;
         }
 
@@ -119,37 +119,37 @@
          */
         void close() throw( cms::CMSException );
 
-	/**
-	 * Set CA file and path.
-	 */
-	virtual void setCAFilePath( std::string const& file,
-				    std::string const& path )
-	    throw( SocketException );
-
-	/**
-	 * Set client certificate file and private key file.
-	 */
-	virtual void setCertFile( std::string const& cert_file,
-				  std::string const& key_file )
-	    throw( SocketException );
-
-	/**
-	 * Set password for key and possibly certificate.
-	 */
-	virtual void setPassword( std::string const& password )
-	    throw( SocketException );
-
-	/**
-	 * If the peer should be verified.
-	 */
-	virtual void setVerifyPeer( bool value, std::string const& name )
-	    throw( SocketException );
-
-	/**
-	 * Set cipher list for SSL.
-	 */
-	virtual void setCiphers( std::string const& ciphers )
-	    throw( SocketException );
+        /**
+         * Set CA file and path.
+         */
+        virtual void setCAFilePath( std::string const& file,
+                std::string const& path )
+        throw( SocketException );
+
+        /**
+         * Set client certificate file and private key file.
+         */
+        virtual void setCertFile( std::string const& cert_file,
+                std::string const& key_file )
+        throw( SocketException );
+
+        /**
+         * Set password for key and possibly certificate.
+         */
+        virtual void setPassword( std::string const& password )
+        throw( SocketException );
+
+        /**
+         * If the peer should be verified.
+         */
+        virtual void setVerifyPeer( bool value, std::string const& name )
+        throw( SocketException );
+
+        /**
+         * Set cipher list for SSL.
+         */
+        virtual void setCiphers( std::string const& ciphers )
+        throw( SocketException );
     };
 
 }}

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketFactory.cpp?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketFactory.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketFactory.cpp Sun Oct 28 07:17:03 2007
@@ -25,8 +25,8 @@
 #include <stdio.h>
 
 #ifdef AMQ_HAVE_OPENSSL
-#include <openssl/ssl.h>
-#include <openssl/rand.h>
+    #include <openssl/ssl.h>
+    #include <openssl/rand.h>
 #endif /* AMQ_HAVE_OPENSSL */
 
 using namespace std;
@@ -43,111 +43,108 @@
 void SSLSocketFactory::locking_cb( int mode, int type, const char *, int )
 {
     if( mode & CRYPTO_LOCK )
-	locks[type].lock ();
+    locks[type].lock ();
     else
-	locks[type].unlock ();
+    locks[type].unlock ();
 }
 
 #endif /* AMQ_HAVE_OPENSSL */
 
 ////////////////////////////////////////////////////////////////////////////////
-
-SSLSocketFactory::SSLSocketFactory()
-{
+SSLSocketFactory::SSLSocketFactory() {
 #ifdef AMQ_HAVE_OPENSSL
     manageLocks = false;
 
     // Initialize only if locking callback is not yet set.
-    if( !CRYPTO_get_locking_callback() ){
+    if( !CRYPTO_get_locking_callback() ) {
 
-	// General library initialization.
-	CRYPTO_malloc_init();
-	SSL_load_error_strings();
-	SSL_library_init();
-	OpenSSL_add_all_algorithms();
-
-	// Set up threading.
-	if( !locks ){
-	    manageLocks = true;
-	    locks = new Mutex[CRYPTO_num_locks()];
-	    CRYPTO_set_id_callback( &Thread::getId );
-	    CRYPTO_set_locking_callback( &locking_cb );
-	}
+        // General library initialization.
+        CRYPTO_malloc_init();
+        SSL_load_error_strings();
+        SSL_library_init();
+        OpenSSL_add_all_algorithms();
+
+        // Set up threading.
+        if( !locks ) {
+            manageLocks = true;
+            locks = new Mutex[CRYPTO_num_locks()];
+            CRYPTO_set_id_callback( &Thread::getId );
+            CRYPTO_set_locking_callback( &locking_cb );
+        }
     }
 
     // Seed the random number generator.
     // Not really safe, but what can you do if the system does not have a good
     // random source..
-    if( !RAND_status() ){
-	std::vector<unsigned char> data (64);
-	Random().nextBytes( data );
+    if( !RAND_status() ) {
+        std::vector<unsigned char> data (64);
+        Random().nextBytes( data );
 #ifdef WIN32
-	RAND_seed( static_cast<const void *>( data._Myfirst ), (int)data.size() );
+        RAND_seed( static_cast<const void *>( data._Myfirst ), (int)data.size() );
 #else
-	RAND_seed( static_cast<const void *>( data.data() ), data.size() );
+        RAND_seed( static_cast<const void *>( &data.front() ), data.size() );
 #endif
     }
 
 #endif /* AMQ_HAVE_OPENSSL */
 }
 
-SSLSocketFactory::~SSLSocketFactory()
-{
+///////////////////////////////////////////////////////////////////////////////
+SSLSocketFactory::~SSLSocketFactory() {
 #ifdef AMQ_HAVE_OPENSSL
 
-  if( manageLocks ){
-      CRYPTO_set_locking_callback( 0 );
-      delete [] locks;
-      locks = 0;
-  }
+    if( manageLocks ) {
+        CRYPTO_set_locking_callback( 0 );
+        delete [] locks;
+        locks = 0;
+    }
 
 #endif /* AMQ_HAVE_OPENSSL */
 }
 
-TcpSocket* SSLSocketFactory::createTcpSocket(
-    const util::Properties &properties )
-    throw ( SocketException )
-{
+///////////////////////////////////////////////////////////////////////////////
+TcpSocket* SSLSocketFactory::createTcpSocket(const util::Properties &properties)
+        throw (SocketException ) {
 #ifdef AMQ_HAVE_OPENSSL
     std::string ca_file
-	= properties.getProperty( "sslCAFile", "" );
+    = properties.getProperty( "sslCAFile", "" );
     std::string ca_path
-	= properties.getProperty( "sslCAPath", "" );
+    = properties.getProperty( "sslCAPath", "" );
 
     std::string cert_file
-	= properties.getProperty( "sslCertFile", "" );
+    = properties.getProperty( "sslCertFile", "" );
     std::string key_file
-	= properties.getProperty( "sslKeyFile", cert_file );
+    = properties.getProperty( "sslKeyFile", cert_file );
 
     std::string password
-	= properties.getProperty( "sslPassword", "" );
+    = properties.getProperty( "sslPassword", "" );
 
     bool verify_peer
-	= properties.getProperty( "sslVerifyPeer", "false" ) == "true";
+    = properties.getProperty( "sslVerifyPeer", "false" ) == "true";
     std::string verify_name
-	= properties.getProperty( "sslVerifyName", "" );
+    = properties.getProperty( "sslVerifyName", "" );
 
     std::string ciphers
-	= properties.getProperty( "sslCiphers", "" );
+    = properties.getProperty( "sslCiphers", "" );
 
     SSLSocket *socket = new SSLSocket();
 
     try {
-	try {
-	    socket->setPassword( password );
-	    socket->setCAFilePath( ca_file, ca_path );
-	    socket->setCertFile( cert_file, key_file );
-	    socket->setVerifyPeer( verify_peer, verify_name );
-	    socket->setCiphers( ciphers );
-	}
+        try {
+            socket->setPassword( password );
+            socket->setCAFilePath( ca_file, ca_path );
+            socket->setCertFile( cert_file, key_file );
+            socket->setVerifyPeer( verify_peer, verify_name );
+            socket->setCiphers( ciphers );
+        }
         catch ( SocketException& ex ) {
-	    ex.setMark( __FILE__, __LINE__ );
-	    try{
-		delete socket;
-	    } catch( SocketException& ex2 ){ /* Absorb */ }
+            ex.setMark( __FILE__, __LINE__ );
+            try {
+                delete socket;
+            } catch( SocketException& ex2 ) { /* Absorb */}
 
-	    throw ex;
-	}
+            throw ex;
+        }
 
         return socket;
     }

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketFactory.h?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketFactory.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketFactory.h Sun Oct 28 07:17:03 2007
@@ -21,38 +21,36 @@
 
 #include <activemq/concurrent/Mutex.h>
 
-namespace activemq{
-namespace network{
+namespace activemq {
+namespace network {
 
     /**
      * Socket Factory implementation for use in Creating SSL Sockets
      *
      * @see <code>SSLSocket</code>
      */
-    class SSLSocketFactory : public TcpSocketFactory
-    {
-#ifdef AMQ_HAVE_OPENSSL	
-
-	/**
-	 * If we should manage locks.
-	 */
-	bool manageLocks;
-
-	/**
-	 * Locks for OpenSSL and callback to manage them.
-	 */
-	static concurrent::Mutex *locks;
-	static void locking_cb( int mode, int n, const char* file, int line );
-
-#endif /* AMQ_HAVE_OPENSSL */ 	
-
+    class SSLSocketFactory : public TcpSocketFactory {
+    #ifdef AMQ_HAVE_OPENSSL	
+    
+        /**
+         * If we should manage locks.
+         */
+        bool manageLocks;
+    
+        /**
+         * Locks for OpenSSL and callback to manage them.
+         */
+        static concurrent::Mutex *locks;
+        static void locking_cb( int mode, int n, const char* file, int line );
+    
+    #endif /* AMQ_HAVE_OPENSSL */ 	
+    
     public:
-	SSLSocketFactory();
-	~SSLSocketFactory();
-
-	virtual TcpSocket* createTcpSocket(
-            const util::Properties &properties )
-	    throw ( SocketException );
+        SSLSocketFactory();
+        virtual ~SSLSocketFactory();
+    
+        virtual TcpSocket* createTcpSocket(const util::Properties &properties)
+                throw (SocketException );
     };
 
 }}

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketInputStream.cpp?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketInputStream.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketInputStream.cpp Sun Oct 28 07:17:03 2007
@@ -31,16 +31,16 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 SSLSocketInputStream::SSLSocketInputStream(
-    network::Socket::SocketHandle socket, SSL* ssl )
-  : SocketInputStream( socket ),
-    ssl( ssl )
+        network::Socket::SocketHandle socket, SSL* ssl )
+: SocketInputStream( socket ),
+ssl( ssl )
 {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 std::size_t SSLSocketInputStream::read( unsigned char* buffer,
-					std::size_t bufferSize )
-  throw (IOException)
+        std::size_t bufferSize )
+throw (IOException)
 {
     int len = 0;
 
@@ -49,36 +49,36 @@
     while( !closed ) {
 
         // Read data from the socket.
-	len = SSL_read( ssl, buffer, bufferSize );
+        len = SSL_read( ssl, buffer, bufferSize );
 
-	switch (SSL_get_error( ssl, len ))
-	  {
-	  case SSL_ERROR_NONE:
-	    return len;
-
-	  case SSL_ERROR_WANT_READ:
-	  case SSL_ERROR_WANT_WRITE:
-	    // Repeat the operation.
-	    break;
+        switch (SSL_get_error( ssl, len ))
+        {
+            case SSL_ERROR_NONE:
+            return len;
+
+            case SSL_ERROR_WANT_READ:
+            case SSL_ERROR_WANT_WRITE:
+            // Repeat the operation.
+            break;
 
-	  case SSL_ERROR_ZERO_RETURN:
+            case SSL_ERROR_ZERO_RETURN:
             throw IOException( __FILE__, __LINE__,
-			       "activemq::io::SSLSocketInputStream::read"
-			       " - The connection is broken" );
+                    "activemq::io::SSLSocketInputStream::read"
+                    " - The connection is broken" );
 
-	  case SSL_ERROR_SSL:
+            case SSL_ERROR_SSL:
             throw IOException( __FILE__, __LINE__,
-			       "activemq::io::SSLSocketInputStream::read"
-			       " - %s",
-			       SSLError::getErrorString().c_str());
-
-	  case SSL_ERROR_SYSCALL:
-	    if( SocketError::getErrorCode() != SocketError::INTERRUPTED )
-		throw IOException( __FILE__, __LINE__,
-				   "activemq::io::SSLSocketInputStream::read"
-				   " - %s",
-				   SocketError::getErrorString().c_str() );
-	    break;
+                    "activemq::io::SSLSocketInputStream::read"
+                    " - %s",
+                    SSLError::getErrorString().c_str());
+
+            case SSL_ERROR_SYSCALL:
+            if( SocketError::getErrorCode() != SocketError::INTERRUPTED )
+            throw IOException( __FILE__, __LINE__,
+                    "activemq::io::SSLSocketInputStream::read"
+                    " - %s",
+                    SocketError::getErrorString().c_str() );
+            break;
         }
     }
 

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketInputStream.h?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketInputStream.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketInputStream.h Sun Oct 28 07:17:03 2007
@@ -24,8 +24,8 @@
 #ifdef AMQ_HAVE_OPENSSL
 #include <openssl/ssl.h>
 
-namespace activemq{
-namespace network{
+namespace activemq {
+namespace network {
 
     /**
      * Input stream for performing reads on a socket.  This
@@ -35,7 +35,7 @@
     {
     private:
 
-	SSL* ssl;
+        SSL* ssl;
 
     public:
 
@@ -54,8 +54,8 @@
          * @throws IOException thrown if an error occurs.
          */
         virtual std::size_t read( unsigned char* buffer,
-                                  std::size_t bufferSize )
-            throw (io::IOException);
+                std::size_t bufferSize )
+        throw (io::IOException);
     };
 
 }}

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketOutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketOutputStream.cpp?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketOutputStream.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketOutputStream.cpp Sun Oct 28 07:17:03 2007
@@ -27,15 +27,15 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 SSLSocketOutputStream::SSLSocketOutputStream( Socket::SocketHandle socket,
-					      SSL* ssl)
-  : SocketOutputStream( socket ),
-    ssl( ssl )
+        SSL* ssl)
+: SocketOutputStream( socket ),
+ssl( ssl )
 {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void SSLSocketOutputStream::write( const unsigned char* buffer, std::size_t len )
-    throw (IOException)
+throw (IOException)
 {
     std::size_t remaining = len;
 
@@ -43,36 +43,36 @@
     {
         int len = SSL_write( ssl, buffer, remaining );
 
-	switch (SSL_get_error( ssl, len ))
-	  {
-	  case SSL_ERROR_NONE:
-	    buffer += len;
-	    remaining -= len;
-	    break;
-
-	  case SSL_ERROR_WANT_READ:
-	  case SSL_ERROR_WANT_WRITE:
-	    // Repeat the operation.
-	    break;
+        switch (SSL_get_error( ssl, len ))
+        {
+            case SSL_ERROR_NONE:
+            buffer += len;
+            remaining -= len;
+            break;
+
+            case SSL_ERROR_WANT_READ:
+            case SSL_ERROR_WANT_WRITE:
+            // Repeat the operation.
+            break;
 
-	  case SSL_ERROR_ZERO_RETURN:
+            case SSL_ERROR_ZERO_RETURN:
             throw IOException( __FILE__, __LINE__,
-			       "activemq::io::SSLSocketInputStream::write"
-			       " - The connection is broken" );
+                    "activemq::io::SSLSocketInputStream::write"
+                    " - The connection is broken" );
 
-	  case SSL_ERROR_SSL:
+            case SSL_ERROR_SSL:
             throw IOException( __FILE__, __LINE__,
-			       "activemq::io::SSLSocketInputStream::write"
-			       " - %s",
-			       SSLError::getErrorString().c_str());
-
-	  case SSL_ERROR_SYSCALL:
-	    if( SocketError::getErrorCode() != SocketError::INTERRUPTED )
-		throw IOException( __FILE__, __LINE__,
-				   "activemq::io::SSLSocketInputStream::write"
-				   " - %s",
-				   SocketError::getErrorString().c_str() );
-	    break;
+                    "activemq::io::SSLSocketInputStream::write"
+                    " - %s",
+                    SSLError::getErrorString().c_str());
+
+            case SSL_ERROR_SYSCALL:
+            if( SocketError::getErrorCode() != SocketError::INTERRUPTED )
+            throw IOException( __FILE__, __LINE__,
+                    "activemq::io::SSLSocketInputStream::write"
+                    " - %s",
+                    SocketError::getErrorString().c_str() );
+            break;
         }
     }
 }

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketOutputStream.h?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketOutputStream.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SSLSocketOutputStream.h Sun Oct 28 07:17:03 2007
@@ -25,8 +25,8 @@
 #ifdef AMQ_HAVE_OPENSSL
 #include <openssl/ssl.h>
 
-namespace activemq{
-namespace network{
+namespace activemq {
+namespace network {
 
     /**
      * Output stream for performing write operations
@@ -36,7 +36,7 @@
     {
     private:
 
-	SSL* ssl;
+        SSL* ssl;
 
     public:
 
@@ -53,7 +53,7 @@
          * @throws IOException thrown if an error occurs.
          */
         virtual void write( const unsigned char* buffer,
-                            std::size_t len ) throw ( io::IOException );
+                std::size_t len ) throw ( io::IOException );
 
     };
 

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketError.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketError.cpp?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketError.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketError.cpp Sun Oct 28 07:17:03 2007
@@ -31,54 +31,54 @@
 #if defined(HAVE_WINSOCK2_H)
     const int SocketError::INTERRUPTED = WSAEINTR;
 #else
-    const int SocketError::INTERRUPTED = EINTR;
+    const int SocketError::INTERRUPTED= EINTR;
 #endif
 
 ////////////////////////////////////////////////////////////////////////////////
 int SocketError::getErrorCode() {
-    
-    #if defined(HAVE_WINSOCK2_H)
-    
-        return ::WSAGetLastError();
-        
-    #else
-         
-        return errno;
-        
-    #endif
+
+#if defined(HAVE_WINSOCK2_H)
+
+    return ::WSAGetLastError();
+
+#else
+
+    return errno;
+
+#endif
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 std::string SocketError::getErrorString() {
-    
+
     std::string returnValue;
-    
+
     // Get the error code.
     int errorCode = getErrorCode();
-    
-    #if defined(HAVE_WINSOCK2_H)
-  
-        // Create the error string.
-        static const int errorStringSize = 512;
-        char errorString[errorStringSize];
-        memset( errorString, 0, errorStringSize );
-        ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
-           0,
-           errorCode,
-           0,
-           errorString,
-           errorStringSize - 1,
-           NULL);
-           
-        returnValue = errorString;
-        
-    #else
-         
-        // Create the error string.
-        returnValue = ::strerror(errorCode);
-        
-    #endif
-    
+
+#if defined(HAVE_WINSOCK2_H)
+
+    // Create the error string.
+    static const int errorStringSize = 512;
+    char errorString[errorStringSize];
+    memset( errorString, 0, errorStringSize );
+    ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
+            0,
+            errorCode,
+            0,
+            errorString,
+            errorStringSize - 1,
+            NULL);
+
+    returnValue = errorString;
+
+#else
+
+    // Create the error string.
+    returnValue =:: strerror(errorCode);
+
+#endif
+
     return returnValue;
 }
 

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketFactory.h?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketFactory.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketFactory.h Sun Oct 28 07:17:03 2007
@@ -20,22 +20,21 @@
 #include <activemq/network/SocketException.h>
 #include <activemq/util/Properties.h>
 
-namespace activemq{
-namespace network{
+namespace activemq {
+namespace network {
 
-    class Socket;
+class Socket;
 
     /**
      * Socket Factory for use in Creating Sockets
-
+    
      * @see <code>Socket</code>
      */
-    class SocketFactory
-    {
+    class SocketFactory {
     public:
-
-	virtual ~SocketFactory() {};
-
+    
+        virtual ~SocketFactory() {}
+    
         /**
          * Creates and returns a Socket dervied Object based on the values
          * defined in the Properties Object that is passed in.
@@ -43,10 +42,9 @@
          * @param properties a IProperties pointer.
          * @throws SocketException.
          */
-        virtual Socket* createSocket( const std::string& uri,
-                                     const util::Properties& properties )
-            throw ( SocketException ) = 0;
-
+        virtual Socket* createSocket(const std::string& uri,
+                const util::Properties& properties) throw (SocketException ) = 0;
+    
     };
 
 }}

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketInputStream.cpp?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketInputStream.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketInputStream.cpp Sun Oct 28 07:17:03 2007
@@ -25,13 +25,13 @@
 #endif
 
 #ifdef HAVE_SYS_IOCTL_H
-#define BSD_COMP /* Get FIONREAD on Solaris2. */
-#include <sys/ioctl.h>
+    #define BSD_COMP /* Get FIONREAD on Solaris2. */
+    #include <sys/ioctl.h>
 #endif
 
 // Pick up FIONREAD on Solaris 2.5.
 #ifdef HAVE_SYS_FILIO_H
-#include <sys/filio.h>
+    #include <sys/filio.h>
 #endif
 
 #include <activemq/network/SocketInputStream.h>
@@ -52,112 +52,111 @@
 using namespace std;
 
 ////////////////////////////////////////////////////////////////////////////////
-SocketInputStream::SocketInputStream( network::Socket::SocketHandle socket ) {
+SocketInputStream::SocketInputStream(network::Socket::SocketHandle socket) {
 
     this->socket = socket;
     this->closed = false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-SocketInputStream::~SocketInputStream() {}
+SocketInputStream::~SocketInputStream() {
+}
 
 ////////////////////////////////////////////////////////////////////////////////
-void SocketInputStream::close() throw( cms::CMSException ){
+void SocketInputStream::close() throw(cms::CMSException ) {
     this->closed = true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::size_t SocketInputStream::available() const throw (activemq::io::IOException){
+std::size_t SocketInputStream::available() const
+        throw (activemq::io::IOException) {
 
-// The windows version
+    // The windows version
 #if defined(HAVE_WINSOCK2_H)
 
     unsigned long numBytes = 0;
 
-    if( ::ioctlsocket(socket, FIONREAD, &numBytes ) == SOCKET_ERROR ){
+    if( ::ioctlsocket(socket, FIONREAD, &numBytes ) == SOCKET_ERROR ) {
         throw SocketException(
-            __FILE__, __LINE__,
-            "SocketInputStream::available - ioctlsocket failed" );
+                __FILE__, __LINE__,
+                "SocketInputStream::available - ioctlsocket failed" );
     }
 
     return (std::size_t)numBytes;
 
 #else // !defined(HAVE_WINSOCK2_H)
-
     // If FIONREAD is defined - use ioctl to find out how many bytes
     // are available.
-    #if defined(FIONREAD)
+#if defined(FIONREAD)
 
-        std::size_t numBytes = 0;
-        if( ::ioctl (socket, FIONREAD, &numBytes) != -1 ){
-            return numBytes;
-        }
+    std::size_t numBytes = 0;
+    if( ::ioctl (socket, FIONREAD, &numBytes) != -1 ) {
+        return numBytes;
+    }
 
-    #endif
+#endif
 
     // If we didn't get anything we can use select.  This is a little
     // less functional.  We will poll on the socket - if there is data
     // available, we'll return 1, otherwise we'll return zero.
-    #if defined(HAVE_SELECT)
-
-        fd_set rd;
-        FD_ZERO(&rd);
-        FD_SET( socket, &rd );
-        struct timeval tv;
-        tv.tv_sec = 0;
-        tv.tv_usec = 0;
-        int returnCode = ::select(socket+1, &rd, NULL, NULL, &tv);
-        if(returnCode == -1){
-            throw IOException(__FILE__, __LINE__, SocketError::getErrorString().c_str() );
-        }
-        return (returnCode == 0)? 0 : 1;
+#if defined(HAVE_SELECT)
 
-    #else
+    fd_set rd;
+    FD_ZERO(&rd);
+    FD_SET( socket, &rd );
+    struct timeval tv;
+    tv.tv_sec = 0;
+    tv.tv_usec = 0;
+    int returnCode = ::select(socket+1, &rd, NULL, NULL, &tv);
+    if(returnCode == -1) {
+        throw IOException(__FILE__, __LINE__, SocketError::getErrorString().c_str() );
+    }
+    return (returnCode == 0)? 0 : 1;
 
-        return 0;
+#else
 
-    #endif /* HAVE_SELECT */
+    return 0;
 
+#endif /* HAVE_SELECT */
 
 #endif // !defined(HAVE_WINSOCK2_H)
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-unsigned char SocketInputStream::read() throw (IOException){
+unsigned char SocketInputStream::read() throw (IOException) {
 
     unsigned char c;
-    std::size_t len = read( &c, 1 );
-    if( len != sizeof(c) && !closed ){
+    std::size_t len = read( &c, 1);
+    if (len != sizeof(c) && !closed) {
         throw IOException( __FILE__, __LINE__,
-            "activemq::io::SocketInputStream::read - failed reading a byte");
+                "activemq::io::SocketInputStream::read - failed reading a byte");
     }
 
     return c;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::size_t SocketInputStream::read( unsigned char* buffer,
-                                     std::size_t bufferSize ) throw (IOException)
-{
+std::size_t SocketInputStream::read(unsigned char* buffer,
+        std::size_t bufferSize) throw (IOException) {
     int len = 0;
 
     // Loop to ignore any signal interruptions that occur during the read.
     do {
 
         // Read data from the socket.
-        len = ::recv(socket, (char*)buffer, (int)bufferSize, 0);
+        len =:: recv(socket, (char*)buffer, (int)bufferSize, 0);
 
         // Check for a closed socket.
-        if( len == 0 || closed ){
+        if( len == 0 || closed ) {
             throw IOException( __FILE__, __LINE__,
-                "activemq::io::SocketInputStream::read - The connection is broken" );
+                    "activemq::io::SocketInputStream::read - The connection is broken" );
         }
 
-    } while( !closed && len == -1 &&
-             SocketError::getErrorCode() == SocketError::INTERRUPTED );
+    }while( !closed && len == -1 &&
+            SocketError::getErrorCode() == SocketError::INTERRUPTED );
 
     // Check for error.
-    if( len == -1 ){
+    if( len == -1 ) {
 
         // Otherwise, this was a bad error - throw an exception.
         throw IOException( __FILE__, __LINE__,
@@ -169,10 +168,10 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 std::size_t SocketInputStream::skip( std::size_t num AMQCPP_UNUSED )
-    throw ( io::IOException, exceptions::UnsupportedOperationException ) {
+throw ( io::IOException, exceptions::UnsupportedOperationException ) {
 
     throw exceptions::UnsupportedOperationException(
-        __FILE__, __LINE__,
-        "SocketInputStream::skip - skip() method is not supported");
+    __FILE__, __LINE__,
+    "SocketInputStream::skip - skip() method is not supported");
 }
 

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketInputStream.h?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketInputStream.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketInputStream.h Sun Oct 28 07:17:03 2007
@@ -22,69 +22,68 @@
 #include <activemq/network/Socket.h>
 #include <activemq/concurrent/Mutex.h>
 
-namespace activemq{
-namespace network{
+namespace activemq {
+namespace network {
 
     /**
      * Input stream for performing reads on a socket.  This
      * class will only work properly for blocking sockets.
      */
-    class SocketInputStream : public io::InputStream
-    {
+    class SocketInputStream : public io::InputStream {
     protected:
-
+    
         // The socket handle.
         Socket::SocketHandle socket;
         concurrent::Mutex mutex;
         bool closed;
-
+    
     public:
-
+    
         /**
          * Constructor.
          * @param socket the socket handle.
          */
-        SocketInputStream( Socket::SocketHandle socket );
-
+        SocketInputStream(Socket::SocketHandle socket);
+    
         /**
          * Destructor.
          */
         virtual ~SocketInputStream();
-
+    
         /**
          * Enables socket level output of the recieved data
          * @param debug true to turn on debugging
          */
         /*virtual void setDebug( bool debug ){
-            this->debug = debug;
-        }*/
-
+         this->debug = debug;
+         }*/
+    
         /**
          * Locks the object.
          * @throws ActiveMQException
          */
-        virtual void lock() throw( exceptions::ActiveMQException ){
+        virtual void lock() throw(exceptions::ActiveMQException ) {
             mutex.lock();
         }
-
+    
         /**
          * Unlocks the object.
          * @throws ActiveMQException
          */
-        virtual void unlock() throw( exceptions::ActiveMQException ){
+        virtual void unlock() throw(exceptions::ActiveMQException ) {
             mutex.unlock();
         }
-
+    
         /**
          * Waits on a signal from this object, which is generated
          * by a call to Notify.  Must have this object locked before
          * calling.
          * @throws ActiveMQException
          */
-        virtual void wait() throw( exceptions::ActiveMQException ){
+        virtual void wait() throw(exceptions::ActiveMQException ) {
             mutex.wait();
         }
-
+    
         /**
          * Waits on a signal from this object, which is generated
          * by a call to Notify.  Must have this object locked before
@@ -93,32 +92,32 @@
          * @param millisecs time in millisecsonds to wait, or WAIT_INIFINITE
          * @throws ActiveMQException
          */
-        virtual void wait( unsigned long millisecs )
-            throw( exceptions::ActiveMQException ) {
-
-            mutex.wait( millisecs );
+        virtual void wait(unsigned long millisecs)
+                throw(exceptions::ActiveMQException ) {
+    
+            mutex.wait(millisecs);
         }
-
+    
         /**
          * Signals a waiter on this object that it can now wake
          * up and continue.  Must have this object locked before
          * calling.
          * @throws ActiveMQException
          */
-        virtual void notify() throw( exceptions::ActiveMQException ){
+        virtual void notify() throw(exceptions::ActiveMQException ) {
             mutex.notify();
         }
-
+    
         /**
          * Signals the waiters on this object that it can now wake
          * up and continue.  Must have this object locked before
          * calling.
          * @throws ActiveMQException
          */
-        virtual void notifyAll() throw( exceptions::ActiveMQException ){
+        virtual void notifyAll() throw(exceptions::ActiveMQException ) {
             mutex.notifyAll();
         }
-
+    
         /**
          * Returns the number of bytes available on the socket to
          * be read right now.
@@ -126,15 +125,15 @@
          * be read on the socket.
          */
         virtual std::size_t available() const throw (activemq::io::IOException);
-
+    
         /**
          * Reads a single byte from the buffer.  If no data
          * is available, blocks until their is.
          * @return The next byte.
          * @throws IOException thrown if an error occurs.
          */
-        virtual unsigned char read() throw ( io::IOException );
-
+        virtual unsigned char read() throw (io::IOException );
+    
         /**
          * Reads an array of bytes from the buffer.  If no data
          * is available, blocks until there is.
@@ -143,25 +142,23 @@
          * @return The number of bytes read.
          * @throws IOException thrown if an error occurs.
          */
-        virtual std::size_t read( unsigned char* buffer,
-                                  std::size_t bufferSize )
-            throw (io::IOException);
-
+        virtual std::size_t read(unsigned char* buffer, std::size_t bufferSize)
+                throw (io::IOException);
+    
         /**
          * Close - does nothing.  It is the responsibility of the owner
          * of the socket object to close it.
          * @throws CMSException
          */
-        virtual void close() throw( cms::CMSException );
-
+        virtual void close() throw(cms::CMSException );
+    
         /**
          * Not supported.
          * @throws an UnsupportedOperationException.
          */
-        virtual std::size_t skip( std::size_t num )
-            throw ( io::IOException,
-                    exceptions::UnsupportedOperationException );
-
+        virtual std::size_t skip(std::size_t num) throw (io::IOException,
+                exceptions::UnsupportedOperationException );
+    
     };
 
 }}

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketOutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketOutputStream.cpp?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketOutputStream.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketOutputStream.cpp Sun Oct 28 07:17:03 2007
@@ -45,8 +45,7 @@
 using namespace std;
 
 ////////////////////////////////////////////////////////////////////////////////
-SocketOutputStream::SocketOutputStream( Socket::SocketHandle socket )
-{
+SocketOutputStream::SocketOutputStream(Socket::SocketHandle socket) {
     this->socket = socket;
     this->closed = false;
 }
@@ -57,29 +56,26 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void SocketOutputStream::close() throw( cms::CMSException ) {
+void SocketOutputStream::close() throw(cms::CMSException ) {
     this->closed = true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void SocketOutputStream::write( unsigned char c ) throw (IOException)
-{
-    write( &c, 1 );
+void SocketOutputStream::write(unsigned char c) throw (IOException) {
+    write( &c, 1);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void SocketOutputStream::write( const unsigned char* buffer, std::size_t len )
-    throw (IOException)
-{
+void SocketOutputStream::write(const unsigned char* buffer, std::size_t len)
+        throw (IOException) {
     std::size_t remaining = len;
-    int sendOpts = AMQ_SEND_OPTS;
+    int sendOpts= AMQ_SEND_OPTS;
 
-    while( remaining > 0 && !closed )
-    {
-        int length = ::send( socket, (const char*)buffer, (int)remaining, sendOpts );
-        if( length == -1 || closed ){
+    while (remaining > 0 && !closed) {
+        int length =:: send( socket, (const char*)buffer, (int)remaining, sendOpts );
+        if( length == -1 || closed ) {
             throw IOException( __FILE__, __LINE__,
-                "activemq::io::SocketOutputStream::write - %s", SocketError::getErrorString().c_str() );
+                    "activemq::io::SocketOutputStream::write - %s", SocketError::getErrorString().c_str() );
         }
 
         buffer+=length;

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketOutputStream.h?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketOutputStream.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/SocketOutputStream.h Sun Oct 28 07:17:03 2007
@@ -22,58 +22,57 @@
 #include <activemq/network/Socket.h>
 #include <activemq/concurrent/Mutex.h>
 
-namespace activemq{
-namespace network{
+namespace activemq {
+namespace network {
 
     /**
      * Output stream for performing write operations
      * on a socket.
      */
-    class SocketOutputStream : public io::OutputStream
-    {
+    class SocketOutputStream : public io::OutputStream {
     protected:
-
+    
         // The socket.
         Socket::SocketHandle socket;
         concurrent::Mutex mutex;
         bool closed;
-
+    
     public:
-
+    
         /**
          * Constructor.
          * @param socket the socket handle.
          */
-        SocketOutputStream( Socket::SocketHandle socket );
-
+        SocketOutputStream(Socket::SocketHandle socket);
+    
         virtual ~SocketOutputStream();
-
+    
         /**
          * Locks the object.
          * @throws ActiveMQException
          */
-        virtual void lock() throw( exceptions::ActiveMQException ){
+        virtual void lock() throw(exceptions::ActiveMQException ) {
             mutex.lock();
         }
-
+    
         /**
          * Unlocks the object.
          * @throws ActiveMQException
          */
-        virtual void unlock() throw( exceptions::ActiveMQException ){
+        virtual void unlock() throw(exceptions::ActiveMQException ) {
             mutex.unlock();
         }
-
+    
         /**
          * Waits on a signal from this object, which is generated
          * by a call to Notify.  Must have this object locked before
          * calling.
          * @throws ActiveMQException
          */
-        virtual void wait() throw( exceptions::ActiveMQException ){
+        virtual void wait() throw(exceptions::ActiveMQException ) {
             mutex.wait();
         }
-
+    
         /**
          * Waits on a signal from this object, which is generated
          * by a call to Notify.  Must have this object locked before
@@ -82,60 +81,61 @@
          * @param millisecs time in millisecsonds to wait, or WAIT_INIFINITE
          * @throws ActiveMQException
          */
-        virtual void wait( unsigned long millisecs )
-            throw( exceptions::ActiveMQException ) {
-
-            mutex.wait( millisecs );
+        virtual void wait(unsigned long millisecs)
+                throw(exceptions::ActiveMQException ) {
+    
+            mutex.wait(millisecs);
         }
-
+    
         /**
          * Signals a waiter on this object that it can now wake
          * up and continue.  Must have this object locked before
          * calling.
          * @throws ActiveMQException
          */
-        virtual void notify() throw( exceptions::ActiveMQException ){
+        virtual void notify() throw(exceptions::ActiveMQException ) {
             mutex.notify();
         }
-
+    
         /**
          * Signals the waiters on this object that it can now wake
          * up and continue.  Must have this object locked before
          * calling.
          */
-        virtual void notifyAll() throw( exceptions::ActiveMQException ){
+        virtual void notifyAll() throw(exceptions::ActiveMQException ) {
             mutex.notifyAll();
-         }
-
+        }
+    
         /**
          * Writes a single byte to the output stream.
          * @param c the byte.
          * @throws IOException thrown if an error occurs.
          */
-        virtual void write( unsigned char c ) throw ( io::IOException );
-
+        virtual void write(unsigned char c) throw (io::IOException );
+    
         /**
          * Writes an array of bytes to the output stream.
          * @param buffer The array of bytes to write.
          * @param len The number of bytes from the buffer to be written.
          * @throws IOException thrown if an error occurs.
          */
-        virtual void write( const unsigned char* buffer,
-                            std::size_t len ) throw ( io::IOException );
-
+        virtual void write(const unsigned char* buffer, std::size_t len)
+                throw (io::IOException );
+    
         /**
          * Flush - does nothing.
          * @throws IOException
          */
-        virtual void flush() throw ( io::IOException ){};
-
+        virtual void flush() throw (io::IOException ) {
+        }
+    
         /**
          * Close - does nothing.  It is the responsibility of the owner
          * of the socket object to close it.
          * @throws CMSException
          */
-        virtual void close() throw( cms::CMSException );
-
+        virtual void close() throw(cms::CMSException );
+    
     };
 
 }}

Modified: activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/TcpSocket.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/TcpSocket.cpp?rev=589358&r1=589357&r2=589358&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/TcpSocket.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-ssl/src/main/activemq/network/TcpSocket.cpp Sun Oct 28 07:17:03 2007
@@ -53,35 +53,32 @@
 
 #if defined(HAVE_WINSOCK2_H)
 
-    // Static socket initializer needed for winsock
+// Static socket initializer needed for winsock
 
-    TcpSocket::StaticSocketInitializer::StaticSocketInitializer() {
-        socketInitError = NULL;
-        const WORD version_needed = MAKEWORD(2,2); // lo-order byte: major version
-        WSAData temp;
-        if( WSAStartup( version_needed, &temp ) ){
-           clear();
-           socketInitError = new SocketException ( __FILE__, __LINE__,
-               "winsock.dll was not found");
-        }
-    }
-    TcpSocket::StaticSocketInitializer::~StaticSocketInitializer() {
+TcpSocket::StaticSocketInitializer::StaticSocketInitializer() {
+    socketInitError = NULL;
+    const WORD version_needed = MAKEWORD(2,2); // lo-order byte: major version
+    WSAData temp;
+    if( WSAStartup( version_needed, &temp ) ) {
         clear();
-        WSACleanup();
+        socketInitError = new SocketException ( __FILE__, __LINE__,
+                "winsock.dll was not found");
     }
+}
+TcpSocket::StaticSocketInitializer::~StaticSocketInitializer() {
+    clear();
+    WSACleanup();
+}
 
-    // Create static instance of the socket initializer.
-    TcpSocket::StaticSocketInitializer TcpSocket::staticSocketInitializer;
+// Create static instance of the socket initializer.
+TcpSocket::StaticSocketInitializer TcpSocket::staticSocketInitializer;
 
 #endif
 
 ////////////////////////////////////////////////////////////////////////////////
-TcpSocket::TcpSocket() throw (SocketException)
-:
-    socketHandle( INVALID_SOCKET_HANDLE ),
-    inputStream( NULL ),
-    outputStream( NULL )
-{
+TcpSocket::TcpSocket() throw (SocketException) :
+    socketHandle(INVALID_SOCKET_HANDLE), inputStream( NULL),
+            outputStream( NULL) {
 
     try {
 
@@ -96,12 +93,9 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-TcpSocket::TcpSocket( SocketHandle socketHandle )
-:
-    socketHandle( INVALID_SOCKET_HANDLE ),
-    inputStream( NULL ),
-    outputStream( NULL )
-{
+TcpSocket::TcpSocket(SocketHandle socketHandle) :
+    socketHandle(INVALID_SOCKET_HANDLE), inputStream( NULL),
+            outputStream( NULL) {
     try {
 
 #if defined(HAVE_WINSOCK2_H)
@@ -119,42 +113,40 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-TcpSocket::~TcpSocket()
-{
+TcpSocket::~TcpSocket() {
     // No shutdown, just close - dont want blocking destructor.
     close();
 
     // Destroy the input stream.
-    if( inputStream != NULL ){
+    if (inputStream != NULL) {
         delete inputStream;
         inputStream = NULL;
     }
 
     // Destroy the output stream.
-    if( outputStream != NULL ){
+    if (outputStream != NULL) {
         delete outputStream;
         outputStream = NULL;
     }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-InputStream* TcpSocket::getInputStream(){
+InputStream* TcpSocket::getInputStream() {
     return inputStream;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-OutputStream* TcpSocket::getOutputStream(){
+OutputStream* TcpSocket::getOutputStream() {
     return outputStream;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::connect(const char* host, int port) throw ( SocketException )
-{
-    try{
+void TcpSocket::connect(const char* host, int port) throw (SocketException ) {
+    try {
 
         if( isConnected() ) {
             throw SocketException( __FILE__, __LINE__,
-                "Socket::connect - Socket already connected.  host: %s, port: %d", host, port );
+                    "Socket::connect - Socket already connected.  host: %s, port: %d", host, port );
         }
 
         // Create the socket.
@@ -164,11 +156,10 @@
         if( port <= 0 || port > 65535 ) {
             close();
             throw SocketException ( __FILE__, __LINE__,
-                "Socket::connect- Port out of range: %d", port );
+                    "Socket::connect- Port out of range: %d", port );
         }
 
 #ifdef SO_NOSIGPIPE // Don't want to get a SIGPIPE on FreeBSD and Mac OS X
-
         int optval = 1;
         checkResult( ::setsockopt( socketHandle, SOL_SOCKET, SO_NOSIGPIPE, (char*)&optval, sizeof(optval)) );
 
@@ -205,35 +196,34 @@
 
         // Attempt the connection to the server.
         checkResult( ::connect( socketHandle,
-                            ( const sockaddr * )&target_addr,
-                            sizeof( target_addr ) ) );
+                        ( const sockaddr * )&target_addr,
+                        sizeof( target_addr ) ) );
 
-	initialize ();
+        initialize ();
     }
     catch( SocketException& ex ) {
         ex.setMark( __FILE__, __LINE__);
-        try{ close(); } catch( cms::CMSException& cx){ /* Absorb */ }
+        try {close();} catch( cms::CMSException& cx) { /* Absorb */}
         throw ex;
     }
-    catch( ... ){
-        try{ close(); } catch( cms::CMSException& cx){ /* Absorb */ }
+    catch( ... ) {
+        try {close();} catch( cms::CMSException& cx) { /* Absorb */}
         throw SocketException( __FILE__, __LINE__, "connect() caught unknown exception");
     }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::initialize () throw( SocketException )
-{
+void TcpSocket::initialize() throw(SocketException ) {
     // Destroy the input stream.
-    if( inputStream != NULL ){
-	delete inputStream;
-	inputStream = NULL;
+    if (inputStream != NULL) {
+        delete inputStream;
+        inputStream = NULL;
     }
 
     // Destroy the output stream.
-    if( outputStream != NULL ){
-	delete outputStream;
-	outputStream = NULL;
+    if (outputStream != NULL) {
+        delete outputStream;
+        outputStream = NULL;
     }
 
     // Create an input/output stream for this socket.
@@ -242,36 +232,34 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::close() throw( cms::CMSException )
-{
+void TcpSocket::close() throw(cms::CMSException ) {
     // Close the input stream.
-    if( inputStream != NULL ){
+    if (inputStream != NULL) {
         inputStream->close();
     }
 
     // Close the output stream.
-    if( outputStream != NULL ){
+    if (outputStream != NULL) {
         outputStream->close();
     }
 
-    if( isConnected() )
-    {
-        ::shutdown( socketHandle, SHUT_RDWR );
+    if (isConnected() ) {
+::        shutdown( socketHandle, SHUT_RDWR );
 
-        #if !defined(HAVE_WINSOCK2_H)
-            ::close( socketHandle );
-        #else
-           ::closesocket( socketHandle );
-        #endif
+#if !defined(HAVE_WINSOCK2_H)
+        ::close( socketHandle );
+#else
+        ::closesocket( socketHandle );
+#endif
 
-       socketHandle = INVALID_SOCKET_HANDLE;
+        socketHandle = INVALID_SOCKET_HANDLE;
     }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int TcpSocket::getSoLinger() const throw( SocketException ){
+int TcpSocket::getSoLinger() const throw(SocketException ) {
 
-   try{
+    try {
         linger value;
         socklen_t length = sizeof( value );
         checkResult(::getsockopt( socketHandle, SOL_SOCKET, SO_LINGER, (char*)&value, &length ));
@@ -283,9 +271,9 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::setSoLinger( int dolinger ) throw( SocketException ){
+void TcpSocket::setSoLinger(int dolinger) throw(SocketException ) {
 
-    try{
+    try {
         linger value;
         value.l_onoff = dolinger != 0;
         value.l_linger = dolinger;
@@ -296,9 +284,9 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-bool TcpSocket::getKeepAlive() const throw( SocketException ){
+bool TcpSocket::getKeepAlive() const throw(SocketException ) {
 
-    try{
+    try {
         int value;
         socklen_t length = sizeof( int );
         checkResult(::getsockopt( socketHandle, SOL_SOCKET, SO_KEEPALIVE, (char*)&value, &length ));
@@ -309,9 +297,9 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::setKeepAlive( const bool keepAlive ) throw( SocketException ){
+void TcpSocket::setKeepAlive(const bool keepAlive) throw(SocketException ) {
 
-    try{
+    try {
         int value = keepAlive? 1 : 0;
         checkResult(::setsockopt(socketHandle, SOL_SOCKET, SO_KEEPALIVE, (char*)&value, sizeof(int)) );
     }
@@ -320,9 +308,9 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int TcpSocket::getReceiveBufferSize() const throw( SocketException ){
+int TcpSocket::getReceiveBufferSize() const throw(SocketException ) {
 
-    try{
+    try {
         int value;
         socklen_t length = sizeof( value );
         checkResult(::getsockopt( socketHandle, SOL_SOCKET, SO_RCVBUF, (char*)&value, &length ));
@@ -333,9 +321,9 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::setReceiveBufferSize( int size ) throw( SocketException ){
+void TcpSocket::setReceiveBufferSize(int size) throw(SocketException ) {
 
-    try{
+    try {
         checkResult(::setsockopt( socketHandle, SOL_SOCKET, SO_RCVBUF, (char*)&size, sizeof(size) ));
     }
     AMQ_CATCH_RETHROW( SocketException )
@@ -343,9 +331,9 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-bool TcpSocket::getReuseAddress() const throw( SocketException ){
+bool TcpSocket::getReuseAddress() const throw(SocketException ) {
 
-    try{
+    try {
         int value;
         socklen_t length = sizeof( int );
         checkResult(::getsockopt( socketHandle, SOL_SOCKET, SO_REUSEADDR, (char*)&value, &length ));
@@ -356,9 +344,9 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::setReuseAddress( bool reuse ) throw( SocketException ){
+void TcpSocket::setReuseAddress(bool reuse) throw(SocketException ) {
 
-    try{
+    try {
         int value = reuse? 1 : 0;
         checkResult(::setsockopt( socketHandle, SOL_SOCKET, SO_REUSEADDR, (char*)&value, sizeof(int) ));
     }
@@ -367,9 +355,9 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int TcpSocket::getSendBufferSize() const throw( SocketException ){
+int TcpSocket::getSendBufferSize() const throw(SocketException ) {
 
-    try{
+    try {
         int value;
         socklen_t length = sizeof( value );
         checkResult(::getsockopt( socketHandle, SOL_SOCKET, SO_SNDBUF, (char*)&value, &length ));
@@ -380,9 +368,9 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::setSendBufferSize( int size ) throw( SocketException ){
+void TcpSocket::setSendBufferSize(int size) throw(SocketException ) {
 
-    try{
+    try {
         checkResult(::setsockopt( socketHandle, SOL_SOCKET, SO_SNDBUF, (char*)&size, sizeof(size) ));
     }
     AMQ_CATCH_RETHROW( SocketException )
@@ -390,9 +378,8 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::setSoTimeout ( const int millisecs ) throw ( SocketException )
-{
-    try{
+void TcpSocket::setSoTimeout(const int millisecs) throw (SocketException ) {
+    try {
 
 #if !defined(HAVE_WINSOCK2_H)
         timeval timot;
@@ -410,9 +397,8 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int TcpSocket::getSoTimeout() const throw( SocketException )
-{
-    try{
+int TcpSocket::getSoTimeout() const throw(SocketException ) {
+    try {
 
 #if !defined(HAVE_WINSOCK2_H)
         timeval timot;
@@ -439,9 +425,9 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-bool TcpSocket::getTcpNoDelay() const throw ( cms::CMSException ) {
+bool TcpSocket::getTcpNoDelay() const throw (cms::CMSException ) {
 
-    try{
+    try {
         int value;
         socklen_t length = sizeof( int );
         checkResult(::getsockopt( socketHandle, IPPROTO_TCP, TCP_NODELAY, (char*)&value, &length ));
@@ -452,9 +438,9 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::setTcpNoDelay( bool value ) throw ( cms::CMSException ) {
+void TcpSocket::setTcpNoDelay(bool value) throw (cms::CMSException ) {
 
-    try{
+    try {
         int ivalue = value ? 1 : 0;
         checkResult(::setsockopt( socketHandle, IPPROTO_TCP, TCP_NODELAY, (char*)&ivalue, sizeof(int) ));
     }
@@ -463,12 +449,11 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::checkResult( int value ) const throw (SocketException) {
+void TcpSocket::checkResult(int value) const throw (SocketException) {
 
-    if( value < 0 ){
+    if (value < 0) {
         throw SocketException( __FILE__, __LINE__,
-            SocketError::getErrorString().c_str() );
+                SocketError::getErrorString().c_str() );
     }
 }
-
 



Mime
View raw message