Changeset 6dff9d4 for ipc.c


Ignore:
Timestamp:
2006-03-01T21:08:03Z (14 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
8a56e52
Parents:
7cf85e7
Message:

Also listen for admin connections on a unix domain socket at /var/run/bitlbee

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ipc.c

    r7cf85e7 r6dff9d4  
    2828#include "ipc.h"
    2929#include "commands.h"
     30#ifndef _WIN32
     31#include <sys/un.h>
     32#endif
    3033
    3134GSList *child_list = NULL;
     
    457460}
    458461
     462
     463static gboolean new_ipc_client (GIOChannel *gio, GIOCondition cond, gpointer data)
     464{
     465        struct bitlbee_child *child = g_new0( struct bitlbee_child, 1 );
     466        int serversock;
     467
     468        serversock = g_io_channel_unix_get_fd(gio);
     469
     470        child->ipc_fd = accept(serversock, NULL, 0);
     471               
     472        child->ipc_inpa = gaim_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
     473               
     474        child_list = g_slist_append( child_list, child );
     475
     476        return TRUE;
     477}
     478
     479#ifndef _WIN32
     480int ipc_master_listen_socket()
     481{
     482        struct sockaddr_un un_addr;
     483        int serversock;
     484        GIOChannel *gio;
     485
     486        /* Clean up old socket files that were hanging around.. */
     487        unlink(IPCSOCKET);
     488
     489        un_addr.sun_family = AF_UNIX;
     490        strcpy(un_addr.sun_path, IPCSOCKET);
     491
     492        serversock = socket(AF_UNIX, SOCK_STREAM, PF_UNIX);
     493
     494        bind(serversock, &un_addr, sizeof(un_addr));
     495
     496        listen(serversock, 5);
     497       
     498        gio = g_io_channel_unix_new(serversock);
     499
     500        g_io_add_watch(gio, G_IO_IN, new_ipc_client, NULL);
     501        return 1;
     502}
     503#else
     504        /* FIXME: Open named pipe \\.\BITLBEE */
     505#endif
     506
    459507int ipc_master_load_state()
    460508{
Note: See TracChangeset for help on using the changeset viewer.