Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > c67c6057ffd14254a26624517a2352e6 > files > 244

i3-doc-3.e-3.bf1.fc14.noarch.rpm

<!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/util.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&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;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&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<h1>include/util.h</h1><a href="a00052.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 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 <span class="preprocessor">#include &lt;xcb/xcb.h&gt;</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;err.h&gt;</span>
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 <span class="preprocessor">#include &quot;<a class="code" href="a00036.html">data.h</a>&quot;</span>
<a name="l00015"></a>00015 
<a name="l00016"></a>00016 <span class="preprocessor">#ifndef _UTIL_H</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span><span class="preprocessor">#define _UTIL_H</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span>
<a name="l00019"></a><a class="code" href="a00052.html#a0b2164ee75646f16a7388a36e6800c35">00019</a> <span class="preprocessor">#define die(...) errx(EXIT_FAILURE, __VA_ARGS__);</span>
<a name="l00020"></a><a class="code" href="a00052.html#ad484926a44f04ac0640b81561442091a">00020</a> <span class="preprocessor"></span><span class="preprocessor">#define exit_if_null(pointer, ...) { if (pointer == NULL) die(__VA_ARGS__); }</span>
<a name="l00021"></a><a class="code" href="a00052.html#af748ddf5e598faa86c68328e84cf67de">00021</a> <span class="preprocessor"></span><span class="preprocessor">#define STARTS_WITH(string, needle) (strncasecmp(string, needle, strlen(needle)) == 0)</span>
<a name="l00022"></a><a class="code" href="a00052.html#a637193044fe053d19ac4ca175b00e213">00022</a> <span class="preprocessor"></span><span class="preprocessor">#define CIRCLEQ_NEXT_OR_NULL(head, elm, field) (CIRCLEQ_NEXT(elm, field) != CIRCLEQ_END(head) ? \</span>
<a name="l00023"></a>00023 <span class="preprocessor">                                                CIRCLEQ_NEXT(elm, field) : NULL)</span>
<a name="l00024"></a><a class="code" href="a00052.html#a36f127da0b693024f8fc7018cecaecab">00024</a> <span class="preprocessor"></span><span class="preprocessor">#define CIRCLEQ_PREV_OR_NULL(head, elm, field) (CIRCLEQ_PREV(elm, field) != CIRCLEQ_END(head) ? \</span>
<a name="l00025"></a>00025 <span class="preprocessor">                                                CIRCLEQ_PREV(elm, field) : NULL)</span>
<a name="l00026"></a><a class="code" href="a00052.html#a7da994865329c8424d49403dec5fef5e">00026</a> <span class="preprocessor"></span><span class="preprocessor">#define FOR_TABLE(workspace) \</span>
<a name="l00027"></a>00027 <span class="preprocessor">                        for (int cols = 0; cols &lt; (workspace)-&gt;cols; cols++) \</span>
<a name="l00028"></a>00028 <span class="preprocessor">                                for (int rows = 0; rows &lt; (workspace)-&gt;rows; rows++)</span>
<a name="l00029"></a><a class="code" href="a00052.html#ae88e84de75be0b138a19509d288b4cf4">00029</a> <span class="preprocessor"></span><span class="preprocessor">#define FREE(pointer) do { \</span>
<a name="l00030"></a>00030 <span class="preprocessor">        if (pointer != NULL) { \</span>
<a name="l00031"></a>00031 <span class="preprocessor">                free(pointer); \</span>
<a name="l00032"></a>00032 <span class="preprocessor">                pointer = NULL; \</span>
<a name="l00033"></a>00033 <span class="preprocessor">        } \</span>
<a name="l00034"></a>00034 <span class="preprocessor">} \</span>
<a name="l00035"></a>00035 <span class="preprocessor">while (0)</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span>
<a name="l00037"></a>00037 <a class="code" href="a00047.html#a4abce769a262e090c1f601605b9d6c76">TAILQ_HEAD</a>(keyvalue_table_head, <a class="code" href="a00018.html" title="Emulates the behaviour of tables of libxcb-wm, which in libxcb 0.3.4 suddenly vanished...">keyvalue_element</a>);
<a name="l00038"></a>00038 <span class="keyword">extern</span> <span class="keyword">struct </span>keyvalue_table_head <a class="code" href="a00077.html#a38dffc58d761d720f7c63d35f2efd71d">by_parent</a>;
<a name="l00039"></a>00039 <span class="keyword">extern</span> <span class="keyword">struct </span>keyvalue_table_head <a class="code" href="a00077.html#aadfb9c6f265623f83355191df37c86c8">by_child</a>;
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 <span class="keywordtype">int</span> <a class="code" href="a00077.html#abd8bbcfabb3ddef2ccaafb9928a37b95">min</a>(<span class="keywordtype">int</span> a, <span class="keywordtype">int</span> b);
<a name="l00042"></a>00042 <span class="keywordtype">int</span> <a class="code" href="a00077.html#af082905f7eac6d03e92015146bbc1925">max</a>(<span class="keywordtype">int</span> a, <span class="keywordtype">int</span> b);
<a name="l00043"></a>00043 
<a name="l00049"></a>00049 <span class="keywordtype">bool</span> <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(uint32_t *destination, <span class="keyword">const</span> uint32_t new_value);
<a name="l00050"></a>00050 
<a name="l00056"></a>00056 <span class="keywordtype">void</span> *<a class="code" href="a00077.html#a46c23cb2833f4b674f5cfc977f16b990" title="Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there...">smalloc</a>(<span class="keywordtype">size_t</span> size);
<a name="l00057"></a>00057 
<a name="l00063"></a>00063 <span class="keywordtype">void</span> *<a class="code" href="a00077.html#ad475e1b898d9da9b2a8b92e3da51b3dd" title="Safe-wrapper around calloc which exits if malloc returns NULL (meaning that there...">scalloc</a>(<span class="keywordtype">size_t</span> size);
<a name="l00064"></a>00064 
<a name="l00070"></a>00070 <span class="keywordtype">char</span> *<a class="code" href="a00077.html#a11822d1f4b182be3fa03d2a5af536e1a" title="Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there...">sstrdup</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *str);
<a name="l00071"></a>00071 
<a name="l00076"></a>00076 <span class="keywordtype">bool</span> <a class="code" href="a00077.html#a387447a095debe780790788f18e88d6e" title="Inserts an element into the given keyvalue-table using the given key.">table_put</a>(<span class="keyword">struct</span> keyvalue_table_head *head, uint32_t key, <span class="keywordtype">void</span> *value);
<a name="l00077"></a>00077 
<a name="l00083"></a>00083 <span class="keywordtype">void</span> *<a class="code" href="a00077.html#a325edcce10c699e46d7638d4361599e7" title="Removes the element from the given keyvalue-table with the given key and returns...">table_remove</a>(<span class="keyword">struct</span> keyvalue_table_head *head, uint32_t key);
<a name="l00084"></a>00084 
<a name="l00090"></a>00090 <span class="keywordtype">void</span> *<a class="code" href="a00077.html#ae1529a1d81e2457f9a2402eda35735d7" title="Returns the value of the element of the given keyvalue-table with the given key.">table_get</a>(<span class="keyword">struct</span> keyvalue_table_head *head, uint32_t key);
<a name="l00091"></a>00091 
<a name="l00102"></a>00102 <span class="keywordtype">void</span> <a class="code" href="a00077.html#a4a1b0dbf1f2e37a0ad5a0f6cc786225c" title="Starts the given application by passing it through a shell.">start_application</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *command);
<a name="l00103"></a>00103 
<a name="l00109"></a>00109 <span class="keywordtype">void</span> <a class="code" href="a00077.html#ae8ee4cede01d9a00cbeaffbc5f096f8d" title="Checks a generic cookie for errors and quits with the given message if there was...">check_error</a>(xcb_connection_t *conn, xcb_void_cookie_t cookie,
<a name="l00110"></a>00110                  <span class="keywordtype">char</span> *err_message);
<a name="l00111"></a>00111 
<a name="l00119"></a>00119 <span class="keywordtype">char</span> *<a class="code" href="a00077.html#a1d926a6371d3d87f2dd85c1a27d83f4b" title="Converts the given string to UCS-2 big endian for use with xcb_image_text_16().">convert_utf8_to_ucs2</a>(<span class="keywordtype">char</span> *input, <span class="keywordtype">int</span> *real_strlen);
<a name="l00120"></a>00120 
<a name="l00126"></a>00126 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *<a class="code" href="a00077.html#ad5a21e1f5f7065c1997717c13559907a" title="Returns the client which comes next in focus stack (= was selected before) for the...">get_last_focused_client</a>(xcb_connection_t *conn, <a class="code" href="a00013.html" title="A container is either in default, stacking or tabbed mode.">Container</a> *container,
<a name="l00127"></a>00127                                 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *exclude);
<a name="l00128"></a>00128 
<a name="l00135"></a>00135 <span class="keywordtype">void</span> <a class="code" href="a00077.html#a323dcf30475bb3bf165100e74d225b48" title="Sets the given client as focused by updating the data structures correctly, updating...">set_focus</a>(xcb_connection_t *conn, <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client, <span class="keywordtype">bool</span> set_anyways);
<a name="l00136"></a>00136 
<a name="l00142"></a>00142 <span class="keywordtype">void</span> <a class="code" href="a00077.html#a796c789f58b40c431d9c35860585367e" title="Called when the user switches to another mode or when the container is destroyed...">leave_stack_mode</a>(xcb_connection_t *conn, <a class="code" href="a00013.html" title="A container is either in default, stacking or tabbed mode.">Container</a> *container);
<a name="l00143"></a>00143 
<a name="l00149"></a>00149 <span class="keywordtype">void</span> <a class="code" href="a00077.html#a5b3f86291e1bab74d7edc044a9d87a52" title="Switches the layout of the given container taking care of the necessary house-keeping...">switch_layout_mode</a>(xcb_connection_t *conn, <a class="code" href="a00013.html" title="A container is either in default, stacking or tabbed mode.">Container</a> *container, <span class="keywordtype">int</span> mode);
<a name="l00150"></a>00150 
<a name="l00157"></a>00157 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *<a class="code" href="a00077.html#ad77b9ae748e9583f072306af098dafed" title="Gets the first matching client for the given window class/window title.">get_matching_client</a>(xcb_connection_t *conn,
<a name="l00158"></a>00158                             <span class="keyword">const</span> <span class="keywordtype">char</span> *window_classtitle, <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *specific);
<a name="l00159"></a>00159 
<a name="l00160"></a>00160 <span class="comment">/*</span>
<a name="l00161"></a>00161 <span class="comment"> * Restart i3 in-place</span>
<a name="l00162"></a>00162 <span class="comment"> * appends -a to argument list to disable autostart</span>
<a name="l00163"></a>00163 <span class="comment"> *</span>
<a name="l00164"></a>00164 <span class="comment"> */</span>
<a name="l00165"></a>00165 <span class="keywordtype">void</span> <a class="code" href="a00077.html#aa6932bace7059f6a57068cdf87de1e1f">i3_restart</a>();
<a name="l00166"></a>00166 
<a name="l00167"></a>00167 <span class="preprocessor">#if defined(__OpenBSD__)</span>
<a name="l00168"></a>00168 <span class="preprocessor"></span><span class="comment">/* OpenBSD does not provide memmem(), so we provide FreeBSD’s implementation */</span>
<a name="l00169"></a>00169 <span class="keywordtype">void</span> *memmem(<span class="keyword">const</span> <span class="keywordtype">void</span> *l, <span class="keywordtype">size_t</span> l_len, <span class="keyword">const</span> <span class="keywordtype">void</span> *s, <span class="keywordtype">size_t</span> s_len);
<a name="l00170"></a>00170 <span class="preprocessor">#endif</span>
<a name="l00171"></a>00171 <span class="preprocessor"></span>
<a name="l00172"></a>00172 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated by&nbsp;
<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>