src/ipc.c File Reference

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <err.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <libgen.h>
#include <ev.h>
#include <yajl/yajl_gen.h>
#include <yajl/yajl_parse.h>
#include "queue.h"
#include "ipc.h"
#include "i3.h"
#include "util.h"
#include "commands.h"
#include "log.h"
#include "table.h"
#include "randr.h"
#include "config.h"
Include dependency graph for ipc.c:

Go to the source code of this file.

Defines

#define y(x,...)   yajl_gen_ ## x (gen, ##__VA_ARGS__)
#define ystr(str)   yajl_gen_string(gen, (unsigned char*)str, strlen(str))

Functions

 TAILQ_HEAD (ipc_client_head, ipc_client)
static bool mkdirp (const char *path)
static void ipc_send_message (int fd, const unsigned char *payload, int message_type, int message_size)
void ipc_send_event (const char *event, uint32_t message_type, const char *payload)
 Sends the specified event to all IPC clients which are currently connected and subscribed to this kind of event.
void ipc_shutdown ()
 Calls shutdown() on each socket and closes it.
 IPC_HANDLER (command)
 IPC_HANDLER (get_workspaces)
 IPC_HANDLER (get_outputs)
static int add_subscription (void *extra, const unsigned char *s, unsigned int len)
 IPC_HANDLER (subscribe)
static void ipc_receive_message (EV_P_ struct ev_io *w, int revents)
void ipc_new_client (EV_P_ struct ev_io *w, int revents)
 Handler for activity on the listening socket, meaning that a new client has just connected and we should accept() him.
int ipc_create_socket (const char *filename)
 Creates the UNIX domain socket at the given path, sets it to non-blocking mode, bind()s and listen()s on it.

Variables

handler_t handlers [4]

Define Documentation

#define y ( x,
...   )     yajl_gen_ ## x (gen, ##__VA_ARGS__)

Definition at line 41 of file ipc.c.

Referenced by handle_configure_request(), IPC_HANDLER(), and open_input_window().

#define ystr ( str   )     yajl_gen_string(gen, (unsigned char*)str, strlen(str))

Definition at line 42 of file ipc.c.

Referenced by IPC_HANDLER().


Function Documentation

static int add_subscription ( void *  extra,
const unsigned char *  s,
unsigned int  len 
) [static]

Definition at line 290 of file ipc.c.

References DLOG, ipc_client::events, ipc_client::num_events, and scalloc().

Referenced by IPC_HANDLER().

Here is the call graph for this function:

int ipc_create_socket ( const char *  filename  ) 

Creates the UNIX domain socket at the given path, sets it to non-blocking mode, bind()s and listen()s on it.

Definition at line 502 of file ipc.c.

References DLOG, glob_path(), mkdirp(), path_exists(), and sstrdup().

Referenced by main().

Here is the call graph for this function:

IPC_HANDLER ( subscribe   ) 

Definition at line 317 of file ipc.c.

References add_subscription(), ELOG, ipc_client::fd, ipc_send_message(), and TAILQ_FOREACH.

Here is the call graph for this function:

IPC_HANDLER ( get_outputs   ) 

Definition at line 241 of file ipc.c.

References xoutput::active, xoutput::current_workspace, Rect::height, ipc_send_message(), xoutput::name, Workspace::num, outputs, xoutput::rect, TAILQ_FOREACH, Rect::width, Rect::x, Rect::y, y, and ystr.

Here is the call graph for this function:

IPC_HANDLER ( get_workspaces   ) 
IPC_HANDLER ( command   ) 

Definition at line 158 of file ipc.c.

References global_conn, ipc_send_message(), parse_command(), and scalloc().

Here is the call graph for this function:

void ipc_new_client ( EV_P_ struct ev_io *  w,
int  revents 
)

Handler for activity on the listening socket, meaning that a new client has just connected and we should accept() him.

Sets up the event handler for activity on the new connection and inserts the file descriptor into the list of clients.

Definition at line 472 of file ipc.c.

References DLOG, ipc_receive_message(), scalloc(), and TAILQ_INSERT_TAIL.

Referenced by main().

Here is the call graph for this function:

static void ipc_receive_message ( EV_P_ struct ev_io *  w,
int  revents 
) [static]
void ipc_send_event ( const char *  event,
uint32_t  message_type,
const char *  payload 
)

Sends the specified event to all IPC clients which are currently connected and subscribed to this kind of event.

Definition at line 121 of file ipc.c.

References ipc_client::events, ipc_client::fd, ipc_send_message(), ipc_client::num_events, and TAILQ_FOREACH.

Referenced by handle_screen_change(), handle_unmap_notify_event(), initialize_output(), parse_command(), workspace_assign_to(), workspace_get(), workspace_show(), and workspace_update_urgent_flag().

Here is the call graph for this function:

static void ipc_send_message ( int  fd,
const unsigned char *  payload,
int  message_type,
int  message_size 
) [static]

Definition at line 87 of file ipc.c.

References DLOG.

Referenced by IPC_HANDLER(), and ipc_send_event().

void ipc_shutdown (  ) 

Calls shutdown() on each socket and closes it.

This function to be called when exiting or restarting only!

Definition at line 145 of file ipc.c.

References ipc_client::fd, and TAILQ_FOREACH.

Referenced by i3_restart(), and parse_command().

static bool mkdirp ( const char *  path  )  [static]

Definition at line 63 of file ipc.c.

References ELOG.

Referenced by ipc_create_socket().

TAILQ_HEAD ( ipc_client_head  ,
ipc_client   
)

Definition at line 44 of file ipc.c.


Variable Documentation

Initial value:
 {
        handle_command,
        handle_get_workspaces,
        handle_subscribe,
        handle_get_outputs
}

Definition at line 364 of file ipc.c.

Referenced by ipc_receive_message().


Generated on 2 Jul 2010 for i3 by  doxygen 1.6.1