diff src/win32/win32dep.c @ 3907:41e7544a9c67

[gaim-migrate @ 4060] wgaim_cleanup added committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Tue, 05 Nov 2002 23:00:53 +0000
parents 3e508dd31b76
children c25cf0495533
line wrap: on
line diff
--- a/src/win32/win32dep.c	Tue Nov 05 22:59:53 2002 +0000
+++ b/src/win32/win32dep.c	Tue Nov 05 23:00:53 2002 +0000
@@ -145,9 +145,35 @@
 /* Windows Initializations */
 
 void wgaim_init(void) {
+	WORD wVersionRequested;
+	WSADATA wsaData;
+	int err;
 	char* locale=0;
 	char newenv[128];
 
+	debug_printf("wgaim_init\n");
+	/*
+	 *  Winsock init
+	 */
+	wVersionRequested = MAKEWORD( 2, 2 );
+
+	err = WSAStartup( wVersionRequested, &wsaData );
+	if ( err != 0 ) {
+		return 1;
+	}
+
+	/* Confirm that the winsock DLL supports 2.2 */
+	/* Note that if the DLL supports versions greater than
+	   2.2 in addition to 2.2, it will still return 2.2 in 
+	   wVersion since that is the version we requested. */
+
+	if ( LOBYTE( wsaData.wVersion ) != 2 ||
+			HIBYTE( wsaData.wVersion ) != 2 ) {
+		debug_printf("Could not find a usable WinSock DLL.  Oh well.\n");
+		WSACleanup( );
+		return 1;
+	}
+
 	/* Filter to catch systray events */
 	gdk_add_client_message_filter (GDK_POINTER_TO_ATOM (WM_TRAYMESSAGE),
 				       traymsg_filter_func,
@@ -165,11 +191,25 @@
 		debug_printf("putenv failed\n");
 	g_free(locale);
 
-	/* IdleTracker Initialization */
+	/*
+	 *  IdleTracker Initialization
+	 */
 	if(!IdleTrackerInit())
 		debug_printf("IdleTracker failed to initialize\n");
 }
 
+/* Windows Cleanup */
+
+void wgaim_cleanup(void) {
+	debug_printf("wgaim_cleanup\n");
+
+	/* winsock cleanup */
+	WSACleanup( );
+
+	/* IdleTracker cleanup */
+	IdleTrackerTerm();
+}
+
 BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) {
 	gaimdll_hInstance = hinstDLL;
 	return TRUE;