Commit d5e4667b authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

win32: revector system_Init() a bit

parent 1ed466fa
...@@ -39,43 +39,32 @@ ...@@ -39,43 +39,32 @@
#include <winsock.h> #include <winsock.h>
/*****************************************************************************
* system_Init: initialize winsock and misc other things.
*****************************************************************************/
void system_Init( void )
{
WSADATA Data;
#if !defined( UNDER_CE ) static int system_InitWSA(int hi, int lo)
timeBeginPeriod(5); {
#endif WSADATA data;
/* WinSock Library Init. */ if (WSAStartup(MAKEWORD(hi, lo), &data) == 0)
if( !WSAStartup( MAKEWORD( 2, 2 ), &Data ) )
{ {
/* Aah, pretty useless check, we should always have Winsock 2.2 if (LOBYTE(data.wVersion) == 2 && HIBYTE(data.wVersion) == 2)
* since it appeared in Win98. */ return 0;
if( LOBYTE( Data.wVersion ) != 2 || HIBYTE( Data.wVersion ) != 2 ) /* Winsock DLL is not usable */
/* We could not find a suitable WinSock DLL. */ WSACleanup( );
WSACleanup( );
else
/* Everything went ok. */
return;
} }
return -1;
}
/* Let's try with WinSock 1.1 */ /**
if( !WSAStartup( MAKEWORD( 1, 1 ), &Data ) ) * Initializes MME timer, Winsock.
{ */
/* Confirm that the WinSock DLL supports 1.1.*/ void system_Init(void)
if( LOBYTE( Data.wVersion ) != 1 || HIBYTE( Data.wVersion ) != 1 ) {
/* We could not find a suitable WinSock DLL. */ #if !defined( UNDER_CE )
WSACleanup( ); timeBeginPeriod(5);
else #endif
/* Everything went ok. */
return;
}
fprintf( stderr, "error: can't initialize WinSocks\n" ); if (system_InitWSA(2, 2) && system_InitWSA(1, 1))
fputs("Error: cannot initialize Winsocks\n", stderr);
} }
/***************************************************************************** /*****************************************************************************
...@@ -327,10 +316,10 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam, ...@@ -327,10 +316,10 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam,
return DefWindowProc( hwnd, uMsg, wParam, lParam ); return DefWindowProc( hwnd, uMsg, wParam, lParam );
} }
/***************************************************************************** /**
* system_End: terminate winsock. * Cleans up after system_Init() and system_Configure().
*****************************************************************************/ */
void system_End( void ) void system_End(void)
{ {
HWND ipcwindow; HWND ipcwindow;
...@@ -349,5 +338,6 @@ void system_End( void ) ...@@ -349,5 +338,6 @@ void system_End( void )
timeEndPeriod(5); timeEndPeriod(5);
#endif #endif
/* XXX: In theory, we should not call this if WSAStartup() failed. */
WSACleanup(); WSACleanup();
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment