Changes in / [f665dab:96ace1b]


Ignore:
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • .bzrignore

    rf665dab r96ace1b  
    1010decode
    1111encode
     12bitlbee.pc
  • Makefile

    rf665dab r96ace1b  
    1111# Program variables
    1212objects = account.o bitlbee.o conf.o crypting.o help.o ini.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_text.o unix.o url.o user.o util.o
     13headers = account.h bitlbee.h commands.h conf.h config.h crypting.h help.h ini.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h url.h user.h protocols/http_client.h protocols/md5.h protocols/nogaim.h protocols/proxy.h protocols/sha.h protocols/ssl_client.h
    1314subdirs = protocols
    1415
     
    2223        $(MAKE) -C doc
    2324
    24 uninstall: uninstall-bin uninstall-doc
     25uninstall: uninstall-bin uninstall-doc 
    2526        @echo -e '\nmake uninstall does not remove files in '$(DESTDIR)$(ETCDIR)', you can use make uninstall-etc to do that.\n'
    2627
     
    5859uninstall-bin:
    5960        rm -f $(DESTDIR)$(BINDIR)/$(OUTFILE)
     61
     62install-dev:
     63        mkdir -p $(DESTDIR)$(INCLUDEDIR)
     64        install -m 0644 $(headers) $(DESTDIR)$(INCLUDEDIR)
     65        mkdir -p $(DESTDIR)$(PCDIR)
     66        install -m 0644 bitlbee.pc $(DESTDIR)$(PCDIR)
     67
     68uninstall-dev:
     69        rm -f $(foreach hdr,$(headers),$(DESTDIR)$(INCLUDEDIR)/$(hdr))
     70        -rmdir $(DESTDIR)$(INCLUDEDIR)
     71        rm -f $(DESTDIR)$(PCDIR)/bitlbee.pc
    6072
    6173install-etc:
  • bitlbee.c

    rf665dab r96ace1b  
    118118        if( global.conf->runmode == RUNMODE_FORKDAEMON )
    119119                ipc_master_load_state();
     120
     121        if( global.conf->runmode == RUNMODE_DAEMON ||
     122                global.conf->runmode == RUNMODE_FORKDAEMON )
     123                ipc_master_listen_socket();
    120124       
    121125        if( ( fp = fopen( global.conf->pidfile, "w" ) ) )
  • bitlbee.h

    rf665dab r96ace1b  
    102102#include "storage.h"
    103103#include "set.h"
    104 #include "protocols/nogaim.h"
     104#include "nogaim.h"
    105105#include "commands.h"
    106106#include "account.h"
  • conf.c

    rf665dab r96ace1b  
    139139                                "  -D  Daemon mode. (Still EXPERIMENTAL!)\n"
    140140                                "  -F  Forking daemon. (one process per client)\n"
     141                                "  -P  Specify PID-file (not for inetd mode)\n"
    141142                                "  -i  Specify the interface (by IP address) to listen on.\n"
    142143                                "      (Default: 0.0.0.0 (any interface))\n"
  • configure

    rf665dab r96ace1b  
    1515config='/var/lib/bitlbee/'
    1616pidfile='/var/run/bitlbee.pid'
     17ipcsocket='/var/run/bitlbee'
    1718plugindir='$prefix/lib/bitlbee'
     19pcdir='$prefix/lib/pkgconfig'
     20includedir='$prefix/include/bitlbee'
    1821
    1922msn=1
     
    5053--pidfile=...                                           $pidfile
    5154--config=...                                            $config
     55--ipcsocket=...                                         $ipcsocket
    5256
    5357--msn=0/1       Disable/enable MSN part                 $msn
     
    7983config=`eval echo "$config/" | sed 's/\/\{1,\}/\//g'`
    8084plugindir=`eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g'`
    81 pidfile=`eval echo "$pidfile/" | sed 's/\/\{1,\}/\//g'`
     85pidfile=`eval echo "$pidfile" | sed 's/\/\{1,\}/\//g'`
     86ipcsocket=`eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g'`
     87includedir=`eval echo "$includedir" | sed 's/\/\{1,\}/\//g'`
     88pcdir=`eval echo "$pcdir" | sed 's/\/\{1,\}/\//g'`
    8289
    8390cat<<EOF>Makefile.settings
     
    8996DATADIR=$datadir
    9097PLUGINDIR=$plugindir
    91 PIDFILE=$pidfile
    9298CONFIG=$config
     99IPCSOCKET=$ipcsocket
     100INCLUDEDIR=$includedir
     101PCDIR=$pcdir
    93102
    94103ARCH=$arch
     
    112121#define PLUGINDIR "$plugindir"
    113122#define PIDFILE "$pidfile"
     123#define IPCSOCKET "$ipcsocket"
    114124#define ARCH "$arch"
    115125#define CPU "$cpu"
     
    336346fi
    337347
     348cat <<EOF>bitlbee.pc
     349prefix=$prefix
     350includedir=$includedir
     351
     352Name: bitlbee
     353Description: IRC to IM gateway
     354Requires: glib-2.0
     355Version: $BITLBEE_VERSION
     356Libs:
     357Cflags: -I\${includedir}
     358
     359EOF
     360
    338361protocols=''
    339362protoobjs=''
  • doc/example_plugin.c

    rf665dab r96ace1b  
    33 * a shared library and place it in the plugin directory:
    44 *
    5  * gcc -o example.so -shared example.c
     5 * gcc -o example.so -shared example.c `pkg-config --cflags bitlbee`
    66 * cp example.so /usr/local/lib/bitlbee
    77 */
    88#include <stdio.h>
     9#include <bitlbee.h>
    910
    1011void init_plugin(void)
  • ipc.c

    rf665dab r96ace1b  
    2828#include "ipc.h"
    2929#include "commands.h"
     30#ifndef _WIN32
     31#include <sys/un.h>
     32#endif
    3033
    3134GSList *child_list = NULL;
     
    3437static void ipc_master_cmd_client( irc_t *data, char **cmd )
    3538{
     39        /* Normally data points at an irc_t block, but for the IPC master
     40           this is different. We think this scary cast is better than
     41           creating a new command_t structure, just to make the compiler
     42           happy. */
    3643        struct bitlbee_child *child = (void*) data;
    3744       
     
    457464}
    458465
     466
     467static gboolean new_ipc_client (GIOChannel *gio, GIOCondition cond, gpointer data)
     468{
     469        struct bitlbee_child *child = g_new0( struct bitlbee_child, 1 );
     470        int serversock;
     471
     472        serversock = g_io_channel_unix_get_fd(gio);
     473
     474        child->ipc_fd = accept(serversock, NULL, 0);
     475
     476        if (child->ipc_fd == -1) {
     477                log_message( LOGLVL_WARNING, "Unable to accept connection on UNIX domain socket: %s", strerror(errno) );
     478                return TRUE;
     479        }
     480               
     481        child->ipc_inpa = gaim_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
     482               
     483        child_list = g_slist_append( child_list, child );
     484
     485        return TRUE;
     486}
     487
     488#ifndef _WIN32
     489int ipc_master_listen_socket()
     490{
     491        struct sockaddr_un un_addr;
     492        int serversock;
     493        GIOChannel *gio;
     494
     495        /* Clean up old socket files that were hanging around.. */
     496        if (unlink(IPCSOCKET) == -1 && errno != ENOENT) {
     497                log_message( LOGLVL_ERROR, "Could not remove old IPC socket at %s: %s", IPCSOCKET, strerror(errno) );
     498                return 0;
     499        }
     500
     501        un_addr.sun_family = AF_UNIX;
     502        strcpy(un_addr.sun_path, IPCSOCKET);
     503
     504        serversock = socket(AF_UNIX, SOCK_STREAM, PF_UNIX);
     505
     506        if (serversock == -1) {
     507                log_message( LOGLVL_WARNING, "Unable to create UNIX socket: %s", strerror(errno) );
     508                return 0;
     509        }
     510
     511        if (bind(serversock, &un_addr, sizeof(un_addr)) == -1) {
     512                log_message( LOGLVL_WARNING, "Unable to bind UNIX socket to %s: %s", IPCSOCKET, strerror(errno) );
     513                return 0;
     514        }
     515
     516        if (listen(serversock, 5) == -1) {
     517                log_message( LOGLVL_WARNING, "Unable to listen on UNIX socket: %s", strerror(errno) );
     518                return 0;
     519        }
     520       
     521        gio = g_io_channel_unix_new(serversock);
     522       
     523        if (gio == NULL) {
     524                log_message( LOGLVL_WARNING, "Unable to create IO channel for unix socket" );
     525                return 0;
     526        }
     527
     528        g_io_add_watch(gio, G_IO_IN, new_ipc_client, NULL);
     529        return 1;
     530}
     531#else
     532        /* FIXME: Open named pipe \\.\BITLBEE */
     533#endif
     534
    459535int ipc_master_load_state()
    460536{
  • ipc.h

    rf665dab r96ace1b  
    5757void ipc_master_set_statefile( char *fn );
    5858int ipc_master_load_state();
    59 
     59int ipc_master_listen_socket();
    6060
    6161extern GSList *child_list;
Note: See TracChangeset for help on using the changeset viewer.