Changeset 99318ad


Ignore:
Timestamp:
2005-11-07T16:32:40Z (18 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
abe53d3
Parents:
d1d6776
Message:

Import work on services-based Win32 port

Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.c

    rd1d6776 r99318ad  
    5757        GIOChannel *ch;
    5858       
    59         log_link( LOGLVL_ERROR, LOGOUTPUT_SYSLOG );
    60         log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG );
    61        
    6259        global.listen_socket = socket( AF_INET, SOCK_STREAM, 0 );
    6360        if( global.listen_socket == -1 )
     
    112109        if( !irc_new( 0 ) )
    113110                return( 1 );
    114        
    115         log_link( LOGLVL_ERROR, LOGOUTPUT_IRC );
    116         log_link( LOGLVL_WARNING, LOGOUTPUT_IRC );
    117111       
    118112        return( 0 );
  • unix.c

    rd1d6776 r99318ad  
    6161        if( global.conf->runmode == RUNMODE_INETD )
    6262        {
     63                log_link( LOGLVL_ERROR, LOGOUTPUT_IRC );
     64                log_link( LOGLVL_WARNING, LOGOUTPUT_IRC );
     65       
    6366                i = bitlbee_inetd_init();
    6467                log_message( LOGLVL_INFO, "Bitlbee %s starting in inetd mode.", BITLBEE_VERSION );
     
    6770        else if( global.conf->runmode == RUNMODE_DAEMON )
    6871        {
     72                log_link( LOGLVL_ERROR, LOGOUTPUT_SYSLOG );
     73                log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG );
     74
    6975                i = bitlbee_daemon_init();
    7076                log_message( LOGLVL_INFO, "Bitlbee %s starting in daemon mode.", BITLBEE_VERSION );
  • win32.c

    rd1d6776 r99318ad  
    55  \********************************************************************/
    66
    7 /* Main file (Unix specific part)                                       */
     7/* Main file (Windows specific part)                                   */
    88
    99/*
     
    2424*/
    2525
     26#define BITLBEE_CORE
    2627#include "bitlbee.h"
    2728#include "commands.h"
     
    3031#include "help.h"
    3132#include <signal.h>
    32 #include <unistd.h>
    33 #include <sys/time.h>
    34 #include <winreg.h>
    35 #include <winbase.h>
     33#include <windows.h>
    3634
    3735global_t global;        /* Against global namespace pollution */
    3836
    39 int main( int argc, char *argv[] )
     37static void WINAPI service_ctrl (DWORD dwControl)
     38{
     39        switch (dwControl)
     40        {
     41        case SERVICE_CONTROL_STOP:
     42                        /* FIXME */
     43            break;
     44
     45        case SERVICE_CONTROL_INTERROGATE:
     46            break;
     47
     48        default:
     49            break;
     50
     51    }
     52}
     53
     54void service_main (DWORD argc, LPTSTR *argv)
    4055{
    4156        int i = -1;
     57        SERVICE_STATUS_HANDLE handle;
     58        SERVICE_STATUS status;
     59
     60    handle = RegisterServiceCtrlHandler("bitlbee", service_ctrl);
     61
     62    if (!handle)
     63                return;
     64
     65    status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
     66    status.dwServiceSpecificExitCode = 0;
     67
    4268        memset( &global, 0, sizeof( global_t ) );
    4369       
    4470        global.loop = g_main_new( FALSE );
    45        
    46         log_init( );
    47         nogaim_init( );
    4871       
    4972        global.conf = conf_load( argc, argv );
    5073        if( global.conf == NULL )
    51                 return( 1 );
     74                return;
    5275       
    5376        if( global.conf->runmode == RUNMODE_INETD )
     
    6891       
    6992        if( i != 0 )
    70                 return( i );
     93                return;
    7194       
    7295        if( access( global.conf->configdir, F_OK ) != 0 )
    7396                log_message( LOGLVL_WARNING, "The configuration directory %s does not exist. Configuration won't be saved.", global.conf->configdir );
    74         else if( access( global.conf->configdir, R_OK ) != 0 || access( global.conf->configdir, W_OK ) != 0 )
     97        else if( access( global.conf->configdir, 06 ) != 0 )
    7598                log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to %s.", global.conf->configdir );
    7699        if( help_init( &(global.help) ) == NULL )
    77100                log_message( LOGLVL_WARNING, "Error opening helpfile %s.", global.helpfile );
     101
     102        SetServiceStatus(handle, &status);
    78103       
    79104        g_main_run( global.loop );
    80        
    81         return( 0 );
     105}
     106
     107int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
     108{
     109    SERVICE_TABLE_ENTRY dispatch_table[] =
     110    {
     111        { TEXT("bitlbee"), (LPSERVICE_MAIN_FUNCTION)service_main },
     112        { NULL, NULL }
     113    };
     114
     115        nogaim_init( );
     116
     117    if (!StartServiceCtrlDispatcher(dispatch_table))
     118                log_message( LOGLVL_ERROR, "StartServiceCtrlDispatcher failed.");
     119       
     120        return 0;
    82121}
    83122
     
    119158        HKEY key, key_main, key_proxy;
    120159        char *tmp;
    121         RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Bitlbee", &key);
    122         RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Bitlbee\\main", &key_main);
    123         RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Bitlbee\\proxy", &key_proxy);
     160
     161        RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Bitlbee", &key);
     162        RegOpenKey(key, "main", &key_main);
     163        RegOpenKey(key, "proxy", &key_proxy);
    124164       
    125165        memset( &global, 0, sizeof( global_t ) );
     
    190230  return (addr->s_addr == INADDR_NONE) ? 0 : 1;
    191231}
     232
     233void log_error(char *msg)
     234{
     235        log_message(LOGLVL_ERROR, "%s", msg);
     236}
     237
     238void log_message(int level, char *message, ...)
     239{
     240    HANDLE  hEventSource;
     241    LPTSTR  lpszStrings[2];
     242        WORD elevel;
     243    va_list ap;
     244
     245    va_start(ap, message);
     246
     247    hEventSource = RegisterEventSource(NULL, TEXT("bitlbee"));
     248
     249    lpszStrings[0] = TEXT("bitlbee");
     250    lpszStrings[1] = g_strdup_vprintf(message, ap);
     251    va_end(ap);
     252
     253        switch (level) {
     254        case LOGLVL_ERROR: elevel = EVENTLOG_ERROR_TYPE; break;
     255        case LOGLVL_WARNING: elevel = EVENTLOG_WARNING_TYPE; break;
     256        case LOGLVL_INFO: elevel = EVENTLOG_INFORMATION_TYPE; break;
     257#ifdef DEBUG
     258        case LOGLVL_DEBUG: elevel = EVENTLOG_AUDIT_SUCCESS; break;
     259#endif
     260        }
     261
     262    if (hEventSource != NULL) {
     263        ReportEvent(hEventSource,
     264        elevel,
     265        0,                   
     266        0,                   
     267        NULL,                 
     268        2,                   
     269        0,                   
     270        lpszStrings,         
     271        NULL);               
     272
     273        DeregisterEventSource(hEventSource);
     274    }
     275
     276        g_free(lpszStrings[1]);
     277}
  • win32/BUILD.TXT

    rd1d6776 r99318ad  
    55   bzr branch http://jelmer.vernstok.nl/oss/bitlbee/bzr/win32 bitlbee-win32
    662. Download and install the required development files:
    7     from http://www.ethereal.com/distribution/win32/development/:
    8     - libiconv
     7    from ftp://ftp.gtk.org/pub/gtk/v2.8/win32/
    98    - glib
    109    - glib-dev
     10        - libiconv
     11        - gettext
    1112    from http://ftp.mozilla.org/pub/mozilla.org/
    1213    - nss
  • win32/bitlbee.dsp

    rd1d6776 r99318ad  
    4343# PROP Target_Dir ""
    4444# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
    45 # 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
     45# 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
    4646# SUBTRACT CPP /YX
    4747# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
     
    5454LINK32=link.exe
    5555# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
    56 # 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"
     56# 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"
    5757# SUBTRACT LINK32 /incremental:yes /nodefaultlib
    5858
     
    7171# PROP Target_Dir ""
    7272# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
    73 # 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
     73# 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
    7474# SUBTRACT CPP /YX
    7575# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
     
    8282LINK32=link.exe
    8383# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
    84 # 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"
     84# 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"
    8585
    8686!ENDIF
     
    104104
    105105SOURCE=.\bitlbee.rc
    106 # End Source File
    107 # Begin Source File
    108 
    109 SOURCE=.\bitlbeewin.cpp
     106
     107!IF  "$(CFG)" == "bitlbee - Win32 Release"
     108
     109!ELSEIF  "$(CFG)" == "bitlbee - Win32 Debug"
     110
     111!ENDIF
     112
    110113# End Source File
    111114# Begin Source File
     
    131134# Begin Source File
    132135
    133 SOURCE=.\MainDlg.cpp
    134 # End Source File
    135 # Begin Source File
    136 
    137136SOURCE=..\protocols\md5.c
    138137# End Source File
     
    147146# Begin Source File
    148147
    149 SOURCE=.\PropAccess.cpp
    150 # End Source File
    151 # Begin Source File
    152 
    153 SOURCE=.\PropConn.cpp
    154 # End Source File
    155 # Begin Source File
    156 
    157 SOURCE=.\PropLog.cpp
    158 # End Source File
    159 # Begin Source File
    160 
    161 SOURCE=.\PropPaths.cpp
    162 # End Source File
    163 # Begin Source File
    164 
    165 SOURCE=.\PropUsers.cpp
    166 # End Source File
    167 # Begin Source File
    168 
    169148SOURCE=..\protocols\proxy.c
    170149# End Source File
     
    183162# Begin Source File
    184163
    185 SOURCE=.\TrayNot.cpp
    186 # End Source File
    187 # Begin Source File
    188 
    189164SOURCE=..\user.c
    190165# End Source File
     
    201176!ENDIF
    202177
     178# End Source File
     179# Begin Source File
     180
     181SOURCE=..\win32.c
    203182# End Source File
    204183# End Group
     
    216195# Begin Source File
    217196
    218 SOURCE=.\bitlbeewin.h
    219 # End Source File
    220 # Begin Source File
    221 
    222197SOURCE=..\commands.h
    223198# End Source File
     
    252227# Begin Source File
    253228
    254 SOURCE=.\MainDlg.h
    255 # End Source File
    256 # Begin Source File
    257 
    258229SOURCE=..\protocols\md5.h
    259230# End Source File
     
    268239# Begin Source File
    269240
    270 SOURCE=.\PropAccess.h
    271 # End Source File
    272 # Begin Source File
    273 
    274 SOURCE=.\PropConn.h
    275 # End Source File
    276 # Begin Source File
    277 
    278 SOURCE=.\PropLog.h
    279 # End Source File
    280 # Begin Source File
    281 
    282 SOURCE=.\PropPaths.h
    283 # End Source File
    284 # Begin Source File
    285 
    286 SOURCE=.\PropUsers.h
    287 # End Source File
    288 # Begin Source File
    289 
    290 SOURCE=.\Resource.h
    291 # End Source File
    292 # Begin Source File
    293 
    294241SOURCE=..\set.h
    295242# End Source File
     
    301248
    302249SOURCE=..\sock.h
    303 # End Source File
    304 # Begin Source File
    305 
    306 SOURCE=.\TrayNot.h
    307250# End Source File
    308251# Begin Source File
  • win32/bitlbee.dsw

    rd1d6776 r99318ad  
    44###############################################################################
    55
    6 Project: "bitlbee"=".\bitlbee.dsp" - Package Owner=<4>
     6Project: "admin"=.\admin1\admin.dsp - Package Owner=<4>
    77
    88Package=<5>
     
    1616###############################################################################
    1717
    18 Project: "bitlbee_ssl"=".\bitlbee_ssl\bitlbee_ssl.dsp" - Package Owner=<4>
     18Project: "bitlbee"=.\bitlbee.dsp - Package Owner=<4>
    1919
    2020Package=<5>
     
    2828###############################################################################
    2929
    30 Project: "jabber"=".\jabber.dsp" - Package Owner=<4>
     30Project: "bitlbee_ssl"=.\bitlbee_ssl.dsp - Package Owner=<4>
     31
     32Package=<5>
     33{{{
     34}}}
     35
     36Package=<4>
     37{{{
     38}}}
     39
     40###############################################################################
     41
     42Project: "jabber"=.\jabber.dsp - Package Owner=<4>
    3143
    3244Package=<5>
     
    4658###############################################################################
    4759
    48 Project: "msn"=".\msn.dsp" - Package Owner=<4>
     60Project: "msn"=.\msn.dsp - Package Owner=<4>
    4961
    5062Package=<5>
     
    6476###############################################################################
    6577
    66 Project: "oscar"=".\oscar.dsp" - Package Owner=<4>
     78Project: "oscar"=.\oscar.dsp - Package Owner=<4>
    6779
    6880Package=<5>
     
    7991###############################################################################
    8092
    81 Project: "yahoo"=".\yahoo.dsp" - Package Owner=<4>
     93Project: "yahoo"=.\yahoo.dsp - Package Owner=<4>
    8294
    8395Package=<5>
Note: See TracChangeset for help on using the changeset viewer.