diff options
author | Sterling Hughes <sterling@bumblebury.com> | 2001-07-12 01:57:28 +0000 |
---|---|---|
committer | Sterling Hughes <sterling@bumblebury.com> | 2001-07-12 01:57:28 +0000 |
commit | 45037a39aa7141510f6c6bcff65d102c65e6566e (patch) | |
tree | 4ea1de0d8a604c21fab41989b3579bc3934766f4 /src | |
parent | 31336d63ae4479155a2fed861ac2ac38949a035c (diff) |
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().
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 50 |
1 files changed, 1 insertions, 49 deletions
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(); } |