i3
|
00001 /* 00002 * vim:ts=4:sw=4:expandtab 00003 * 00004 * i3 - an improved dynamic tiling window manager 00005 * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE) 00006 * 00007 * ipc.c: UNIX domain socket IPC (initialization, client handling, protocol). 00008 * 00009 */ 00010 #ifndef _IPC_H 00011 #define _IPC_H 00012 00013 #include <ev.h> 00014 #include <stdbool.h> 00015 #include <yajl/yajl_gen.h> 00016 #include <yajl/yajl_parse.h> 00017 00018 #include "data.h" 00019 #include "tree.h" 00020 00021 #include "i3/ipc.h" 00022 00023 extern char *current_socketpath; 00024 00025 typedef struct ipc_client { 00026 int fd; 00027 00028 /* The events which this client wants to receive */ 00029 int num_events; 00030 char **events; 00031 00032 TAILQ_ENTRY(ipc_client) clients; 00033 } ipc_client; 00034 00035 /* 00036 * Callback type for the different message types. 00037 * 00038 * message is the raw packet, as received from the UNIX domain socket. size 00039 * is the remaining size of bytes for this packet. 00040 * 00041 * message_size is the size of the message as the sender specified it. 00042 * message_type is the type of the message as the sender specified it. 00043 * 00044 */ 00045 typedef void(*handler_t)(int, uint8_t*, int, uint32_t, uint32_t); 00046 00047 /* Macro to declare a callback */ 00048 #define IPC_HANDLER(name) \ 00049 static void handle_ ## name (int fd, uint8_t *message, \ 00050 int size, uint32_t message_size, \ 00051 uint32_t message_type) 00052 00060 void ipc_new_client(EV_P_ struct ev_io *w, int revents); 00061 00067 int ipc_create_socket(const char *filename); 00068 00074 void ipc_send_event(const char *event, uint32_t message_type, const char *payload); 00075 00081 void ipc_shutdown(); 00082 00083 void dump_node(yajl_gen gen, Con *con, bool inplace_restart); 00084 00085 #endif