<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>i3: include/ipc.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.2-20100208 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <h1>include/ipc.h</h1><a href="a00042.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> * vim:ts=8:expandtab</span> <a name="l00003"></a>00003 <span class="comment"> *</span> <a name="l00004"></a>00004 <span class="comment"> * i3 - an improved dynamic tiling window manager</span> <a name="l00005"></a>00005 <span class="comment"> *</span> <a name="l00006"></a>00006 <span class="comment"> * © 2009-2010 Michael Stapelberg and contributors</span> <a name="l00007"></a>00007 <span class="comment"> *</span> <a name="l00008"></a>00008 <span class="comment"> * See file LICENSE for license information.</span> <a name="l00009"></a>00009 <span class="comment"> *</span> <a name="l00010"></a>00010 <span class="comment"> */</span> <a name="l00011"></a>00011 <a name="l00012"></a>00012 <span class="preprocessor">#ifndef _IPC_H</span> <a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#define _IPC_H</span> <a name="l00014"></a>00014 <span class="preprocessor"></span> <a name="l00015"></a>00015 <span class="preprocessor">#include <ev.h></span> <a name="l00016"></a>00016 <a name="l00017"></a>00017 <span class="preprocessor">#include "i3/ipc.h"</span> <a name="l00018"></a>00018 <a name="l00019"></a><a class="code" href="a00017.html#abbf0032a20872af40f2c48187482c479">00019</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="a00017.html">ipc_client</a> { <a name="l00020"></a>00020 <span class="keywordtype">int</span> <a class="code" href="a00017.html#abbf0032a20872af40f2c48187482c479">fd</a>; <a name="l00021"></a>00021 <a name="l00022"></a><a class="code" href="a00017.html#a46ac6148b46c11a44deb54146c616d86">00022</a> <span class="comment">/* The events which this client wants to receive */</span> <a name="l00023"></a><a class="code" href="a00017.html#a33769d4392c623c174ffd78c643fa2a3">00023</a> <span class="keywordtype">int</span> <a class="code" href="a00017.html#a46ac6148b46c11a44deb54146c616d86">num_events</a>; <a name="l00024"></a>00024 <span class="keywordtype">char</span> **<a class="code" href="a00017.html#a33769d4392c623c174ffd78c643fa2a3">events</a>; <a name="l00025"></a>00025 <a name="l00026"></a>00026 <a class="code" href="a00017.html#a8bfe76352eed42e1bd58eb15c14ce2d9">TAILQ_ENTRY</a>(<a class="code" href="a00017.html">ipc_client</a>) clients; <a name="l00027"></a>00027 } <a class="code" href="a00017.html">ipc_client</a>; <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="comment">/*</span> <a name="l00030"></a>00030 <span class="comment"> * Callback type for the different message types.</span> <a name="l00031"></a>00031 <span class="comment"> *</span> <a name="l00032"></a>00032 <span class="comment"> * message is the raw packet, as received from the UNIX domain socket. size</span> <a name="l00033"></a>00033 <span class="comment"> * is the remaining size of bytes for this packet.</span> <a name="l00034"></a>00034 <span class="comment"> *</span> <a name="l00035"></a>00035 <span class="comment"> * message_size is the size of the message as the sender specified it.</span> <a name="l00036"></a>00036 <span class="comment"> * message_type is the type of the message as the sender specified it.</span> <a name="l00037"></a>00037 <span class="comment"> *</span> <a name="l00038"></a>00038 <span class="comment"> */</span> <a name="l00039"></a><a class="code" href="a00042.html#a6b1a00999ddde8264249521fa10d7b08">00039</a> typedef <span class="keywordtype">void</span>(*<a class="code" href="a00042.html#a6b1a00999ddde8264249521fa10d7b08">handler_t</a>)(<span class="keywordtype">int</span>, uint8_t*, <span class="keywordtype">int</span>, uint32_t, uint32_t); <a name="l00040"></a>00040 <a name="l00041"></a>00041 <span class="comment">/* Macro to declare a callback */</span> <a name="l00042"></a><a class="code" href="a00042.html#a0d061102ea72ae69fcd76e0692ccac71">00042</a> <span class="preprocessor">#define IPC_HANDLER(name) \</span> <a name="l00043"></a>00043 <span class="preprocessor"> static void handle_ ## name (int fd, uint8_t *message, \</span> <a name="l00044"></a>00044 <span class="preprocessor"> int size, uint32_t message_size, \</span> <a name="l00045"></a>00045 <span class="preprocessor"> uint32_t message_type)</span> <a name="l00046"></a>00046 <span class="preprocessor"></span> <a name="l00054"></a>00054 <span class="keywordtype">void</span> <a class="code" href="a00068.html#ab60981ffa93c190e40d52e05f6c8a4d8" title="Handler for activity on the listening socket, meaning that a new client has just...">ipc_new_client</a>(EV_P_ <span class="keyword">struct</span> ev_io *w, <span class="keywordtype">int</span> revents); <a name="l00055"></a>00055 <a name="l00061"></a>00061 <span class="keywordtype">int</span> <a class="code" href="a00068.html#a173c2426068f80edfacc45e1fca642d4" title="Creates the UNIX domain socket at the given path, sets it to non-blocking mode, bind()s...">ipc_create_socket</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *filename); <a name="l00062"></a>00062 <a name="l00068"></a>00068 <span class="keywordtype">void</span> <a class="code" href="a00068.html#ad525c6fad9f4978ae1f06282ad9de6c6" title="Sends the specified event to all IPC clients which are currently connected and subscribed...">ipc_send_event</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *event, uint32_t message_type, <span class="keyword">const</span> <span class="keywordtype">char</span> *payload); <a name="l00069"></a>00069 <a name="l00075"></a>00075 <span class="keywordtype">void</span> <a class="code" href="a00068.html#ae12d3a1c83452d7fb9b9ae9ce23bb424" title="Calls shutdown() on each socket and closes it.">ipc_shutdown</a>(); <a name="l00076"></a>00076 <a name="l00077"></a>00077 <span class="preprocessor">#endif</span> </pre></div></div> <hr class="footer"/><address style="text-align: right;"><small>Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2-20100208 </small></address> </body> </html>