Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > c6601b2b228e5b275ef3625eb28da668 > files > 20

libinotifytools-devel-3.13-3mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>libinotifytools: inotifytools/inotifytools.h File Reference</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.5.9 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</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>File&nbsp;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>inotifytools/inotifytools.h File Reference</h1>inotifytools library public interface.  
<a href="#_details">More...</a>
<p>

<p>
<a href="inotifytools_8h_source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#7efdc91ac4b26c374d287aa11b3af994">inotifytools_cleanup</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#313399ccce221c8a5862892396d1a8ec">inotifytools_error</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#744bb8792d8ea8edbaf8f845fe1d9307">inotifytools_event_to_str</a> (int events)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#317a5b1ea969f570a49c4549b22e7e71">inotifytools_event_to_str_sep</a> (int events, char sep)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#fd4dcc915248f2d0b0ae708e88611186">inotifytools_filename_from_wd</a> (int wd)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#6ed4450ad545bde13a1328e53ed8cf6d">inotifytools_fprintf</a> (FILE *file, struct inotify_event *event, char *fmt)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#1d96f4600d1187670304b83439b0cd05">inotifytools_get_max_queued_events</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#9e8052a5fb77768cec9fff4aed9b9eb0">inotifytools_get_max_user_instances</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#e3b79f096737ef3c7e176324514b4556">inotifytools_get_max_user_watches</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#af934e6f66eb02f3c6e72d65c9bd610c">inotifytools_get_num_watches</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#70bf8afcf5dce7d324d3a1a4cf48871a">inotifytools_get_stat_by_filename</a> (char const *filename, int event)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#4d5002bd8504b70faed608886e0fa307">inotifytools_get_stat_by_wd</a> (int wd, int event)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#f3de070bdf428d548e0b54f5e9043dcc">inotifytools_get_stat_total</a> (int event)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#07f4f258123feb8864f89663a2785ef0">inotifytools_ignore_events_by_regex</a> (char const *pattern, int flags)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#3765c7874caeb0732926f34ae3c3cd63">inotifytools_initialize</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#e25cb60b12e3555795f55fb8c55db692">inotifytools_initialize_stats</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">struct inotify_event *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#2e121fde1cac7875d25a7e6c3bc57e1a">inotifytools_next_event</a> (int timeout)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">struct inotify_event *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#188fd24a5d8ff504e1a3616ded73a4c1">inotifytools_next_events</a> (int timeout, int num_events)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#c2c06dd72f39a6145ea3b6661378df31">inotifytools_printf</a> (struct inotify_event *event, char *fmt)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#2a4ca66a9d8b0825d4272cd5003a9a0f">inotifytools_remove_watch_by_filename</a> (char const *filename)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#771f60d2232201c691fe725d5cf7e019">inotifytools_remove_watch_by_wd</a> (int wd)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#c6f5ecf6f3d854535132fe9790db008d">inotifytools_replace_filename</a> (char const *oldname, char const *newname)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#764239f33bd2a092c445362e75828181">inotifytools_set_filename_by_filename</a> (char const *oldname, char const *newname)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#f80acc2952c748a80641926ff222571c">inotifytools_set_filename_by_wd</a> (int wd, char const *filename)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#f4528ccdf013b4c86e8f7fe4db88244a">inotifytools_set_printf_timefmt</a> (char *fmt)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#92f2dc66af4fd01b09b64b6813686282">inotifytools_snprintf</a> (char *out, int size, struct inotify_event *event, char *fmt)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#abf4cbafd50012f6e35b32a052677c74">inotifytools_sprintf</a> (char *out, struct inotify_event *event, char *fmt)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#c5f03415912fa505bcb7f2caf9273b45">inotifytools_str_to_event</a> (char const *event)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#7e26c94c983d93669813c439883b334f">inotifytools_str_to_event_sep</a> (char const *event, char sep)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#f9ce33904730bcafbda98c35b1ba4931">inotifytools_watch_file</a> (char const *filename, int events)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#88c6a7db52fbd9310ef72d2588c9c1df">inotifytools_watch_files</a> (char const *filenames[], int events)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#583ff8d0e64f527af4232814ad493dce">inotifytools_watch_recursively</a> (char const *path, int events)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#20981c7f1410d458b5ef0654b9adf1e4">inotifytools_watch_recursively_with_exclude</a> (char const *path, int events, char const **exclude_list)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="inotifytools_8h.html#594e7f515b392c07c4f1f4eeffcda6c3">inotifytools_wd_from_filename</a> (char const *filename)</td></tr>

</table>
<hr><h2>Detailed Description</h2>
inotifytools library public interface. 
<p>
<dl class="author" compact><dt><b>Author:</b></dt><dd>Rohan McGovern, &lt;<a href="mailto:rohan@mcgovern.id.au">rohan@mcgovern.id.au</a>&gt;</dd></dl>
This library provides a thin layer on top of the basic inotify interface. The primary use is to easily set up watches on files, potentially many files at once, and read events without having to deal with low-level I/O. There are also several utility functions for inotify-related string formatting.<p>
To use this library, you must <code>#include</code> the following headers accordingly: <ul>
<li><code>&lt;<a class="el" href="inotifytools_8h.html" title="inotifytools library public interface.">inotifytools/inotifytools.h</a>&gt;</code> - to use any functions declared in this file. </li>
<li><code>&lt;inotifytools/inotify.h&gt;</code> - to have the <code>inotify_event</code> type defined and the numeric IN_* event constants defined. If <code>&lt;sys/inotify.h&gt;</code> was present on your system at compile time, this header simply includes that. Otherwise it includes <code>&lt;inotifytools/inotify-nosys.h&gt;</code>.</li>
</ul>
<h2><a class="anchor" name="example">
Example</a></h2>
This very simple program recursively watches the entire directory tree under its working directory for events, then prints them out with a timestamp. <div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;stdio.h&gt;</span>
<span class="preprocessor">#include &lt;string.h&gt;</span>
<span class="preprocessor">#include &lt;<a class="code" href="inotifytools_8h.html" title="inotifytools library public interface.">inotifytools/inotifytools.h</a>&gt;</span>
<span class="preprocessor">#include &lt;inotifytools/inotify.h&gt;</span>

<span class="comment">/*</span>
<span class="comment"> * libinotifytools example program.</span>
<span class="comment"> * Compile with gcc -linotifytools example.c</span>
<span class="comment"> */</span>
<span class="keywordtype">int</span> main() {
        <span class="comment">// initialize and watch the entire directory tree from the current working</span>
        <span class="comment">// directory downwards for all events</span>
        <span class="keywordflow">if</span> ( !<a class="code" href="inotifytools_8h.html#3765c7874caeb0732926f34ae3c3cd63">inotifytools_initialize</a>()
          || !<a class="code" href="inotifytools_8h.html#583ff8d0e64f527af4232814ad493dce">inotifytools_watch_recursively</a>( <span class="stringliteral">"."</span>, IN_ALL_EVENTS ) ) {
                fprintf(stderr, <span class="stringliteral">"%s\n"</span>, strerror( <a class="code" href="inotifytools_8h.html#313399ccce221c8a5862892396d1a8ec">inotifytools_error</a>() ) );
                <span class="keywordflow">return</span> -1;
        }

        <span class="comment">// set time format to 24 hour time, HH:MM:SS</span>
        <a class="code" href="inotifytools_8h.html#f4528ccdf013b4c86e8f7fe4db88244a">inotifytools_set_printf_timefmt</a>( <span class="stringliteral">"%T"</span> );

        <span class="comment">// Output all events as "&lt;timestamp&gt; &lt;path&gt; &lt;events&gt;"</span>
        <span class="keyword">struct </span>inotify_event * <span class="keyword">event</span> = <a class="code" href="inotifytools_8h.html#2e121fde1cac7875d25a7e6c3bc57e1a">inotifytools_next_event</a>( -1 );
        <span class="keywordflow">while</span> ( event ) {
                <a class="code" href="inotifytools_8h.html#c2c06dd72f39a6145ea3b6661378df31">inotifytools_printf</a>( event, <span class="stringliteral">"%T %w%f %e\n"</span> );
                <span class="keyword">event</span> = <a class="code" href="inotifytools_8h.html#2e121fde1cac7875d25a7e6c3bc57e1a">inotifytools_next_event</a>( -1 );
        }
}

</pre></div><h2><a class="anchor" name="events">
Events</a></h2>
<dl class="note" compact><dt><b>Note:</b></dt><dd>This section comes almost verbatim from the inotify(7) man page.</dd></dl>
<dl class="warning" compact><dt><b>Warning:</b></dt><dd>The information here applies to inotify in Linux 2.6.17. Older versions of Linux may not support all the events described here.</dd></dl>
The following numeric events can be specified to functions in inotifytools, and may be present in events returned through inotifytools:<p>
<ul>
<li><code>IN_ACCESS</code> - File was accessed (read) <em>*</em> </li>
<li><code>IN_ATTRIB</code> - Metadata changed (permissions, timestamps, extended attributes, etc.) <em>*</em> </li>
<li><code>IN_CLOSE_WRITE</code> - File opened for writing was closed <em>*</em> </li>
<li><code>IN_CLOSE_NOWRITE</code> - File not opened for writing was closed <em>*</em> </li>
<li><code>IN_CREATE</code> - File/directory created in watched directory <em>*</em> </li>
<li><code>IN_DELETE</code> - File/directory deleted from watched directory <em>*</em> </li>
<li><code>IN_DELETE_SELF</code> - Watched file/directory was itself deleted </li>
<li><code>IN_MODIFY</code> - File was modified <em>*</em> </li>
<li><code>IN_MOVE_SELF</code> - Watched file/directory was itself moved </li>
<li><code>IN_MOVED_FROM</code> - File moved out of watched directory <em>*</em> </li>
<li><code>IN_MOVED_TO</code> - File moved into watched directory <em>*</em> </li>
<li><code>IN_OPEN</code> - File was opened <em>*</em> </li>
</ul>
When monitoring a directory, the events marked with an asterisk <em>*</em> above can occur for files in the directory, in which case the name field in the returned inotify_event structure identifies the name of the file within the directory.<p>
The IN_ALL_EVENTS macro is defined as a bit mask of all of the above events.<p>
Two additional convenience macros are IN_MOVE, which equates to IN_MOVED_FROM|IN_MOVED_TO, and IN_CLOSE which equates to IN_CLOSE_WRITE|IN_CLOSE_NOWRITE.<p>
The following bitmasks can also be provided when creating a new watch:<p>
<ul>
<li><code>IN_DONT_FOLLOW</code> - Don't dereference pathname if it is a symbolic link </li>
<li><code>IN_MASK_ADD</code> - Add (OR) events to watch mask for this pathname if it already exists (instead of replacing mask) </li>
<li><code>IN_ONESHOT</code> - Monitor pathname for one event, then remove from watch list </li>
<li><code>IN_ONLYDIR</code> - Only watch pathname if it is a directory</li>
</ul>
The following bitmasks may occur in events generated by a watch:<p>
<ul>
<li><code>IN_IGNORED</code> - Watch was removed explicitly (inotifytools_remove_watch_*) or automatically (file was deleted, or file system was unmounted) </li>
<li><code>IN_ISDIR</code> - Subject of this event is a directory </li>
<li><code>IN_Q_OVERFLOW</code> - Event queue overflowed (wd is -1 for this event) </li>
<li><code>IN_UNMOUNT</code> - File system containing watched object was unmounted</li>
</ul>
<h2><a class="anchor" name="TODO">
TODO list</a></h2>
<dl class="todo" compact><dt><b><a class="el" href="todo.html#_todo000001">Todo:</a></b></dt><dd>Improve wd/filename mapping. Currently there is no explicit code for handling different filenames mapping to the same inode (and hence, wd). gamin's approach sounds good: let the user watch an inode using several different filenames, and when an event occurs on the inode, generate an event for each filename. </dd></dl>

<p>Definition in file <a class="el" href="inotifytools_8h_source.html">inotifytools.h</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="7efdc91ac4b26c374d287aa11b3af994"></a><!-- doxytag: member="inotifytools.h::inotifytools_cleanup" ref="7efdc91ac4b26c374d287aa11b3af994" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void inotifytools_cleanup           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Close inotify and free the memory used by inotifytools.<p>
If you call this function, you must call <a class="el" href="inotifytools_8h.html#3765c7874caeb0732926f34ae3c3cd63">inotifytools_initialize()</a> again before any other functions can be used. 
<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00326">326</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00326">inotifytools_cleanup()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l00326">inotifytools_cleanup()</a>.</p>

</div>
</div><p>
<a class="anchor" name="313399ccce221c8a5862892396d1a8ec"></a><!-- doxytag: member="inotifytools.h::inotifytools_error" ref="313399ccce221c8a5862892396d1a8ec" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_error           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the last error which occurred.<p>
When a function fails, call this to find out why. The returned value is a typical <em>errno</em> value, the meaning of which depends on context. For example, if <a class="el" href="inotifytools_8h.html#f9ce33904730bcafbda98c35b1ba4931">inotifytools_watch_file()</a> fails because you attempt to watch a file which doesn't exist, this function will return <em>ENOENT</em>.<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>an error code. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01588">1588</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l01588">inotifytools_error()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01588">inotifytools_error()</a>.</p>

</div>
</div><p>
<a class="anchor" name="744bb8792d8ea8edbaf8f845fe1d9307"></a><!-- doxytag: member="inotifytools.h::inotifytools_event_to_str" ref="744bb8792d8ea8edbaf8f845fe1d9307" args="(int events)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">char* inotifytools_event_to_str           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>events</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Convert event from integer form to string form (as in inotify.h).<p>
The returned string is from static storage; subsequent calls to this function or <a class="el" href="inotifytools_8h.html#317a5b1ea969f570a49c4549b22e7e71">inotifytools_event_to_str_sep()</a> will overwrite it. Don't free() it and make a copy if you want to keep it.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>events</em>&nbsp;</td><td>OR'd event(s) in integer form as defined in inotify.h. See section <a class="el" href="inotifytools_8h.html#events">Events</a>.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>comma-separated string representing the event(s), in no particular order</dd></dl>
<h2><a class="anchor" name="example">
Example</a></h2>
<div class="fragment"><pre class="fragment"> <span class="keywordtype">int</span> eventnum == IN_MODIFY | IN_CLOSE | IN_CREATE;
 <span class="keywordtype">char</span> * eventstr = <a class="code" href="inotifytools_8h.html#744bb8792d8ea8edbaf8f845fe1d9307">inotifytools_event_to_str</a>( eventnum );
 printf( <span class="stringliteral">"%s\n"</span>, eventstr );
 <span class="comment">// outputs something like MODIFY,CLOSE,CREATE but order not guaranteed.</span>
</pre></div> 
<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00628">628</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00628">inotifytools_event_to_str()</a>, and <a class="el" href="inotifytools_8c_source.html#l00656">inotifytools_event_to_str_sep()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l00628">inotifytools_event_to_str()</a>, and <a class="el" href="inotifytools_8c_source.html#l01814">inotifytools_snprintf()</a>.</p>

</div>
</div><p>
<a class="anchor" name="317a5b1ea969f570a49c4549b22e7e71"></a><!-- doxytag: member="inotifytools.h::inotifytools_event_to_str_sep" ref="317a5b1ea969f570a49c4549b22e7e71" args="(int events, char sep)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">char* inotifytools_event_to_str_sep           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>events</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char&nbsp;</td>
          <td class="paramname"> <em>sep</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Convert event from integer form to string form (as in inotify.h).<p>
The returned string is from static storage; subsequent calls to this function or <a class="el" href="inotifytools_8h.html#744bb8792d8ea8edbaf8f845fe1d9307">inotifytools_event_to_str()</a> will overwrite it. Don't free() it and make a copy if you want to keep it.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>events</em>&nbsp;</td><td>OR'd event(s) in integer form as defined in inotify.h</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>sep</em>&nbsp;</td><td>character used to separate events</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd><em>sep</em> separated string representing the event(s), in no particular order. If the integer is not made of OR'ed inotify events, the string returned will be a hexadecimal representation of the integer.</dd></dl>
<h2><a class="anchor" name="example">
Example</a></h2>
<div class="fragment"><pre class="fragment"> <span class="keywordtype">int</span> eventnum == IN_MODIFY | IN_CLOSE | IN_CREATE;
 <span class="keywordtype">char</span> * eventstr = <a class="code" href="inotifytools_8h.html#317a5b1ea969f570a49c4549b22e7e71">inotifytools_event_to_str_sep</a>( eventnum, <span class="charliteral">'-'</span> );
 printf( <span class="stringliteral">"%s\n"</span>, eventstr );
 <span class="comment">// outputs something like MODIFY-CLOSE-CREATE but order not guaranteed.</span>
</pre></div> 
<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00656">656</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00656">inotifytools_event_to_str_sep()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l00628">inotifytools_event_to_str()</a>, <a class="el" href="inotifytools_8c_source.html#l00656">inotifytools_event_to_str_sep()</a>, and <a class="el" href="inotifytools_8c_source.html#l01814">inotifytools_snprintf()</a>.</p>

</div>
</div><p>
<a class="anchor" name="fd4dcc915248f2d0b0ae708e88611186"></a><!-- doxytag: member="inotifytools.h::inotifytools_filename_from_wd" ref="fd4dcc915248f2d0b0ae708e88611186" args="(int wd)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">char* inotifytools_filename_from_wd           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>wd</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the filename used to establish a watch.<p>
<a class="el" href="inotifytools_8h.html#3765c7874caeb0732926f34ae3c3cd63">inotifytools_initialize()</a> must be called before this function can be used.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>wd</em>&nbsp;</td><td>watch descriptor.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>filename associated with watch descriptor <em>wd</em>, or NULL if <em>wd</em> is not associated with any filename.</dd></dl>
<dl class="note" compact><dt><b>Note:</b></dt><dd>This always returns the filename which was used to establish a watch. This means the filename may be a relative path. If this isn't desired, then always use absolute paths when watching files. Also, this is not necessarily the filename which might have been used to cause an event on the file, since inotify is inode based and there can be many filenames mapping to a single inode. Finally, if a file is moved or renamed while being watched, the filename returned will still be the original name. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00763">763</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00763">inotifytools_filename_from_wd()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l00763">inotifytools_filename_from_wd()</a>, and <a class="el" href="inotifytools_8c_source.html#l01814">inotifytools_snprintf()</a>.</p>

</div>
</div><p>
<a class="anchor" name="6ed4450ad545bde13a1328e53ed8cf6d"></a><!-- doxytag: member="inotifytools.h::inotifytools_fprintf" ref="6ed4450ad545bde13a1328e53ed8cf6d" args="(FILE *file, struct inotify_event *event, char *fmt)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_fprintf           </td>
          <td>(</td>
          <td class="paramtype">FILE *&nbsp;</td>
          <td class="paramname"> <em>file</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct inotify_event *&nbsp;</td>
          <td class="paramname"> <em>event</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&nbsp;</td>
          <td class="paramname"> <em>fmt</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Print a string to a file using an inotify_event and a printf-like syntax. The string written will only ever be up to 4096 characters in length.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>file</em>&nbsp;</td><td>file to print to</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>event</em>&nbsp;</td><td>the event to use to construct a string.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>fmt</em>&nbsp;</td><td>the format string used to construct a string.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>number of characters written, or -1 if an error occurs.</dd></dl>
<h2><a class="anchor" name="syntax">
Format string syntax</a></h2>
The following tokens will be replaced with the specified string: <ul>
<li><code>%w</code> - This will be replaced with the name of the Watched file on which an event occurred. </li>
<li><code>%f</code> - When an event occurs within a directory, this will be replaced with the name of the File which caused the event to occur. Otherwise, this will be replaced with an empty string. </li>
<li><code>%e</code> - Replaced with the Event(s) which occurred, comma-separated. </li>
<li><code>%Xe</code> - Replaced with the Event(s) which occurred, separated by whichever character is in the place of `X'. </li>
<li><code>%T</code> - Replaced by the current Time in the format specified by the string previously passed to <a class="el" href="inotifytools_8h.html#f4528ccdf013b4c86e8f7fe4db88244a">inotifytools_set_printf_timefmt()</a>, or replaced with an empty string if that function has never been called.</li>
</ul>
<h2><a class="anchor" name="example">
Example</a></h2>
<div class="fragment"><pre class="fragment"> <span class="comment">// suppose this is the only file watched.</span>
 <a class="code" href="inotifytools_8h.html#f9ce33904730bcafbda98c35b1ba4931">inotifytools_watch_file</a>( <span class="stringliteral">"mydir/"</span>, IN_CLOSE );

 <span class="comment">// wait until an event occurs</span>
 <span class="keyword">struct </span>inotify_event * <span class="keyword">event</span> = <a class="code" href="inotifytools_8h.html#2e121fde1cac7875d25a7e6c3bc57e1a">inotifytools_next_event</a>( -1 );

 <a class="code" href="inotifytools_8h.html#6ed4450ad545bde13a1328e53ed8cf6d">inotifytools_fprintf</a>(stderr, event, <span class="stringliteral">"in %w, file %f had event(s): %.e\n"</span>);
 <span class="comment">// suppose the file 'myfile' in mydir was read from and closed.  Then,</span>
 <span class="comment">// this prints to standard error something like:</span>
 <span class="comment">// "in mydir/, file myfile had event(s): CLOSE_NOWRITE.CLOSE.ISDIR\n"</span>
</pre></div> 
<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01705">1705</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l01705">inotifytools_fprintf()</a>, and <a class="el" href="inotifytools_8c_source.html#l01763">inotifytools_sprintf()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01705">inotifytools_fprintf()</a>, and <a class="el" href="inotifytools_8c_source.html#l01660">inotifytools_printf()</a>.</p>

</div>
</div><p>
<a class="anchor" name="1d96f4600d1187670304b83439b0cd05"></a><!-- doxytag: member="inotifytools.h::inotifytools_get_max_queued_events" ref="1d96f4600d1187670304b83439b0cd05" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_get_max_queued_events           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the event queue size.<p>
This setting can also be read or modified by accessing the file <em>/proc/sys/fs/inotify/max_queued_events</em>.<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the maximum number of events which will be queued in the kernel. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01953">1953</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l01953">inotifytools_get_max_queued_events()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01953">inotifytools_get_max_queued_events()</a>.</p>

</div>
</div><p>
<a class="anchor" name="9e8052a5fb77768cec9fff4aed9b9eb0"></a><!-- doxytag: member="inotifytools.h::inotifytools_get_max_user_instances" ref="9e8052a5fb77768cec9fff4aed9b9eb0" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_get_max_user_instances           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the maximum number of user instances of inotify.<p>
This setting can also be read or modified by accessing the file <em>/proc/sys/fs/inotify/max_user_instances</em>.<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the maximum number of inotify file descriptors a single user can obtain. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01968">1968</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l01968">inotifytools_get_max_user_instances()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01968">inotifytools_get_max_user_instances()</a>.</p>

</div>
</div><p>
<a class="anchor" name="e3b79f096737ef3c7e176324514b4556"></a><!-- doxytag: member="inotifytools.h::inotifytools_get_max_user_watches" ref="e3b79f096737ef3c7e176324514b4556" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_get_max_user_watches           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the maximum number of user watches.<p>
This setting can also be read or modified by accessing the file <em>/proc/sys/fs/inotify/max_user_watches</em>.<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the maximum number of inotify watches a single user can obtain per inotify instance. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01983">1983</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l01983">inotifytools_get_max_user_watches()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01983">inotifytools_get_max_user_watches()</a>.</p>

</div>
</div><p>
<a class="anchor" name="af934e6f66eb02f3c6e72d65c9bd610c"></a><!-- doxytag: member="inotifytools.h::inotifytools_get_num_watches" ref="af934e6f66eb02f3c6e72d65c9bd610c" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_get_num_watches           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the number of watches set up through libinotifytools.<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>number of watches set up by <a class="el" href="inotifytools_8h.html#f9ce33904730bcafbda98c35b1ba4931">inotifytools_watch_file()</a>, <a class="el" href="inotifytools_8h.html#88c6a7db52fbd9310ef72d2588c9c1df">inotifytools_watch_files()</a> and <a class="el" href="inotifytools_8h.html#583ff8d0e64f527af4232814ad493dce">inotifytools_watch_recursively()</a>. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01614">1614</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l01614">inotifytools_get_num_watches()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01614">inotifytools_get_num_watches()</a>.</p>

</div>
</div><p>
<a class="anchor" name="70bf8afcf5dce7d324d3a1a4cf48871a"></a><!-- doxytag: member="inotifytools.h::inotifytools_get_stat_by_filename" ref="70bf8afcf5dce7d324d3a1a4cf48871a" args="(char const *filename, int event)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_get_stat_by_filename           </td>
          <td>(</td>
          <td class="paramtype">char const *&nbsp;</td>
          <td class="paramname"> <em>filename</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>event</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get statistics by a particular filename.<p>
<a class="el" href="inotifytools_8h.html#e25cb60b12e3555795f55fb8c55db692">inotifytools_initialize_stats()</a> must be called before this function can be used.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>filename</em>&nbsp;</td><td>name of file to get stats for.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>event</em>&nbsp;</td><td>a single inotify event to get statistics for, or 0 for event total. See section <a class="el" href="inotifytools_8h.html#events">Events</a>.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the number of times the event specified by <em>event</em> has occurred on the file specified by <em>filename</em> since stats collection was enabled, or -1 if the file is not being watched or <em>event</em> is invalid.</dd></dl>
<dl class="note" compact><dt><b>Note:</b></dt><dd>The filename specified must always be the original name used to establish the watch. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01572">1572</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l01572">inotifytools_get_stat_by_filename()</a>, <a class="el" href="inotifytools_8c_source.html#l01495">inotifytools_get_stat_by_wd()</a>, and <a class="el" href="inotifytools_8c_source.html#l00784">inotifytools_wd_from_filename()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01572">inotifytools_get_stat_by_filename()</a>.</p>

</div>
</div><p>
<a class="anchor" name="4d5002bd8504b70faed608886e0fa307"></a><!-- doxytag: member="inotifytools.h::inotifytools_get_stat_by_wd" ref="4d5002bd8504b70faed608886e0fa307" args="(int wd, int event)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_get_stat_by_wd           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>wd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>event</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get statistics by a particular watch descriptor.<p>
<a class="el" href="inotifytools_8h.html#e25cb60b12e3555795f55fb8c55db692">inotifytools_initialize_stats()</a> must be called before this function can be used.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>wd</em>&nbsp;</td><td>watch descriptor to get stats for.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>event</em>&nbsp;</td><td>a single inotify event to get statistics for, or 0 for event total. See section <a class="el" href="inotifytools_8h.html#events">Events</a>.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the number of times the event specified by <em>event</em> has occurred on the watch descriptor specified by <em>wd</em> since stats collection was enabled, or -1 if <em>event</em> or <em>wd</em> are invalid. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01495">1495</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l01495">inotifytools_get_stat_by_wd()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01572">inotifytools_get_stat_by_filename()</a>, and <a class="el" href="inotifytools_8c_source.html#l01495">inotifytools_get_stat_by_wd()</a>.</p>

</div>
</div><p>
<a class="anchor" name="f3de070bdf428d548e0b54f5e9043dcc"></a><!-- doxytag: member="inotifytools.h::inotifytools_get_stat_total" ref="f3de070bdf428d548e0b54f5e9043dcc" args="(int event)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_get_stat_total           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>event</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get statistics aggregated across all watches.<p>
<a class="el" href="inotifytools_8h.html#e25cb60b12e3555795f55fb8c55db692">inotifytools_initialize_stats()</a> must be called before this function can be used.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>event</em>&nbsp;</td><td>a single inotify event to get statistics for, or 0 for event total. See section <a class="el" href="inotifytools_8h.html#events">Events</a>.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the number of times the event specified by <em>event</em> has occurred over all watches since stats collection was enabled, or -1 if <em>event</em> is not a valid event. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01518">1518</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l01518">inotifytools_get_stat_total()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01518">inotifytools_get_stat_total()</a>.</p>

</div>
</div><p>
<a class="anchor" name="07f4f258123feb8864f89663a2785ef0"></a><!-- doxytag: member="inotifytools.h::inotifytools_ignore_events_by_regex" ref="07f4f258123feb8864f89663a2785ef0" args="(char const *pattern, int flags)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_ignore_events_by_regex           </td>
          <td>(</td>
          <td class="paramtype">char const *&nbsp;</td>
          <td class="paramname"> <em>pattern</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>flags</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Ignore inotify events matching a particular regular expression.<p>
<em>pattern</em> is a regular expression and <em>flags</em> is a bitwise combination of POSIX regular expression flags.<p>
On future calls to <a class="el" href="inotifytools_8h.html#188fd24a5d8ff504e1a3616ded73a4c1">inotifytools_next_events()</a> or <a class="el" href="inotifytools_8h.html#2e121fde1cac7875d25a7e6c3bc57e1a">inotifytools_next_event()</a>, the regular expression is executed on the filename of files on which events occur. If the regular expression matches, the matched event will be ignored. 
<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l02000">2000</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l02000">inotifytools_ignore_events_by_regex()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l02000">inotifytools_ignore_events_by_regex()</a>.</p>

</div>
</div><p>
<a class="anchor" name="3765c7874caeb0732926f34ae3c3cd63"></a><!-- doxytag: member="inotifytools.h::inotifytools_initialize" ref="3765c7874caeb0732926f34ae3c3cd63" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_initialize           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Initialise inotify.<p>
You must call this function before using any function which adds or removes watches or attempts to access any information about watches.<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>1 on success, 0 on failure. On failure, the error can be obtained from <a class="el" href="inotifytools_8h.html#313399ccce221c8a5862892396d1a8ec">inotifytools_error()</a>. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00281">281</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00281">inotifytools_initialize()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l00281">inotifytools_initialize()</a>.</p>

</div>
</div><p>
<a class="anchor" name="e25cb60b12e3555795f55fb8c55db692"></a><!-- doxytag: member="inotifytools.h::inotifytools_initialize_stats" ref="e25cb60b12e3555795f55fb8c55db692" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void inotifytools_initialize_stats           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Initialize or reset statistics.<p>
<a class="el" href="inotifytools_8h.html#3765c7874caeb0732926f34ae3c3cd63">inotifytools_initialize()</a> must be called before this function can be used.<p>
When this function is called, all subsequent events will be tallied. Statistics can then be obtained via the <em>inotifytools_get_stat_*</em> functions.<p>
After the first call, subsequent calls to this function will reset the event tallies to 0. 
<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00418">418</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00418">inotifytools_initialize_stats()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l00418">inotifytools_initialize_stats()</a>.</p>

</div>
</div><p>
<a class="anchor" name="2e121fde1cac7875d25a7e6c3bc57e1a"></a><!-- doxytag: member="inotifytools.h::inotifytools_next_event" ref="2e121fde1cac7875d25a7e6c3bc57e1a" args="(int timeout)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct inotify_event* inotifytools_next_event           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>timeout</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [read]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the next inotify event to occur.<p>
<a class="el" href="inotifytools_8h.html#3765c7874caeb0732926f34ae3c3cd63">inotifytools_initialize()</a> must be called before this function can be used.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>timeout</em>&nbsp;</td><td>maximum amount of time, in seconds, to wait for an event. If <em>timeout</em> is 0, the function is non-blocking. If <em>timeout</em> is negative, the function will block until an event occurs.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>pointer to an inotify event, or NULL if function timed out before an event occurred. The event is located in static storage and it may be overwritten in subsequent calls; do not call free() on it, and make a copy if you want to keep it.</dd></dl>
<dl class="note" compact><dt><b>Note:</b></dt><dd>Your program should call this function or <a class="el" href="inotifytools_8h.html#188fd24a5d8ff504e1a3616ded73a4c1">inotifytools_next_events()</a> frequently; between calls to this function, inotify events will be queued in the kernel, and eventually the queue will overflow and you will miss some events.<p>
If the function <a class="el" href="inotifytools_8h.html#07f4f258123feb8864f89663a2785ef0">inotifytools_ignore_events_by_regex()</a> has been called with a non-NULL parameter, this function will not return on events which match the regular expression passed to that function. However, the <em>timeout</em> period begins again each time a matching event occurs. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01038">1038</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l01038">inotifytools_next_event()</a>, and <a class="el" href="inotifytools_8c_source.html#l01092">inotifytools_next_events()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01038">inotifytools_next_event()</a>.</p>

</div>
</div><p>
<a class="anchor" name="188fd24a5d8ff504e1a3616ded73a4c1"></a><!-- doxytag: member="inotifytools.h::inotifytools_next_events" ref="188fd24a5d8ff504e1a3616ded73a4c1" args="(int timeout, int num_events)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct inotify_event* inotifytools_next_events           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>timeout</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>num_events</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td><code> [read]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the next inotify events to occur.<p>
<a class="el" href="inotifytools_8h.html#3765c7874caeb0732926f34ae3c3cd63">inotifytools_initialize()</a> must be called before this function can be used.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>timeout</em>&nbsp;</td><td>maximum amount of time, in seconds, to wait for an event. If <em>timeout</em> is 0, the function is non-blocking. If <em>timeout</em> is negative, the function will block until an event occurs.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>num_events</em>&nbsp;</td><td>approximate number of inotify events to wait for until this function returns. Use this for buffering reads to inotify if you expect to receive large amounts of events. You are NOT guaranteed that this number of events will actually be read; instead, you are guaranteed that the number of bytes read from inotify is <em>num_events</em> * sizeof(struct inotify_event). Obviously the larger this number is, the greater the latency between when an event occurs and when you'll know about it. May not be larger than 4096.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>pointer to an inotify event, or NULL if function timed out before an event occurred or <em>num_events</em> &lt; 1. The event is located in static storage and it may be overwritten in subsequent calls; do not call free() on it, and make a copy if you want to keep it. When <em>num_events</em> is greater than 1, this will return a pointer to the first event only, and you MUST call this function again to get pointers to subsequent events; don't try to add to the pointer to find the next events or you will run into trouble.</dd></dl>
<dl class="note" compact><dt><b>Note:</b></dt><dd>You may actually get different events with different values of <em>num_events</em>. This is because inotify does some in-kernel filtering of duplicate events, meaning some duplicate events will not be reported if <em>num_events</em> &gt; 1. For some purposes this is fine, but for others (such as gathering accurate statistics on numbers of event occurrences) you must call this function with <em>num_events</em> = 1, or simply use <a class="el" href="inotifytools_8h.html#2e121fde1cac7875d25a7e6c3bc57e1a">inotifytools_next_event()</a>.<p>
Your program should call this function or <a class="el" href="inotifytools_8h.html#188fd24a5d8ff504e1a3616ded73a4c1">inotifytools_next_events()</a> frequently; between calls to this function, inotify events will be queued in the kernel, and eventually the queue will overflow and you will miss some events.<p>
If the function <a class="el" href="inotifytools_8h.html#07f4f258123feb8864f89663a2785ef0">inotifytools_ignore_events_by_regex()</a> has been called with a non-NULL parameter, this function will not return on events which match the regular expression passed to that function. However, the <em>timeout</em> period begins again each time a matching event occurs. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01092">1092</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l01092">inotifytools_next_events()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01038">inotifytools_next_event()</a>, and <a class="el" href="inotifytools_8c_source.html#l01092">inotifytools_next_events()</a>.</p>

</div>
</div><p>
<a class="anchor" name="c2c06dd72f39a6145ea3b6661378df31"></a><!-- doxytag: member="inotifytools.h::inotifytools_printf" ref="c2c06dd72f39a6145ea3b6661378df31" args="(struct inotify_event *event, char *fmt)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_printf           </td>
          <td>(</td>
          <td class="paramtype">struct inotify_event *&nbsp;</td>
          <td class="paramname"> <em>event</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&nbsp;</td>
          <td class="paramname"> <em>fmt</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Print a string to standard out using an inotify_event and a printf-like syntax. The string written will only ever be up to 4096 characters in length.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>event</em>&nbsp;</td><td>the event to use to construct a string.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>fmt</em>&nbsp;</td><td>the format string used to construct a string.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>number of characters written, or -1 if an error occurs.</dd></dl>
<h2><a class="anchor" name="syntax">
Format string syntax</a></h2>
The following tokens will be replaced with the specified string: <ul>
<li><code>%w</code> - This will be replaced with the name of the Watched file on which an event occurred. </li>
<li><code>%f</code> - When an event occurs within a directory, this will be replaced with the name of the File which caused the event to occur. Otherwise, this will be replaced with an empty string. </li>
<li><code>%e</code> - Replaced with the Event(s) which occurred, comma-separated. </li>
<li><code>%Xe</code> - Replaced with the Event(s) which occurred, separated by whichever character is in the place of `X'. </li>
<li><code>%T</code> - Replaced by the current Time in the format specified by the string previously passed to <a class="el" href="inotifytools_8h.html#f4528ccdf013b4c86e8f7fe4db88244a">inotifytools_set_printf_timefmt()</a>, or replaced with an empty string if that function has never been called.</li>
</ul>
<h2><a class="anchor" name="example">
Example</a></h2>
<div class="fragment"><pre class="fragment"> <span class="comment">// suppose this is the only file watched.</span>
 <a class="code" href="inotifytools_8h.html#f9ce33904730bcafbda98c35b1ba4931">inotifytools_watch_file</a>( <span class="stringliteral">"mydir/"</span>, IN_CLOSE );

 <span class="comment">// wait until an event occurs</span>
 <span class="keyword">struct </span>inotify_event * <span class="keyword">event</span> = <a class="code" href="inotifytools_8h.html#2e121fde1cac7875d25a7e6c3bc57e1a">inotifytools_next_event</a>( -1 );

 <a class="code" href="inotifytools_8h.html#c2c06dd72f39a6145ea3b6661378df31">inotifytools_printf</a>(stderr, event, <span class="stringliteral">"in %w, file %f had event(s): %.e\n"</span>);
 <span class="comment">// suppose the file 'myfile' in mydir was read from and closed.  Then,</span>
 <span class="comment">// this prints to standard out something like:</span>
 <span class="comment">// "in mydir/, file myfile had event(s): CLOSE_NOWRITE.CLOSE.ISDIR\n"</span>
</pre></div> 
<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01660">1660</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l01705">inotifytools_fprintf()</a>, and <a class="el" href="inotifytools_8c_source.html#l01660">inotifytools_printf()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01660">inotifytools_printf()</a>.</p>

</div>
</div><p>
<a class="anchor" name="2a4ca66a9d8b0825d4272cd5003a9a0f"></a><!-- doxytag: member="inotifytools.h::inotifytools_remove_watch_by_filename" ref="2a4ca66a9d8b0825d4272cd5003a9a0f" args="(char const *filename)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_remove_watch_by_filename           </td>
          <td>(</td>
          <td class="paramtype">char const *&nbsp;</td>
          <td class="paramname"> <em>filename</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Remove a watch on a file specified by filename.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>filename</em>&nbsp;</td><td>Name of file on which watch should be removed.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>1 on success, 0 on failure. On failure, the error can be obtained from <a class="el" href="inotifytools_8h.html#313399ccce221c8a5862892396d1a8ec">inotifytools_error()</a>.</dd></dl>
<dl class="note" compact><dt><b>Note:</b></dt><dd>The filename specified must always be the original name used to establish the watch. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00930">930</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00930">inotifytools_remove_watch_by_filename()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l00930">inotifytools_remove_watch_by_filename()</a>.</p>

</div>
</div><p>
<a class="anchor" name="771f60d2232201c691fe725d5cf7e019"></a><!-- doxytag: member="inotifytools.h::inotifytools_remove_watch_by_wd" ref="771f60d2232201c691fe725d5cf7e019" args="(int wd)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_remove_watch_by_wd           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>wd</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Remove a watch on a file specified by watch descriptor.<p>
<a class="el" href="inotifytools_8h.html#3765c7874caeb0732926f34ae3c3cd63">inotifytools_initialize()</a> must be called before this function can be used.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>wd</em>&nbsp;</td><td>Watch descriptor of watch to be removed.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>1 on success, 0 on failure. If the given watch doesn't exist, returns 1. On failure, the error can be obtained from <a class="el" href="inotifytools_8h.html#313399ccce221c8a5862892396d1a8ec">inotifytools_error()</a>. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00907">907</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00907">inotifytools_remove_watch_by_wd()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l00907">inotifytools_remove_watch_by_wd()</a>.</p>

</div>
</div><p>
<a class="anchor" name="c6f5ecf6f3d854535132fe9790db008d"></a><!-- doxytag: member="inotifytools.h::inotifytools_replace_filename" ref="c6f5ecf6f3d854535132fe9790db008d" args="(char const *oldname, char const *newname)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void inotifytools_replace_filename           </td>
          <td>(</td>
          <td class="paramtype">char const *&nbsp;</td>
          <td class="paramname"> <em>oldname</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char const *&nbsp;</td>
          <td class="paramname"> <em>newname</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Replace a certain filename prefix on all watches.<p>
This function should be used to update filenames for an entire directory tree when a directory is known to have been moved or renamed. At the moment, libinotifytools does not automatically handle this situation.<p>
<a class="el" href="inotifytools_8h.html#3765c7874caeb0732926f34ae3c3cd63">inotifytools_initialize()</a> must be called before this function can be used.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>oldname</em>&nbsp;</td><td>Current filename prefix.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>newname</em>&nbsp;</td><td>New filename prefix.</td></tr>
  </table>
</dl>
<h2><a class="anchor" name="example">
Example</a></h2>
<div class="fragment"><pre class="fragment"> <span class="comment">// if /home/user1/original_dir is moved to /home/user2/new_dir, then to</span>
 <span class="comment">// update all watches:</span>
 <a class="code" href="inotifytools_8h.html#c6f5ecf6f3d854535132fe9790db008d">inotifytools_replace_filename</a>( <span class="stringliteral">"/home/user1/original_dir"</span>,
                                <span class="stringliteral">"/home/user2/new_dir"</span> );
</pre></div> 
<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00857">857</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00857">inotifytools_replace_filename()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l00857">inotifytools_replace_filename()</a>.</p>

</div>
</div><p>
<a class="anchor" name="764239f33bd2a092c445362e75828181"></a><!-- doxytag: member="inotifytools.h::inotifytools_set_filename_by_filename" ref="764239f33bd2a092c445362e75828181" args="(char const *oldname, char const *newname)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void inotifytools_set_filename_by_filename           </td>
          <td>(</td>
          <td class="paramtype">char const *&nbsp;</td>
          <td class="paramname"> <em>oldname</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char const *&nbsp;</td>
          <td class="paramname"> <em>newname</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Set the filename for one or more watches with a particular existing filename.<p>
This function should be used to update a filename when a file is known to have been moved or renamed. At the moment, libinotifytools does not automatically handle this situation.<p>
<a class="el" href="inotifytools_8h.html#3765c7874caeb0732926f34ae3c3cd63">inotifytools_initialize()</a> must be called before this function can be used.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>oldname</em>&nbsp;</td><td>Current filename.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>newname</em>&nbsp;</td><td>New filename. </td></tr>
  </table>
</dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00827">827</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00827">inotifytools_set_filename_by_filename()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l00827">inotifytools_set_filename_by_filename()</a>.</p>

</div>
</div><p>
<a class="anchor" name="f80acc2952c748a80641926ff222571c"></a><!-- doxytag: member="inotifytools.h::inotifytools_set_filename_by_wd" ref="f80acc2952c748a80641926ff222571c" args="(int wd, char const *filename)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void inotifytools_set_filename_by_wd           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>wd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char const *&nbsp;</td>
          <td class="paramname"> <em>filename</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Set the filename for a particular watch descriptor.<p>
This function should be used to update a filename when a file is known to have been moved or renamed. At the moment, libinotifytools does not automatically handle this situation.<p>
<a class="el" href="inotifytools_8h.html#3765c7874caeb0732926f34ae3c3cd63">inotifytools_initialize()</a> must be called before this function can be used.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>wd</em>&nbsp;</td><td>Watch descriptor.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>filename</em>&nbsp;</td><td>New filename. </td></tr>
  </table>
</dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00805">805</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00805">inotifytools_set_filename_by_wd()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l00805">inotifytools_set_filename_by_wd()</a>.</p>

</div>
</div><p>
<a class="anchor" name="f4528ccdf013b4c86e8f7fe4db88244a"></a><!-- doxytag: member="inotifytools.h::inotifytools_set_printf_timefmt" ref="f4528ccdf013b4c86e8f7fe4db88244a" args="(char *fmt)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void inotifytools_set_printf_timefmt           </td>
          <td>(</td>
          <td class="paramtype">char *&nbsp;</td>
          <td class="paramname"> <em>fmt</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Set time format for printf functions.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>fmt</em>&nbsp;</td><td>A format string valid for use with strftime, or NULL. If NULL, time substitutions will no longer be made in printf functions. Note that this format string is not validated at all; using an incorrect format string will cause the printf functions to give incorrect results. </td></tr>
  </table>
</dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01941">1941</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l01941">inotifytools_set_printf_timefmt()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01941">inotifytools_set_printf_timefmt()</a>.</p>

</div>
</div><p>
<a class="anchor" name="92f2dc66af4fd01b09b64b6813686282"></a><!-- doxytag: member="inotifytools.h::inotifytools_snprintf" ref="92f2dc66af4fd01b09b64b6813686282" args="(char *out, int size, struct inotify_event *event, char *fmt)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_snprintf           </td>
          <td>(</td>
          <td class="paramtype">char *&nbsp;</td>
          <td class="paramname"> <em>out</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct inotify_event *&nbsp;</td>
          <td class="paramname"> <em>event</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&nbsp;</td>
          <td class="paramname"> <em>fmt</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Construct a string using an inotify_event and a printf-like syntax. The string can only ever be up to 4096 characters in length.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>out</em>&nbsp;</td><td>location in which to store string.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>size</em>&nbsp;</td><td>maximum amount of characters to write.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>event</em>&nbsp;</td><td>the event to use to construct a string.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>fmt</em>&nbsp;</td><td>the format string used to construct a string.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>number of characters written, or -1 if an error occurs.</dd></dl>
<h2><a class="anchor" name="syntax">
Format string syntax</a></h2>
The following tokens will be replaced with the specified string: <ul>
<li><code>%w</code> - This will be replaced with the name of the Watched file on which an event occurred. </li>
<li><code>%f</code> - When an event occurs within a directory, this will be replaced with the name of the File which caused the event to occur. Otherwise, this will be replaced with an empty string. </li>
<li><code>%e</code> - Replaced with the Event(s) which occurred, comma-separated. </li>
<li><code>%Xe</code> - Replaced with the Event(s) which occurred, separated by whichever character is in the place of `X'. </li>
<li><code>%T</code> - Replaced by the current Time in the format specified by the string previously passed to <a class="el" href="inotifytools_8h.html#f4528ccdf013b4c86e8f7fe4db88244a">inotifytools_set_printf_timefmt()</a>, or replaced with an empty string if that function has never been called.</li>
</ul>
<h2><a class="anchor" name="example">
Example</a></h2>
<div class="fragment"><pre class="fragment"> <span class="comment">// suppose this is the only file watched.</span>
 <a class="code" href="inotifytools_8h.html#f9ce33904730bcafbda98c35b1ba4931">inotifytools_watch_file</a>( <span class="stringliteral">"mydir/"</span>, IN_CLOSE );

 <span class="comment">// wait until an event occurs</span>
 <span class="keyword">struct </span>inotify_event * <span class="keyword">event</span> = <a class="code" href="inotifytools_8h.html#2e121fde1cac7875d25a7e6c3bc57e1a">inotifytools_next_event</a>( -1 );

 <span class="keywordtype">char</span> mystring[1024];
 <a class="code" href="inotifytools_8h.html#92f2dc66af4fd01b09b64b6813686282">inotifytools_snprintf</a>( mystring, 1024, event,
                        <span class="stringliteral">"in %w, file %f had event(s): %.e\n"</span> );
 printf( mystring );
 <span class="comment">// suppose the file 'myfile' in mydir was written to and closed.  Then,</span>
 <span class="comment">// this prints something like:</span>
 <span class="comment">// "in mydir/, file myfile had event(s): CLOSE_WRITE.CLOSE.ISDIR\n"</span>
</pre></div> 
<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01814">1814</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00628">inotifytools_event_to_str()</a>, <a class="el" href="inotifytools_8c_source.html#l00656">inotifytools_event_to_str_sep()</a>, <a class="el" href="inotifytools_8c_source.html#l00763">inotifytools_filename_from_wd()</a>, and <a class="el" href="inotifytools_8c_source.html#l01814">inotifytools_snprintf()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01814">inotifytools_snprintf()</a>, and <a class="el" href="inotifytools_8c_source.html#l01763">inotifytools_sprintf()</a>.</p>

</div>
</div><p>
<a class="anchor" name="abf4cbafd50012f6e35b32a052677c74"></a><!-- doxytag: member="inotifytools.h::inotifytools_sprintf" ref="abf4cbafd50012f6e35b32a052677c74" args="(char *out, struct inotify_event *event, char *fmt)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_sprintf           </td>
          <td>(</td>
          <td class="paramtype">char *&nbsp;</td>
          <td class="paramname"> <em>out</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct inotify_event *&nbsp;</td>
          <td class="paramname"> <em>event</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&nbsp;</td>
          <td class="paramname"> <em>fmt</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Construct a string using an inotify_event and a printf-like syntax. The string can only ever be up to 4096 characters in length.<p>
This function will keep writing until it reaches 4096 characters. If your allocated array is not large enough to hold the entire string, your program may crash. <a class="el" href="inotifytools_8h.html#92f2dc66af4fd01b09b64b6813686282">inotifytools_snprintf()</a> is safer and you should use it where possible.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>out</em>&nbsp;</td><td>location in which to store string.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>event</em>&nbsp;</td><td>the event to use to construct a string.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>fmt</em>&nbsp;</td><td>the format string used to construct a string.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>number of characters written, or -1 if an error occurs.</dd></dl>
<h2><a class="anchor" name="syntax">
Format string syntax</a></h2>
The following tokens will be replaced with the specified string: <ul>
<li><code>%w</code> - This will be replaced with the name of the Watched file on which an event occurred. </li>
<li><code>%f</code> - When an event occurs within a directory, this will be replaced with the name of the File which caused the event to occur. Otherwise, this will be replaced with an empty string. </li>
<li><code>%e</code> - Replaced with the Event(s) which occurred, comma-separated. </li>
<li><code>%Xe</code> - Replaced with the Event(s) which occurred, separated by whichever character is in the place of `X'. </li>
<li><code>%T</code> - Replaced by the current Time in the format specified by the string previously passed to <a class="el" href="inotifytools_8h.html#f4528ccdf013b4c86e8f7fe4db88244a">inotifytools_set_printf_timefmt()</a>, or replaced with an empty string if that function has never been called.</li>
</ul>
<h2><a class="anchor" name="example">
Example</a></h2>
<div class="fragment"><pre class="fragment"> <span class="comment">// suppose this is the only file watched.</span>
 <a class="code" href="inotifytools_8h.html#f9ce33904730bcafbda98c35b1ba4931">inotifytools_watch_file</a>( <span class="stringliteral">"mydir/"</span>, IN_CLOSE );

 <span class="comment">// wait until an event occurs</span>
 <span class="keyword">struct </span>inotify_event * <span class="keyword">event</span> = <a class="code" href="inotifytools_8h.html#2e121fde1cac7875d25a7e6c3bc57e1a">inotifytools_next_event</a>( -1 );

 <span class="keywordtype">char</span> mystring[1024];
 <span class="comment">// hope this doesn't crash - if filename is really long, might not fit into</span>
 <span class="comment">// mystring!</span>
 <a class="code" href="inotifytools_8h.html#abf4cbafd50012f6e35b32a052677c74">inotifytools_sprintf</a>(mystring, event, <span class="stringliteral">"in %w, file %f had event(s): %.e\n"</span>);
 printf( mystring );
 <span class="comment">// suppose the file 'myfile' in mydir was written to and closed.  Then,</span>
 <span class="comment">// this prints something like:</span>
 <span class="comment">// "in mydir/, file myfile had event(s): CLOSE_WRITE.CLOSE.ISDIR\n"</span>
</pre></div> 
<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01763">1763</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l01814">inotifytools_snprintf()</a>, and <a class="el" href="inotifytools_8c_source.html#l01763">inotifytools_sprintf()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01705">inotifytools_fprintf()</a>, and <a class="el" href="inotifytools_8c_source.html#l01763">inotifytools_sprintf()</a>.</p>

</div>
</div><p>
<a class="anchor" name="c5f03415912fa505bcb7f2caf9273b45"></a><!-- doxytag: member="inotifytools.h::inotifytools_str_to_event" ref="c5f03415912fa505bcb7f2caf9273b45" args="(char const *event)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_str_to_event           </td>
          <td>(</td>
          <td class="paramtype">char const *&nbsp;</td>
          <td class="paramname"> <em>event</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Convert comma-separated events from string form to integer form (as in inotify.h).<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>event</em>&nbsp;</td><td>a sequence of events in string form as defined in inotify.h without leading IN_ prefix (e.g., MODIFY, ATTRIB), comma-separated. Case insensitive. Can be a single event. Can be empty or NULL. See section <a class="el" href="inotifytools_8h.html#events">Events</a>.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>integer representing the mask specified by <em>event</em>, or 0 if any string in <em>event</em> is empty or NULL, or -1 if any string in <em>event</em> does not match any event.</dd></dl>
<h2><a class="anchor" name="example">
Example</a></h2>
<div class="fragment"><pre class="fragment"> <span class="keywordtype">char</span> * eventstr = <span class="stringliteral">"MODIFY,CLOSE,CREATE"</span>;
 <span class="keywordtype">int</span> eventnum = <a class="code" href="inotifytools_8h.html#c5f03415912fa505bcb7f2caf9273b45">inotifytools_str_to_event</a>( eventstr );
 <span class="keywordflow">if</span> ( eventnum == IN_MODIFY | IN_CLOSE | IN_CREATE ) {
    printf( <span class="stringliteral">"This code always gets executed!\n"</span> );
 }
</pre></div> 
<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00541">541</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00541">inotifytools_str_to_event()</a>, and <a class="el" href="inotifytools_8c_source.html#l00471">inotifytools_str_to_event_sep()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l00541">inotifytools_str_to_event()</a>.</p>

</div>
</div><p>
<a class="anchor" name="7e26c94c983d93669813c439883b334f"></a><!-- doxytag: member="inotifytools.h::inotifytools_str_to_event_sep" ref="7e26c94c983d93669813c439883b334f" args="(char const *event, char sep)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_str_to_event_sep           </td>
          <td>(</td>
          <td class="paramtype">char const *&nbsp;</td>
          <td class="paramname"> <em>event</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char&nbsp;</td>
          <td class="paramname"> <em>sep</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Convert character separated events from string form to integer form (as in inotify.h).<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>event</em>&nbsp;</td><td>a sequence of events in string form as defined in inotify.h without leading IN_ prefix (e.g., MODIFY, ATTRIB), separated by the <em>sep</em> character. Case insensitive. Can be a single event. Can be empty or NULL. See section <a class="el" href="inotifytools_8h.html#events">Events</a>.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>sep</em>&nbsp;</td><td>Character used to separate events. <em>sep</em> must not be a character in a-z, A-Z, or _.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>integer representing the mask specified by <em>event</em>, or 0 if any string in <em>event</em> is empty or NULL, or -1 if any string in <em>event</em> does not match any event or <em>sep</em> is invalid.</dd></dl>
<h2><a class="anchor" name="example">
Example</a></h2>
<div class="fragment"><pre class="fragment"> <span class="keywordtype">char</span> * eventstr = <span class="stringliteral">"MODIFY:CLOSE:CREATE"</span>;
 <span class="keywordtype">int</span> eventnum = <a class="code" href="inotifytools_8h.html#7e26c94c983d93669813c439883b334f">inotifytools_str_to_event_sep</a>( eventstr, <span class="charliteral">':'</span> );
 <span class="keywordflow">if</span> ( eventnum == IN_MODIFY | IN_CLOSE | IN_CREATE ) {
    printf( <span class="stringliteral">"This code always gets executed!\n"</span> );
 }
</pre></div> 
<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00471">471</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00471">inotifytools_str_to_event_sep()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l00541">inotifytools_str_to_event()</a>, and <a class="el" href="inotifytools_8c_source.html#l00471">inotifytools_str_to_event_sep()</a>.</p>

</div>
</div><p>
<a class="anchor" name="f9ce33904730bcafbda98c35b1ba4931"></a><!-- doxytag: member="inotifytools.h::inotifytools_watch_file" ref="f9ce33904730bcafbda98c35b1ba4931" args="(char const *filename, int events)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_watch_file           </td>
          <td>(</td>
          <td class="paramtype">char const *&nbsp;</td>
          <td class="paramname"> <em>filename</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>events</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Set up a watch on a file.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>filename</em>&nbsp;</td><td>Absolute or relative path of file to watch.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>events</em>&nbsp;</td><td>bitwise ORed inotify events to watch for. See section <a class="el" href="inotifytools_8h.html#events">Events</a>.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>1 on success, 0 on failure. On failure, the error can be obtained from <a class="el" href="inotifytools_8h.html#313399ccce221c8a5862892396d1a8ec">inotifytools_error()</a>. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00953">953</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00953">inotifytools_watch_file()</a>, and <a class="el" href="inotifytools_8c_source.html#l00975">inotifytools_watch_files()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l00953">inotifytools_watch_file()</a>, and <a class="el" href="inotifytools_8c_source.html#l01282">inotifytools_watch_recursively_with_exclude()</a>.</p>

</div>
</div><p>
<a class="anchor" name="88c6a7db52fbd9310ef72d2588c9c1df"></a><!-- doxytag: member="inotifytools.h::inotifytools_watch_files" ref="88c6a7db52fbd9310ef72d2588c9c1df" args="(char const *filenames[], int events)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_watch_files           </td>
          <td>(</td>
          <td class="paramtype">char const *&nbsp;</td>
          <td class="paramname"> <em>filenames</em>[], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>events</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Set up a watch on a list of files.<p>
<a class="el" href="inotifytools_8h.html#3765c7874caeb0732926f34ae3c3cd63">inotifytools_initialize()</a> must be called before this function can be used.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>filenames</em>&nbsp;</td><td>null-terminated array of absolute or relative paths of files to watch.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>events</em>&nbsp;</td><td>bitwise OR'ed inotify events to watch for. See section <a class="el" href="inotifytools_8h.html#events">Events</a>.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>1 on success, 0 on failure. On failure, the error can be obtained from <a class="el" href="inotifytools_8h.html#313399ccce221c8a5862892396d1a8ec">inotifytools_error()</a>. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00975">975</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00975">inotifytools_watch_files()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l00953">inotifytools_watch_file()</a>, and <a class="el" href="inotifytools_8c_source.html#l00975">inotifytools_watch_files()</a>.</p>

</div>
</div><p>
<a class="anchor" name="583ff8d0e64f527af4232814ad493dce"></a><!-- doxytag: member="inotifytools.h::inotifytools_watch_recursively" ref="583ff8d0e64f527af4232814ad493dce" args="(char const *path, int events)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_watch_recursively           </td>
          <td>(</td>
          <td class="paramtype">char const *&nbsp;</td>
          <td class="paramname"> <em>path</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>events</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Set up recursive watches on an entire directory tree.<p>
<a class="el" href="inotifytools_8h.html#3765c7874caeb0732926f34ae3c3cd63">inotifytools_initialize()</a> must be called before this function can be used.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>path</em>&nbsp;</td><td>path of directory or file to watch. If the path is a directory, every subdirectory will also be watched for the same events up to the maximum readable depth. If the path is a file, the file is watched exactly as if <a class="el" href="inotifytools_8h.html#f9ce33904730bcafbda98c35b1ba4931">inotifytools_watch_file()</a> were used.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>events</em>&nbsp;</td><td>Inotify events to watch for. See section <a class="el" href="inotifytools_8h.html#events">Events</a>.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>1 on success, 0 on failure. On failure, the error can be obtained from <a class="el" href="inotifytools_8h.html#313399ccce221c8a5862892396d1a8ec">inotifytools_error()</a>. Note that some errors on subdirectories will be ignored; for example, if you watch a directory tree which contains some directories which you do not have access to, those directories will not be watched, but this function will still return 1 if no other errors occur.</dd></dl>
<dl class="note" compact><dt><b>Note:</b></dt><dd>This function does not attempt to work atomically. If you use this function to watch a directory tree and files or directories are being created or removed within that directory tree, there are no guarantees as to whether or not those files will be watched. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01246">1246</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l01246">inotifytools_watch_recursively()</a>, and <a class="el" href="inotifytools_8c_source.html#l01282">inotifytools_watch_recursively_with_exclude()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01246">inotifytools_watch_recursively()</a>.</p>

</div>
</div><p>
<a class="anchor" name="20981c7f1410d458b5ef0654b9adf1e4"></a><!-- doxytag: member="inotifytools.h::inotifytools_watch_recursively_with_exclude" ref="20981c7f1410d458b5ef0654b9adf1e4" args="(char const *path, int events, char const **exclude_list)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_watch_recursively_with_exclude           </td>
          <td>(</td>
          <td class="paramtype">char const *&nbsp;</td>
          <td class="paramname"> <em>path</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>events</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char const **&nbsp;</td>
          <td class="paramname"> <em>exclude_list</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Set up recursive watches on an entire directory tree, optionally excluding some directories.<p>
<a class="el" href="inotifytools_8h.html#3765c7874caeb0732926f34ae3c3cd63">inotifytools_initialize()</a> must be called before this function can be used.<p>
<dl class="author" compact><dt><b>Author:</b></dt><dd>UH</dd></dl>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>path</em>&nbsp;</td><td>path of directory or file to watch. If the path is a directory, every subdirectory will also be watched for the same events up to the maximum readable depth. If the path is a file, the file is watched exactly as if <a class="el" href="inotifytools_8h.html#f9ce33904730bcafbda98c35b1ba4931">inotifytools_watch_file()</a> were used.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>exclude_list</em>&nbsp;</td><td>NULL terminated path list of directories not to watch. Can be NULL if no paths are to be excluded. Directories may or may not include a trailing '/'.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>events</em>&nbsp;</td><td>Inotify events to watch for. See section <a class="el" href="inotifytools_8h.html#events">Events</a>.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>1 on success, 0 on failure. On failure, the error can be obtained from <a class="el" href="inotifytools_8h.html#313399ccce221c8a5862892396d1a8ec">inotifytools_error()</a>. Note that some errors on subdirectories will be ignored; for example, if you watch a directory tree which contains some directories which you do not have access to, those directories will not be watched, but this function will still return 1 if no other errors occur.</dd></dl>
<dl class="note" compact><dt><b>Note:</b></dt><dd>This function does not attempt to work atomically. If you use this function to watch a directory tree and files or directories are being created or removed within that directory tree, there are no guarantees as to whether or not those files will be watched. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l01282">1282</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00953">inotifytools_watch_file()</a>, and <a class="el" href="inotifytools_8c_source.html#l01282">inotifytools_watch_recursively_with_exclude()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01246">inotifytools_watch_recursively()</a>, and <a class="el" href="inotifytools_8c_source.html#l01282">inotifytools_watch_recursively_with_exclude()</a>.</p>

</div>
</div><p>
<a class="anchor" name="594e7f515b392c07c4f1f4eeffcda6c3"></a><!-- doxytag: member="inotifytools.h::inotifytools_wd_from_filename" ref="594e7f515b392c07c4f1f4eeffcda6c3" args="(char const *filename)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int inotifytools_wd_from_filename           </td>
          <td>(</td>
          <td class="paramtype">char const *&nbsp;</td>
          <td class="paramname"> <em>filename</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the watch descriptor for a particular filename.<p>
<a class="el" href="inotifytools_8h.html#3765c7874caeb0732926f34ae3c3cd63">inotifytools_initialize()</a> must be called before this function can be used.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>filename</em>&nbsp;</td><td>file name to find watch descriptor for.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>watch descriptor associated with filename, or -1 if <em>filename</em> is not associated with any watch descriptor.</dd></dl>
<dl class="note" compact><dt><b>Note:</b></dt><dd>The filename specified must always be the original name used to establish the watch. </dd></dl>

<p>Definition at line <a class="el" href="inotifytools_8c_source.html#l00784">784</a> of file <a class="el" href="inotifytools_8c_source.html">inotifytools.c</a>.</p>

<p>References <a class="el" href="inotifytools_8c_source.html#l00784">inotifytools_wd_from_filename()</a>.</p>

<p>Referenced by <a class="el" href="inotifytools_8c_source.html#l01572">inotifytools_get_stat_by_filename()</a>, and <a class="el" href="inotifytools_8c_source.html#l00784">inotifytools_wd_from_filename()</a>.</p>

</div>
</div><p>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Sep 4 02:03:43 2009 for libinotifytools by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>