aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitlbee.c6
-rw-r--r--unix.c6
-rw-r--r--win32.c122
-rw-r--r--win32/BUILD.TXT5
-rw-r--r--win32/bitlbee.dsp85
-rw-r--r--win32/bitlbee.dsw24
-rw-r--r--win32/configure.mingw3237
7 files changed, 145 insertions, 140 deletions
diff --git a/bitlbee.c b/bitlbee.c
index 32e28541..1054a42f 100644
--- a/bitlbee.c
+++ b/bitlbee.c
@@ -56,9 +56,6 @@ int bitlbee_daemon_init()
int i;
GIOChannel *ch;
- log_link( LOGLVL_ERROR, LOGOUTPUT_SYSLOG );
- log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG );
-
global.listen_socket = socket( AF_INET, SOCK_STREAM, 0 );
if( global.listen_socket == -1 )
{
@@ -112,9 +109,6 @@ int bitlbee_inetd_init()
if( !irc_new( 0 ) )
return( 1 );
- log_link( LOGLVL_ERROR, LOGOUTPUT_IRC );
- log_link( LOGLVL_WARNING, LOGOUTPUT_IRC );
-
return( 0 );
}
diff --git a/unix.c b/unix.c
index 140be68e..159b3126 100644
--- a/unix.c
+++ b/unix.c
@@ -60,12 +60,18 @@ int main( int argc, char *argv[] )
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 );
}
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 );
}
diff --git a/win32.c b/win32.c
index 5234c046..25adb9f0 100644
--- a/win32.c
+++ b/win32.c
@@ -4,7 +4,7 @@
* Copyright 2002-2004 Wilmer van der Gaast and others *
\********************************************************************/
-/* Main file (Unix specific part) */
+/* Main file (Windows specific part) */
/*
This program is free software; you can redistribute it and/or modify
@@ -22,33 +22,56 @@
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 <unistd.h>
-#include <sys/time.h>
-#include <winreg.h>
-#include <winbase.h>
+#include <windows.h>
global_t global; /* Against global namespace pollution */
-int main( int argc, char *argv[] )
+static void WINAPI service_ctrl (DWORD dwControl)
+{
+ switch (dwControl)
+ {
+ case SERVICE_CONTROL_STOP:
+ /* FIXME */
+ break;
+
+ case SERVICE_CONTROL_INTERROGATE:
+ break;
+
+ default:
+ break;
+
+ }
+}
+
+void service_main (DWORD argc, LPTSTR *argv)
{
int i = -1;
+ SERVICE_STATUS_HANDLE handle;
+ SERVICE_STATUS status;
+
+ handle = RegisterServiceCtrlHandler("bitlbee", service_ctrl);
+
+ if (!handle)
+ return;
+
+ status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+ status.dwServiceSpecificExitCode = 0;
+
memset( &global, 0, sizeof( global_t ) );
global.loop = g_main_new( FALSE );
- log_init( );
- nogaim_init( );
-
global.conf = conf_load( argc, argv );
if( global.conf == NULL )
- return( 1 );
+ return;
if( global.conf->runmode == RUNMODE_INETD )
{
@@ -67,18 +90,34 @@ int main( int argc, char *argv[] )
}
if( i != 0 )
- return( i );
+ 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, R_OK ) != 0 || access( global.conf->configdir, W_OK ) != 0 )
+ 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) ) == NULL )
log_message( LOGLVL_WARNING, "Error opening helpfile %s.", global.helpfile );
+
+ SetServiceStatus(handle, &status);
g_main_run( global.loop );
-
- return( 0 );
+}
+
+int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+{
+ SERVICE_TABLE_ENTRY dispatch_table[] =
+ {
+ { TEXT("bitlbee"), (LPSERVICE_MAIN_FUNCTION)service_main },
+ { NULL, NULL }
+ };
+
+ nogaim_init( );
+
+ if (!StartServiceCtrlDispatcher(dispatch_table))
+ log_message( LOGLVL_ERROR, "StartServiceCtrlDispatcher failed.");
+
+ return 0;
}
double gettime()
@@ -118,9 +157,10 @@ conf_t *conf_load( int argc, char *argv[] )
conf_t *conf;
HKEY key, key_main, key_proxy;
char *tmp;
- RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Bitlbee", &key);
- RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Bitlbee\\main", &key_main);
- RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Bitlbee\\proxy", &key_proxy);
+
+ RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Bitlbee", &key);
+ RegOpenKey(key, "main", &key_main);
+ RegOpenKey(key, "proxy", &key_proxy);
memset( &global, 0, sizeof( global_t ) );
global.loop = g_main_new(FALSE);
@@ -189,3 +229,49 @@ 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);
+
+ 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]);
+}
diff --git a/win32/BUILD.TXT b/win32/BUILD.TXT
index 718152b7..03e1b8d9 100644
--- a/win32/BUILD.TXT
+++ b/win32/BUILD.TXT
@@ -4,10 +4,11 @@ Instructions for building the Bitlbee Win32 port
1. Download the latest version using bzr (http://www.bazaar-ng.org/):
bzr branch http://jelmer.vernstok.nl/oss/bitlbee/bzr/win32 bitlbee-win32
2. Download and install the required development files:
- from http://www.ethereal.com/distribution/win32/development/:
- - libiconv
+ from ftp://ftp.gtk.org/pub/gtk/v2.8/win32/
- glib
- glib-dev
+ - libiconv
+ - gettext
from http://ftp.mozilla.org/pub/mozilla.org/
- nss
- nspr
diff --git a/win32/bitlbee.dsp b/win32/bitlbee.dsp
index ef0f3ada..3f26fca0 100644
--- a/win32/bitlbee.dsp
+++ b/win32/bitlbee.dsp
@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "..\protocols" /I ".." /I "deps\include" /I "deps\include\glib-2.0" /I "deps\lib\glib-2.0\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "GLIB2" /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "..\protocols" /I ".." /I "deps\include" /I "deps\include\glib-2.0" /I "deps\lib\glib-2.0\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
@@ -53,7 +53,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib iconv.lib glib-2.0.lib gmodule-2.0.lib /nologo /subsystem:windows /machine:I386 /libpath:"release" /libpath:"deps\lib"
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib iconv.lib glib-2.0.lib gmodule-2.0.lib wsock32.lib advapi32.lib /nologo /subsystem:windows /machine:I386 /libpath:"release" /libpath:"deps\lib"
# SUBTRACT LINK32 /incremental:yes /nodefaultlib
!ELSEIF "$(CFG)" == "bitlbee - Win32 Debug"
@@ -70,7 +70,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "." /I "..\protocols" /I ".." /I "deps\include" /I "deps\include\glib-2.0" /I "deps\lib\glib-2.0\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "GLIB2" /FR /FD /c
+# ADD CPP /nologo /Gd /MDd /Ze /W3 /Gm /GX /Zi /Od /I "." /I "..\protocols" /I ".." /I "deps\include" /I "deps\include\glib-2.0" /I "deps\lib\glib-2.0\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /FR /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
@@ -81,7 +81,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 iconv.lib glib-2.0.lib gmodule-2.0.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"debug" /libpath:"deps\lib"
+# ADD LINK32 iconv.lib glib-2.0.lib gmodule-2.0.lib wsock32.lib kernel32.lib user32.lib advapi32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"debug" /libpath:"deps\lib"
!ENDIF
@@ -103,10 +103,13 @@ SOURCE=..\bitlbee.c
# Begin Source File
SOURCE=.\bitlbee.rc
-# End Source File
-# Begin Source File
-SOURCE=.\bitlbeewin.cpp
+!IF "$(CFG)" == "bitlbee - Win32 Release"
+
+!ELSEIF "$(CFG)" == "bitlbee - Win32 Debug"
+
+!ENDIF
+
# End Source File
# Begin Source File
@@ -130,10 +133,6 @@ SOURCE=..\irc.c
# End Source File
# Begin Source File
-SOURCE=.\MainDlg.cpp
-# End Source File
-# Begin Source File
-
SOURCE=..\protocols\md5.c
# End Source File
# Begin Source File
@@ -146,26 +145,6 @@ SOURCE=..\protocols\nogaim.c
# End Source File
# Begin Source File
-SOURCE=.\PropAccess.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PropConn.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PropLog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PropPaths.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PropUsers.cpp
-# End Source File
-# Begin Source File
-
SOURCE=..\protocols\proxy.c
# End Source File
# Begin Source File
@@ -182,10 +161,6 @@ SOURCE=..\protocols\sha.c
# End Source File
# Begin Source File
-SOURCE=.\TrayNot.cpp
-# End Source File
-# Begin Source File
-
SOURCE=..\user.c
# End Source File
# Begin Source File
@@ -201,6 +176,10 @@ SOURCE=..\protocols\util.c
!ENDIF
# End Source File
+# Begin Source File
+
+SOURCE=..\win32.c
+# End Source File
# End Group
# Begin Group "Header Files"
@@ -215,10 +194,6 @@ SOURCE=..\bitlbee.h
# End Source File
# Begin Source File
-SOURCE=.\bitlbeewin.h
-# End Source File
-# Begin Source File
-
SOURCE=..\commands.h
# End Source File
# Begin Source File
@@ -251,10 +226,6 @@ SOURCE=..\log.h
# End Source File
# Begin Source File
-SOURCE=.\MainDlg.h
-# End Source File
-# Begin Source File
-
SOURCE=..\protocols\md5.h
# End Source File
# Begin Source File
@@ -267,30 +238,6 @@ SOURCE=..\protocols\nogaim.h
# End Source File
# Begin Source File
-SOURCE=.\PropAccess.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\PropConn.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\PropLog.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\PropPaths.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\PropUsers.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource.h
-# End Source File
-# Begin Source File
-
SOURCE=..\set.h
# End Source File
# Begin Source File
@@ -303,10 +250,6 @@ SOURCE=..\sock.h
# End Source File
# Begin Source File
-SOURCE=.\TrayNot.h
-# End Source File
-# Begin Source File
-
SOURCE=..\user.h
# End Source File
# End Group
diff --git a/win32/bitlbee.dsw b/win32/bitlbee.dsw
index e91fea5e..7f446962 100644
--- a/win32/bitlbee.dsw
+++ b/win32/bitlbee.dsw
@@ -3,7 +3,7 @@ Microsoft Developer Studio Workspace File, Format Version 5.00
###############################################################################
-Project: "bitlbee"=".\bitlbee.dsp" - Package Owner=<4>
+Project: "admin"=.\admin1\admin.dsp - Package Owner=<4>
Package=<5>
{{{
@@ -15,7 +15,7 @@ Package=<4>
###############################################################################
-Project: "bitlbee_ssl"=".\bitlbee_ssl\bitlbee_ssl.dsp" - Package Owner=<4>
+Project: "bitlbee"=.\bitlbee.dsp - Package Owner=<4>
Package=<5>
{{{
@@ -27,7 +27,19 @@ Package=<4>
###############################################################################
-Project: "jabber"=".\jabber.dsp" - Package Owner=<4>
+Project: "bitlbee_ssl"=.\bitlbee_ssl.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "jabber"=.\jabber.dsp - Package Owner=<4>
Package=<5>
{{{
@@ -45,7 +57,7 @@ Package=<4>
###############################################################################
-Project: "msn"=".\msn.dsp" - Package Owner=<4>
+Project: "msn"=.\msn.dsp - Package Owner=<4>
Package=<5>
{{{
@@ -63,7 +75,7 @@ Package=<4>
###############################################################################
-Project: "oscar"=".\oscar.dsp" - Package Owner=<4>
+Project: "oscar"=.\oscar.dsp - Package Owner=<4>
Package=<5>
{{{
@@ -78,7 +90,7 @@ Package=<4>
###############################################################################
-Project: "yahoo"=".\yahoo.dsp" - Package Owner=<4>
+Project: "yahoo"=.\yahoo.dsp - Package Owner=<4>
Package=<5>
{{{
diff --git a/win32/configure.mingw32 b/win32/configure.mingw32
deleted file mode 100644
index 678e9243..00000000
--- a/win32/configure.mingw32
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/sh
-DEPSDIR=$1
-export PKG_CONFIG_LIBDIR=$DEPSDIR/lib/pkgconfig
-export PKG_CONFIG_OPTS=--define-variable=prefix=$DEPSDIR
-export PKG_CONFIG="pkg-config $PKG_CONFIG_OPTS"
-
-cat<<EOF>config.h
-/* BitlBee settings, generated by $0
-
- Do *NOT* use any of these defines in your code without thinking twice, most
- of them can/will be overridden at run-time */
-#define CPU "i386"
-#define IPV6
-#define GLIB2
-#define ARCH "Windows"
-EOF
-
-cat<<EOF>Makefile.settings
-## BitlBee settings, generated by $0
-PREFIX=
-BINDIR=\$(PREFIX)/sbin/
-ETCDIR=\$(PREFIX)/etc/bitlbee/
-MANDIR=\$(PREFIX)/share/man/
-DATADIR=\$(PREFIX)/share/bitlbee/
-CONFIG=\$(PREFIX)/lib/bitlbee/
-ARCH=Windows
-CPU=i386
-OUTFILE=bitlbee.exe
-STRIP=i586-mingw32msvc-strip
-
-DESTDIR=
-LFLAGS=`$PKG_CONFIG --libs glib-2.0` -L$DEPSDIR/lib -lws2_32 -liconv
-CFLAGS=`$PKG_CONFIG --cflags glib-2.0` -I$DEPSDIR/include -I`pwd` -I`pwd`/protocols
-CC=i586-mingw32msvc-gcc
-CXX=i586-mingw32msvc-g++
-LD=i586-mingw32msvc-ld
-EOF