Index: .bzrignore
===================================================================
--- .bzrignore	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ .bzrignore	(revision b6cd9e9fe0aa86e83fc4a43b3db2240839e2103a)
@@ -2,13 +2,4 @@
 config.h
 bitlbee
-Debug
-Debugx
-deps
-admin/Debug
-admin/admin.plg
-bitlbee.plg
-*.plg
-*.aps
-*.clw
 user-guide.txt
 user-guide.html
Index: Makefile
===================================================================
--- Makefile	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ Makefile	(revision b6cd9e9fe0aa86e83fc4a43b3db2240839e2103a)
@@ -10,13 +10,7 @@
 
 # Program variables
-objects = account.o bitlbee.o crypting.o help.o ipc.o irc.o irc_commands.o nick.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS) user.o
+objects = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS) unix.o user.o
 headers = account.h bitlbee.h commands.h conf.h config.h crypting.h help.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h user.h lib/events.h lib/http_client.h lib/ini.h lib/md5.h lib/misc.h lib/proxy.h lib/sha1.h lib/ssl_client.h lib/url.h protocols/nogaim.h
 subdirs = lib protocols
-
-ifeq ($(TARGET),i586-mingw32msvc)
-objects += win32.o
-else
-objects += unix.o conf.o log.o
-endif
 
 # Expansion of variables
Index: bitlbee.c
===================================================================
--- bitlbee.c	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ bitlbee.c	(revision b6cd9e9fe0aa86e83fc4a43b3db2240839e2103a)
@@ -123,5 +123,4 @@
 		ipc_master_listen_socket();
 	
-#ifndef _WIN32
 	if( ( fp = fopen( global.conf->pidfile, "w" ) ) )
 	{
@@ -133,5 +132,4 @@
 		log_message( LOGLVL_WARNING, "Warning: Couldn't write PID to `%s'", global.conf->pidfile );
 	}
-#endif
 	
 	return( 0 );
@@ -142,4 +140,7 @@
 	if( !irc_new( 0 ) )
 		return( 1 );
+	
+	log_link( LOGLVL_ERROR, LOGOUTPUT_IRC );
+	log_link( LOGLVL_WARNING, LOGOUTPUT_IRC );
 	
 	return( 0 );
@@ -253,4 +254,5 @@
 	struct sockaddr_in conn_info;
 	int new_socket = accept( global.listen_socket, (struct sockaddr *) &conn_info, &size );
+	pid_t client_pid = 0;
 	
 	if( new_socket == -1 )
@@ -260,8 +262,6 @@
 	}
 	
-#ifndef _WIN32
 	if( global.conf->runmode == RUNMODE_FORKDAEMON )
 	{
-		pid_t client_pid = 0;
 		int fds[2];
 		
@@ -320,5 +320,4 @@
 	}
 	else
-#endif
 	{
 		log_message( LOGLVL_INFO, "Creating new connection with fd %d.", new_socket );
Index: bitlbee.h
===================================================================
--- bitlbee.h	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ bitlbee.h	(revision b6cd9e9fe0aa86e83fc4a43b3db2240839e2103a)
@@ -48,8 +48,7 @@
 #include <stdio.h>
 #include <ctype.h>
-#include <errno.h>
-
 #ifndef _WIN32
 #include <syslog.h>
+#include <errno.h>
 #endif
 
Index: configure
===================================================================
--- configure	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ configure	(revision b6cd9e9fe0aa86e83fc4a43b3db2240839e2103a)
@@ -20,5 +20,4 @@
 ipcsocket='/var/run/bitlbee.sock'
 pcdir='$prefix/lib/pkgconfig'
-systemlibdirs="/lib /usr/lib /usr/local/lib"
 
 msn=1
@@ -110,5 +109,4 @@
 PCDIR=$pcdir
 
-TARGET=$target
 ARCH=$arch
 CPU=$cpu
@@ -136,15 +134,10 @@
 EOF
 
-
-
 if [ -n "$target" ]; then
-	PKG_CONFIG_LIBDIR=/usr/$target/lib/pkgconfig
-	export PKG_CONFIG_LIBDIR
+	PKG_CONFIG_PATH=/usr/$target/lib/pkgconfig
 	PATH=/usr/$target/bin:$PATH
 	CC=$target-cc
 	LD=$target-ld
-	systemlibdirs="/usr/$target/lib"
-fi
-
+fi
 
 if [ "$debug" = "1" ]; then
@@ -292,6 +285,4 @@
 elif [ "$ssl" = "nss" ]; then
 	detect_nss
-elif [ "$ssl" = "sspi" ]; then
-	echo
 elif [ "$ssl" = "openssl" ]; then
 	echo
@@ -350,5 +341,5 @@
 echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
 
-for i in $systemlibdirs; do
+for i in /lib /usr/lib /usr/local/lib; do
 	if [ -f $i/libresolv.a ]; then
 		echo '#define HAVE_RESOLV_A' >> config.h
@@ -510,9 +501,4 @@
 	echo 'Cygwin is not officially supported.'
 ;;
-Windows )
-	echo OUTFILE=bitlbee.exe >> Makefile.settings
-	echo LFLAGS+=-lwsock32 >> Makefile.settings
-	echo EFLAGS+=-lsecur32 >> Makefile.settings
-;;
 * )
 	echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
Index: c/BUILD.win32
===================================================================
--- doc/BUILD.win32	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ 	(revision )
@@ -1,35 +1,0 @@
-Instructions for building BitlBee on Windows 
-================================================
-
-1. Download the latest version using bzr (http://www.bazaar-ng.org/):
-
-   H:\> bzr branch http://win32.bitlbee.org/bzr bitlbee-win32
-   ...
-
-2. Download and install the required development files: 
-    from ftp://ftp.gtk.org/pub/gtk/v2.8/win32/
-    - glib
-    - glib-dev
-    - libiconv (in dependencies/)
-    - gettext (in dependencies/)
-    from http://ftp.mozilla.org/pub/mozilla.org/
-    - nss (in security/nss/)
-    - nspr (in nspr/)
-
-  glib and gettext are only required for actually running BitlBee - building
-  should work fine without them.
-
-3. Set the following variables in Makefile.settings, if you don't have the 
-   libraries above installed in the default directories searched by MSVC:
-
-   - GLIB_DIR
-   - NSS_DIR
-   - NSPR_DIR
-
-4. Build:
-
-	H:\BitlBee> nmake /f win32.mk
-	...
-
-5. To build setup files, compile the bitlbee.iss file using the Inno Setup 
-   program (available from www.jrsoftware.org).
Index: ipc.c
===================================================================
--- ipc.c	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ ipc.c	(revision b6cd9e9fe0aa86e83fc4a43b3db2240839e2103a)
@@ -439,5 +439,4 @@
 }
 
-#ifndef _WIN32
 char *ipc_master_save_state()
 {
@@ -505,4 +504,5 @@
 }
 
+#ifndef _WIN32
 int ipc_master_listen_socket()
 {
@@ -541,9 +541,5 @@
 }
 #else
-int ipc_master_listen_socket()
-{
 	/* FIXME: Open named pipe \\.\BITLBEE */
-	return 0;
-}
 #endif
 
Index: lib/misc.c
===================================================================
--- lib/misc.c	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ lib/misc.c	(revision b6cd9e9fe0aa86e83fc4a43b3db2240839e2103a)
@@ -392,4 +392,69 @@
 }
 
+/* A pretty reliable random number generator. Tries to use the /dev/random
+   devices first, and falls back to the random number generator from libc
+   when it fails. Opens randomizer devices with O_NONBLOCK to make sure a
+   lack of entropy won't halt BitlBee. */
+void random_bytes( unsigned char *buf, int count )
+{
+	static int use_dev = -1;
+	
+	/* Actually this probing code isn't really necessary, is it? */
+	if( use_dev == -1 )
+	{
+		if( access( "/dev/random", R_OK ) == 0 || access( "/dev/urandom", R_OK ) == 0 )
+			use_dev = 1;
+		else
+		{
+			use_dev = 0;
+			srand( ( getpid() << 16 ) ^ time( NULL ) );
+		}
+	}
+	
+	if( use_dev )
+	{
+		int fd;
+		
+		/* At least on Linux, /dev/random can block if there's not
+		   enough entropy. We really don't want that, so if it can't
+		   give anything, use /dev/urandom instead. */
+		if( ( fd = open( "/dev/random", O_RDONLY | O_NONBLOCK ) ) >= 0 )
+			if( read( fd, buf, count ) == count )
+			{
+				close( fd );
+				return;
+			}
+		close( fd );
+		
+		/* urandom isn't supposed to block at all, but just to be
+		   sure. If it blocks, we'll disable use_dev and use the libc
+		   randomizer instead. */
+		if( ( fd = open( "/dev/urandom", O_RDONLY | O_NONBLOCK ) ) >= 0 )
+			if( read( fd, buf, count ) == count )
+			{
+				close( fd );
+				return;
+			}
+		close( fd );
+		
+		/* If /dev/random blocks once, we'll still try to use it
+		   again next time. If /dev/urandom also fails for some
+		   reason, stick with libc during this session. */
+		
+		use_dev = 0;
+		srand( ( getpid() << 16 ) ^ time( NULL ) );
+	}
+	
+	if( !use_dev )
+	{
+		int i;
+		
+		/* Possibly the LSB of rand() isn't very random on some
+		   platforms. Seems okay on at least Linux and OSX though. */
+		for( i = 0; i < count; i ++ )
+			buf[i] = rand() & 0xff;
+	}
+}
+
 int is_bool( char *value )
 {
Index: protocols/nogaim.h
===================================================================
--- protocols/nogaim.h	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ protocols/nogaim.h	(revision b6cd9e9fe0aa86e83fc4a43b3db2240839e2103a)
@@ -131,23 +131,4 @@
 	struct im_connection *ic; /* the connection it belongs to */
 };
-
-struct ft 
-{
-	const char *filename;
-	
-	/* Total number of bytes in file */
-	size_t total_bytes;
-	
-	/* Current number of bytes received */
-	size_t cur_bytes;
-};
-
-struct ft_request 
-{
-	const char *filename;
-	struct gaim_connection *gc;
-};
-
-typedef void (*ft_recv_handler) (struct ft *, void *data, size_t len);
 
 struct prpl {
Index: protocols/oscar/AUTHORS
===================================================================
--- protocols/oscar/AUTHORS	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ protocols/oscar/AUTHORS	(revision b6cd9e9fe0aa86e83fc4a43b3db2240839e2103a)
@@ -28,2 +28,4 @@
 E: awwaiid@auk.cx
 D: Figured out original password roasting
+
+
Index: otocols/ssl_sspi.c
===================================================================
--- protocols/ssl_sspi.c	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ 	(revision )
@@ -1,278 +1,0 @@
-  /********************************************************************\
-  * BitlBee -- An IRC to other IM-networks gateway                     *
-  *                                                                    *
-  * Copyright 2002-2004 Wilmer van der Gaast and others                *
-  \********************************************************************/
-
-/* SSL module - SSPI backend */
-
-/* Copyright (C) 2005 Jelmer Vernooij <jelmer@samba.org> */
-
-/*
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License with
-  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
-  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-  Suite 330, Boston, MA  02111-1307  USA
-*/
-
-#include "ssl_client.h"
-#include <windows.h>
-#define SECURITY_WIN32
-#include <security.h>
-#include <sspi.h>
-#include <schannel.h>
-#include "sock.h"
-
-static gboolean initialized = FALSE;
-int ssl_errno;
-
-struct scd
-{
-	int fd;
-	ssl_input_function func;
-	gpointer data;
-	gboolean established;
-  	CredHandle cred;		/* SSL credentials */
-	CtxtHandle context;		/* SSL context */
-	SecPkgContext_StreamSizes sizes;
-
-	char *host;
-
-	char *pending_raw_data;
-	gsize pending_raw_data_len;
-	char *pending_data;
-	gsize pending_data_len;
-};
-
-static void ssl_connected(gpointer, gint, GaimInputCondition);
-
-void sspi_global_init(void)
-{
-	/* FIXME */
-}
-
-void sspi_global_deinit(void)
-{
-	/* FIXME */
-}
-
-void *ssl_connect(char *host, int port, ssl_input_function func, gpointer data)
-{
-	struct scd *conn = g_new0(struct scd, 1);
-		
-	conn->fd = proxy_connect(host, port, ssl_connected, conn);
-	sock_make_nonblocking(conn->fd);
-	conn->func = func;
-	conn->data = data;
-	conn->host = g_strdup(host);
-	
-	if (conn->fd < 0)
-	{
-		g_free(conn);
-		return NULL;
-	}
-	
-	if (!initialized)
-	{
-		sspi_global_init();
-		initialized = TRUE;
-		atexit(sspi_global_deinit);
-	}
-
-	return conn;
-}
-
-static void ssl_connected(gpointer _conn, gint fd, GaimInputCondition cond)
-{
-	struct scd *conn = _conn;
-	SCHANNEL_CRED ssl_cred;
-	TimeStamp timestamp;
-	SecBuffer ibuf[2],obuf[1];
-	SecBufferDesc ibufs,obufs;
-	ULONG req = ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT |
-    	ISC_REQ_CONFIDENTIALITY | ISC_REQ_USE_SESSION_KEY |
-      	ISC_REQ_ALLOCATE_MEMORY | ISC_REQ_STREAM | ISC_REQ_EXTENDED_ERROR |
-		ISC_REQ_MANUAL_CRED_VALIDATION;
-	ULONG a;
-	gsize size = 0;
-	gchar *data = NULL;
-
-	memset(&ssl_cred, 0, sizeof(SCHANNEL_CRED));
-	ssl_cred.dwVersion = SCHANNEL_CRED_VERSION;
-	ssl_cred.grbitEnabledProtocols = SP_PROT_SSL3_CLIENT;
-
-	SECURITY_STATUS st = AcquireCredentialsHandle(NULL, UNISP_NAME, SECPKG_CRED_OUTBOUND, NULL, &ssl_cred, NULL, NULL, &conn->cred, &timestamp);
-
-	if (st != SEC_E_OK) {
-		conn->func(conn->data, NULL, cond);
-		return;
-	}
-	
-	do {
-		/* initialize buffers */
-	    ibuf[0].cbBuffer = size; ibuf[0].pvBuffer = data;
-	    ibuf[1].cbBuffer = 0; ibuf[1].pvBuffer = NULL;
-	    obuf[0].cbBuffer = 0; obuf[0].pvBuffer = NULL;
-    	ibuf[0].BufferType = obuf[0].BufferType = SECBUFFER_TOKEN;
-	    ibuf[1].BufferType = SECBUFFER_EMPTY;
-
-		/* initialize buffer descriptors */
-	    ibufs.ulVersion = obufs.ulVersion = SECBUFFER_VERSION;
-	    ibufs.cBuffers = 2; obufs.cBuffers = 1;
-	    ibufs.pBuffers = ibuf; obufs.pBuffers = obuf;
-
-		st = InitializeSecurityContext(&conn->cred, size?&conn->context:NULL, conn->host, req, 0, SECURITY_NETWORK_DREP, size?&ibufs:NULL, 0, &conn->context, &obufs, &a, &timestamp);  
-    	if (obuf[0].pvBuffer && obuf[0].cbBuffer) {
-			/* FIXME: Check return value */
-			send(conn->fd, obuf[0].pvBuffer, obuf[0].cbBuffer, 0);
-		}
-
-		switch (st) {
-		case SEC_I_INCOMPLETE_CREDENTIALS:
-			break;
-		case SEC_I_CONTINUE_NEEDED:
-			break;
-		case SEC_E_INCOMPLETE_MESSAGE:
-			break;
-		case SEC_E_OK:
-			break;
-		}
-	
-		QueryContextAttributes(&conn->context, SECPKG_ATTR_STREAM_SIZES, &conn->sizes);
-	} while (1);
-
-	conn->func(conn->data, conn, cond);
-}
-
-int ssl_read(void *conn, char *retdata, int len)
-{
-	struct scd *scd = conn;
-	SecBufferDesc msg;
-	SecBuffer buf[4];
-	int ret = -1, i;
-	char *data = g_malloc(scd->sizes.cbHeader + scd->sizes.cbMaximumMessage + scd->sizes.cbTrailer);
-
-	/* FIXME: Try to read some data */
-
-  	msg.ulVersion = SECBUFFER_VERSION;
-	msg.cBuffers = 4;
-	msg.pBuffers = buf;
-	
-	buf[0].BufferType = SECBUFFER_DATA;
-	buf[0].cbBuffer = len;
-	buf[0].pvBuffer = data;
-
-	buf[1].BufferType = SECBUFFER_EMPTY;
-	buf[2].BufferType = SECBUFFER_EMPTY;
-	buf[3].BufferType = SECBUFFER_EMPTY;
-
-	SECURITY_STATUS st = DecryptMessage(&scd->context, &msg, 0, NULL);
-
-	if (st != SEC_E_OK) {
-		/* FIXME */
-		return -1;
-	}
-
-	for (i = 0; i < 4; i++) {
-		if (buf[i].BufferType == SECBUFFER_DATA) {
-			memcpy(retdata, buf[i].pvBuffer, len);
-			ret = len;
-		}	
-	}
-
-	g_free(data);
-	return -1;
-}
-
-int ssl_write(void *conn, const char *userdata, int len)
-{
-	struct scd *scd = conn;
-	SecBuffer buf[4];
-	SecBufferDesc msg;
-	char *data;
-	int ret;
-
-	msg.ulVersion = SECBUFFER_VERSION;
-	msg.cBuffers = 4;
-	msg.pBuffers = buf;
-
-	data = g_malloc(scd->sizes.cbHeader + scd->sizes.cbMaximumMessage + scd->sizes.cbTrailer);
-	memcpy(data + scd->sizes.cbHeader, userdata, len);
-
-	buf[0].BufferType = SECBUFFER_STREAM_HEADER;
-	buf[0].cbBuffer = scd->sizes.cbHeader;
-	buf[0].pvBuffer = data;
-
-	buf[1].BufferType = SECBUFFER_DATA;
-	buf[1].cbBuffer = len;
-	buf[1].pvBuffer = data + scd->sizes.cbHeader;
-
-	buf[2].BufferType = SECBUFFER_STREAM_TRAILER;
-	buf[2].cbBuffer = scd->sizes.cbTrailer;
-	buf[2].pvBuffer = data + scd->sizes.cbHeader + len;
-	buf[3].BufferType = SECBUFFER_EMPTY;
-
-	SECURITY_STATUS st = EncryptMessage(&scd->context, 0, &msg, 0);
-
-	ret = send(scd->fd, data, 
-				buf[0].cbBuffer + buf[1].cbBuffer + buf[2].cbBuffer, 0);
-
-	g_free(data);
-
-	return ret;
-}
-
-void ssl_disconnect(void *conn)
-{
-	struct scd *scd = conn;
-
-	SecBufferDesc msg;
-	SecBuffer buf;
-	DWORD dw;
-
-	dw = SCHANNEL_SHUTDOWN;
-	buf.cbBuffer = sizeof(dw);
-	buf.BufferType = SECBUFFER_TOKEN;
-	buf.pvBuffer = &dw;
-	
-	msg.ulVersion = SECBUFFER_VERSION;
-	msg.cBuffers = 1;
-	msg.pBuffers = &buf;
-
-	SECURITY_STATUS st = ApplyControlToken(&scd->context, &msg);
-
-	if (st != SEC_E_OK) {
-		/* FIXME */
-	}
-	
-	/* FIXME: call InitializeSecurityContext(Schannel), passing 
-	 * in empty buffers*/
-
-	DeleteSecurityContext(&scd->context);
-
-	FreeCredentialsHandle(&scd->cred);
-
-	closesocket(scd->fd);
-	g_free(scd->host);
-	g_free(scd);
-}
-
-int ssl_getfd(void *conn)
-{
-	return ((struct scd*)conn)->fd;
-}
-
-GaimInputCondition ssl_getdirection( void *conn )
-{
-	return GAIM_INPUT_WRITE; /* FIXME: or GAIM_INPUT_READ */
-}
Index: protocols/yahoo/libyahoo2.c
===================================================================
--- protocols/yahoo/libyahoo2.c	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ protocols/yahoo/libyahoo2.c	(revision b6cd9e9fe0aa86e83fc4a43b3db2240839e2103a)
@@ -69,4 +69,6 @@
 #ifdef __MINGW32__
 # include <winsock2.h>
+# define write(a,b,c) send(a,b,c,0)
+# define read(a,b,c)  recv(a,b,c,0)
 #endif
 
Index: protocols/yahoo/yahoo_httplib.c
===================================================================
--- protocols/yahoo/yahoo_httplib.c	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ protocols/yahoo/yahoo_httplib.c	(revision b6cd9e9fe0aa86e83fc4a43b3db2240839e2103a)
@@ -51,4 +51,6 @@
 #ifdef __MINGW32__
 # include <winsock2.h>
+# define write(a,b,c) send(a,b,c,0)
+# define read(a,b,c)  recv(a,b,c,0)
 # define snprintf _snprintf
 #endif
Index: sock.h
===================================================================
--- sock.h	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ sock.h	(revision b6cd9e9fe0aa86e83fc4a43b3db2240839e2103a)
@@ -16,9 +16,15 @@
 #else
 # include <winsock2.h>
-# include <ws2tcpip.h>
+# ifndef _MSC_VER
+#  include <ws2tcpip.h>
+# endif
 # if !defined(BITLBEE_CORE) && defined(_MSC_VER)
 #   pragma comment(lib,"bitlbee.lib")
 # endif
 # include <io.h>
+# define read(a,b,c) recv(a,b,c,0)
+# define write(a,b,c) send(a,b,c,0)
+# define umask _umask
+# define mode_t int
 # define sock_make_nonblocking(fd) { int non_block = 1; ioctlsocket(fd, FIONBIO, &non_block); }
 # define sock_make_blocking(fd) { int non_block = 0; ioctlsocket(fd, FIONBIO, &non_block); }
Index: storage_text.c
===================================================================
--- storage_text.c	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ storage_text.c	(revision b6cd9e9fe0aa86e83fc4a43b3db2240839e2103a)
@@ -27,12 +27,4 @@
 #include "bitlbee.h"
 #include "crypting.h"
-#ifdef _WIN32
-# define umask _umask
-# define mode_t int
-#endif
-
-#ifndef F_OK
-#define F_OK 0
-#endif
 
 static void text_init (void)
Index: unix.c
===================================================================
--- unix.c	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ unix.c	(revision b6cd9e9fe0aa86e83fc4a43b3db2240839e2103a)
@@ -60,7 +60,4 @@
 	if( global.conf->runmode == RUNMODE_INETD )
 	{
-		log_link( LOGLVL_ERROR, LOGOUTPUT_IRC );
-		log_link( LOGLVL_WARNING, LOGOUTPUT_IRC );
-	
 		i = bitlbee_inetd_init();
 		log_message( LOGLVL_INFO, "Bitlbee %s starting in inetd mode.", BITLBEE_VERSION );
@@ -69,7 +66,4 @@
 	else if( global.conf->runmode == RUNMODE_DAEMON )
 	{
-		log_link( LOGLVL_ERROR, LOGOUTPUT_SYSLOG );
-		log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG );
-
 		i = bitlbee_daemon_init();
 		log_message( LOGLVL_INFO, "Bitlbee %s starting in daemon mode.", BITLBEE_VERSION );
@@ -225,69 +219,2 @@
 	return( (double) time->tv_sec + (double) time->tv_usec / 1000000 );
 }
-
-/* A pretty reliable random number generator. Tries to use the /dev/random
-   devices first, and falls back to the random number generator from libc
-   when it fails. Opens randomizer devices with O_NONBLOCK to make sure a
-   lack of entropy won't halt BitlBee. */
-void random_bytes( unsigned char *buf, int count )
-{
-	static int use_dev = -1;
-	
-	/* Actually this probing code isn't really necessary, is it? */
-	if( use_dev == -1 )
-	{
-		if( access( "/dev/random", R_OK ) == 0 || access( "/dev/urandom", R_OK ) == 0 )
-			use_dev = 1;
-		else
-		{
-			use_dev = 0;
-			srand( ( getpid() << 16 ) ^ time( NULL ) );
-		}
-	}
-	
-	if( use_dev )
-	{
-		int fd;
-		
-		/* At least on Linux, /dev/random can block if there's not
-		   enough entropy. We really don't want that, so if it can't
-		   give anything, use /dev/urandom instead. */
-		if( ( fd = open( "/dev/random", O_RDONLY | O_NONBLOCK ) ) >= 0 )
-			if( read( fd, buf, count ) == count )
-			{
-				close( fd );
-				return;
-			}
-		close( fd );
-		
-		/* urandom isn't supposed to block at all, but just to be
-		   sure. If it blocks, we'll disable use_dev and use the libc
-		   randomizer instead. */
-		if( ( fd = open( "/dev/urandom", O_RDONLY | O_NONBLOCK ) ) >= 0 )
-			if( read( fd, buf, count ) == count )
-			{
-				close( fd );
-				return;
-			}
-		close( fd );
-		
-		/* If /dev/random blocks once, we'll still try to use it
-		   again next time. If /dev/urandom also fails for some
-		   reason, stick with libc during this session. */
-		
-		use_dev = 0;
-		srand( ( getpid() << 16 ) ^ time( NULL ) );
-	}
-	
-	if( !use_dev )
-	{
-		int i;
-		
-		/* Possibly the LSB of rand() isn't very random on some
-		   platforms. Seems okay on at least Linux and OSX though. */
-		for( i = 0; i < count; i ++ )
-			buf[i] = rand() & 0xff;
-	}
-}
-
-
Index: ils/cross-compile.win32
===================================================================
--- utils/cross-compile.win32	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ 	(revision )
@@ -1,21 +1,0 @@
-#!/bin/sh
-# Simple cross compilation script for BitlBee using mingw32
-# (C) Jelmer Vernooij <jelmer@samba.org> 2005-2006
-
-GTK_SITE=ftp://ftp.gtk.org/pub/gtk/v2.8/win32
-
-GLIB_VERSION=2.10.1
-LIBICONV_VERSION=1.9.1
-GETTEXT_VERSION=0.14.5
-
-wget -c $GTK_SITE/glib-dev-$GLIB_VERSION.zip
-wget -c $GTK_SITE/dependencies/libiconv-$LIBICONV_VERSION.bin.woe32.zip 
-wget -c $GTK_SITE/dependencies/gettext-dev-$GETTEXT_VERSION.zip 
-
-DEPSDIR=`mktemp -d`
-
-unzip -d $DEPSDIR -o libiconv-$LIBICONV_VERSION.bin.woe32.zip
-unzip -d $DEPSDIR -o glib-dev-$GLIB_VERSION.zip
-unzip -d $DEPSDIR -o gettext-dev-$GETTEXT_VERSION.zip
-
-LD=i586-mingw32msvc-ld CC=i586-mingw32msvc-gcc STRIP=i586-mingw32msvc-strip PKG_CONFIG_PATH="$DEPSDIR/lib/pkgconfig" PKG_CONFIG="pkg-config --define-variable=prefix=\"$DEPSDIR\"" ./configure --ssl=sspi --arch=Windows
Index: n32.c
===================================================================
--- win32.c	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ 	(revision )
@@ -1,319 +1,0 @@
-  /********************************************************************\
-  * BitlBee -- An IRC to other IM-networks gateway                     *
-  *                                                                    *
-  * Copyright 2002-2004 Wilmer van der Gaast and others                *
-  \********************************************************************/
-
-/* Main file (Windows specific part)                                   */
-
-/*
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License with
-  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
-  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-  Suite 330, Boston, MA  02111-1307  USA
-*/
-
-#define BITLBEE_CORE
-#include "bitlbee.h"
-#include "commands.h"
-#include "crypting.h"
-#include "protocols/nogaim.h"
-#include "help.h"
-#include <signal.h>
-#include <windows.h>
-
-global_t global;	/* Against global namespace pollution */
-
-static void WINAPI service_ctrl (DWORD dwControl)
-{
-	switch (dwControl)
-	{
-        case SERVICE_CONTROL_STOP:
-			/* FIXME */
-            break;
-
-        case SERVICE_CONTROL_INTERROGATE:
-            break;
-
-        default:
-            break;
-
-    }
-}
-
-static void bitlbee_init(int argc, char **argv)
-{
-	int i = -1;
-	memset( &global, 0, sizeof( global_t ) );
-
-	b_main_init();
-	
-	global.conf = conf_load( argc, argv );
-	if( global.conf == NULL )
-		return;
-	
-	if( global.conf->runmode == RUNMODE_INETD )
-	{
-		i = bitlbee_inetd_init();
-		log_message( LOGLVL_INFO, "Bitlbee %s starting in inetd mode.", BITLBEE_VERSION );
-
-	}
-	else if( global.conf->runmode == RUNMODE_DAEMON )
-	{
-		i = bitlbee_daemon_init();
-		log_message( LOGLVL_INFO, "Bitlbee %s starting in daemon mode.", BITLBEE_VERSION );
-	} 
-	else 
-	{
-		log_message( LOGLVL_INFO, "No bitlbee mode specified...");
-	}
-	
-	if( i != 0 )
-		return;
- 	
-	if( access( global.conf->configdir, F_OK ) != 0 )
-		log_message( LOGLVL_WARNING, "The configuration directory %s does not exist. Configuration won't be saved.", global.conf->configdir );
-	else if( access( global.conf->configdir, 06 ) != 0 )
-		log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to %s.", global.conf->configdir );
-	if( help_init( &(global.help), HELP_FILE ) == NULL )
-		log_message( LOGLVL_WARNING, "Error opening helpfile %s.", global.helpfile );
-}
-
-void service_main (DWORD argc, LPTSTR *argv)
-{
-	SERVICE_STATUS_HANDLE handle;
-	SERVICE_STATUS status;
-
-    handle = RegisterServiceCtrlHandler("bitlbee", service_ctrl);
-
-    if (!handle)
-		return;
-
-    status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
-    status.dwServiceSpecificExitCode = 0;
-
-	bitlbee_init(argc, argv);
-
-	SetServiceStatus(handle, &status);
-	
-	b_main_run( );
-}
-
-SERVICE_TABLE_ENTRY dispatch_table[] =
-{
-   { TEXT("bitlbee"), (LPSERVICE_MAIN_FUNCTION)service_main },
-   { NULL, NULL }
-};
-
-static int debug = 0;
-
-static void usage()
-{
-	printf("Options:\n");
-	printf("-h   Show this help message\n");
-	printf("-d   Debug mode (simple console program)\n");
-}
-
-int main( int argc, char **argv)
-{    
-	int i;
-	WSADATA WSAData;
-
-	nogaim_init( );
-
-	for (i = 1; i < argc; i++) {
-		if (!strcmp(argv[i], "-d")) debug = 1;
-		if (!strcmp(argv[i], "-h")) {
-			usage();
-			return 0;
-		}
-	}
-
-    WSAStartup(MAKEWORD(1,1), &WSAData);
-
-	if (!debug) {
-		if (!StartServiceCtrlDispatcher(dispatch_table))
-			log_message( LOGLVL_ERROR, "StartServiceCtrlDispatcher failed.");
-	} else {
-			bitlbee_init(argc, argv);
- 			b_main_run();
-	}
-	
-	return 0;
-}
-
-double gettime()
-{
-	return (GetTickCount() / 1000);
-}
-
-void conf_get_string(HKEY section, const char *name, const char *def, char **dest)
-{
-	char buf[4096];
-	long x;
-	if (RegQueryValue(section, name, buf, &x) == ERROR_SUCCESS) {
-		*dest = g_strdup(buf);
-	} else if (!def) {
-		*dest = NULL;
-	} else {
-		*dest = g_strdup(def);
-	}
-}
-
-
-void conf_get_int(HKEY section, const char *name, int def, int *dest)
-{
-	char buf[20];
-	long x;
-	DWORD y;
-	if (RegQueryValue(section, name, buf, &x) == ERROR_SUCCESS) {
-		memcpy(&y, buf, sizeof(DWORD));
-		*dest = y;
-	} else {
-		*dest = def;
-	}
-}
-
-conf_t *conf_load( int argc, char *argv[] ) 
-{
-	conf_t *conf;
-	HKEY key, key_main, key_proxy;
-	char *tmp;
-
-	RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Bitlbee", &key);
-	RegOpenKey(key, "main", &key_main);
-	RegOpenKey(key, "proxy", &key_proxy);
-	
-	memset( &global, 0, sizeof( global_t ) );
-	b_main_init();
-
-	conf = g_new0( conf_t,1 );
-	global.conf = conf;
-	conf_get_string(key_main, "interface_in", "0.0.0.0", &global.conf->iface_in);
-	conf_get_string(key_main, "interface_out", "0.0.0.0", &global.conf->iface_out);
-	conf_get_string(key_main, "port", "6667", &global.conf->port);
-	conf_get_int(key_main, "verbose", 0, &global.conf->verbose);
-	conf_get_string(key_main, "auth_pass", "", &global.conf->auth_pass);
-	conf_get_string(key_main, "oper_pass", "", &global.conf->oper_pass);
-	conf_get_int(key_main, "ping_interval_timeout", 60, &global.conf->ping_interval);
-	conf_get_string(key_main, "hostname", "localhost", &global.conf->hostname);
-	conf_get_string(key_main, "configdir", NULL, &global.conf->configdir);
-	conf_get_string(key_main, "motdfile", NULL, &global.conf->motdfile);
-	conf_get_string(key_main, "helpfile", NULL, &global.helpfile);
-	global.conf->runmode = RUNMODE_DAEMON;
-	conf_get_int(key_main, "AuthMode", AUTHMODE_OPEN, (int *)&global.conf->authmode);
-	conf_get_string(key_proxy, "host", "", &tmp); strcpy(proxyhost, tmp);
-	conf_get_string(key_proxy, "user", "", &tmp); strcpy(proxyuser, tmp);
-	conf_get_string(key_proxy, "password", "", &tmp); strcpy(proxypass, tmp);
-	conf_get_int(key_proxy, "type", PROXY_NONE, &proxytype);
-	conf_get_int(key_proxy, "port", 3128, &proxyport);
-
-	RegCloseKey(key);
-	RegCloseKey(key_main);
-	RegCloseKey(key_proxy);
-
-	return conf;
-}
-
-void conf_loaddefaults( irc_t *irc )
-{
-	HKEY key_defaults;
-	int i;
-	char name[4096], data[4096];
-	DWORD namelen = sizeof(name), datalen = sizeof(data);
-	DWORD type;
-	if (RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Bitlbee\\defaults", &key_defaults) != ERROR_SUCCESS) {
-		return;
-	}
-
-	for (i = 0; RegEnumValue(key_defaults, i, name, &namelen, NULL, &type, data, &datalen) == ERROR_SUCCESS; i++) {
-		set_t *s = set_find( &irc->set, name );
-			
-		if( s )
-		{
-			if( s->def ) g_free( s->def );
-			s->def = g_strdup( data );
-		}
-
-		namelen = sizeof(name);
-		datalen = sizeof(data);
-	}
-
-	RegCloseKey(key_defaults);
-}
-
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff
-#endif
-
-int
-inet_aton(const char *cp, struct in_addr *addr)
-{
-  addr->s_addr = inet_addr(cp);
-  return (addr->s_addr == INADDR_NONE) ? 0 : 1;
-}
-
-void log_error(char *msg)
-{
-	log_message(LOGLVL_ERROR, "%s", msg);
-}
-
-void log_message(int level, char *message, ...)
-{
-    HANDLE  hEventSource;
-    LPTSTR  lpszStrings[2];
-	WORD elevel;
-    va_list ap;
-
-    va_start(ap, message);
-
-	if (debug) {
-		vprintf(message, ap);
-		putchar('\n');
-		va_end(ap);
-		return;
-	}
-
-    hEventSource = RegisterEventSource(NULL, TEXT("bitlbee"));
-
-    lpszStrings[0] = TEXT("bitlbee");
-    lpszStrings[1] = g_strdup_vprintf(message, ap);
-    va_end(ap);
-
-	switch (level) {
-	case LOGLVL_ERROR: elevel = EVENTLOG_ERROR_TYPE; break;
-	case LOGLVL_WARNING: elevel = EVENTLOG_WARNING_TYPE; break;
-	case LOGLVL_INFO: elevel = EVENTLOG_INFORMATION_TYPE; break;
-#ifdef DEBUG
-	case LOGLVL_DEBUG: elevel = EVENTLOG_AUDIT_SUCCESS; break;
-#endif
-	}
-
-    if (hEventSource != NULL) {
-        ReportEvent(hEventSource, 
-        elevel,
-        0,                    
-        0,                    
-        NULL,                 
-        2,                    
-        0,                    
-        lpszStrings,          
-        NULL);                
-
-        DeregisterEventSource(hEventSource);
-    }
-
-	g_free(lpszStrings[1]);
-}
-
-void log_link(int level, int output) { /* FIXME */ }
Index: n32.mk
===================================================================
--- win32.mk	(revision ddd477993505b1a97b705489c45a3f63594452b8)
+++ 	(revision )
@@ -1,136 +1,0 @@
-!INCLUDE Makefile.settings
-
-GLIB_CFLAGS = /I "$(GLIB_DIR)\include" \
-	      /I "$(GLIB_DIR)\include\glib-2.0" \
-	      /I "$(GLIB_DIR)\lib\glib-2.0\include"
-
-GLIB_LFLAGS = /libpath:"$(GLIB_DIR)\lib" 
-
-NSS_CFLAGS = /I "$(NSS_DIR)\include" /I "$(NSPR_DIR)\include"
-NSS_LFLAGS = /libpath:"$(NSS_DIR)\lib" /libpath:"$(NSPR_DIR)\lib" 
-NSS_LIBS = nss3.lib ssl3.lib libnspr4.lib
-
-COMMON_LIBS = kernel32.lib user32.lib advapi32.lib shell32.lib iconv.lib \
-			glib-2.0.lib gmodule-2.0.lib wsock32.lib advapi32.lib 
-
-
-MAIN_OBJS = account.obj bitlbee.obj commands.obj crypting.obj \
-	help.obj irc.obj protocols\md5.obj protocols\nogaim.obj \
-	protocols\sha.obj protocols\proxy.obj query.obj nick.obj set.obj \
-	user.obj protocols\util.obj win32.obj 
-
-MAIN_LIBS = $(COMMON_LIBS)
-
-SSL_OBJS = protocols\ssl_nss.obj
-SSL_LIBS = $(NSS_LFLAGS) $(NSS_LIBS)
-
-MSN_OBJS = \
-	protocols\msn\msn.obj \
-	protocols\msn\msn_util.obj \
-	protocols\msn\ns.obj \
-	protocols\msn\passport.obj \
-	protocols\msn\sb.obj \
-	protocols\msn\tables.obj \
-	$(SSL_OBJS)
-
-MSN_LIBS = $(COMMON_LIBS) $(SSL_LIBS)
-
-OSCAR_OBJS = \
-	protocols\oscar\admin.obj \
-	protocols\oscar\auth.obj \
-	protocols\oscar\bos.obj \
-	protocols\oscar\buddylist.obj \
-	protocols\oscar\chat.obj \
-	protocols\oscar\chatnav.obj \
-	protocols\oscar\conn.obj \
-	protocols\oscar\icq.obj \
-	protocols\oscar\im.obj \
-	protocols\oscar\info.obj \
-	protocols\oscar\misc.obj \
-	protocols\oscar\msgcookie.obj \
-	protocols\oscar\oscar.obj \
-	protocols\oscar\oscar_util.obj \
-	protocols\oscar\rxhandlers.obj \
-	protocols\oscar\rxqueue.obj \
-	protocols\oscar\search.obj \
-	protocols\oscar\service.obj \
-	protocols\oscar\snac.obj \
-	protocols\oscar\ssi.obj \
-	protocols\oscar\stats.obj \
-	protocols\oscar\tlv.obj \
-	protocols\oscar\txqueue.obj
-
-OSCAR_LIBS = $(COMMON_LIBS)
-
-JABBER_OBJS = \
-	protocols\jabber\expat.obj \
-	protocols\jabber\genhash.obj \
-	protocols\jabber\hashtable.obj \
-	protocols\jabber\jabber.obj \
-	protocols\jabber\jconn.obj \
-	protocols\jabber\jid.obj \
-	protocols\jabber\jpacket.obj \
-	protocols\jabber\jutil.obj \
-	protocols\jabber\karma.obj \
-	protocols\jabber\log.obj \
-	protocols\jabber\pool.obj \
-	protocols\jabber\pproxy.obj \
-	protocols\jabber\rate.obj \
-	protocols\jabber\str.obj \
-	protocols\jabber\xhash.obj \
-	protocols\jabber\xmlnode.obj \
-	protocols\jabber\xmlparse.obj \
-	protocols\jabber\xmlrole.obj \
-	protocols\jabber\xmltok.obj \
-	protocols\jabber\xstream.obj \
-	$(SSL_OBJS)
-
-JABBER_LIBS = $(COMMON_LIBS) $(SSL_LIBS)
-
-YAHOO_OBJS = \
-	protocols\yahoo\crypt.obj \
-	protocols\yahoo\libyahoo2.obj \
-	protocols\yahoo\vc50.idb \
-	protocols\yahoo\yahoo.obj \
-	protocols\yahoo\yahoo_fn.obj \
-	protocols\yahoo\yahoo_httplib.obj \
-	protocols\yahoo\yahoo_list.obj \
-	protocols\yahoo\yahoo_util.obj
-
-YAHOO_LIBS = $(COMMON_LIBS)
-
-CC=cl.exe
-CFLAGS=$(GLIB_CFLAGS) $(NSS_CFLAGS) /D NDEBUG /D WIN32 /D _WINDOWS \
-       /I . /I protocols /I protocols\oscar /nologo \
-       /D GLIB2 /D ARCH="\"Windows\"" /D CPU="\"x86\"" \
-       /D PLUGINDIR="plugins"
-
-.c.obj:
-	$(CC) $(CFLAGS) /c /Fo$@ $<
-
-ALL: bitlbee.exe libmsn.dll liboscar.dll libjabber.dll libyahoo.dll
-	
-LINK32=link.exe
-LINK32_FLAGS=/nologo $(GLIB_LFLAGS)
-
-bitlbee.exe: $(DEF_FILE) $(MAIN_OBJS)
-    $(LINK32) $(MAIN_LIBS) $(LINK32_FLAGS) /out:bitlbee.exe $(MAIN_OBJS)
-
-libmsn.dll: $(MSN_OBJS) 
-	$(LINK32) /DLL /SUBSYSTEM:WINDOWS /ENTRY:msn_init $(MSN_LIBS) $(LINK32_FLAGS) /out:libmsn.dll $(MSN_OBJS)
-
-libyahoo.dll: $(YAHOO_OBJS)
-	$(LINK32) /DLL /SUBSYSTEM:WINDOWS /ENTRY:yahoo_init $(YAHOO_LIBS) $(LINK32_FLAGS) /out:libyahoo.dll $(YAHOO_OBJS)
-
-liboscar.dll: $(OSCAR_OBJS)
-	$(LINK32) /DLL /SUBSYSTEM:WINDOWS /ENTRY:oscar_init $(OSCAR_LIBS) $(LINK32_FLAGS) /out:liboscar.dll $(OSCAR_OBJS)
-
-libjabber.dll: $(JABBER_OBJS)
-	$(LINK32) /DLL /SUBSYSTEM:WINDOWS /ENTRY:jabber_init $(JABBER_LIBS) $(LINK32_FLAGS) /out:libjabber.dll $(JABBER_OBJS)
-
-clean:
-	@-erase $(MAIN_OBJS)
-	@-erase $(MSN_OBJS)
-	@-erase $(JABBER_OBJS)
-	@-erase $(OSCAR_OBJS)
-	@-erase $(YAHOO_OBJS)
