#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"
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] |
Definition at line 41 of file ipc.c.
Referenced by IPC_HANDLER().
#define ystr | ( | str | ) | yajl_gen_string(gen, (unsigned char*)str, strlen(str)) |
Definition at line 42 of file ipc.c.
Referenced by IPC_HANDLER().
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().
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().
IPC_HANDLER | ( | command | ) |
Definition at line 158 of file ipc.c.
References global_conn, ipc_send_message(), parse_command(), and scalloc().
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.
IPC_HANDLER | ( | subscribe | ) |
Definition at line 317 of file ipc.c.
References ELOG, ipc_client::fd, ipc_send_message(), and TAILQ_FOREACH.
IPC_HANDLER | ( | get_workspaces | ) |
Definition at line 178 of file ipc.c.
References c_ws, xoutput::current_workspace, Rect::height, ipc_send_message(), xoutput::name, Workspace::num, Workspace::output, Workspace::rect, SLIST_END, SLIST_FIRST, TAILQ_FOREACH, Workspace::urgent, Workspace::utf8_name, Rect::width, workspaces, Rect::x, Rect::y, y, and ystr.
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().
static void ipc_receive_message | ( | EV_P_ struct ev_io * | w, | |
int | revents | |||
) | [static] |
Definition at line 381 of file ipc.c.
References DLOG, ipc_client::events, ipc_client::fd, handlers, 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 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().
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] |
TAILQ_HEAD | ( | ipc_client_head | , | |
ipc_client | ||||
) |
{ handle_command, handle_get_workspaces, handle_subscribe, handle_get_outputs }
Definition at line 364 of file ipc.c.
Referenced by ipc_receive_message().