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