aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile12
-rw-r--r--bitlbee.c6
-rw-r--r--bitlbee.h7
-rwxr-xr-xconfigure4
-rw-r--r--doc/BUILD.win3210
-rw-r--r--help.c6
-rw-r--r--ipc.c10
-rw-r--r--lib/events.h2
-rw-r--r--lib/events_glib.c6
-rw-r--r--lib/misc.c2
-rw-r--r--lib/proxy.c8
-rw-r--r--lib/proxy.h2
-rw-r--r--lib/ssl_sspi.c278
-rw-r--r--protocols/msn/soap.h2
-rw-r--r--protocols/oscar/rxqueue.c2
-rw-r--r--protocols/oscar/txqueue.c2
-rw-r--r--protocols/yahoo/libyahoo2.c2
-rw-r--r--protocols/yahoo/yahoo_httplib.c2
-rw-r--r--protocols/yahoo/yahoo_util.h2
-rw-r--r--sock.h14
-rw-r--r--win32.c331
21 files changed, 4 insertions, 706 deletions
diff --git a/Makefile b/Makefile
index be71ef8f..f452bc9a 100644
--- a/Makefile
+++ b/Makefile
@@ -9,19 +9,11 @@
-include Makefile.settings
# Program variables
-objects = bitlbee.o dcc.o help.o ipc.o irc.o irc_im.o irc_channel.o irc_commands.o irc_send.o irc_user.o irc_util.o nick.o $(OTR_BI) query.o root_commands.o set.o storage.o $(STORAGE_OBJS)
+objects = bitlbee.o dcc.o help.o ipc.o irc.o irc_im.o irc_channel.o irc_commands.o irc_send.o irc_user.o irc_util.o nick.o $(OTR_BI) query.o root_commands.o set.o storage.o $(STORAGE_OBJS) unix.o conf.o log.o
headers = $(wildcard *.h lib/*.h protocols/*.h)
subdirs = lib protocols
-ifeq ($(TARGET),i586-mingw32msvc)
-objects += win32.o
-LDFLAGS+=-lws2_32
-EFLAGS+=-lsecur32
-OUTFILE=bitlbee.exe
-else
-objects += unix.o conf.o log.o
-OUTFILE=bitlbee
-endif
+OUTFILE = bitlbee
# Expansion of variables
subdirobjs = $(foreach dir,$(subdirs),$(dir)/$(dir).o)
diff --git a/bitlbee.c b/bitlbee.c
index 563d9344..93754d05 100644
--- a/bitlbee.c
+++ b/bitlbee.c
@@ -126,7 +126,6 @@ int bitlbee_daemon_init()
global.listen_watch_source_id = b_input_add( global.listen_socket, B_EV_IO_READ, bitlbee_io_new_client, NULL );
-#ifndef _WIN32
if( !global.conf->nofork )
{
i = fork();
@@ -150,7 +149,6 @@ int bitlbee_daemon_init()
open( "/dev/null", O_WRONLY );
}
}
-#endif
if( global.conf->runmode == RUNMODE_FORKDAEMON )
ipc_master_load_state( getenv( "_BITLBEE_RESTART_STATE" ) );
@@ -158,7 +156,6 @@ int bitlbee_daemon_init()
if( global.conf->runmode == RUNMODE_DAEMON || global.conf->runmode == RUNMODE_FORKDAEMON )
ipc_master_listen_socket();
-#ifndef _WIN32
if( ( fp = fopen( global.conf->pidfile, "w" ) ) )
{
fprintf( fp, "%d\n", (int) getpid() );
@@ -168,7 +165,6 @@ int bitlbee_daemon_init()
{
log_message( LOGLVL_WARNING, "Warning: Couldn't write PID to `%s'", global.conf->pidfile );
}
-#endif
if( !global.conf->nofork )
{
@@ -294,7 +290,6 @@ static gboolean bitlbee_io_new_client( gpointer data, gint fd, b_input_condition
return TRUE;
}
-#ifndef _WIN32
if( global.conf->runmode == RUNMODE_FORKDAEMON )
{
pid_t client_pid = 0;
@@ -356,7 +351,6 @@ static gboolean bitlbee_io_new_client( gpointer data, gint fd, b_input_condition
}
}
else
-#endif
{
log_message( LOGLVL_INFO, "Creating new connection with fd %d.", new_socket );
irc_new( new_socket );
diff --git a/bitlbee.h b/bitlbee.h
index 9bfd19cb..9bbf3f8d 100644
--- a/bitlbee.h
+++ b/bitlbee.h
@@ -34,9 +34,6 @@ extern "C" {
#define _GNU_SOURCE /* Stupid GNU :-P */
#endif
-/* Depend on Windows 2000 for now since we need getaddrinfo() */
-#define _WIN32_WINNT 0x0501
-
#define PACKAGE "BitlBee"
#define BITLBEE_VERSION "3.2.2"
#define VERSION BITLBEE_VERSION
@@ -59,11 +56,7 @@ extern "C" {
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
-
-#ifndef _WIN32
#include <syslog.h>
-#endif
-
#include <glib.h>
#include <gmodule.h>
diff --git a/configure b/configure
index 71502aa4..580ece7c 100755
--- a/configure
+++ b/configure
@@ -483,8 +483,6 @@ elif [ "$ssl" = "gnutls" ]; then
detect_gnutls
elif [ "$ssl" = "nss" ]; then
detect_nss
-elif [ "$ssl" = "sspi" ]; then
- echo
elif [ "$ssl" = "openssl" ]; then
echo
echo 'No detection code exists for OpenSSL. Make sure that you have a complete'
@@ -805,9 +803,9 @@ AIX )
echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings
;;
CYGWIN* )
- echo 'Cygwin is not officially supported.'
;;
Windows )
+ echo 'Native windows compilation is not supported anymore, use cygwin instead.'
;;
* )
echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
diff --git a/doc/BUILD.win32 b/doc/BUILD.win32
deleted file mode 100644
index e1afe600..00000000
--- a/doc/BUILD.win32
+++ /dev/null
@@ -1,10 +0,0 @@
-Instructions for building BitlBee for Windows
-=============================================
-
-1) Install the mingw32 compiler
-
-2) Compile GLib2 for the target i586-mingw32msvc
-
-3) Cross-compile BitlBee:
-
-$ ./configure --target=i586-mingw32msvc --ssl=bogus --arch=Windows
diff --git a/help.c b/help.c
index 86013cb3..7ae0c61d 100644
--- a/help.c
+++ b/help.c
@@ -41,11 +41,7 @@ help_t *help_init( help_t **help, const char *helpfile )
*help = h = g_new0 ( help_t, 1 );
- h->fd = open( helpfile, O_RDONLY
-#ifdef _WIN32
- | O_BINARY
-#endif
- );
+ h->fd = open( helpfile, O_RDONLY );
if( h->fd == -1 )
{
diff --git a/ipc.c b/ipc.c
index 0356ad75..4c8d1431 100644
--- a/ipc.c
+++ b/ipc.c
@@ -27,10 +27,8 @@
#include "bitlbee.h"
#include "ipc.h"
#include "commands.h"
-#ifndef _WIN32
#include <sys/uio.h>
#include <sys/un.h>
-#endif
GSList *child_list = NULL;
static int ipc_child_recv_fd = -1;
@@ -842,7 +840,6 @@ void ipc_child_disable()
global.listen_socket = -1;
}
-#ifndef _WIN32
char *ipc_master_save_state()
{
char *fn = g_strdup( "/tmp/bee-restart.XXXXXX" );
@@ -941,13 +938,6 @@ int ipc_master_listen_socket()
return 1;
}
-#else
-int ipc_master_listen_socket()
-{
- /* FIXME: Open named pipe \\.\BITLBEE */
- return 0;
-}
-#endif
int ipc_master_load_state( char *statefile )
{
diff --git a/lib/events.h b/lib/events.h
index 66c4c6b4..e31ddba4 100644
--- a/lib/events.h
+++ b/lib/events.h
@@ -36,11 +36,9 @@
#define _EVENTS_H_
#include <sys/types.h>
-#ifndef _WIN32
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
-#endif
#include <glib.h>
#include <gmodule.h>
diff --git a/lib/events_glib.c b/lib/events_glib.c
index 8f53fbbf..369d47f2 100644
--- a/lib/events_glib.c
+++ b/lib/events_glib.c
@@ -30,17 +30,11 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
-#ifndef _WIN32
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
-#else
-#include "sock.h"
-#define ETIMEDOUT WSAETIMEDOUT
-#define EINPROGRESS WSAEINPROGRESS
-#endif
#include <fcntl.h>
#include <errno.h>
#include "proxy.h"
diff --git a/lib/misc.c b/lib/misc.c
index f1da03cb..6ceb6f3c 100644
--- a/lib/misc.c
+++ b/lib/misc.c
@@ -419,7 +419,6 @@ signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t si
lack of entropy won't halt BitlBee. */
void random_bytes( unsigned char *buf, int count )
{
-#ifndef _WIN32
static int use_dev = -1;
/* Actually this probing code isn't really necessary, is it? */
@@ -469,7 +468,6 @@ void random_bytes( unsigned char *buf, int count )
}
if( !use_dev )
-#endif
{
int i;
diff --git a/lib/proxy.c b/lib/proxy.c
index b6b02d72..6ada4917 100644
--- a/lib/proxy.c
+++ b/lib/proxy.c
@@ -25,17 +25,11 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
-#ifndef _WIN32
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
-#else
-#include "sock.h"
-#define ETIMEDOUT WSAETIMEDOUT
-#define EINPROGRESS WSAEINPROGRESS
-#endif
#include <fcntl.h>
#include <errno.h>
#include "nogaim.h"
@@ -75,7 +69,6 @@ static gboolean gaim_io_connected(gpointer data, gint source, b_input_condition
int error = ETIMEDOUT;
len = sizeof(error);
-#ifndef _WIN32
if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0 || error) {
if ((phb->gai_cur = phb->gai_cur->ai_next)) {
int new_fd;
@@ -100,7 +93,6 @@ static gboolean gaim_io_connected(gpointer data, gint source, b_input_condition
}
return FALSE;
}
-#endif
freeaddrinfo(phb->gai);
sock_make_blocking(source);
b_event_remove(phb->inpa);
diff --git a/lib/proxy.h b/lib/proxy.h
index 680790a5..b3be0a66 100644
--- a/lib/proxy.h
+++ b/lib/proxy.h
@@ -27,11 +27,9 @@
#define _PROXY_H_
#include <sys/types.h>
-#ifndef _WIN32
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
-#endif
#include <glib.h>
#include <gmodule.h>
diff --git a/lib/ssl_sspi.c b/lib/ssl_sspi.c
deleted file mode 100644
index e14c451e..00000000
--- a/lib/ssl_sspi.c
+++ /dev/null
@@ -1,278 +0,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 B_EV_IO_WRITE; /* FIXME: or B_EV_IO_READ */
-}
diff --git a/protocols/msn/soap.h b/protocols/msn/soap.h
index cb731ea7..1fd1f32b 100644
--- a/protocols/msn/soap.h
+++ b/protocols/msn/soap.h
@@ -35,12 +35,10 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
-#ifndef _WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
-#endif
#include "nogaim.h"
diff --git a/protocols/oscar/rxqueue.c b/protocols/oscar/rxqueue.c
index 081e967c..9ac8466e 100644
--- a/protocols/oscar/rxqueue.c
+++ b/protocols/oscar/rxqueue.c
@@ -8,9 +8,7 @@
#include <aim.h>
-#ifndef _WIN32
#include <sys/socket.h>
-#endif
/*
*
diff --git a/protocols/oscar/txqueue.c b/protocols/oscar/txqueue.c
index d38986d0..e48511fa 100644
--- a/protocols/oscar/txqueue.c
+++ b/protocols/oscar/txqueue.c
@@ -8,9 +8,7 @@
#include <aim.h>
#include "im.h"
-#ifndef _WIN32
#include <sys/socket.h>
-#endif
/*
* Allocate a new tx frame.
diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c
index da427279..972ee134 100644
--- a/protocols/yahoo/libyahoo2.c
+++ b/protocols/yahoo/libyahoo2.c
@@ -47,9 +47,7 @@
*
*/
-#ifndef _WIN32
#include <unistd.h>
-#endif
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
diff --git a/protocols/yahoo/yahoo_httplib.c b/protocols/yahoo/yahoo_httplib.c
index fd63d507..93fdb263 100644
--- a/protocols/yahoo/yahoo_httplib.c
+++ b/protocols/yahoo/yahoo_httplib.c
@@ -37,9 +37,7 @@ char *strchr(), *strrchr();
#endif
#include <errno.h>
-#ifndef _WIN32
#include <unistd.h>
-#endif
#include <ctype.h>
#include "yahoo2.h"
#include "yahoo2_callbacks.h"
diff --git a/protocols/yahoo/yahoo_util.h b/protocols/yahoo/yahoo_util.h
index 8cb721c1..6b4da304 100644
--- a/protocols/yahoo/yahoo_util.h
+++ b/protocols/yahoo/yahoo_util.h
@@ -64,7 +64,6 @@ void *y_memdup(const void *addr, int n);
char **y_strsplit(char *str, char *sep, int nelem);
void y_strfreev(char **vector);
-#ifndef _WIN32
int strncasecmp(const char *s1, const char *s2, size_t n);
int strcasecmp(const char *s1, const char *s2);
@@ -72,7 +71,6 @@ char *strdup(const char *s);
int snprintf(char *str, size_t size, const char *format, ...);
int vsnprintf(char *str, size_t size, const char *format, va_list ap);
-#endif
#endif
diff --git a/sock.h b/sock.h
index a0d49d95..c82f5275 100644
--- a/sock.h
+++ b/sock.h
@@ -1,7 +1,6 @@
#include <errno.h>
#include <fcntl.h>
-#ifndef _WIN32
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -11,16 +10,3 @@
#define sock_make_blocking(fd) fcntl(fd, F_SETFL, 0)
#define sockerr_again() (errno == EINPROGRESS || errno == EINTR)
void closesocket( int fd );
-#else
-# include <winsock2.h>
-# include <ws2tcpip.h>
-# if !defined(BITLBEE_CORE) && defined(_MSC_VER)
-# pragma comment(lib,"bitlbee.lib")
-# endif
-# include <io.h>
-# 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); }
-# define sockerr_again() (WSAGetLastError() == WSAEINTR || WSAGetLastError() == WSAEINPROGRESS || WSAGetLastError() == WSAEWOULDBLOCK)
-# define ETIMEDOUT WSAETIMEDOUT
-# define sleep(a) Sleep(a*1000)
-#endif
diff --git a/win32.c b/win32.c
deleted file mode 100644
index 99d2a8ca..00000000
--- a/win32.c
+++ /dev/null
@@ -1,331 +0,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 "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 */ }
-
-struct tm *
-gmtime_r (const time_t *timer, struct tm *result)
-{
- struct tm *local_result;
- local_result = gmtime (timer);
-
- if (local_result == NULL || result == NULL)
- return NULL;
-
- memcpy (result, local_result, sizeof (result));
- return result;
-}