mirror of
https://github.com/znc/znc.git
synced 2026-05-14 13:25:49 +02:00
Update to latest Csocket and use its new init interface
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1288 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
+26
-1
@@ -28,7 +28,7 @@
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* $Revision: 1.89 $
|
||||
* $Revision: 1.90 $
|
||||
*/
|
||||
|
||||
#include "Csocket.h"
|
||||
@@ -311,6 +311,31 @@ int GetAddrInfo( const CS_STRING & sHostname, Csock *pSock, CSSockAddr & csSockA
|
||||
return( ETIMEDOUT );
|
||||
}
|
||||
|
||||
bool InitCsocket()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
int iResult = WSAStartup( MAKEWORD( 2, 2 ), &wsaData );
|
||||
if( iResult != NO_ERROR )
|
||||
return( false );
|
||||
#endif /* _WIN32 */
|
||||
#ifdef HAVE_LIBSSL
|
||||
if( !InitSSL() )
|
||||
return( false );
|
||||
#endif /* HAVE_LIBSSL */
|
||||
return( true );
|
||||
}
|
||||
|
||||
void ShutdownCsocket()
|
||||
{
|
||||
#ifdef HAVE_LIBSSL
|
||||
ERR_free_strings();
|
||||
#endif /* HAVE_LIBSSL */
|
||||
#ifdef _WIN32
|
||||
WSACleanup();
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBSSL
|
||||
bool InitSSL( ECompType eCompressionType )
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* $Revision: 1.199 $
|
||||
* $Revision: 1.200 $
|
||||
*/
|
||||
|
||||
// note to compile with win32 need to link to winsock2, using gcc its -lws2_32
|
||||
@@ -261,15 +261,27 @@ enum ECompType
|
||||
CT_RLE = 2
|
||||
};
|
||||
|
||||
void SSLErrors( const char *filename, u_int iLineNum );
|
||||
|
||||
/**
|
||||
* @brief You HAVE to call this in order to use the SSL library
|
||||
* @brief You HAVE to call this in order to use the SSL library, calling InitCsocket() also calls this
|
||||
* so unless you need to call InitSSL for a specific reason call InitCsocket()
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
bool InitSSL( ECompType eCompressionType = CT_NONE );
|
||||
void SSLErrors( const char *filename, u_int iLineNum );
|
||||
|
||||
#endif /* HAVE_LIBSSL */
|
||||
|
||||
/**
|
||||
* This does all the csocket initialized inclusing InitSSL() and win32 specific initializations, only needs to be called once
|
||||
*/
|
||||
bool InitCsocket();
|
||||
/**
|
||||
* Shutdown and release global allocated memory
|
||||
*/
|
||||
void ShutdownCsocket();
|
||||
|
||||
//! @todo need to make this sock specific via getsockopt
|
||||
inline int GetSockError()
|
||||
{
|
||||
@@ -280,27 +292,6 @@ inline int GetSockError()
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
inline bool InitWin32()
|
||||
{
|
||||
WSADATA wsaData;
|
||||
int iResult = WSAStartup( MAKEWORD( 2, 2 ), &wsaData );
|
||||
if( iResult != NO_ERROR )
|
||||
return( false );
|
||||
|
||||
return( true );
|
||||
}
|
||||
inline void ShutdownWin32()
|
||||
{
|
||||
WSACleanup();
|
||||
}
|
||||
#define InitCsocket InitWin32
|
||||
#define ShutdownCsocket ShutdownWin32
|
||||
#else
|
||||
#define InitCsocket (void)0
|
||||
#define ShutdownCsocket (void)0
|
||||
#endif /* _WIN32 */
|
||||
|
||||
//! wrappers for FD_SET and such to work in templates.
|
||||
inline void TFD_ZERO( fd_set *set )
|
||||
{
|
||||
|
||||
@@ -74,10 +74,6 @@ int main(int argc, char** argv) {
|
||||
srand(time(NULL));
|
||||
CUtils::SetStdoutIsTTY(isatty(1));
|
||||
|
||||
#ifdef HAVE_LIBSSL
|
||||
InitSSL();
|
||||
#endif /* HAVE_LIBSSL */
|
||||
|
||||
int iArg, iOptIndex = -1;
|
||||
bool bMakeConf = false;
|
||||
bool bMakePass = false;
|
||||
|
||||
@@ -26,6 +26,11 @@ namespace
|
||||
};
|
||||
|
||||
CZNC::CZNC() {
|
||||
if (!InitCsocket()) {
|
||||
CUtils::PrintError("Failed to initialize Csocket!");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
#ifdef _MODULES
|
||||
m_pModules = new CGlobalModules();
|
||||
#endif
|
||||
@@ -68,6 +73,7 @@ CZNC::~CZNC() {
|
||||
delete m_pModules;
|
||||
#endif
|
||||
|
||||
ShutdownCsocket();
|
||||
DeletePidFile();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user