src/ipc.c File Reference

#include <sys/socket.h>
#include <sys/un.h>
#include <fcntl.h>
#include <libgen.h>
#include <ev.h>
#include <yajl/yajl_gen.h>
#include <yajl/yajl_parse.h>
#include <yajl/yajl_version.h>
#include "all.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)
static void dump_rect (yajl_gen gen, const char *name, Rect r)
void dump_node (yajl_gen gen, struct Con *con, bool inplace_restart)
 IPC_HANDLER (tree)
 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

char * current_socketpath = NULL
handler_t handlers [5]

Define Documentation

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

Definition at line 28 of file ipc.c.

Referenced by dump_node(), dump_rect(), and IPC_HANDLER().


Function Documentation

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

Definition at line 468 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:

void dump_node ( yajl_gen  gen,
struct Con con,
bool  inplace_restart 
)

Definition at line 174 of file ipc.c.

References BS_1PIXEL, BS_NONE, BS_NORMAL, Match::dock, dump_node(), dump_rect(), focused, HORIZ, Match::insert_where, NO_ORIENTATION, TAILQ_FOREACH, VERT, y, and ystr.

Referenced by dump_node(), IPC_HANDLER(), and store_restart_layout().

Here is the call graph for this function:

static void dump_rect ( yajl_gen  gen,
const char *  name,
Rect  r 
) [static]

Definition at line 160 of file ipc.c.

References Rect::height, Rect::width, Rect::x, Rect::y, y, and ystr.

Referenced by dump_node().

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 691 of file ipc.c.

References current_socketpath, DLOG, FREE, mkdirp(), path_exists(), resolve_tilde(), and sstrdup().

Referenced by main().

Here is the call graph for this function:

IPC_HANDLER ( subscribe   ) 

Definition at line 499 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 410 of file ipc.c.

References xoutput::active, xoutput::con, con_get_fullscreen_con(), Rect::height, ipc_send_message(), Con::name, xoutput::name, 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 ( tree   ) 

Definition at line 311 of file ipc.c.

References croot, dump_node(), ipc_send_message(), and y.

Here is the call graph for this function:

IPC_HANDLER ( command   ) 

Definition at line 144 of file ipc.c.

References ipc_send_message(), LOG, parse_cmd(), 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 661 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]

Definition at line 568 of file ipc.c.

References DLOG, ipc_client::events, ipc_client::fd, ipc_client::num_events, TAILQ_FOREACH, and TAILQ_REMOVE.

Referenced by ipc_new_client().

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 107 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(), workspace_get(), workspace_show(), workspace_update_urgent_flag(), and yyparse().

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 73 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 131 of file ipc.c.

References ipc_client::fd, and TAILQ_FOREACH.

Referenced by i3_restart().

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

Definition at line 49 of file ipc.c.

References ELOG.

Referenced by ipc_create_socket().

TAILQ_HEAD ( ipc_client_head  ,
ipc_client   
)

Definition at line 30 of file ipc.c.


Variable Documentation

char* current_socketpath = NULL

Definition at line 24 of file ipc.c.

Referenced by ipc_create_socket(), and x_set_i3_atoms().

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

Definition at line 550 of file ipc.c.


Generated on 7 Feb 2013 for i3 by  doxygen 1.6.1