diff --git a/Chan.h b/Chan.h index aadec5a4..ed45de22 100644 --- a/Chan.h +++ b/Chan.h @@ -34,7 +34,7 @@ public: void SendBuffer(); void IncClientRequests(); - bool DecClientRequests(); + bool DecClientRequests(); bool Who(); void OnWho(const string& sNick, const string& sIdent, const string& sHost); diff --git a/Csocket.cpp b/Csocket.cpp index 94885e6a..793aa595 100644 --- a/Csocket.cpp +++ b/Csocket.cpp @@ -2,29 +2,29 @@ * * Copyright (c) 1999-2004 Jim Hull * All rights reserved -* -* Redistribution and use in source and binary forms, with or without modification, +* +* Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: -* Redistributions of source code must retain the above copyright notice, this +* Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright notice, this list +* Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. -* Redistributions in any form must be accompanied by information on how to obtain -* complete source code for the DB software and any accompanying software that uses the DB software. -* The source code must either be included in the distribution or be available for no more than -* the cost of distribution plus a nominal fee, and must be freely redistributable -* under reasonable conditions. For an executable file, complete source code means the source -* code for all modules it contains. It does not include source code for modules or files +* Redistributions in any form must be accompanied by information on how to obtain +* complete source code for the DB software and any accompanying software that uses the DB software. +* The source code must either be included in the distribution or be available for no more than +* the cost of distribution plus a nominal fee, and must be freely redistributable +* under reasonable conditions. For an executable file, complete source code means the source +* code for all modules it contains. It does not include source code for modules or files * that typically accompany the major components of the operating system on which the executable file runs. * -* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, -* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, -* OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL SLEEPYCAT SOFTWARE BE LIABLE FOR ANY DIRECT, -* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, +* OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL SLEEPYCAT SOFTWARE BE LIABLE FOR ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @@ -108,7 +108,7 @@ unsigned long long millitime() unsigned long long iTime = 0; gettimeofday( &tv, NULL ); iTime = (unsigned long long )tv.tv_sec * 1000; - iTime += ( (unsigned long long)tv.tv_usec / 1000 ); + iTime += ( (unsigned long long)tv.tv_usec / 1000 ); return( iTime ); } @@ -121,7 +121,7 @@ bool GetHostByName( const CS_STRING & sHostName, struct in_addr *paddr ) struct hostent hentbuff; int err; - for( u_int a = 0; a < 20; a++ ) + for( u_int a = 0; a < 20; a++ ) { memset( (char *)hbuff, '\0', 2048 ); int iRet = gethostbyname_r( sHostName.c_str(), &hentbuff, hbuff, 2048, &hent, &err ); @@ -130,7 +130,7 @@ bool GetHostByName( const CS_STRING & sHostName, struct in_addr *paddr ) { bRet = true; break; - } + } if ( iRet != TRY_AGAIN ) break; @@ -155,7 +155,7 @@ bool GetHostByName( const CS_STRING & sHostName, struct in_addr *paddr ) return( bRet ); } -CCron::CCron() +CCron::CCron() { m_iCycles = 0; m_iMaxCycles = 0; @@ -166,7 +166,7 @@ CCron::CCron() } //! This is used by the Job Manager, and not you directly -void CCron::run() +void CCron::run() { if ( m_bPause ) return; @@ -229,20 +229,20 @@ const CS_STRING & CCron::GetName() const { return( m_sName ); } void CCron::SetName( const CS_STRING & sName ) { m_sName = sName; } void CCron::RunJob() { CS_DEBUG( "This should be overriden" ); } -Csock::Csock( int itimeout ) -{ - Init( "", 0, itimeout ); +Csock::Csock( int itimeout ) +{ + Init( "", 0, itimeout ); } -Csock::Csock( const CS_STRING & sHostname, int iport, int itimeout ) +Csock::Csock( const CS_STRING & sHostname, int iport, int itimeout ) { Init( sHostname, iport, itimeout ); } // override this for accept sockets -Csock *Csock::GetSockObj( const CS_STRING & sHostname, int iPort ) -{ - return( NULL ); +Csock *Csock::GetSockObj( const CS_STRING & sHostname, int iPort ) +{ + return( NULL ); } Csock::~Csock() @@ -261,13 +261,13 @@ Csock::~Csock() FREE_SSL(); FREE_CTX(); -#endif /* HAVE_LIBSSL */ +#endif /* HAVE_LIBSSL */ // delete any left over crons for( vector::size_type i = 0; i < m_vcCrons.size(); i++ ) CS_Delete( m_vcCrons[i] ); } -Csock & Csock::operator<<( const CS_STRING & s ) +Csock & Csock::operator<<( const CS_STRING & s ) { Write( s ); return( *this ); @@ -279,55 +279,55 @@ Csock & Csock::operator<<( ostream & ( *io )( ostream & ) ) return( *this ); } -Csock & Csock::operator<<( int i ) +Csock & Csock::operator<<( int i ) { stringstream s; s << i; Write( s.str() ); return( *this ); } -Csock & Csock::operator<<( unsigned int i ) +Csock & Csock::operator<<( unsigned int i ) { stringstream s; s << i; Write( s.str() ); return( *this ); } -Csock & Csock::operator<<( long i ) -{ - stringstream s; - s << i; - Write( s.str() ); - return( *this ); -} -Csock & Csock::operator<<( unsigned long i ) +Csock & Csock::operator<<( long i ) { stringstream s; s << i; Write( s.str() ); return( *this ); } -Csock & Csock::operator<<( unsigned long long i ) +Csock & Csock::operator<<( unsigned long i ) { stringstream s; s << i; Write( s.str() ); return( *this ); } -Csock & Csock::operator<<( float i ) +Csock & Csock::operator<<( unsigned long long i ) { stringstream s; s << i; Write( s.str() ); return( *this ); } -Csock & Csock::operator<<( double i ) +Csock & Csock::operator<<( float i ) { stringstream s; s << i; Write( s.str() ); return( *this ); -} +} +Csock & Csock::operator<<( double i ) +{ + stringstream s; + s << i; + Write( s.str() ); + return( *this ); +} bool Csock::Connect( const CS_STRING & sBindHost ) { @@ -387,10 +387,10 @@ bool Csock::Connect( const CS_STRING & sBindHost ) } if ( m_bBLOCK ) - { + { // unset the flags afterwords, rather than have connect block - int fdflags = fcntl (m_iReadSock, F_GETFL, 0); - fdflags &= ~O_NONBLOCK; + int fdflags = fcntl (m_iReadSock, F_GETFL, 0); + fdflags &= ~O_NONBLOCK; fcntl( m_iReadSock, F_SETFL, fdflags ); } @@ -536,7 +536,7 @@ bool Csock::AcceptSSL() if ( err == 1 ) { m_bFullsslAccept = true; - return( true ); + return( true ); } m_bFullsslAccept = false; @@ -550,13 +550,13 @@ bool Csock::AcceptSSL() #endif /* HAVE_LIBSSL */ - return( false ); + return( false ); } //! This sets up the SSL Client, this is used internally bool Csock::SSLClientSetup() { -#ifdef HAVE_LIBSSL +#ifdef HAVE_LIBSSL m_bssl = true; FREE_SSL(); FREE_CTX(); @@ -578,7 +578,7 @@ bool Csock::SSLClientSetup() { CS_DEBUG( "WARNING: MakeConnection .... SSLv3_client_method failed!" ); return( false ); - } + } break; case SSL23: @@ -629,14 +629,14 @@ bool Csock::SSLClientSetup() #else return( false ); -#endif /* HAVE_LIBSSL */ +#endif /* HAVE_LIBSSL */ } bool Csock::SSLServerSetup() { #ifdef HAVE_LIBSSL m_bssl = true; - FREE_SSL(); + FREE_SSL(); FREE_CTX(); switch( m_iMethod ) @@ -656,7 +656,7 @@ bool Csock::SSLServerSetup() { CS_DEBUG( "WARNING: MakeConnection .... SSLv3_server_method failed!" ); return( false ); - } + } break; case SSL23: @@ -680,7 +680,7 @@ bool Csock::SSLServerSetup() SSL_CTX_set_default_passwd_cb_userdata( m_ssl_ctx, (void *)this ); if ( ( m_sPemFile.empty() ) || ( access( m_sPemFile.c_str(), R_OK ) != 0 ) ) - { + { CS_DEBUG( "There is a problem with [" << m_sPemFile << "]" ); return( false ); } @@ -724,12 +724,12 @@ bool Csock::SSLServerSetup() return( true ); #else return( false ); -#endif /* HAVE_LIBSSL */ -} +#endif /* HAVE_LIBSSL */ +} bool Csock::ConnectSSL( const CS_STRING & sBindhost ) { -#ifdef HAVE_LIBSSL +#ifdef HAVE_LIBSSL if ( m_iReadSock == -1 ) if ( !Connect( sBindhost ) ) return( false ); @@ -744,7 +744,7 @@ bool Csock::ConnectSSL( const CS_STRING & sBindhost ) { int fdflags = fcntl ( m_iReadSock, F_GETFL, 0); fcntl( m_iReadSock, F_SETFL, fdflags|O_NONBLOCK ); - } + } int iErr = SSL_connect( m_ssl ); if ( iErr != 1 ) @@ -757,13 +757,13 @@ bool Csock::ConnectSSL( const CS_STRING & sBindhost ) bPass = true; if ( m_bBLOCK ) - { + { // unset the flags afterwords, rather then have connect block - int fdflags = fcntl (m_iReadSock, F_GETFL, 0); - fdflags &= ~O_NONBLOCK; + int fdflags = fcntl (m_iReadSock, F_GETFL, 0); + fdflags &= ~O_NONBLOCK; fcntl( m_iReadSock, F_SETFL, fdflags ); - } + } return( bPass ); #else @@ -790,7 +790,7 @@ bool Csock::Write( const char *data, int len ) if ( ( m_iMaxBytes > 0 ) && ( m_iMaxMilliSeconds > 0 ) ) { unsigned long long iNOW = millitime(); - // figure out the shaping here + // figure out the shaping here // if NOW - m_iLastSendTime > m_iMaxMilliSeconds then send a full length of ( iBytesToSend ) if ( ( iNOW - m_iLastSendTime ) > m_iMaxMilliSeconds ) { @@ -815,9 +815,9 @@ bool Csock::Write( const char *data, int len ) } else iBytesToSend = m_sSend.length(); -#ifdef HAVE_LIBSSL +#ifdef HAVE_LIBSSL if ( m_bssl ) - { + { if ( m_sSSLBuffer.empty() ) // on retrying to write data, ssl wants the data in the SAME spot and the SAME size m_sSSLBuffer.append( m_sSend.data(), iBytesToSend ); @@ -825,7 +825,7 @@ bool Csock::Write( const char *data, int len ) int iErr = SSL_write( m_ssl, m_sSSLBuffer.data(), m_sSSLBuffer.length() ); if ( ( iErr < 0 ) && ( errno == ECONNREFUSED ) ) - { + { // If ret == -1, the underlying BIO reported an I/O error (man SSL_get_error) ConnectionRefused(); return( false ); @@ -834,7 +834,7 @@ bool Csock::Write( const char *data, int len ) switch( SSL_get_error( m_ssl, iErr ) ) { case SSL_ERROR_NONE: - m_bsslEstablished = true; + m_bsslEstablished = true; // all ok break; @@ -859,14 +859,14 @@ bool Csock::Write( const char *data, int len ) } } - if ( iErr > 0 ) + if ( iErr > 0 ) { m_sSSLBuffer.clear(); m_sSend.erase( 0, iErr ); // reset the timer on successful write (we have to set it here because the write // bit might not always be set, so need to trigger) if ( TMO_WRITE & GetTimeoutType() ) - ResetTimer(); + ResetTimer(); m_iBytesWritten += (unsigned long long)iErr; } @@ -933,7 +933,7 @@ int Csock::Read( char *data, int len ) if ( bytes == -1 ) { if ( errno == ECONNREFUSED ) - return( READ_CONNREFUSED ); + return( READ_CONNREFUSED ); if ( errno == ETIMEDOUT ) return( READ_TIMEDOUT ); @@ -951,7 +951,7 @@ int Csock::Read( char *data, int len ) } #else return( READ_ERR ); -#endif /* HAVE_LIBSSL */ +#endif /* HAVE_LIBSSL */ } m_iBytesRead += (unsigned long long)bytes; @@ -999,7 +999,7 @@ CS_STRING Csock::GetRemoteIP() } bool Csock::IsConnected() { return( m_bIsConnected ); } -void Csock::SetIsConnected( bool b ) { m_bIsConnected = b; } +void Csock::SetIsConnected( bool b ) { m_bIsConnected = b; } int & Csock::GetRSock() { return( m_iReadSock ); } void Csock::SetRSock( int iSock ) { m_iReadSock = iSock; } @@ -1011,16 +1011,16 @@ void Csock::ResetTimer() { m_iTcount = 0; } void Csock::PauseRead() { m_bPauseRead = true; } bool Csock::IsReadPaused() { return( m_bPauseRead ); } -void Csock::UnPauseRead() -{ - m_bPauseRead = false; +void Csock::UnPauseRead() +{ + m_bPauseRead = false; ResetTimer(); } -void Csock::SetTimeout( int iTimeout, u_int iTimeoutType ) -{ +void Csock::SetTimeout( int iTimeout, u_int iTimeoutType ) +{ m_iTimeoutType = iTimeoutType; - m_itimeout = iTimeout; + m_itimeout = iTimeout; } void Csock::SetTimeoutType( u_int iTimeoutType ) { m_iTimeoutType = iTimeoutType; } @@ -1042,7 +1042,7 @@ bool Csock::CheckTimeout() } m_iTcount++; - } + } return( false ); } @@ -1076,7 +1076,7 @@ void Csock::PushBuff( const char *data, int len ) } -CS_STRING & Csock::GetInternalBuffer() { return( m_sbuffer ); } +CS_STRING & Csock::GetInternalBuffer() { return( m_sbuffer ); } void Csock::SetMaxBufferThreshold( u_int iThreshold ) { m_iMaxStoredBufferLength = iThreshold; } u_int Csock::GetMaxBufferThreshold() { return( m_iMaxStoredBufferLength ); } int Csock::GetType() { return( m_iConnType ); } @@ -1085,7 +1085,7 @@ const CS_STRING & Csock::GetSockName() { return( m_sSockName ); } void Csock::SetSockName( const CS_STRING & sName ) { m_sSockName = sName; } const CS_STRING & Csock::GetHostName() { return( m_shostname ); } void Csock::SetHostName( const CS_STRING & sHostname ) { m_shostname = sHostname; } -unsigned long long Csock::GetStartTime() const { return( m_iStartTime ); } +unsigned long long Csock::GetStartTime() const { return( m_iStartTime ); } void Csock::ResetStartTime() { m_iStartTime = 0; } unsigned long long Csock::GetBytesRead() const { return( m_iBytesRead ); } void Csock::ResetBytesRead() { m_iBytesRead = 0; } @@ -1112,14 +1112,14 @@ double Csock::GetAvgWrite( unsigned long long iSample ) return( ( (double)m_iBytesWritten / ( (double)iDifference / (double)iSample ) ) ); } -int Csock::GetRemotePort() +int Csock::GetRemotePort() { if ( m_iRemotePort > 0 ) return( m_iRemotePort ); int iSock = GetSock(); - if ( iSock >= 0 ) + if ( iSock >= 0 ) { struct sockaddr_in mAddr; socklen_t mLen = sizeof(struct sockaddr); @@ -1130,14 +1130,14 @@ int Csock::GetRemotePort() return( m_iRemotePort ); } -int Csock::GetLocalPort() +int Csock::GetLocalPort() { if ( m_iLocalPort > 0 ) return( m_iLocalPort ); int iSock = GetSock(); - if ( iSock >= 0 ) + if ( iSock >= 0 ) { struct sockaddr_in mLocalAddr; socklen_t mLocalLen = sizeof(struct sockaddr); @@ -1203,10 +1203,10 @@ void Csock::SetSSLObject( SSL *ssl ) { m_ssl = ssl; } void Csock::SetCTXObject( SSL_CTX *sslCtx ) { m_ssl_ctx = sslCtx; } void Csock::SetFullSSLAccept() { m_bFullsslAccept = true; } -SSL_SESSION * Csock::GetSSLSession() +SSL_SESSION * Csock::GetSSLSession() { - if ( m_ssl ) - return( SSL_get_session( m_ssl ) ); + if ( m_ssl ) + return( SSL_get_session( m_ssl ) ); return( NULL ); } @@ -1318,7 +1318,7 @@ CS_STRING Csock::GetPeerPubKey() } EVP_PKEY_free( pKey ); } - } + } return( sKey ); } bool Csock::RequiresClientCert() { return( m_bRequireClientCert ); } @@ -1341,7 +1341,7 @@ unsigned long long Csock::GetRateTime() { return( m_iMaxMilliSeconds ); } void Csock::Cron() { for( vector::size_type a = 0; a < m_vcCrons.size(); a++ ) - { + { CCron *pcCron = m_vcCrons[a]; if ( !pcCron->isValid() ) @@ -1461,12 +1461,12 @@ int Csock::SOCKET( bool bListen ) void Csock::Init( const CS_STRING & sHostname, int iport, int itimeout ) { -#ifdef HAVE_LIBSSL +#ifdef HAVE_LIBSSL m_ssl = NULL; m_ssl_ctx = NULL; -#endif /* HAVE_LIBSSL */ +#endif /* HAVE_LIBSSL */ m_iReadSock = -1; - m_iWriteSock = -1; + m_iWriteSock = -1; m_itimeout = itimeout; m_bssl = false; m_bIsConnected = false; diff --git a/Csocket.h b/Csocket.h index 8f37f982..407218a0 100644 --- a/Csocket.h +++ b/Csocket.h @@ -2,29 +2,29 @@ * * Copyright (c) 1999-2004 Jim Hull * All rights reserved -* -* Redistribution and use in source and binary forms, with or without modification, +* +* Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: -* Redistributions of source code must retain the above copyright notice, this +* Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright notice, this list +* Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. -* Redistributions in any form must be accompanied by information on how to obtain -* complete source code for the DB software and any accompanying software that uses the DB software. -* The source code must either be included in the distribution or be available for no more than -* the cost of distribution plus a nominal fee, and must be freely redistributable -* under reasonable conditions. For an executable file, complete source code means the source -* code for all modules it contains. It does not include source code for modules or files +* Redistributions in any form must be accompanied by information on how to obtain +* complete source code for the DB software and any accompanying software that uses the DB software. +* The source code must either be included in the distribution or be available for no more than +* the cost of distribution plus a nominal fee, and must be freely redistributable +* under reasonable conditions. For an executable file, complete source code means the source +* code for all modules it contains. It does not include source code for modules or files * that typically accompany the major components of the operating system on which the executable file runs. * -* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, -* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, -* OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL SLEEPYCAT SOFTWARE BE LIABLE FOR ANY DIRECT, -* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, +* OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL SLEEPYCAT SOFTWARE BE LIABLE FOR ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @@ -318,7 +318,7 @@ namespace Csocket * * @param sBindhost the ip you want to bind to locally * @return true on success - */ + */ virtual bool ConnectSSL( const CS_STRING & sBindhost = "" ); @@ -330,7 +330,7 @@ namespace Csocket * * @param data the data to send * @param len the length of data - * + * */ virtual bool Write( const char *data, int len ); @@ -432,7 +432,7 @@ namespace Csocket //! Gets the starting time of this socket - unsigned long long GetStartTime() const; + unsigned long long GetStartTime() const; //! Resets the start time void ResetStartTime(); @@ -618,7 +618,7 @@ namespace Csocket * Don't bother using these callbacks if you are using this class directly (without Socket Manager) * as the Socket Manager calls most of these callbacks * - * + * * Incoming Connection Event * return false and the connection will fail * default returns true @@ -642,7 +642,7 @@ namespace Csocket //! return the data imediatly ready for read virtual int GetPending(); - ////////////////////////////////////////////////// + ////////////////////////////////////////////////// private: int m_iReadSock, m_iWriteSock, m_itimeout, m_iport, m_iConnType, m_iTcount, m_iMethod, m_iRemotePort, m_iLocalPort; @@ -684,11 +684,11 @@ namespace Csocket * Another thing to note, is that all sockets are deleted implicitly, so obviously you * cant pass in Csock classes created on the stack. For those of you who don't * know STL very well, the reason I did this is because whenever you add to certain stl containers - * (ie vector, or map), its completely rebuilt using the copy constructor on each element. - * That then means the constructor and destructor are called on every item in the container. - * Not only is this more overhead then just moving pointers around, its dangerous as if you have - * an object that is newed and deleted in the destructor the value of its pointer is copied in the - * default copy constructor. This means everyone has to know better and create a copy constructor, + * (ie vector, or map), its completely rebuilt using the copy constructor on each element. + * That then means the constructor and destructor are called on every item in the container. + * Not only is this more overhead then just moving pointers around, its dangerous as if you have + * an object that is newed and deleted in the destructor the value of its pointer is copied in the + * default copy constructor. This means everyone has to know better and create a copy constructor, * or I just make everyone new their object :) * * class CBlahSock : public TSocketManager @@ -701,13 +701,13 @@ namespace Csocket { public: TSocketManager() : vector() - { - m_errno = SUCCESS; + { + m_errno = SUCCESS; m_iCallTimeouts = millitime(); m_iSelectWait = 100000; // Default of 100 milliseconds } - virtual ~TSocketManager() + virtual ~TSocketManager() { Cleanup(); } @@ -720,13 +720,13 @@ namespace Csocket vector::clear(); } - virtual void Cleanup() + virtual void Cleanup() { for( u_int a = 0; a < m_vcCrons.size(); a++ ) CS_Delete( m_vcCrons[a] ); - m_vcCrons.clear(); - clear(); + m_vcCrons.clear(); + clear(); } enum EMessages @@ -792,7 +792,7 @@ namespace Csocket /** * Create a listening socket - * + * * \param iPort the port to listen on * \param sSockName the name of the socket * \param isSSL if the sockets created require an ssl layer @@ -831,7 +831,7 @@ namespace Csocket T *pNewSock = ListenHost( 0, sSockName, sBindHost, isSSL, iMaxConns, pcSock, iTimeout ); if ( pNewSock ) { - int iSock = pNewSock->GetSock(); + int iSock = pNewSock->GetSock(); if ( iSock < 0 ) { @@ -858,7 +858,7 @@ namespace Csocket * Best place to call this class for running, all the call backs are called * You should through this in your main while loop (long as its not blocking) * all the events are called as needed - */ + */ virtual void Loop () { map mpeSocks; @@ -875,9 +875,9 @@ namespace Csocket EMessages iErrno = itSock->second; if ( iErrno == SUCCESS ) - { + { // read in data - // if this is a + // if this is a char *buff; int iLen = 0; @@ -895,7 +895,7 @@ namespace Csocket int bytes = pcSock->Read( buff, iLen ); - if ( ( bytes != T::READ_TIMEDOUT ) && ( bytes != T::READ_CONNREFUSED ) + if ( ( bytes != T::READ_TIMEDOUT ) && ( bytes != T::READ_CONNREFUSED ) && ( !pcSock->IsConnected() ) ) { pcSock->SetIsConnected( true ); @@ -938,7 +938,7 @@ namespace Csocket pcSock->PushBuff( buff, bytes ); pcSock->ReadData( buff, bytes ); break; - } + } } // free up the buff @@ -959,7 +959,7 @@ namespace Csocket break; } - unsigned long long iMilliNow = millitime(); + unsigned long long iMilliNow = millitime(); if ( ( iMilliNow - m_iCallTimeouts ) > 1000 ) { m_iCallTimeouts = iMilliNow; @@ -1138,7 +1138,7 @@ namespace Csocket * @see GetErrno() */ virtual void Select( map & mpeSocks ) - { + { mpeSocks.clear(); struct timeval tv; fd_set rfds, wfds; @@ -1150,7 +1150,7 @@ namespace Csocket if ( m_iSelectWait == 0 ) iQuickReset = 0; - TFD_ZERO( &rfds ); + TFD_ZERO( &rfds ); TFD_ZERO( &wfds ); // before we go any further, Process work needing to be done on the job @@ -1207,7 +1207,7 @@ namespace Csocket { pcSock->Close(); } - } else + } else { if ( !bIsReadPaused ) TFD_SET( iRSock, &rfds ); @@ -1273,7 +1273,7 @@ namespace Csocket } else { m_errno = SUCCESS; - } + } // find out wich one is ready for( unsigned int i = 0; i < this->size(); i++ ) @@ -1341,7 +1341,7 @@ namespace Csocket NewpcSock->SetWSock( inSock ); bool bAddSock = true; -#ifdef HAVE_LIBSSL +#ifdef HAVE_LIBSSL // // is this ssl ? if ( pcSock->GetSSL() ) @@ -1373,7 +1373,7 @@ namespace Csocket } } } - } + } //! internal use only @@ -1389,7 +1389,7 @@ namespace Csocket virtual void Cron() { for( unsigned int a = 0; a < m_vcCrons.size(); a++ ) - { + { CCron *pcCron = m_vcCrons[a]; if ( !pcCron->isValid() ) @@ -1403,7 +1403,7 @@ namespace Csocket EMessages m_errno; vector m_vcCrons; - unsigned long long m_iCallTimeouts; + unsigned long long m_iCallTimeouts; u_int m_iSelectWait; }; diff --git a/Makefile.in b/Makefile.in index 607d48b3..9f8a2335 100644 --- a/Makefile.in +++ b/Makefile.in @@ -29,7 +29,7 @@ clean: distclean: clean rm -rf Makefile config.log config.status znc/Makefile - + -include .depend %.o: %.cpp diff --git a/Modules.h b/Modules.h index caaa1c3f..66a378c0 100644 --- a/Modules.h +++ b/Modules.h @@ -10,7 +10,7 @@ using std::string; #define VERSION 0.033 #define MODULEDEFS(CLASS) extern "C" { CModule* Load(void* p, CUser* pUser, const string& sModName); void Unload(CModule* pMod); double GetVersion(); } double GetVersion() { return VERSION; } CModule* Load(void* p, CUser* pUser, const string& sModName) { return new CLASS(p, pUser, sModName); } void Unload(CModule* pMod) { if (pMod) { delete pMod; } } -#define MODCONSTRUCTOR(CLASS) CLASS(void *pDLL, CUser* pUser, const string& sModName) : CModule(pDLL, pUser, sModName) +#define MODCONSTRUCTOR(CLASS) CLASS(void *pDLL, CUser* pUser, const string& sModName) : CModule(pDLL, pUser, sModName) // Forward Declarations class CUser; @@ -43,7 +43,7 @@ protected: }; class CModule { -public: +public: CModule(void* pDLL, CUser* pUser, const string& sModName); virtual ~CModule(); @@ -119,7 +119,7 @@ protected: }; class CModules : public vector { -public: +public: CModules(); virtual ~CModules(); diff --git a/User.cpp b/User.cpp index 1a4d444c..60b82375 100644 --- a/User.cpp +++ b/User.cpp @@ -300,7 +300,7 @@ bool CUser::PutIRC(const string& sLine) { pIRCSock->PutServ(sLine); return true; } - + bool CUser::PutUser(const string& sLine) { CUserSock* pUserSock = GetUserSock(); diff --git a/UserSock.cpp b/UserSock.cpp index e5db1031..c69118b9 100644 --- a/UserSock.cpp +++ b/UserSock.cpp @@ -79,7 +79,7 @@ void CUserSock::ReadLine(const string& sData) { if ((m_bGotPass) && (m_bGotUser)) { AuthUser(); } - return; // Don't forward this msg. ZNC will handle nick changes until auth is complete + return; // Don't forward this msg. ZNC will handle nick changes until auth is complete } if ((m_pUser) && (strcasecmp(sNick.c_str(), m_pUser->GetNick().c_str()) == 0)) { @@ -981,7 +981,7 @@ void CUserSock::PutIRC(const string& sLine) { void CUserSock::PutServ(const string& sLine) { DEBUG_ONLY(cout << GetSockName() << " -> [" << sLine << "]" << endl); - Write(sLine + "\r\n"); + Write(sLine + "\r\n"); } void CUserSock::PutStatusNotice(const string& sLine) { diff --git a/Utils.cpp b/Utils.cpp index 78974abc..264ec2ce 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -185,7 +185,7 @@ int CUtils::MakeDir(const string& sPath, mode_t iMode) { } if (stat(sWorkDir.c_str(), &st) == 0) - { + { int iChdir = chdir(sWorkDir.c_str()); if (iChdir != 0) { return iChdir; // could not change to dir @@ -582,7 +582,7 @@ CFile::CFile(const string& sLongName) { if (uPos != string::npos) { m_sShortName = m_sShortName.substr(uPos +1); } -} +} CFile::~CFile() { if (m_iFD != -1) { Close(); diff --git a/Utils.h b/Utils.h index 5c8b16eb..b294ccf5 100644 --- a/Utils.h +++ b/Utils.h @@ -114,7 +114,7 @@ public: m_sFileName = sFile; } - //! timeout in milliseconds + //! timeout in milliseconds bool TryExLock(const string& sLockFile, unsigned long long iTimeout = 0) { Open(sLockFile); return TryExLock(iTimeout); @@ -359,7 +359,7 @@ private: #define RF_BUFF 4096 inline bool ReadFile(const string & sFilename, string & sLine) { char inbuff[RF_BUFF]; - int bytes; + int bytes; // clear ourselves out sLine.clear(); @@ -408,7 +408,7 @@ inline bool ReadLine(const string & sData, string & sLine, u_int & iPos) { u_int iFind = sData.find("\n", iPos); if (iFind == string::npos) { - sLine = sData.substr(iPos, (sData.length() - iPos)); + sLine = sData.substr(iPos, (sData.length() - iPos)); iPos = string::npos; return true; } diff --git a/config.guess b/config.guess index 31ec9156..fa7872b8 100755 --- a/config.guess +++ b/config.guess @@ -895,7 +895,7 @@ EOF ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 ;; + exit 0 ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit 0 ;; diff --git a/main.cpp b/main.cpp index 094f4619..3d890e8f 100644 --- a/main.cpp +++ b/main.cpp @@ -5,7 +5,7 @@ #include "znc.h" #include "md5.h" -static struct option g_LongOpts[] = +static struct option g_LongOpts[] = { { "help", 0, NULL, 0 }, { "makepass", 0, NULL, 0 }, @@ -25,7 +25,7 @@ void GenerateHelp( const char *appname ) #ifdef HAVE_LIBSSL CUtils::PrintMessage("\t--makepem Generates a pemfile for use with SSL"); CUtils::PrintMessage("\t--encrypt-pem Encrypts the pemfile"); -#endif /* HAVE_LIBSSL */ +#endif /* HAVE_LIBSSL */ } void die(int sig) { @@ -55,7 +55,7 @@ int main(int argc, char** argv) { #ifdef HAVE_LIBSSL bool bMakePem = false; bool bEncPem = false; -#endif /* HAVE_LIBSSL */ +#endif /* HAVE_LIBSSL */ bool bMakePass = false; while( ( iArg = getopt_long( argc, argv, "h", g_LongOpts, &iOptIndex ) != -1 ) ) { switch( iArg ) { @@ -70,7 +70,7 @@ int main(int argc, char** argv) { bMakePem = true; else if ( sOption == "encrypt-pem" ) bEncPem = true; -#endif /* HAVE_LIBSSL */ +#endif /* HAVE_LIBSSL */ else if ( sOption == "help" ) { GenerateHelp( argv[0] ); return( 0 ); @@ -83,7 +83,7 @@ int main(int argc, char** argv) { } case 'h': GenerateHelp( argv[0] ); - return( 0 ); + return( 0 ); default : { GenerateHelp( argv[0] ); @@ -125,7 +125,7 @@ int main(int argc, char** argv) { delete pZNC; return 0; } -#endif /* HAVE_LIBSSL */ +#endif /* HAVE_LIBSSL */ if ( bMakePass ) { char* pass = CUtils::GetPass("Enter Password"); char* pass1 = (char*) malloc(strlen(pass) +1); @@ -186,7 +186,7 @@ int main(int argc, char** argv) { CUtils::PrintMessage("ZNC - by prozac@gmail.com"); exit(0); } - + // Redirect std in/out/err to /dev/null close(0); open("/dev/null", O_RDONLY); close(1); open("/dev/null", O_WRONLY);