From 45037a39aa7141510f6c6bcff65d102c65e6566e Mon Sep 17 00:00:00 2001 From: Sterling Hughes Date: Thu, 12 Jul 2001 01:57:28 +0000 Subject: Add win32 initialization support to curl_global_init() and curl_global_cleanup(). Update corresponding man pages... Improve the logic in curl_global_cleanup() and curl_global_init() so that they are not called twice if the application libraries have been initialized and make sure to reset the init flags in curl_global_cleanup(). --- src/main.c | 50 +------------------------------------------------- 1 file changed, 1 insertion(+), 49 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 125222db5..9f83a855b 100644 --- a/src/main.c +++ b/src/main.c @@ -126,52 +126,6 @@ char *strdup(char *str) extern void hugehelp(void); -/*********************************************************************** - * Start with some silly functions to make win32-systems survive - ***********************************************************************/ -#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) -static void win32_cleanup(void) -{ - WSACleanup(); -} - -static CURLcode win32_init(void) -{ - WORD wVersionRequested; - WSADATA wsaData; - int err; - wVersionRequested = MAKEWORD(1, 1); - - err = WSAStartup(wVersionRequested, &wsaData); - - if (err != 0) - /* Tell the user that we couldn't find a useable */ - /* winsock.dll. */ - return CURLE_FAILED_INIT; - - /* Confirm that the Windows Sockets DLL supports 1.1.*/ - /* Note that if the DLL supports versions greater */ - /* than 1.1 in addition to 1.1, it will still return */ - /* 1.1 in wVersion since that is the version we */ - /* requested. */ - - if ( LOBYTE( wsaData.wVersion ) != 1 || - HIBYTE( wsaData.wVersion ) != 1 ) { - /* Tell the user that we couldn't find a useable */ - - /* winsock.dll. */ - WSACleanup(); - return CURLE_FAILED_INIT; - } - return CURLE_OK; -} -/* The Windows Sockets DLL is acceptable. Proceed. */ -#else -static CURLcode win32_init(void) { return CURLE_OK; } -#define win32_cleanup() -#endif - - /* * This is the main global constructor for the app. Call this before * _any_ libcurl usage. If this fails, *NO* libcurl functions may be @@ -179,8 +133,7 @@ static CURLcode win32_init(void) { return CURLE_OK; } */ CURLcode main_init(void) { - curl_global_init(CURL_GLOBAL_DEFAULT); - return win32_init(); + return curl_global_init(CURL_GLOBAL_DEFAULT); } /* @@ -189,7 +142,6 @@ CURLcode main_init(void) */ void main_free(void) { - win32_cleanup(); curl_global_cleanup(); } -- cgit v1.2.3