<refentry id="camel-camel-lock">
<refmeta>
<refentrytitle role="top_of_page" id="camel-camel-lock.top_of_page">camel-lock</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>CAMEL Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>camel-lock</refname>
<refpurpose></refpurpose>
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
</refnamediv>

<refsynopsisdiv id="camel-camel-lock.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>
#define             <link linkend="CAMEL-LOCK-DOT-RETRY:CAPS">CAMEL_LOCK_DOT_RETRY</link>
#define             <link linkend="CAMEL-LOCK-DOT-DELAY:CAPS">CAMEL_LOCK_DOT_DELAY</link>
#define             <link linkend="CAMEL-LOCK-DOT-STALE:CAPS">CAMEL_LOCK_DOT_STALE</link>
#define             <link linkend="CAMEL-LOCK-RETRY:CAPS">CAMEL_LOCK_RETRY</link>
#define             <link linkend="CAMEL-LOCK-DELAY:CAPS">CAMEL_LOCK_DELAY</link>
enum                <link linkend="CamelLockType">CamelLockType</link>;
<link linkend="int">int</link>                 <link linkend="camel-lock-dot">camel_lock_dot</link>                      (const <link linkend="char">char</link> *path,
                                                         <link linkend="CamelException">CamelException</link> *ex);
<link linkend="int">int</link>                 <link linkend="camel-lock-fcntl">camel_lock_fcntl</link>                    (<link linkend="int">int</link> fd,
                                                         <link linkend="CamelLockType">CamelLockType</link> type,
                                                         <link linkend="CamelException">CamelException</link> *ex);
<link linkend="int">int</link>                 <link linkend="camel-lock-flock">camel_lock_flock</link>                    (<link linkend="int">int</link> fd,
                                                         <link linkend="CamelLockType">CamelLockType</link> type,
                                                         <link linkend="CamelException">CamelException</link> *ex);
<link linkend="void">void</link>                <link linkend="camel-unlock-dot">camel_unlock_dot</link>                    (const <link linkend="char">char</link> *path);
<link linkend="void">void</link>                <link linkend="camel-unlock-fcntl">camel_unlock_fcntl</link>                  (<link linkend="int">int</link> fd);
<link linkend="void">void</link>                <link linkend="camel-unlock-flock">camel_unlock_flock</link>                  (<link linkend="int">int</link> fd);
<link linkend="int">int</link>                 <link linkend="camel-lock-folder">camel_lock_folder</link>                   (const <link linkend="char">char</link> *path,
                                                         <link linkend="int">int</link> fd,
                                                         <link linkend="CamelLockType">CamelLockType</link> type,
                                                         <link linkend="CamelException">CamelException</link> *ex);
<link linkend="void">void</link>                <link linkend="camel-unlock-folder">camel_unlock_folder</link>                 (const <link linkend="char">char</link> *path,
                                                         <link linkend="int">int</link> fd);
</synopsis>
</refsynopsisdiv>









<refsect1 id="camel-camel-lock.description" role="desc">
<title role="desc.title">Description</title>
<para>

</para>
</refsect1>

<refsect1 id="camel-camel-lock.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="CAMEL-LOCK-DOT-RETRY:CAPS" role="macro">
<title>CAMEL_LOCK_DOT_RETRY</title>
<indexterm zone="CAMEL-LOCK-DOT-RETRY:CAPS"><primary>CAMEL_LOCK_DOT_RETRY</primary></indexterm><programlisting>#define CAMEL_LOCK_DOT_RETRY (5) /* number of times to retry lock */
</programlisting>
<para>

</para></refsect2>
<refsect2 id="CAMEL-LOCK-DOT-DELAY:CAPS" role="macro">
<title>CAMEL_LOCK_DOT_DELAY</title>
<indexterm zone="CAMEL-LOCK-DOT-DELAY:CAPS"><primary>CAMEL_LOCK_DOT_DELAY</primary></indexterm><programlisting>#define CAMEL_LOCK_DOT_DELAY (2) /* delay between locking retries */
</programlisting>
<para>

</para></refsect2>
<refsect2 id="CAMEL-LOCK-DOT-STALE:CAPS" role="macro">
<title>CAMEL_LOCK_DOT_STALE</title>
<indexterm zone="CAMEL-LOCK-DOT-STALE:CAPS"><primary>CAMEL_LOCK_DOT_STALE</primary></indexterm><programlisting>#define CAMEL_LOCK_DOT_STALE (60) /* seconds before a lock becomes stale */
</programlisting>
<para>

</para></refsect2>
<refsect2 id="CAMEL-LOCK-RETRY:CAPS" role="macro">
<title>CAMEL_LOCK_RETRY</title>
<indexterm zone="CAMEL-LOCK-RETRY:CAPS"><primary>CAMEL_LOCK_RETRY</primary></indexterm><programlisting>#define CAMEL_LOCK_RETRY (5) /* number of times to retry lock */
</programlisting>
<para>

</para></refsect2>
<refsect2 id="CAMEL-LOCK-DELAY:CAPS" role="macro">
<title>CAMEL_LOCK_DELAY</title>
<indexterm zone="CAMEL-LOCK-DELAY:CAPS"><primary>CAMEL_LOCK_DELAY</primary></indexterm><programlisting>#define CAMEL_LOCK_DELAY (2) /* delay between locking retries */
</programlisting>
<para>

</para></refsect2>
<refsect2 id="CamelLockType" role="enum">
<title>enum CamelLockType</title>
<indexterm zone="CamelLockType"><primary>CamelLockType</primary></indexterm><programlisting>typedef enum {
	CAMEL_LOCK_READ,
	CAMEL_LOCK_WRITE
} CamelLockType;
</programlisting>
<para>

</para></refsect2>
<refsect2 id="camel-lock-dot" role="function">
<title>camel_lock_dot ()</title>
<indexterm zone="camel-lock-dot"><primary>camel_lock_dot</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_lock_dot                      (const <link linkend="char">char</link> *path,
                                                         <link linkend="CamelException">CamelException</link> *ex);</programlisting>
<para>
Create an exclusive lock using .lock semantics.
All locks are equivalent to write locks (exclusive).</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>path</parameter>&nbsp;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ex</parameter>&nbsp;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> -1 on error, sets <parameter>ex</parameter> appropriately.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-lock-fcntl" role="function">
<title>camel_lock_fcntl ()</title>
<indexterm zone="camel-lock-fcntl"><primary>camel_lock_fcntl</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_lock_fcntl                    (<link linkend="int">int</link> fd,
                                                         <link linkend="CamelLockType">CamelLockType</link> type,
                                                         <link linkend="CamelException">CamelException</link> *ex);</programlisting>
<para>
Create a lock using fcntl(2).
</para>
<para>
<parameter>type</parameter> is CAMEL_LOCK_WRITE or CAMEL_LOCK_READ,
to create exclusive or shared read locks</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>fd</parameter>&nbsp;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>type</parameter>&nbsp;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ex</parameter>&nbsp;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> -1 on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-lock-flock" role="function">
<title>camel_lock_flock ()</title>
<indexterm zone="camel-lock-flock"><primary>camel_lock_flock</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_lock_flock                    (<link linkend="int">int</link> fd,
                                                         <link linkend="CamelLockType">CamelLockType</link> type,
                                                         <link linkend="CamelException">CamelException</link> *ex);</programlisting>
<para>
Create a lock using flock(2).
</para>
<para>
<parameter>type</parameter> is CAMEL_LOCK_WRITE or CAMEL_LOCK_READ,
to create exclusive or shared read locks</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>fd</parameter>&nbsp;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>type</parameter>&nbsp;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ex</parameter>&nbsp;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> -1 on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-unlock-dot" role="function">
<title>camel_unlock_dot ()</title>
<indexterm zone="camel-unlock-dot"><primary>camel_unlock_dot</primary></indexterm><programlisting><link linkend="void">void</link>                camel_unlock_dot                    (const <link linkend="char">char</link> *path);</programlisting>
<para>
Attempt to unlock a .lock lock.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>path</parameter>&nbsp;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-unlock-fcntl" role="function">
<title>camel_unlock_fcntl ()</title>
<indexterm zone="camel-unlock-fcntl"><primary>camel_unlock_fcntl</primary></indexterm><programlisting><link linkend="void">void</link>                camel_unlock_fcntl                  (<link linkend="int">int</link> fd);</programlisting>
<para>
Unlock an fcntl lock.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>fd</parameter>&nbsp;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-unlock-flock" role="function">
<title>camel_unlock_flock ()</title>
<indexterm zone="camel-unlock-flock"><primary>camel_unlock_flock</primary></indexterm><programlisting><link linkend="void">void</link>                camel_unlock_flock                  (<link linkend="int">int</link> fd);</programlisting>
<para>
Unlock an flock lock.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>fd</parameter>&nbsp;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-lock-folder" role="function">
<title>camel_lock_folder ()</title>
<indexterm zone="camel-lock-folder"><primary>camel_lock_folder</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_lock_folder                   (const <link linkend="char">char</link> *path,
                                                         <link linkend="int">int</link> fd,
                                                         <link linkend="CamelLockType">CamelLockType</link> type,
                                                         <link linkend="CamelException">CamelException</link> *ex);</programlisting>
<para>
Attempt to lock a folder, multiple attempts will be made using all
locking strategies available.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>path</parameter>&nbsp;:</term>
<listitem><simpara> Path to the file to lock (used for .locking only).
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>fd</parameter>&nbsp;:</term>
<listitem><simpara> Open file descriptor of the right type to lock.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>type</parameter>&nbsp;:</term>
<listitem><simpara> Type of lock, CAMEL_LOCK_READ or CAMEL_LOCK_WRITE.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ex</parameter>&nbsp;:</term>
<listitem><simpara> 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> -1 on error, <parameter>ex</parameter> will describe the locking system that failed.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-unlock-folder" role="function">
<title>camel_unlock_folder ()</title>
<indexterm zone="camel-unlock-folder"><primary>camel_unlock_folder</primary></indexterm><programlisting><link linkend="void">void</link>                camel_unlock_folder                 (const <link linkend="char">char</link> *path,
                                                         <link linkend="int">int</link> fd);</programlisting>
<para>
Free a lock on a folder.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>path</parameter>&nbsp;:</term>
<listitem><simpara> Filename of folder.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>fd</parameter>&nbsp;:</term>
<listitem><simpara> Open descrptor on which locks were placed.
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>




</refentry>
