changeset 3717:988485669631

[gaim-migrate @ 3850] Warning fixes and WIN32 ifdef removals committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Wed, 16 Oct 2002 19:57:03 +0000
parents d7e83b4db191
children fd3880c03f0d
files src/gaimrc.c src/gtkimhtml.c src/html.c src/list.c src/module.c src/multi.c src/protocols/gg/common.c src/protocols/gg/gg.c src/protocols/gg/libgg.c src/protocols/jabber/expat.c src/protocols/jabber/jabber.c src/protocols/jabber/jabber.h src/protocols/jabber/jconn.c src/protocols/jabber/jutil.c src/protocols/jabber/lib.h src/protocols/jabber/libxode.h src/protocols/jabber/pool.c src/protocols/jabber/sha.c src/protocols/jabber/socket.c src/protocols/jabber/str.c src/protocols/oscar/conn.c src/protocols/oscar/ft.c src/protocols/oscar/oscar.c src/proxy.c src/ui.h
diffstat 25 files changed, 102 insertions(+), 740 deletions(-) [+]
line wrap: on
line diff
--- a/src/gaimrc.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/gaimrc.c	Wed Oct 16 19:57:03 2002 +0000
@@ -1220,13 +1220,8 @@
 	else if (gaim_home_dir())
 		g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S ".gaimrc", gaim_home_dir());
 	else {
-#ifndef _WIN32
 		set_defaults();
 		return;
-#else
-		/* Pre Win 2000 there are no home dirs... */
-		g_snprintf(buf, sizeof(buf), "C:" G_DIR_SEPARATOR_S ".gaimrc");
-#endif
 	}
 
 	if ((f = fopen(buf, "r"))) {
@@ -1291,12 +1286,7 @@
 		g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S ".gaimrc", gaim_home_dir());
 	}
 	else {
-#ifndef _WIN32
 		return;
-#else
-	        /* Pre Win 2000, there are no home dirs.. */
-	        g_snprintf(buf, sizeof(buf), "C:" G_DIR_SEPARATOR_S ".gaimrc");
-#endif
 	}
 	if ((f = fopen(buf, "w"))) {
 		fprintf(f, "# .gaimrc v%d\n", 4);
@@ -1310,9 +1300,8 @@
 #endif
 		gaimrc_write_proxy(f);
 		fclose(f);
-#ifndef _WIN32	
+
 		chmod(buf, S_IRUSR | S_IWUSR);
-#endif
 	}
 	else
 	  debug_printf("Error opening .gaimrc\n");
--- a/src/gtkimhtml.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/gtkimhtml.c	Wed Oct 16 19:57:03 2002 +0000
@@ -107,6 +107,11 @@
 	gchar **image;
 };
 
+/*
+ *  PROTOS
+ */
+extern void debug_printf(char * fmt, ...);
+
 static GtkSmileyTree*
 gtk_smiley_tree_new ()
 {
@@ -2095,24 +2100,13 @@
 #define RGSTRY 13
 #define ENCDNG 14
 
+#if 0
 static const gchar*
 gtk_imhtml_get_font_name (PangoFontDescription *font)
 {
-#if 0
-#ifndef _WIN32
-	return gdk_x11_font_get_name(font);
-#else
-#if 0
-	/* win32 gdkfont.h says this is temporary - GTK 2.0.3 */
-	return 	gdk_font_full_name_get(font);
-#else
-	/* So i can build with GTK 2.0.6 */
-	return "-unknown-arial-normal-r-normal---18--108-120-120-p-0-microsoft-vietnamese-unknown-arial-normal-r-normal---18--108-120-120-p-0-microsoft-vietnamese27";
-#endif
-#endif
-#endif
 	return pango_font_description_get_family(font);
 }
+#endif
 
 static PangoFontDescription *
 gtk_imhtml_font_load (GtkIMHtml *imhtml,
@@ -2835,13 +2829,13 @@
 		*replace = ' ';
 		*length = 6;
 	} else if (!g_strncasecmp (string, "&copy;", 6)) {
-		*replace = '©';
+		*replace = '©'; /* was: '©' */
 		*length = 6;
 	} else if (!g_strncasecmp (string, "&quot;", 6)) {
 		*replace = '\"';
 		*length = 6;
 	} else if (!g_strncasecmp (string, "&reg;", 5)) {
-		*replace = '®';
+		*replace = '®'; /* was: '®' */
 		*length = 5;
 	} else if (*(string + 1) == '#') {
 		guint pound = 0;
--- a/src/html.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/html.c	Wed Oct 16 19:57:03 2002 +0000
@@ -32,9 +32,6 @@
 #include <sys/socket.h>
 #include <netdb.h>
 #include <netinet/in.h>
-#else
-#include <winsock.h>
-#include <io.h>
 #endif
 
 #include <sys/types.h>
@@ -43,6 +40,10 @@
 #include "gaim.h"
 #include "proxy.h"
 
+#ifdef _WIN32
+#include "win32dep.h"
+#endif
+
 gchar *strip_html(gchar *text)
 {
 	int i, j, k;
@@ -144,37 +145,23 @@
 
 	if (!gunk->sentreq) {
 		char buf[256];
-#ifdef _WIN32
-		int imode=1;
-#endif
+
 		g_snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.0\r\n\r\n", gunk->full ? "" : "/",
 			   gunk->full ? gunk->url : gunk->website->page);
 		debug_printf("Request: %s\n", buf);
-#ifdef _WIN32
-		send(sock, buf, strlen(buf), 0);
-		ioctlsocket(sock, FIONBIO, (unsigned long *)&imode);
-#else
+
 		write(sock, buf, strlen(buf));
 		fcntl(sock, F_SETFL, O_NONBLOCK);
-#endif
 		gunk->sentreq = TRUE;
 		gunk->inpa = gaim_input_add(sock, GAIM_INPUT_READ, grab_url_callback, dat);
 		return;
 	}
 
-#ifdef _WIN32
-	if (recv(sock, &data, 1, 0) > 0 || WSAEWOULDBLOCK == WSAGetLastError()) {
-		if (WSAEWOULDBLOCK == WSAGetLastError()) {	
-			WSASetLastError(0);
-			return;
-		}	
-#else
 	if (read(sock, &data, 1) > 0 || errno == EWOULDBLOCK) {
 		if (errno == EWOULDBLOCK) {
 			errno = 0;
 			return;
 		}
-#endif
 		if (!gunk->startsaving) {
 			if (data == '\r')
 				return;
@@ -191,22 +178,14 @@
 			gunk->webdata = g_realloc(gunk->webdata, gunk->len);
 			gunk->webdata[gunk->len - 1] = data;
 		}
-#ifdef _WIN32	
-	} else if (WSAETIMEDOUT == WSAGetLastError()) {
-#else
 	} else if (errno != ETIMEDOUT) {
-#endif
 		gunk->webdata = g_realloc(gunk->webdata, gunk->len + 1);
 		gunk->webdata[gunk->len] = 0;
 
 		debug_printf(_("Received: '%s'\n"), gunk->webdata);
 
 		gaim_input_remove(gunk->inpa);
-#ifdef _WIN32
-		closesocket(sock);
-#else
 		close(sock);
-#endif
 		gunk->callback(gunk->data, gunk->webdata);
 		if (gunk->webdata)
 			g_free(gunk->webdata);
@@ -215,11 +194,7 @@
 		g_free(gunk);
 	} else {
 		gaim_input_remove(gunk->inpa);
-#ifdef _WIN32
-		closesocket(sock);		
-#else	
 		close(sock);
-#endif
 		gunk->callback(gunk->data, NULL);
 		if (gunk->webdata)
 			g_free(gunk->webdata);
--- a/src/list.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/list.c	Wed Oct 16 19:57:03 2002 +0000
@@ -29,11 +29,14 @@
 #include <unistd.h>
 #else
 #include <direct.h>
-#include <io.h>
 #endif
 #include "gaim.h"
 #include "prpl.h"
 
+#ifdef _WIN32
+#include "win32dep.h"
+#endif
+
 #define PATHSIZE 1024
 
 void remove_buddy(struct gaim_connection *gc, struct group *rem_g, struct buddy *rem_b)
@@ -790,11 +793,7 @@
 	strcpy(buf, file);
 	dir = fopen(buf, "r");
 	if (!dir)
-#ifndef _WIN32
 		mkdir(buf, S_IRUSR | S_IWUSR | S_IXUSR);
-#else
-		_mkdir(buf);
-#endif
 	else
 		fclose(dir);
 
@@ -806,11 +805,7 @@
 		toc_build_config(g, buf, 8192 - 1, TRUE);
 		fprintf(f, "%s\n", buf);
 		fclose(f);
-#ifdef _WIN32
-		_chmod(buf, _S_IWRITE);
-#else
 		chmod(path, S_IRUSR | S_IWUSR);
-#endif
 	} else {
 		debug_printf("unable to write %s\n", path);
 	}
--- a/src/module.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/module.c	Wed Oct 16 19:57:03 2002 +0000
@@ -90,7 +90,7 @@
 	GDir *dir;
 	const gchar *file;
 	gchar *path;
-	struct gaim_plugin_description *plugdes;
+	/*struct gaim_plugin_description *plugdes;*/
 	struct gaim_plugin *plug;
 	char *probedirs[3];
 	int l;
@@ -112,7 +112,7 @@
 		if (dir) {
 			while ((file = g_dir_read_name(dir))) {
 #ifdef GAIM_PLUGINS
-				if (is_so_file(file, 
+				if (is_so_file((char*)file, 
 #ifndef _WIN32
 					       ".so"
 #else
@@ -168,7 +168,7 @@
 				}
 #endif
 #ifdef USE_PERL
-				if (is_so_file(file, ".pl")) {
+				if (is_so_file((char*)file, ".pl")) {
 					path = g_build_filename(probedirs[l], file, NULL);
 					plug = probe_perl(path);
 					if (plug) 
@@ -185,14 +185,15 @@
 #ifdef GAIM_PLUGINS
 struct gaim_plugin *load_plugin(const char *filename)
 {
-	struct gaim_plugin *plug;
+	struct gaim_plugin *plug=NULL;
 	struct gaim_plugin_description *desc;
 	struct gaim_plugin_description *(*gaim_plugin_desc)();
 	char *(*cfunc)();
-	GList *c = plugins;
+	/*GList *c = plugins;*/
 	GList *p = probed_plugins;
 	char *(*gaim_plugin_init)(GModule *);
-	char *error, *retval;
+	char *error=NULL;
+	char *retval;
 	gboolean newplug = FALSE;
 
 	if (!g_module_supported())
@@ -201,8 +202,9 @@
 		return NULL;
 
 #ifdef USE_PERL
-	if (is_so_file(filename, ".pl")) {
-		return perl_load_file(filename);
+	if (is_so_file((char*)filename, ".pl")) {
+		/* perl_load_file is returning an int.. this should be fixed */
+		return (struct gaim_plugin *)perl_load_file((char*)filename);
 	}
 #endif
 
--- a/src/multi.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/multi.c	Wed Oct 16 19:57:03 2002 +0000
@@ -35,7 +35,7 @@
 #include "pixmaps/tb_redo.xpm"
 #include "pixmaps/tb_undo.xpm"
 #include "pixmaps/tb_refresh.xpm"
-#include "pixmaps/no_icon.xpm"
+/*#include "pixmaps/no_icon.xpm"*/
 
 #define LOGIN_STEPS 5
 
--- a/src/protocols/gg/common.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/gg/common.c	Wed Oct 16 19:57:03 2002 +0000
@@ -1,4 +1,4 @@
-/* $Id: common.c 3753 2002-10-11 03:14:01Z robflynn $ */
+/* $Id: common.c 3850 2002-10-16 19:57:03Z hermanator $ */
 
 /*
  *  (C) Copyright 2001 Wojtek Kaniewski <wojtekka@irc.pl>,
@@ -29,8 +29,6 @@
 #include <sys/ioctl.h>
 #include <pwd.h>
 #include <sys/wait.h>
-#else
-#include <winsock.h>
 #endif
 #include <sys/time.h>
 #include <errno.h>
@@ -46,6 +44,10 @@
 #include "config.h"
 #include <glib.h>
 
+#ifdef _WIN32
+#include "win32dep.h"
+#endif
+
 /*
  * gg_debug()
  *
@@ -166,24 +168,13 @@
 	gg_debug(GG_DEBUG_FUNCTION, "** gg_connect(%s, %d, %d);\n", inet_ntoa(*a), port, async);
 	
 	if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
-		gg_debug(GG_DEBUG_MISC, "-- socket() failed. errno = %d" 
-#ifndef _WIN32
-			 " (%s)\n", errno, strerror(errno)
-#else
-		         "\n", WSAGetLastError()
-#endif
-		);
+		gg_debug(GG_DEBUG_MISC, "-- socket() failed. errno = %d (%s)\n", errno, strerror(errno));
 		return -1;
 	}
 
 	if (async) {
-#ifndef _WIN32
 		if (ioctl(sock, FIONBIO, &one) == -1) {
 			gg_debug(GG_DEBUG_MISC, "-- ioctl() failed. errno = %d (%s)\n", errno, strerror(errno));
-#else
-		if (ioctlsocket(sock, FIONBIO, (unsigned long *)&one) == SOCKET_ERROR) {
-			gg_debug(GG_DEBUG_MISC, "-- ioctlsocket() failed. errno = %d\n", WSAGetLastError());
-#endif
 			return -1;
 		}
 	}
@@ -193,21 +184,10 @@
 	sin.sin_addr.s_addr = a->s_addr;
 	
 	if ((ret = connect(sock, (struct sockaddr*) &sin, sizeof(sin))) == -1) {
-#ifndef _WIN32
 		if (errno && (!async || errno != EINPROGRESS)) {
 			gg_debug(GG_DEBUG_MISC, "-- connect() failed. errno = %d (%s)\n", errno, strerror(errno));
 			return -1;
 		}
-#else
-		if (ret == SOCKET_ERROR) {
-			gg_debug(GG_DEBUG_MISC, "-- connect() SOCKET_ERROR: %d\n", WSAGetLastError());
-			if((WSAGetLastError() != WSAEWOULDBLOCK) && 
-			   (!async || WSAGetLastError() != WSAEINPROGRESS)) {
-				gg_debug(GG_DEBUG_MISC, "-- connect() failed. errno = %d\n", WSAGetLastError());
-				return -1;
-			}
-		}
-#endif
 		gg_debug(GG_DEBUG_MISC, "-- connect() in progress\n");
 	}
 	
@@ -233,19 +213,11 @@
 	
 	for (; length > 1; buf++, length--) {
 		do {
-#ifndef _WIN32
 			if ((ret = read(sock, buf, 1)) == -1 && errno != EINTR) {
-#else
-			if ((ret = recv(sock, buf, 1, 0)) == SOCKET_ERROR && (WSAGetLastError() != WSAEINTR)) {
-#endif
 				*buf = 0;
 				return;
 			}
-#ifndef _WIN32
 		} while (ret == -1 && errno == EINTR);
-#else
-		} while (ret == SOCKET_ERROR && WSAGetLastError() == WSAEINTR);
-#endif
 
 		if (*buf == '\n') {
 			buf++;
--- a/src/protocols/gg/gg.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/gg/gg.c	Wed Oct 16 19:57:03 2002 +0000
@@ -1,6 +1,6 @@
 /*
  * gaim - Gadu-Gadu Protocol Plugin
- * $Id: gg.c 3753 2002-10-11 03:14:01Z robflynn $
+ * $Id: gg.c 3850 2002-10-16 19:57:03Z hermanator $
  *
  * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
  * 
@@ -440,11 +440,7 @@
 
 	debug_printf("GG login_callback...\n");
 	if (!g_slist_find(connections, gc)) {
-#ifndef _WIN32
 		close(source);
-#else
-		closesocket(source);
-#endif
 		return;
 	}
 	debug_printf("Found GG connection\n");
@@ -892,25 +888,16 @@
 		debug_printf("search_callback: g_slist_find error\n");
 		gaim_input_remove(hdata->inpa);
 		g_free(hdata);
-#ifndef _WIN32
 		close(source);
-#else
-		closesocket(source);
-#endif
 		return;
 	}
 
 	webdata = NULL;
 	len = 0;
-#ifndef _WIN32
+
 	while (read(source, &read_data, 1) > 0 || errno == EWOULDBLOCK) {
 		if (errno == EWOULDBLOCK) {
 			errno = 0;
-#else
-	while (recv(source, &read_data, 1, 0) > 0 || WSAEWOULDBLOCK == WSAGetLastError() ) {
-		if (WSAEWOULDBLOCK == WSAGetLastError()) {
-			WSASetLastError(0);
-#endif
 			continue;
 		}
 
@@ -926,11 +913,7 @@
 	webdata[len] = 0;
 
 	gaim_input_remove(hdata->inpa);
-#ifndef _WIN32
 	close(source);
-#else
-	closesocket(source);
-#endif
 
 	debug_printf("http_results: type %d, webdata [%s]\n", hdata->type, webdata);
 
@@ -973,11 +956,7 @@
 		debug_printf("http_req_callback: g_slist_find error\n");
 		g_free(request);
 		g_free(hdata);
-#ifndef _WIN32
 		close(source);
-#else
-		closesocket(source);
-#endif
 		return;
 	}
 
@@ -999,18 +978,10 @@
 
 	g_free(request);
 
-#ifndef _WIN32
 	if (write(source, buf, strlen(buf)) < strlen(buf)) {
-#else
-	if (send(source, buf, strlen(buf), 0) < strlen(buf)) {
-#endif
 		g_free(buf);
 		g_free(hdata);
-#ifndef _WIN32
 		close(source);
-#else
-		closesocket(source);
-#endif
 		do_error_dialog(_("Error communicating with Gadu-Gadu server"),
 				_("Gaim was unable to complete your request due to a problem "
 				  "communicating to the Gadu-Gadu HTTP server.  Please try again "
--- a/src/protocols/gg/libgg.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/gg/libgg.c	Wed Oct 16 19:57:03 2002 +0000
@@ -1,4 +1,4 @@
-/* $Id: libgg.c 3753 2002-10-11 03:14:01Z robflynn $ */
+/* $Id: libgg.c 3850 2002-10-16 19:57:03Z hermanator $ */
 
 /*
  *  (C) Copyright 2001 Wojtek Kaniewski <wojtekka@irc.pl>,
@@ -27,7 +27,6 @@
 #include <netdb.h>
 #include <pwd.h>
 #else
-#include <winsock.h>
 #include <fcntl.h>
 #endif
 
@@ -54,6 +53,10 @@
 #include "gaim.h"
 #include "proxy.h"
 
+#ifdef _WIN32
+#include "win32dep.h"
+#endif
+
 int gg_debug_level = (GG_DEBUG_NET | GG_DEBUG_TRAFFIC | GG_DEBUG_DUMP | GG_DEBUG_FUNCTION | GG_DEBUG_MISC);
 int gg_http_use_proxy = 0;
 int gg_http_proxy_port = 0;
@@ -68,7 +71,7 @@
 #ifdef __GNUC__
 __attribute__ ((unused))
 #endif
-= "$Id: libgg.c 3753 2002-10-11 03:14:01Z robflynn $";
+= "$Id: libgg.c 3850 2002-10-16 19:57:03Z hermanator $";
 
 #endif 
 
@@ -189,7 +192,6 @@
 
 	if (sess->recv_left < 1) {
 		while (ret != sizeh) {
-#ifndef _WIN32
 			ret = read(sess->fd, &h, sizeh);
 			gg_debug(GG_DEBUG_MISC, "-- header recv(..., %d) = %d\n", sizeh, ret);
 			if (ret < sizeh) {
@@ -198,25 +200,6 @@
 					return NULL;
 				}
 			}
-#else
-			ret = recv(sess->fd, (char*)&h, sizeh, 0);
-			gg_debug(GG_DEBUG_MISC, "-- header recv(..., %d) = %d\n", sizeh, ret);
-			if (ret < sizeh) {
-				/* connection has been gracefully closed */
-				if (ret == 0) {
-					gg_debug(GG_DEBUG_MISC, "Connection has been gracefully closed\n");
-					WSASetLastError(WSAEDISCON);
-					return NULL;
-				}
-				else if (ret == SOCKET_ERROR) {
-					if(WSAGetLastError() != WSAEINTR) {
-						gg_debug(GG_DEBUG_MISC, "-- socket error = %d\n", WSAGetLastError());
-						return NULL;
-					}
-				}
-				
-			}
-#endif
 		}
 
 		h.type = fix32(h.type);
@@ -250,17 +233,12 @@
 	}
 
 	while (size > 0) {
-#ifndef _WIN32
 		ret = read(sess->fd, buf + sizeh + offset, size);
-#else
-		ret = recv(sess->fd, buf + sizeh + offset, size, 0);
-#endif
 		gg_debug(GG_DEBUG_MISC, "-- body recv(..., %d) = %d\n", size, ret);
 		if (ret > -1 && ret <= size) {
 			offset += ret;
 			size -= ret;
 		} else if (ret == -1) {	
-#ifndef _WIN32
 			gg_debug(GG_DEBUG_MISC, "-- errno = %d (%s)\n", errno, strerror(errno));
 			if (errno == EAGAIN) {
 				gg_debug(GG_DEBUG_MISC, "-- %d bytes received, %d left\n", offset, size);
@@ -274,13 +252,6 @@
 				free(buf);
 				return NULL;
 			}
-#else
-			gg_debug(GG_DEBUG_MISC, "-- errno = %d\n", WSAGetLastError());
-			if (WSAGetLastError()!= WSAEINTR) {
-				free(buf);
-				return NULL;
-			}
-#endif
 		}
 	}
 
@@ -352,14 +323,8 @@
 	}
 
 	plen = sizeof(struct gg_header) + length + payload_length;
-#ifndef _WIN32
 	if ((res = write(sock, tmp, plen)) < plen) {
 		gg_debug(GG_DEBUG_MISC, "-- write() failed. res = %d, errno = %d (%s)\n", res, errno, strerror(errno));
-#else
-	if ((res = send(sock, tmp, plen, 0)) < plen) {
-		gg_debug(GG_DEBUG_MISC, "-- send() failed. res = %d, errno = %d\n", 
-			 res, (res == SOCKET_ERROR) ? WSAGetLastError() : 0);
-#endif
 		free(tmp);
 		return -1;
 	}
@@ -510,11 +475,7 @@
 	}
 
 	if (sess->state != GG_STATE_CONNECTED) {
-#ifndef _WIN32
 		errno = ENOTCONN;
-#else
-		WSASetLastError( WSAENOTCONN );
-#endif
 		return -1;
 	}
 
@@ -573,11 +534,7 @@
 	}
 	
 	if (sess->state != GG_STATE_CONNECTED) {
-#ifndef _WIN32
 		errno = ENOTCONN;
-#else
-		WSASetLastError( WSAENOTCONN );
-#endif
 		return -1;
 	}
 
@@ -613,11 +570,7 @@
 	}
 
 	if (sess->state != GG_STATE_CONNECTED) {
-#ifndef _WIN32
 		errno = ENOTCONN;
-#else
-		WSASetLastError( WSAENOTCONN );
-#endif
 		return -1;
 	}
 
@@ -676,11 +629,7 @@
 	}
 	
 	if (sess->state != GG_STATE_CONNECTED) {
-#ifndef _WIN32
 		errno = ENOTCONN;
-#else
-		WSASetLastError( WSAENOTCONN );
-#endif
 		return -1;
 	}
 
@@ -725,11 +674,7 @@
 	}
 
 	if (sess->state != GG_STATE_CONNECTED) {
-#ifndef _WIN32
 		errno = ENOTCONN;
-#else
-		WSASetLastError( WSAENOTCONN );
-#endif
 		return -1;
 	}
 	
@@ -761,11 +706,7 @@
 	}
 
 	if (sess->state != GG_STATE_CONNECTED) {
-#ifndef _WIN32
 		errno = ENOTCONN;
-#else
-		WSASetLastError( WSAENOTCONN );
-#endif
 		return -1;
 	}
 
@@ -983,13 +924,7 @@
 
 			gg_debug(GG_DEBUG_MISC, "== GG_STATE_CONNECTING\n");
 
-			if (sess->async && (getsockopt(sess->fd, SOL_SOCKET, SO_ERROR, 
-#ifndef _WIN32
-						       &res, 
-#else
-						       (char*)&res,
-#endif
-						       &res_size) || res)) {
+			if (sess->async && (getsockopt(sess->fd, SOL_SOCKET, SO_ERROR, &res, &res_size) || res)) {
 #if 0
 				struct in_addr *addr = (struct in_addr*) &sess->server_ip;
 				gg_debug(GG_DEBUG_MISC, "-- http connection failed, errno = %d (%s), trying direct connection\n", res, strerror(res));
@@ -1035,11 +970,7 @@
 			};
 
     			gg_debug(GG_DEBUG_MISC, "=> -----BEGIN-HTTP-QUERY-----\n%s\n=> -----END-HTTP-QUERY-----\n", buf);
-#ifndef _WIN32
 			if (write(sess->fd, buf, strlen(buf)) < strlen(buf)) {
-#else
-			if (send(sess->fd, buf, strlen(buf), 0) < strlen(buf)) {
-#endif
 				gg_debug(GG_DEBUG_MISC, "-- sending query failed\n");
 				errno = EIO;
 				e->type = GG_EVENT_CONN_FAILED;
@@ -1141,13 +1072,7 @@
 
 			gg_debug(GG_DEBUG_MISC, "== GG_STATE_CONNECTING_GG\n");
 
-			if (sess->async && (getsockopt(sess->fd, SOL_SOCKET, SO_ERROR, 
-#ifndef _WIN32
-						       &res, 
-#else
-						       (char*)&res,
-#endif
-						       &res_size) || res)) {
+			if (sess->async && (getsockopt(sess->fd, SOL_SOCKET, SO_ERROR, &res, &res_size) || res)) {
 				struct in_addr *addr = (struct in_addr*) &sess->server_ip;
 
 				gg_debug(GG_DEBUG_MISC, "-- connection failed, trying https connection\n");
@@ -1180,11 +1105,7 @@
 			gg_debug(GG_DEBUG_MISC, "== GG_STATE_READING_KEY\n");
 
 			if (!(h = gg_recv_packet(sess))) {
-#ifndef _WIN32
 				gg_debug(GG_DEBUG_MISC, "-- gg_recv_packet() failed. errno = %d (%s)\n", errno, strerror(errno));
-#else
-				gg_debug(GG_DEBUG_MISC, "-- gg_recv_packet() failed. errno = %d\n", WSAGetLastError());
-#endif
 				e->type = GG_EVENT_CONN_FAILED;
 				e->event.failure = GG_FAILURE_READING;
 				sess->state = GG_STATE_IDLE;
--- a/src/protocols/jabber/expat.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/jabber/expat.c	Wed Oct 16 19:57:03 2002 +0000
@@ -41,6 +41,10 @@
 
 #include "lib.h"
 
+#ifdef _WIN32
+#include "win32dep.h"
+#endif
+
 void expat_startElement(void* userdata, const char* name, const char** atts)
 {
     /* get the xmlnode pointed to by the userdata */
--- a/src/protocols/jabber/jabber.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/jabber/jabber.c	Wed Oct 16 19:57:03 2002 +0000
@@ -35,7 +35,6 @@
 #include <sys/utsname.h>
 #include <unistd.h>
 #else
-#include <winsock.h>
 #include "utsname.h"
 #endif
 
@@ -509,11 +508,7 @@
 	gjab_send_raw(gjc, "</stream:stream>");
 	gjc->state = JCONN_STATE_OFF;
 	gjc->was_connected = 0;
-#ifndef _WIN32
 	close(gjc->fd);
-#else
-	closesocket(gjc->fd);
-#endif
 	gjc->fd = -1;
 	XML_ParserFree(gjc->parser);
 	gjc->parser = NULL;
@@ -759,11 +754,7 @@
 	gjconn gjc;
 
 	if (!g_slist_find(connections, gc)) {
-#ifndef _WIN32
 		close(source);
-#else
-		closesocket(source);
-#endif
 		return;
 	}
 
--- a/src/protocols/jabber/jabber.h	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/jabber/jabber.h	Wed Oct 16 19:57:03 2002 +0000
@@ -28,9 +28,6 @@
 #include <arpa/inet.h>
 #include <strings.h>
 #include <unistd.h>
-#else
-#include <winsock.h>
-#include "win32dep.h"
 #endif
 
 #include <string.h>
--- a/src/protocols/jabber/jconn.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/jabber/jconn.c	Wed Oct 16 19:57:03 2002 +0000
@@ -19,6 +19,10 @@
 
 #include "jabber.h"
 
+#ifdef _WIN32
+#include "win32dep.h"
+#endif
+
 /* local macros for launching event handlers */
 #define STATE_EVT(arg) if(j->on_state) { (j->on_state)(j, (arg) ); }
 
--- a/src/protocols/jabber/jutil.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/jabber/jutil.c	Wed Oct 16 19:57:03 2002 +0000
@@ -41,6 +41,10 @@
 
 #include "lib.h"
 
+#ifdef _WIN32
+#include "win32dep.h"
+#endif
+
 /* util for making presence packets */
 xmlnode jutil_presnew(int type, char *to, char *status)
 {
--- a/src/protocols/jabber/lib.h	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/jabber/lib.h	Wed Oct 16 19:57:03 2002 +0000
@@ -16,8 +16,6 @@
 #include <unistd.h>
 #else
 #include <winsock.h>
-#include <stdlib.h>
-#include "win32dep.h"
 #endif
 
 #include <string.h>
--- a/src/protocols/jabber/libxode.h	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/jabber/libxode.h	Wed Oct 16 19:57:03 2002 +0000
@@ -9,7 +9,7 @@
 #include <resolv.h>
 #include <unistd.h>
 #else
-
+#include <winsock.h>
 #endif
 
 #include <string.h>
--- a/src/protocols/jabber/pool.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/jabber/pool.c	Wed Oct 16 19:57:03 2002 +0000
@@ -41,6 +41,9 @@
 
 #include "lib.h"
 
+#ifdef _WIN32
+#include "win32dep.h"
+#endif
 
 #ifdef POOL_DEBUG
 int pool__total = 0;
--- a/src/protocols/jabber/sha.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/jabber/sha.c	Wed Oct 16 19:57:03 2002 +0000
@@ -22,6 +22,10 @@
 
 #include "lib.h"
 
+#ifdef _WIN32
+#include "win32dep.h"
+#endif
+
 static void shaHashBlock(j_SHA_CTX *ctx);
 
 void shaInit(j_SHA_CTX *ctx) {
--- a/src/protocols/jabber/socket.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/jabber/socket.c	Wed Oct 16 19:57:03 2002 +0000
@@ -41,6 +41,10 @@
 
 #include "lib.h"
 
+#ifdef _WIN32
+#include "win32dep.h"
+#endif
+
 /* socket.c
  *
  * Simple wrapper to make socket creation easy.
--- a/src/protocols/jabber/str.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/jabber/str.c	Wed Oct 16 19:57:03 2002 +0000
@@ -41,6 +41,10 @@
 
 #include "lib.h"
 
+#ifdef _WIN32
+#include "win32dep.h"
+#endif
+
 char *j_strdup(const char *str)
 {
     if(str == NULL)
--- a/src/protocols/oscar/conn.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/oscar/conn.c	Wed Oct 16 19:57:03 2002 +0000
@@ -14,8 +14,10 @@
 #include <netdb.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
-#else
-#include <winsock.h>
+#endif
+
+#ifdef _WIN32
+#include "win32dep.h"
 #endif
 
 /*
@@ -319,11 +321,7 @@
 {
 
 	if (deadconn->fd >= 3)
-#ifndef _WIN32
 		close(deadconn->fd);
-#else
-		closesocket(deadconn->fd);
-#endif
 	deadconn->fd = -1;
 	if (deadconn->handlerlist)
 		aim_clearhandlers(deadconn);
@@ -435,11 +433,7 @@
 		fd = socket(hp->h_addrtype, SOCK_STREAM, 0);
 		if (connect(fd, (struct sockaddr *)&sa, sizeof(struct sockaddr_in)) < 0) {
 			faimdprintf(sess, 0, "proxyconnect: unable to connect to proxy\n");
-#ifndef _WIN32
 			close(fd);
-#else
-			closesocket(fd);
-#endif
 			return -1;
 		}
 
@@ -455,40 +449,20 @@
 			buf[2] = 0x00;
 			i = 3;
 		}
-#ifndef _WIN32
 		if (write(fd, buf, i) < i) {
-#else
-		if (send(fd, buf, i, 0) < i) {
-#endif
 			*statusret = errno;
-#ifndef _WIN32
 			close(fd);
-#else
-			closesocket(fd);
-#endif
 			return -1;
 		}
-#ifndef _WIN32
 		if (read(fd, buf, 2) < 2) {
-#else
-		if (recv(fd, buf, 2, 0) < 2) {
-#endif
 			*statusret = errno;
-#ifndef _WIN32
 			close(fd);
-#else
-			closesocket(fd);
-#endif
 			return -1;
 		}
 
 		if ((buf[0] != 0x05) || (buf[1] == 0xff)) {
 			*statusret = EINVAL;
-#ifndef _WIN32
 			close(fd);
-#else
-			closesocket(fd);
-#endif
 			return -1;
 		}
 
@@ -499,39 +473,19 @@
 			i += aimutil_putstr(buf+i, sess->socksproxy.username, strlen(sess->socksproxy.username));
 			i += aimutil_put8(buf+i, strlen(sess->socksproxy.password));
 			i += aimutil_putstr(buf+i, sess->socksproxy.password, strlen(sess->socksproxy.password));
-#ifndef _WIN32
 			if (write(fd, buf, i) < i) {
-#else
-			if (send(fd, buf, i, 0) < i) {
-#endif
 				*statusret = errno;
-#ifndef _WIN32
 				close(fd);
-#else
-				closesocket(fd);
-#endif
 				return -1;
 			}
-#ifndef _WIN32
 			if (read(fd, buf, 2) < 2) {
-#else
-			if (recv(fd, buf, 2, 0) < 2) {
-#endif
 				*statusret = errno;
-#ifndef _WIN32
 				close(fd);
-#else
-				closesocket(fd);
-#endif
 				return -1;
 			}
 			if ((buf[0] != 0x01) || (buf[1] != 0x00)) {
 				*statusret = EINVAL;
-#ifndef _WIN32
 				close(fd);
-#else
-				closesocket(fd);
-#endif
 				return -1;
 			}
 		}
@@ -543,49 +497,28 @@
 		i += aimutil_put8(buf+i, strlen(host));
 		i += aimutil_putstr(buf+i, host, strlen(host));
 		i += aimutil_put16(buf+i, port);
-#ifndef _WIN32
+
 		if (write(fd, buf, i) < i) {
-#else
-		if (send(fd, buf, i, 0) < i) {
-#endif
 			*statusret = errno;
-#ifndef _WIN32
 			close(fd);
-#else
-			closesocket(fd);
-#endif
 			return -1;
 		}
-#ifndef _WIN32
+
 		if (read(fd, buf, 10) < 10) {
-#else
-		if (recv(fd, buf, 10, 0) < 10) {
-#endif
 			*statusret = errno;
-#ifndef _WIN32
 			close(fd);
-#else
-			closesocket(fd);
-#endif
 			return -1;
 		}
 		if ((buf[0] != 0x05) || (buf[1] != 0x00)) {
 			*statusret = EINVAL;
-#ifndef _WIN32
 			close(fd);
-#else
-			closesocket(fd);
-#endif
 			return -1;
 		}
 
 	} else { /* connecting directly */
 		struct sockaddr_in sa;
 		struct hostent *hp;
-#ifdef _WIN32
-		int imode = 1;
-		int w_errno = 0;
-#endif
+
 		if (!(hp = gethostbyname(host))) {
 			*statusret = (h_errno | AIM_CONN_STATUS_RESOLVERR);
 			return -1;
@@ -599,29 +532,17 @@
 		fd = socket(hp->h_addrtype, SOCK_STREAM, 0);
 
 		if (sess->flags & AIM_SESS_FLAGS_NONBLOCKCONNECT)
-#ifndef _WIN32
 			fcntl(fd, F_SETFL, O_NONBLOCK); /* XXX save flags */
-#else
-			ioctlsocket(fd, FIONBIO, (unsigned long *)&imode);
-#endif
+
 		if (connect(fd, (struct sockaddr *)&sa, sizeof(struct sockaddr_in)) < 0) {
 			if (sess->flags & AIM_SESS_FLAGS_NONBLOCKCONNECT) {
-#ifndef _WIN32
 				if ((errno == EINPROGRESS) || (errno == EINTR)) {
-#else
-				w_errno = WSAGetLastError();
-				if ((w_errno == WSAEINPROGRESS) || (w_errno == WSAEINTR)) {
-#endif
 					if (statusret)
 						*statusret |= AIM_CONN_STATUS_INPROGRESS;
 					return fd;
 				}
 			}
-#ifndef _WIN32
 			close(fd);
-#else
-			closesocket(fd);
-#endif
 			fd = -1;
 		}
 	}
@@ -1073,11 +994,8 @@
 	fd_set fds, wfds;
 	struct timeval tv;
 	int res;
-#ifndef _WIN32
 	int error = ETIMEDOUT;
-#else
-	int error = 0;
-#endif
+
 	aim_rxcallback_t userfunc;
 
 	if (!conn || (conn->fd == -1))
@@ -1094,11 +1012,7 @@
 	tv.tv_usec = 0;
 
 	if ((res = select(conn->fd+1, &fds, &wfds, NULL, &tv)) == -1) {
-#ifndef _WIN32
 		error = errno;
-#else
-		error = WSAGetLastError();
-#endif
 		aim_conn_close(conn);
 		errno = error;
 		return -1;
@@ -1109,13 +1023,8 @@
 
 	if (FD_ISSET(conn->fd, &fds) || FD_ISSET(conn->fd, &wfds)) {
 		int len = sizeof(error);
-#ifndef _WIN32
 		if (getsockopt(conn->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0)
 			error = errno;
-#else
-		if (getsockopt(conn->fd, SOL_SOCKET, SO_ERROR, (char*)&error, &len) < 0)
-			error = WSAGetLastError();
-#endif
 	}
 
 	if (error) {
@@ -1123,9 +1032,8 @@
 		errno = error;
 		return -1;
 	}
-#ifndef _WIN32
 	fcntl(conn->fd, F_SETFL, 0); /* XXX should restore original flags */
-#endif
+
 	conn->status &= ~AIM_CONN_STATUS_INPROGRESS;
 
 	if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE)))
--- a/src/protocols/oscar/ft.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/oscar/ft.c	Wed Oct 16 19:57:03 2002 +0000
@@ -62,21 +62,13 @@
 		return 0; /* not an error */
 
 	if (cliaddr.sa_family != AF_INET) { /* just in case IPv6 really is happening */
-#ifndef _WIN32
 		close(acceptfd);
-#else
-		closesocket(acceptfd);
-#endif
 		aim_conn_close(cur);
 		return -1;
 	} 
 
 	if (!(newconn = aim_cloneconn(sess, cur))) {
-#ifndef _WIN32
 		close(acceptfd);
-#else
-		closesocket(acceptfd);
-#endif
 		aim_conn_close(cur);
 		return -1;
 	}
@@ -342,11 +334,7 @@
 
 	/* XXX switch to aim_cloneconn()? */
 	if (!(newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS_OUT, NULL))) {
-#ifndef _WIN32
 		close(listenfd);
-#else
-		closesocket(listenfd);
-#endif
 		return NULL;
 	}
 
@@ -417,11 +405,7 @@
 	aim_cachecookie(sess, cookie);
 
 	if (!(newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS_OUT, NULL))) {
-#ifndef _WIN32
 		close(listenfd);
-#else
-		closesocket(listenfd);
-#endif
 		return NULL;
 	}
 
@@ -945,11 +929,7 @@
 		if (bind(listenfd, res->ai_addr, res->ai_addrlen) == 0)
 			break;
 		/* success */
-#ifndef _WIN32
 		close(listenfd);
-#else
-		closesocket(listenfd);
-#endif
 	} while ( (res = res->ai_next) );
 
 	if (!res)
@@ -968,9 +948,6 @@
 	int listenfd;
 	const int on = 1;
 	struct sockaddr_in sockin;
-#ifdef _WIN32
-	u_long imode;
-#endif
 
 	if ((listenfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
 		perror("socket(listenfd)");
@@ -979,11 +956,7 @@
 
 	if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) != 0) {
 		perror("setsockopt(listenfd)");
-#ifndef _WIN32
 		close(listenfd);
-#else
-		closesocket(listenfd);
-#endif
 		return -1;
 	} 
 
@@ -993,28 +966,15 @@
 
 	if (bind(listenfd, (struct sockaddr *)&sockin, sizeof(struct sockaddr_in)) != 0) {
 		perror("bind(listenfd)");
-#ifndef _WIN32
 		close(listenfd);
-#else
-		closesocket(listenfd);
-#endif
 		return -1;
 	}
 	if (listen(listenfd, 4) != 0) {
 		perror("listen(listenfd)");
-#ifndef _WIN32
 		close(listenfd);
-#else
-		closesocket(listenfd);
-#endif
 		return -1;
 	}
-#ifndef _WIN32
 	fcntl(listenfd, F_SETFL, O_NONBLOCK);
-#else
-	imode = 1;
-	ioctlsocket(listenfd, FIONBIO, &imode);
-#endif
 	return listenfd;
 #endif
 } 
--- a/src/protocols/oscar/oscar.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/protocols/oscar/oscar.c	Wed Oct 16 19:57:03 2002 +0000
@@ -34,8 +34,6 @@
 #include <arpa/inet.h>
 #include <sys/socket.h>
 #include <unistd.h>
-#else
-#include <winsock.h>
 #endif
 
 #include <errno.h>
@@ -592,11 +590,7 @@
 	aim_conn_t *conn;
 
 	if (!g_slist_find(connections, gc)) {
-#ifndef _WIN32
 		close(source);
-#else
-		closesocket(source);
-#endif
 		return;
 	}
 
@@ -745,11 +739,7 @@
 	aim_conn_t *bosconn;
 
 	if (!g_slist_find(connections, gc)) {
-#ifndef _WIN32
 		close(source);
-#else
-		closesocket(source);
-#endif
 		return;
 	}
 
@@ -943,11 +933,7 @@
 	int x = 0;
 	unsigned char m[17];
 
-#ifndef _WIN32
 	while (read(pos->fd, &in, 1) == 1) {
-#else
-	while (recv(pos->fd, &in, 1, 0) == 1) {
-#endif
 		if (in == '\n')
 			x++;
 		else if (in != '\r')
@@ -961,30 +947,18 @@
 				_("You may be disconnected shortly.  You may want to use TOC until "
 				  "this is fixed.  Check " WEBSITE " for updates."), GAIM_WARNING);
 		gaim_input_remove(pos->inpa);
-#ifndef _WIN32
 		close(pos->fd);
-#else
-		closesocket(pos->fd);
-#endif
 		g_free(pos);
 		return;
 	}
-#ifndef _WIN32
 	read(pos->fd, m, 16);
-#else
-	recv(pos->fd, m, 16, 0);
-#endif
 	m[16] = '\0';
 	debug_printf("Sending hash: ");
 	for (x = 0; x < 16; x++)
 		debug_printf("%02x ", (unsigned char)m[x]);
 	debug_printf("\n");
 	gaim_input_remove(pos->inpa);
-#ifndef _WIN32
 	close(pos->fd);
-#else
-	closesocket(pos->fd);
-#endif
 	aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH);
 	g_free(pos);
 }
@@ -1006,11 +980,7 @@
 	g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA
 			"?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n",
 			pos->offset, pos->len, pos->modname ? pos->modname : "");
-#ifndef _WIN32
 	write(pos->fd, buf, strlen(buf));
-#else
-	send(pos->fd, buf, strlen(buf), 0);
-#endif
 	if (pos->modname)
 		g_free(pos->modname);
 	pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos);
@@ -1164,11 +1134,7 @@
 	aim_conn_t *tstconn;
 
 	if (!g_slist_find(connections, gc)) {
-#ifndef _WIN32
 		close(source);
-#else
-		closesocket(source);
-#endif
 		return;
 	}
 
@@ -1196,11 +1162,7 @@
 	aim_conn_t *tstconn;
 
 	if (!g_slist_find(connections, gc)) {
-#ifndef _WIN32
 		close(source);
-#else
-		closesocket(source);
-#endif
 		return;
 	}
 
@@ -1229,11 +1191,7 @@
 	aim_conn_t *tstconn;
 
 	if (!g_slist_find(connections, gc)) {
-#ifndef _WIN32
 		close(source);
-#else
-		closesocket(source);
-#endif
 		g_free(ccon->show);
 		g_free(ccon->name);
 		g_free(ccon);
@@ -3384,12 +3342,7 @@
 	} else if (len != -1) {
 		/* Trying to send an IM image outside of a direct connection. */
 		oscar_ask_direct_im(gc, name);
-#ifndef _WIN32
 		return -ENOTCONN;
-#else
-		WSASetLastError( WSAENOTCONN );
-		return SOCKET_ERROR;
-#endif
 	}
 	if (imflags & IM_FLAG_AWAY) {
 		ret = aim_send_im(odata->sess, name, AIM_IMFLAGS_AWAY, message);
--- a/src/proxy.c	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/proxy.c	Wed Oct 16 19:57:03 2002 +0000
@@ -133,20 +133,11 @@
 {
 	static struct sockaddr_in sin;
 
-#ifndef _WIN32
 	if (!inet_aton(host, &sin.sin_addr)) {
-#else
-	if ((sin.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE) {
-#endif
 		struct hostent *hp;
 		if(!(hp = gethostbyname(host))) {
-#ifndef _WIN32
 			debug_printf("gaim_gethostbyname(\"%s\", %d) failed: %s",
 				     host, port, hstrerror(h_errno));
-#else
-			debug_printf("gaim_gethostbyname(\"%s\", %d) failed: Error %d",
-				     host, port, WSAGetLastError());
-#endif
 			return NULL;
 		}
 		memset(&sin, 0, sizeof(struct sockaddr_in));
@@ -163,26 +154,10 @@
 {
 	struct PHB *phb = data;
 	unsigned int len;
-#ifdef _WIN32
-	int werror = WSAETIMEDOUT;
-	u_long imode;
-#else
 	int error = ETIMEDOUT;
-#endif 
+
 	debug_printf("Connected\n");
-#ifdef _WIN32
-	len = sizeof(werror);
-	if (getsockopt(source, SOL_SOCKET, SO_ERROR, (char*)&werror, &len) < 0) {
-		closesocket(source);
-		gaim_input_remove(phb->inpa);
-		phb->func(phb->data, -1, GAIM_INPUT_READ);
-		g_free(phb);
-		return;
-	} else
-		WSASetLastError(werror);
-	imode=0;
-	ioctlsocket(source, FIONBIO, &imode);
-#else
+
 	len = sizeof(error);
 	if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
 		close(source);
@@ -192,7 +167,6 @@
 		return;
 	}
 	fcntl(source, F_SETFL, 0);
-#endif
 	gaim_input_remove(phb->inpa);
 	phb->func(phb->data, source, GAIM_INPUT_READ);
 	g_free(phb);
@@ -213,10 +187,7 @@
 {
 	struct sockaddr_in *sin;
 	int fd = -1;
-#ifdef _WIN32
-	u_long imode;
-	int w_errno;
-#endif
+
 	debug_printf("connecting to %s:%d with no proxy\n", host, port);
 
 	if (!(sin = gaim_gethostbyname(host, port))) {
@@ -230,50 +201,19 @@
 		g_free(phb);
 		return -1;
 	}
-#ifdef _WIN32
-	imode=1;
-	ioctlsocket(fd, FIONBIO, &imode);
-#else
 	fcntl(fd, F_SETFL, O_NONBLOCK);
-#endif
+
 	if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0) {
-#ifdef _WIN32
-		w_errno = WSAGetLastError();
-		if ((w_errno == WSAEINPROGRESS) || (w_errno == WSAEINTR) || (w_errno == WSAEWOULDBLOCK)) {
-#else
 		if ((errno == EINPROGRESS) || (errno == EINTR)) {
-#endif
 			debug_printf("Connect would have blocked\n");
 			phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, no_one_calls, phb);
 		} else {
-#ifdef _WIN32
-			debug_printf("connect failed (errno %d)\n", w_errno);
-			closesocket(fd);
-#else
 			debug_printf("connect failed (errno %d)\n", errno);
 			close(fd);
-#endif
 			g_free(phb);
 			return -1;
 		}
 	} else {
-#ifdef _WIN32
-		int werror = WSAETIMEDOUT;
-		unsigned int len;
-		u_long imode;
-
-		debug_printf("Connect didn't block\n");
-		len = sizeof(werror);
-		if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (char*)&werror, &len) < 0) {
-			debug_printf("getsockopt failed\n");
-			closesocket(fd);
-			g_free(phb);
-			return -1;
-		} else
-			WSASetLastError(werror);
-		imode=0;
-		ioctlsocket(fd, FIONBIO, &imode);
-#else
 		unsigned int len;
 		int error = ETIMEDOUT;
 		debug_printf("Connect didn't block\n");
@@ -285,7 +225,6 @@
 			return -1;
 		}
 		fcntl(fd, F_SETFL, 0);
-#endif
 		phb->port = fd;	/* bleh */
 		g_timeout_add(50, clean_connect, phb);	/* we do this because we never
 							   want to call our callback
@@ -307,11 +246,7 @@
 
 	gaim_input_remove(phb->inpa);
 
-#ifdef _WIN32
-	while ((nlc != 2) && (recv(source, &inputline[pos++], 1, 0) == 1)) {
-#else
 	while ((nlc != 2) && (read(source, &inputline[pos++], 1) == 1)) {
-#endif
 		if (inputline[pos - 1] == '\n')
 			nlc++;
 		else if (inputline[pos - 1] != '\r')
@@ -329,11 +264,7 @@
 		return;
 	}
 
-#ifdef _WIN32
-	closesocket(source);
-#else
 	close(source);
-#endif
 	phb->func(phb->data, -1, GAIM_INPUT_READ);
 	g_free(phb->host);
 	g_free(phb);
@@ -345,44 +276,24 @@
 	char cmd[384];
 	struct PHB *phb = data;
 	unsigned int len;
-#ifdef _WIN32
-	int w_error = WSAETIMEDOUT;
-	u_long imode = 0;
-#else
 	int error = ETIMEDOUT;
-#endif
+
 	debug_printf("Connected\n");
 	if (phb->inpa > 0)
 		gaim_input_remove(phb->inpa);
-#ifdef _WIN32
-	len = sizeof(w_error);
-	if (getsockopt(source, SOL_SOCKET, SO_ERROR, (char*)&w_error, &len) < 0) {
-		closesocket(source);
-#else
 	len = sizeof(error);
 	if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
 		close(source);
-#endif
 		phb->func(phb->data, -1, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
 		return;
-#ifdef _WIN32
-	} else
-		WSASetLastError( w_error );
-	ioctlsocket(source, FIONBIO, &imode);
-#else
 	}
 	fcntl(source, F_SETFL, 0);
-#endif
 	g_snprintf(cmd, sizeof(cmd), "CONNECT %s:%d HTTP/1.1\r\nHost: %s:%d\r\n", phb->host, phb->port,
 		   phb->host, phb->port);
 	if (send(source, cmd, strlen(cmd), 0) < 0) {
-#ifdef _WIN32
-		closesocket(source);
-#else
 		close(source);
-#endif
 		phb->func(phb->data, -1, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
@@ -397,11 +308,7 @@
 		g_snprintf(cmd, sizeof(cmd), "Proxy-Authorization: Basic %s\r\n", t2);
 		g_free(t2);
 		if (send(source, cmd, strlen(cmd), 0) < 0) {
-#ifdef _WIN32
-			closesocket(source);
-#else
 			close(source);
-#endif
 			phb->func(phb->data, -1, GAIM_INPUT_READ);
 			g_free(phb->host);
 			g_free(phb);
@@ -411,11 +318,7 @@
 
 	g_snprintf(cmd, sizeof(cmd), "\r\n");
 	if (send(source, cmd, strlen(cmd), 0) < 0) {
-#ifdef _WIN32
-		closesocket(source);
-#else
 		close(source);
-#endif
 		phb->func(phb->data, -1, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
@@ -429,9 +332,7 @@
 {
 	struct sockaddr_in *sin;
 	int fd = -1;
-#ifdef _WIN32
 	u_long imode;
-#endif
 
 	debug_printf("connecting to %s:%d via %s:%d using HTTP\n", host, port, proxyhost, proxyport);
 
@@ -448,61 +349,31 @@
 	phb->host = g_strdup(host);
 	phb->port = port;
 
-#ifdef _WIN32
-	imode = 1;
-	ioctlsocket(fd, FIONBIO, &imode); 
-#else
 	fcntl(fd, F_SETFL, O_NONBLOCK);
-#endif
+
 	if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0) {
-#ifdef _WIN32
-		int w_errno = WSAGetLastError();
-		if ((w_errno == WSAEINPROGRESS) || (w_errno == WSAEINTR)) {
-#else
 		if ((errno == EINPROGRESS) || (errno == EINTR)) {
-#endif
 			debug_printf("Connect would have blocked\n");
 			phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, http_canwrite, phb);
 		} else {
-#ifdef _WIN32
-			closesocket(fd);
-#else
 			close(fd);
-#endif
 			g_free(phb->host);
 			g_free(phb);
 			return -1;
 		}
 	} else {
 		unsigned int len;
-#ifdef _WIN32
-		int werror = WSAETIMEDOUT;
-		u_long imode;
-#else
 		int error = ETIMEDOUT;
-#endif
+
 		debug_printf("Connect didn't block\n");
-#ifdef _WIN32
-		len = sizeof(werror);
-		if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (char*)&werror, &len) < 0) {
-			closesocket(fd);
-#else
 		len = sizeof(error);
 		if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
 			close(fd);
-#endif
 			g_free(phb->host);
 			g_free(phb);
 			return -1;
-#ifdef _WIN32
-		} else
-			WSASetLastError(werror);
-		imode=0;
-		ioctlsocket(fd, FIONBIO, &imode);
-#else
 		}
 		fcntl(fd, F_SETFL, 0);
-#endif
 		http_canwrite(phb, fd, GAIM_INPUT_WRITE);
 	}
 
@@ -517,22 +388,15 @@
 	gaim_input_remove(phb->inpa);
 
 	memset(packet, 0, sizeof(packet));
-#ifdef _WIN32
-	if (recv(source, packet, 9, 0) >= 4 && packet[1] == 90) {
-#else
+
 	if (read(source, packet, 9) >= 4 && packet[1] == 90) {
-#endif
 		phb->func(phb->data, source, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
 		return;
 	}
 
-#ifdef _WIN32
-	closesocket(source);
-#else
 	close(source);
-#endif
 	phb->func(phb->data, -1, GAIM_INPUT_READ);
 	g_free(phb->host);
 	g_free(phb);
@@ -544,44 +408,24 @@
 	struct hostent *hp;
 	struct PHB *phb = data;
 	unsigned int len;
-#ifdef _WIN32
-	int werror = WSAETIMEDOUT;
-	u_long imode;
-#else
 	int error = ETIMEDOUT;
-#endif
+
 	debug_printf("Connected\n");
 	if (phb->inpa > 0)
 		gaim_input_remove(phb->inpa);
-#ifdef _WIN32
-	len = sizeof(werror);
-	if (getsockopt(source, SOL_SOCKET, SO_ERROR, (char*)&werror, &len) < 0) {
-		closesocket(source);
-#else
 	len = sizeof(error);
 	if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
 		close(source);
-#endif
 		phb->func(phb->data, -1, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
 		return;
-#ifdef _WIN32
-	} else
-		WSASetLastError(werror);
-	imode=0;
-	ioctlsocket(source, FIONBIO, &imode);
-#else
 	}
 	fcntl(source, F_SETFL, 0);
-#endif
+
 	/* XXX does socks4 not support host name lookups by the proxy? */
 	if (!(hp = gethostbyname(phb->host))) {
-#ifdef _WIN32
-		closesocket(source);
-#else
 		close(source);
-#endif
 		phb->func(phb->data, -1, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
@@ -597,13 +441,9 @@
 	packet[6] = (unsigned char)(hp->h_addr_list[0])[2];
 	packet[7] = (unsigned char)(hp->h_addr_list[0])[3];
 	packet[8] = 0;
-#ifdef _WIN32
-	if (send(source, packet, 9, 0) != 9) {
-		closesocket(source);
-#else
+
 	if (write(source, packet, 9) != 9) {
 		close(source);
-#endif
 		phb->func(phb->data, -1, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
@@ -617,10 +457,6 @@
 {
 	struct sockaddr_in *sin;
 	int fd = -1;
-#ifdef _WIN32
-	int werrno;
-	u_long imode;
-#endif
 
 	debug_printf("connecting to %s:%d via %s:%d using SOCKS4\n", host, port, proxyhost, proxyport);
 
@@ -637,61 +473,30 @@
 	phb->host = g_strdup(host);
 	phb->port = port;
 
-#ifdef _WIN32
-	imode=1;
-	ioctlsocket(fd, FIONBIO, &imode);
-#else
 	fcntl(fd, F_SETFL, O_NONBLOCK);
-#endif
 	if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0) {
-#ifdef _WIN32
-		werrno = WSAGetLastError();
-		if ((werrno == WSAEINPROGRESS) || (werrno == WSAEINTR)) {
-#else
 		if ((errno == EINPROGRESS) || (errno == EINTR)) {
-#endif
 			debug_printf("Connect would have blocked\n");
 			phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s4_canwrite, phb);
 		} else {
-#ifdef _WIN32
-			closesocket(fd);
-#else
 			close(fd);
-#endif
 			g_free(phb->host);
 			g_free(phb);
 			return -1;
 		}
 	} else {
 		unsigned int len;
-#ifdef _WIN32
-		int werror = WSAETIMEDOUT;
-		u_long imode;
-#else
 		int error = ETIMEDOUT;
-#endif
+
 		debug_printf("Connect didn't block\n");
-#ifdef _WIN32
-		len = sizeof(werror);
-		if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (char*)&werror, &len) < 0) {
-			closesocket(fd);
-#else
 		len = sizeof(error);
 		if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
 			close(fd);
-#endif
 			g_free(phb->host);
 			g_free(phb);
 			return -1;
-#ifdef _WIN32
-		} else
-			WSASetLastError(werror);
-		imode=0;
-		ioctlsocket(fd, FIONBIO, &imode);
-#else
 		}
 		fcntl(fd, F_SETFL, 0);
-#endif
 		s4_canwrite(phb, fd, GAIM_INPUT_WRITE);
 	}
 
@@ -706,17 +511,9 @@
 	gaim_input_remove(phb->inpa);
 	debug_printf("able to read again\n");
 
-#ifdef _WIN32
-	if (recv(source, buf, 10, 0) < 10) {
-#else
 	if (read(source, buf, 10) < 10) {
-#endif
 		debug_printf("or not...\n");
-#ifdef _WIN32
-		closesocket(source);
-#else
 		close(source);
-#endif
 		phb->func(phb->data, -1, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
@@ -724,11 +521,7 @@
 	}
 	if ((buf[0] != 0x05) || (buf[1] != 0x00)) {
 		debug_printf("bad data\n");
-#ifdef _WIN32
-		closesocket(source);
-#else
 		close(source);
-#endif
 		phb->func(phb->data, -1, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
@@ -756,13 +549,8 @@
 	buf[5 + strlen(phb->host)] = phb->port >> 8;
 	buf[5 + strlen(phb->host) + 1] = phb->port & 0xff;
 
-#ifdef _WIN32
-	if (send(source, buf, (5 + strlen(phb->host) + 2), 0) < (5 + strlen(phb->host) + 2)) {
-		closesocket(source);
-#else
 	if (write(source, buf, (5 + strlen(phb->host) + 2)) < (5 + strlen(phb->host) + 2)) {
 		close(source);
-#endif
 		phb->func(phb->data, -1, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
@@ -780,13 +568,8 @@
 	gaim_input_remove(phb->inpa);
 	debug_printf("got auth response\n");
 
-#ifdef _WIN32
-	if (recv(source, buf, 2, 0) < 2) {
-		closesocket(source);
-#else
 	if (read(source, buf, 2) < 2) {
 		close(source);
-#endif
 		phb->func(phb->data, -1, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
@@ -794,11 +577,7 @@
 	}
 
 	if ((buf[0] != 0x01) || (buf[1] != 0x00)) {
-#ifdef _WIN32
-		closesocket(source);
-#else
 		close(source);
-#endif
 		phb->func(phb->data, -1, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
@@ -816,13 +595,8 @@
 	gaim_input_remove(phb->inpa);
 	debug_printf("able to read\n");
 
-#ifdef _WIN32
-	if (recv(source, buf, 2, 0) < 2) {
-		closesocket(source);
-#else
 	if (read(source, buf, 2) < 2) {
 		close(source);
-#endif
 		phb->func(phb->data, -1, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
@@ -830,11 +604,7 @@
 	}
 
 	if ((buf[0] != 0x05) || (buf[1] == 0xff)) {
-#ifdef _WIN32
-		closesocket(source);
-#else
 		close(source);
-#endif
 		phb->func(phb->data, -1, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
@@ -848,13 +618,9 @@
 		memcpy(buf + 2, proxyuser, i);
 		buf[2 + i] = j;
 		memcpy(buf + 2 + i + 1, proxypass, j);
-#ifdef _WIN32
-		if (send(source, buf, 3 + i + j, 0) < 3 + i + j) {
-			closesocket(source);
-#else
+
 		if (write(source, buf, 3 + i + j) < 3 + i + j) {
 			close(source);
-#endif
 			phb->func(phb->data, -1, GAIM_INPUT_READ);
 			g_free(phb->host);
 			g_free(phb);
@@ -873,37 +639,20 @@
 	int i;
 	struct PHB *phb = data;
 	unsigned int len;
-#ifdef _WIN32
-	int werror = WSAETIMEDOUT;
-	u_long imode;
-#else
 	int error = ETIMEDOUT;
-#endif
+
 	debug_printf("Connected\n");
 	if (phb->inpa > 0)
 		gaim_input_remove(phb->inpa);
-#ifdef _WIN32
-	len = sizeof(werror);
-	if (getsockopt(source, SOL_SOCKET, SO_ERROR, (char*)&werror, &len) < 0) {
-		closesocket(source);
-#else
 	len = sizeof(error);
 	if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
 		close(source);
-#endif
 		phb->func(phb->data, -1, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
 		return;
-#ifdef _WIN32
-	} else
-		WSASetLastError(werror);
-	imode=0;
-	ioctlsocket(source, FIONBIO, &imode);
-#else
 	}
 	fcntl(source, F_SETFL, 0);
-#endif
 
 	i = 0;
 	buf[0] = 0x05;		/* SOCKS version 5 */
@@ -917,17 +666,10 @@
 		buf[2] = 0x00;
 		i = 3;
 	}
-#ifdef _WIN32
-	if (send(source, buf, i, 0) < i) {
-#else
+
 	if (write(source, buf, i) < i) {
-#endif
 		debug_printf("unable to write\n");
-#ifdef _WIN32
-		closesocket(source);
-#else
 		close(source);
-#endif
 		phb->func(phb->data, -1, GAIM_INPUT_READ);
 		g_free(phb->host);
 		g_free(phb);
@@ -941,10 +683,6 @@
 {
 	struct sockaddr_in *sin;
 	int fd = -1;
-#ifdef _WIN32
-	u_long imode;
-	int werrno;
-#endif
 
 	debug_printf("connecting to %s:%d via %s:%d using SOCKS5\n", host, port, proxyhost, proxyport);
 
@@ -961,60 +699,30 @@
 	phb->host = g_strdup(host);
 	phb->port = port;
 
-#ifdef _WIN32
-	imode=1;
-	ioctlsocket(fd, FIONBIO, &imode);
-#else
 	fcntl(fd, F_SETFL, O_NONBLOCK);
-#endif
 	if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0) {
-#ifdef _WIN32
-		werrno = WSAGetLastError();
-		if ((werrno == WSAEINPROGRESS) || (werrno == WSAEINTR)) {
-#else
 		if ((errno == EINPROGRESS) || (errno == EINTR)) {
-#endif
 			debug_printf("Connect would have blocked\n");
 			phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s5_canwrite, phb);
 		} else {
-#ifdef _WIN32
-			closesocket(fd);
-#else
 			close(fd);
-#endif
 			g_free(phb->host);
 			g_free(phb);
 			return -1;
 		}
 	} else {
 		unsigned int len;
-#ifdef _WIN32
-		int werror = WSAETIMEDOUT;
-#else
 		int error = ETIMEDOUT;
-#endif
+
 		debug_printf("Connect didn't block\n");
-#ifdef _WIN32
-		len = sizeof(werror);
-		if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (char*)&werror, &len) < 0) {
-			closesocket(fd);
-#else
 		len = sizeof(error);
 		if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
 			close(fd);
-#endif
 			g_free(phb->host);
 			g_free(phb);
 			return -1;
-#ifdef _WIN32
-		} else
-			WSASetLastError(werror);
-		imode=0;
-		ioctlsocket(fd, FIONBIO, &imode);
-#else
 		}
 		fcntl(fd, F_SETFL, 0);
-#endif
 		s5_canwrite(phb, fd, GAIM_INPUT_WRITE);
 	}
 
--- a/src/ui.h	Wed Oct 16 19:44:19 2002 +0000
+++ b/src/ui.h	Wed Oct 16 19:57:03 2002 +0000
@@ -358,6 +358,7 @@
 extern void docklet_add();
 extern void docklet_remove();
 extern void docklet_toggle();
+extern GtkWidget *gaim_new_item(GtkWidget *, const char *);
 
 /* Functions in buddy_chat.c */
 extern void join_chat();