Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ipc.c

    r8a56e52 r5e713f6  
    2828#include "ipc.h"
    2929#include "commands.h"
    30 #ifndef _WIN32
    31 #include <sys/un.h>
    32 #endif
    3330
    3431GSList *child_list = NULL;
     
    3734static void ipc_master_cmd_client( irc_t *data, char **cmd )
    3835{
     36        /* Normally data points at an irc_t block, but for the IPC master
     37           this is different. We think this scary cast is better than
     38           creating a new command_t structure, just to make the compiler
     39           happy. */
    3940        struct bitlbee_child *child = (void*) data;
    4041       
     
    460461}
    461462
    462 
    463 static 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         if (child->ipc_fd == -1) {
    473                 log_message( LOGLVL_WARNING, "Unable to accept connection on UNIX domain socket: %s", strerror(errno) );
    474                 return TRUE;
    475         }
    476                
    477         child->ipc_inpa = gaim_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
    478                
    479         child_list = g_slist_append( child_list, child );
    480 
    481         return TRUE;
    482 }
    483 
    484 #ifndef _WIN32
    485 int ipc_master_listen_socket()
    486 {
    487         struct sockaddr_un un_addr;
    488         int serversock;
    489         GIOChannel *gio;
    490 
    491         /* Clean up old socket files that were hanging around.. */
    492         if (unlink(IPCSOCKET) == -1 && errno != ENOENT) {
    493                 log_message( LOGLVL_ERROR, "Could not remove old IPC socket at %s: %s", IPCSOCKET, strerror(errno) );
    494                 return 0;
    495         }
    496 
    497         un_addr.sun_family = AF_UNIX;
    498         strcpy(un_addr.sun_path, IPCSOCKET);
    499 
    500         serversock = socket(AF_UNIX, SOCK_STREAM, PF_UNIX);
    501 
    502         if (serversock == -1) {
    503                 log_message( LOGLVL_WARNING, "Unable to create UNIX socket: %s", strerror(errno) );
    504                 return 0;
    505         }
    506 
    507         if (bind(serversock, &un_addr, sizeof(un_addr)) == -1) {
    508                 log_message( LOGLVL_WARNING, "Unable to bind UNIX socket to %s: %s", IPCSOCKET, strerror(errno) );
    509                 return 0;
    510         }
    511 
    512         if (listen(serversock, 5) == -1) {
    513                 log_message( LOGLVL_WARNING, "Unable to listen on UNIX socket: %s", strerror(errno) );
    514                 return 0;
    515         }
    516        
    517         gio = g_io_channel_unix_new(serversock);
    518        
    519         if (gio == NULL) {
    520                 log_message( LOGLVL_WARNING, "Unable to create IO channel for unix socket" );
    521                 return 0;
    522         }
    523 
    524         g_io_add_watch(gio, G_IO_IN, new_ipc_client, NULL);
    525         return 1;
    526 }
    527 #else
    528         /* FIXME: Open named pipe \\.\BITLBEE */
    529 #endif
    530 
    531463int ipc_master_load_state()
    532464{
Note: See TracChangeset for help on using the changeset viewer.