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

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

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

<synopsis>
#define             <link linkend="O-BINARY:CAPS">O_BINARY</link>
<link linkend="int">int</link>                 <link linkend="camel-file-util-encode-fixed-int32">camel_file_util_encode_fixed_int32</link>  (<link linkend="FILE:CAPS">FILE</link> *out,
                                                         <link linkend="gint32">gint32</link> );
<link linkend="int">int</link>                 <link linkend="camel-file-util-decode-fixed-int32">camel_file_util_decode_fixed_int32</link>  (<link linkend="FILE:CAPS">FILE</link> *in,
                                                         <link linkend="gint32">gint32</link> *);
<link linkend="int">int</link>                 <link linkend="camel-file-util-encode-uint32">camel_file_util_encode_uint32</link>       (<link linkend="FILE:CAPS">FILE</link> *out,
                                                         <link linkend="guint32">guint32</link> );
<link linkend="int">int</link>                 <link linkend="camel-file-util-decode-uint32">camel_file_util_decode_uint32</link>       (<link linkend="FILE:CAPS">FILE</link> *in,
                                                         <link linkend="guint32">guint32</link> *);
<link linkend="int">int</link>                 <link linkend="camel-file-util-encode-time-t">camel_file_util_encode_time_t</link>       (<link linkend="FILE:CAPS">FILE</link> *out,
                                                         <link linkend="time-t">time_t</link> );
<link linkend="int">int</link>                 <link linkend="camel-file-util-decode-time-t">camel_file_util_decode_time_t</link>       (<link linkend="FILE:CAPS">FILE</link> *in,
                                                         <link linkend="time-t">time_t</link> *);
<link linkend="int">int</link>                 <link linkend="camel-file-util-encode-off-t">camel_file_util_encode_off_t</link>        (<link linkend="FILE:CAPS">FILE</link> *out,
                                                         <link linkend="off-t">off_t</link> );
<link linkend="int">int</link>                 <link linkend="camel-file-util-decode-off-t">camel_file_util_decode_off_t</link>        (<link linkend="FILE:CAPS">FILE</link> *in,
                                                         <link linkend="off-t">off_t</link> *);
<link linkend="int">int</link>                 <link linkend="camel-file-util-encode-size-t">camel_file_util_encode_size_t</link>       (<link linkend="FILE:CAPS">FILE</link> *out,
                                                         <link linkend="size-t">size_t</link> );
<link linkend="int">int</link>                 <link linkend="camel-file-util-decode-size-t">camel_file_util_decode_size_t</link>       (<link linkend="FILE:CAPS">FILE</link> *in,
                                                         <link linkend="size-t">size_t</link> *);
<link linkend="int">int</link>                 <link linkend="camel-file-util-encode-string">camel_file_util_encode_string</link>       (<link linkend="FILE:CAPS">FILE</link> *out,
                                                         const <link linkend="char">char</link> *);
<link linkend="int">int</link>                 <link linkend="camel-file-util-decode-string">camel_file_util_decode_string</link>       (<link linkend="FILE:CAPS">FILE</link> *in,
                                                         <link linkend="char">char</link> **);
<link linkend="int">int</link>                 <link linkend="camel-file-util-encode-fixed-string">camel_file_util_encode_fixed_string</link> (<link linkend="FILE:CAPS">FILE</link> *out,
                                                         const <link linkend="char">char</link> *str,
                                                         <link linkend="size-t">size_t</link> len);
<link linkend="int">int</link>                 <link linkend="camel-file-util-decode-fixed-string">camel_file_util_decode_fixed_string</link> (<link linkend="FILE:CAPS">FILE</link> *in,
                                                         <link linkend="char">char</link> **str,
                                                         <link linkend="size-t">size_t</link> len);
<link linkend="char">char</link>*               <link linkend="camel-file-util-safe-filename">camel_file_util_safe_filename</link>       (const <link linkend="char">char</link> *name);
<link linkend="ssize-t">ssize_t</link>             <link linkend="camel-read">camel_read</link>                          (<link linkend="int">int</link> fd,
                                                         <link linkend="char">char</link> *buf,
                                                         <link linkend="size-t">size_t</link> n);
<link linkend="ssize-t">ssize_t</link>             <link linkend="camel-write">camel_write</link>                         (<link linkend="int">int</link> fd,
                                                         const <link linkend="char">char</link> *buf,
                                                         <link linkend="size-t">size_t</link> n);
<link linkend="ssize-t">ssize_t</link>             <link linkend="camel-read-socket">camel_read_socket</link>                   (<link linkend="int">int</link> fd,
                                                         <link linkend="char">char</link> *buf,
                                                         <link linkend="size-t">size_t</link> n);
<link linkend="ssize-t">ssize_t</link>             <link linkend="camel-write-socket">camel_write_socket</link>                  (<link linkend="int">int</link> fd,
                                                         const <link linkend="char">char</link> *buf,
                                                         <link linkend="size-t">size_t</link> n);
<link linkend="char">char</link>*               <link linkend="camel-file-util-savename">camel_file_util_savename</link>            (const <link linkend="char">char</link> *filename);
</synopsis>
</refsynopsisdiv>









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

</para>
</refsect1>

<refsect1 id="camel-camel-file-utils.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="O-BINARY:CAPS" role="macro">
<title>O_BINARY</title>
<indexterm zone="O-BINARY:CAPS"><primary>O_BINARY</primary></indexterm><programlisting>#define O_BINARY 0
</programlisting>
<para>

</para></refsect2>
<refsect2 id="camel-file-util-encode-fixed-int32" role="function">
<title>camel_file_util_encode_fixed_int32 ()</title>
<indexterm zone="camel-file-util-encode-fixed-int32"><primary>camel_file_util_encode_fixed_int32</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_file_util_encode_fixed_int32  (<link linkend="FILE:CAPS">FILE</link> *out,
                                                         <link linkend="gint32">gint32</link> );</programlisting>
<para>
Encode a gint32, performing no compression, but converting
to network order.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>out</parameter>&nbsp;:</term>
<listitem><simpara> file to output to
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>Param2</parameter>&nbsp;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="0:CAPS"><literal>0</literal></link> on success, <link linkend="1:CAPS"><literal>-1</literal></link> on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-file-util-decode-fixed-int32" role="function">
<title>camel_file_util_decode_fixed_int32 ()</title>
<indexterm zone="camel-file-util-decode-fixed-int32"><primary>camel_file_util_decode_fixed_int32</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_file_util_decode_fixed_int32  (<link linkend="FILE:CAPS">FILE</link> *in,
                                                         <link linkend="gint32">gint32</link> *);</programlisting>
<para>
Retrieve a gint32.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>in</parameter>&nbsp;:</term>
<listitem><simpara> file to read from
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>Param2</parameter>&nbsp;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="0:CAPS"><literal>0</literal></link> on success, <link linkend="1:CAPS"><literal>-1</literal></link> on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-file-util-encode-uint32" role="function">
<title>camel_file_util_encode_uint32 ()</title>
<indexterm zone="camel-file-util-encode-uint32"><primary>camel_file_util_encode_uint32</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_file_util_encode_uint32       (<link linkend="FILE:CAPS">FILE</link> *out,
                                                         <link linkend="guint32">guint32</link> );</programlisting>
<para>
Utility function to save an uint32 to a file.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>out</parameter>&nbsp;:</term>
<listitem><simpara> file to output to
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>Param2</parameter>&nbsp;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="0:CAPS"><literal>0</literal></link> on success, <link linkend="1:CAPS"><literal>-1</literal></link> on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-file-util-decode-uint32" role="function">
<title>camel_file_util_decode_uint32 ()</title>
<indexterm zone="camel-file-util-decode-uint32"><primary>camel_file_util_decode_uint32</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_file_util_decode_uint32       (<link linkend="FILE:CAPS">FILE</link> *in,
                                                         <link linkend="guint32">guint32</link> *);</programlisting>
<para>
Retrieve an encoded uint32 from a file.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>in</parameter>&nbsp;:</term>
<listitem><simpara> file to read from
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>Param2</parameter>&nbsp;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="0:CAPS"><literal>0</literal></link> on success, <link linkend="1:CAPS"><literal>-1</literal></link> on error.  @*dest will contain the
decoded value.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-file-util-encode-time-t" role="function">
<title>camel_file_util_encode_time_t ()</title>
<indexterm zone="camel-file-util-encode-time-t"><primary>camel_file_util_encode_time_t</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_file_util_encode_time_t       (<link linkend="FILE:CAPS">FILE</link> *out,
                                                         <link linkend="time-t">time_t</link> );</programlisting>
<para>
Encode a time_t value to the file.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>out</parameter>&nbsp;:</term>
<listitem><simpara> file to output to
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>Param2</parameter>&nbsp;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="0:CAPS"><literal>0</literal></link> on success, <link linkend="1:CAPS"><literal>-1</literal></link> on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-file-util-decode-time-t" role="function">
<title>camel_file_util_decode_time_t ()</title>
<indexterm zone="camel-file-util-decode-time-t"><primary>camel_file_util_decode_time_t</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_file_util_decode_time_t       (<link linkend="FILE:CAPS">FILE</link> *in,
                                                         <link linkend="time-t">time_t</link> *);</programlisting>
<para>
Decode a time_t value.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>in</parameter>&nbsp;:</term>
<listitem><simpara> file to read from
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>Param2</parameter>&nbsp;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="0:CAPS"><literal>0</literal></link> on success, <link linkend="1:CAPS"><literal>-1</literal></link> on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-file-util-encode-off-t" role="function">
<title>camel_file_util_encode_off_t ()</title>
<indexterm zone="camel-file-util-encode-off-t"><primary>camel_file_util_encode_off_t</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_file_util_encode_off_t        (<link linkend="FILE:CAPS">FILE</link> *out,
                                                         <link linkend="off-t">off_t</link> );</programlisting>
<para>
Encode an off_t type.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>out</parameter>&nbsp;:</term>
<listitem><simpara> file to output to
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>Param2</parameter>&nbsp;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="0:CAPS"><literal>0</literal></link> on success, <link linkend="1:CAPS"><literal>-1</literal></link> on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-file-util-decode-off-t" role="function">
<title>camel_file_util_decode_off_t ()</title>
<indexterm zone="camel-file-util-decode-off-t"><primary>camel_file_util_decode_off_t</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_file_util_decode_off_t        (<link linkend="FILE:CAPS">FILE</link> *in,
                                                         <link linkend="off-t">off_t</link> *);</programlisting>
<para>
Decode an off_t type.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>in</parameter>&nbsp;:</term>
<listitem><simpara> file to read from
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>Param2</parameter>&nbsp;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="0:CAPS"><literal>0</literal></link> on success, <link linkend="1:CAPS"><literal>-1</literal></link> on failure.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-file-util-encode-size-t" role="function">
<title>camel_file_util_encode_size_t ()</title>
<indexterm zone="camel-file-util-encode-size-t"><primary>camel_file_util_encode_size_t</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_file_util_encode_size_t       (<link linkend="FILE:CAPS">FILE</link> *out,
                                                         <link linkend="size-t">size_t</link> );</programlisting>
<para>
Encode an size_t type.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>out</parameter>&nbsp;:</term>
<listitem><simpara> file to output to
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>Param2</parameter>&nbsp;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="0:CAPS"><literal>0</literal></link> on success, <link linkend="1:CAPS"><literal>-1</literal></link> on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-file-util-decode-size-t" role="function">
<title>camel_file_util_decode_size_t ()</title>
<indexterm zone="camel-file-util-decode-size-t"><primary>camel_file_util_decode_size_t</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_file_util_decode_size_t       (<link linkend="FILE:CAPS">FILE</link> *in,
                                                         <link linkend="size-t">size_t</link> *);</programlisting>
<para>
Decode an size_t type.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>in</parameter>&nbsp;:</term>
<listitem><simpara> file to read from
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>Param2</parameter>&nbsp;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="0:CAPS"><literal>0</literal></link> on success, <link linkend="1:CAPS"><literal>-1</literal></link> on failure.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-file-util-encode-string" role="function">
<title>camel_file_util_encode_string ()</title>
<indexterm zone="camel-file-util-encode-string"><primary>camel_file_util_encode_string</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_file_util_encode_string       (<link linkend="FILE:CAPS">FILE</link> *out,
                                                         const <link linkend="char">char</link> *);</programlisting>
<para>
Encode a normal string and save it in the output file.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>out</parameter>&nbsp;:</term>
<listitem><simpara> file to output to
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>Param2</parameter>&nbsp;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="0:CAPS"><literal>0</literal></link> on success, <link linkend="1:CAPS"><literal>-1</literal></link> on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-file-util-decode-string" role="function">
<title>camel_file_util_decode_string ()</title>
<indexterm zone="camel-file-util-decode-string"><primary>camel_file_util_decode_string</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_file_util_decode_string       (<link linkend="FILE:CAPS">FILE</link> *in,
                                                         <link linkend="char">char</link> **);</programlisting>
<para>
Decode a normal string from the input file.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>in</parameter>&nbsp;:</term>
<listitem><simpara> file to read from
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>Param2</parameter>&nbsp;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="0:CAPS"><literal>0</literal></link> on success, <link linkend="1:CAPS"><literal>-1</literal></link> on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-file-util-encode-fixed-string" role="function">
<title>camel_file_util_encode_fixed_string ()</title>
<indexterm zone="camel-file-util-encode-fixed-string"><primary>camel_file_util_encode_fixed_string</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_file_util_encode_fixed_string (<link linkend="FILE:CAPS">FILE</link> *out,
                                                         const <link linkend="char">char</link> *str,
                                                         <link linkend="size-t">size_t</link> len);</programlisting>
<para>
Encode a normal string and save it in the output file.
Unlike <parameter>camel_file_util_encode_string</parameter>, it pads the
<parameter>str</parameter> with "NULL" bytes, if <parameter>len</parameter> is &gt; strlen(str)</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>out</parameter>&nbsp;:</term>
<listitem><simpara> file to output to
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>str</parameter>&nbsp;:</term>
<listitem><simpara> value to output
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>len</parameter>&nbsp;:</term>
<listitem><simpara> total-len of str to store
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="0:CAPS"><literal>0</literal></link> on success, <link linkend="1:CAPS"><literal>-1</literal></link> on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-file-util-decode-fixed-string" role="function">
<title>camel_file_util_decode_fixed_string ()</title>
<indexterm zone="camel-file-util-decode-fixed-string"><primary>camel_file_util_decode_fixed_string</primary></indexterm><programlisting><link linkend="int">int</link>                 camel_file_util_decode_fixed_string (<link linkend="FILE:CAPS">FILE</link> *in,
                                                         <link linkend="char">char</link> **str,
                                                         <link linkend="size-t">size_t</link> len);</programlisting>
<para>
Decode a normal string from the input file.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>in</parameter>&nbsp;:</term>
<listitem><simpara> file to read from
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>str</parameter>&nbsp;:</term>
<listitem><simpara> pointer to a variable to store the value in
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>len</parameter>&nbsp;:</term>
<listitem><simpara> total-len to decode.  
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="0:CAPS"><literal>0</literal></link> on success, <link linkend="1:CAPS"><literal>-1</literal></link> on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-file-util-safe-filename" role="function">
<title>camel_file_util_safe_filename ()</title>
<indexterm zone="camel-file-util-safe-filename"><primary>camel_file_util_safe_filename</primary></indexterm><programlisting><link linkend="char">char</link>*               camel_file_util_safe_filename       (const <link linkend="char">char</link> *name);</programlisting>
<para>
'Flattens' <parameter>name</parameter> into a safe filename string by hex encoding any
chars that may cause problems on the filesystem.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>name</parameter>&nbsp;:</term>
<listitem><simpara> string to 'flattened' into a safe filename
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara>a safe filename string.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-read" role="function">
<title>camel_read ()</title>
<indexterm zone="camel-read"><primary>camel_read</primary></indexterm><programlisting><link linkend="ssize-t">ssize_t</link>             camel_read                          (<link linkend="int">int</link> fd,
                                                         <link linkend="char">char</link> *buf,
                                                         <link linkend="size-t">size_t</link> n);</programlisting>
<para>
Cancellable libc <link linkend="read"><function>read()</function></link> replacement.
</para>
<para>
Code that intends to be portable to Win32 should call this function
only on file descriptors returned from <link linkend="open"><function>open()</function></link>, not on sockets.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>fd</parameter>&nbsp;:</term>
<listitem><simpara> file descriptor
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>buf</parameter>&nbsp;:</term>
<listitem><simpara> buffer to fill
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>n</parameter>&nbsp;:</term>
<listitem><simpara> number of bytes to read into <parameter>buf</parameter>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara>number of bytes read or -1 on fail. On failure, errno will
be set appropriately.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-write" role="function">
<title>camel_write ()</title>
<indexterm zone="camel-write"><primary>camel_write</primary></indexterm><programlisting><link linkend="ssize-t">ssize_t</link>             camel_write                         (<link linkend="int">int</link> fd,
                                                         const <link linkend="char">char</link> *buf,
                                                         <link linkend="size-t">size_t</link> n);</programlisting>
<para>
Cancellable libc <link linkend="write"><function>write()</function></link> replacement.
</para>
<para>
Code that intends to be portable to Win32 should call this function
only on file descriptors returned from <link linkend="open"><function>open()</function></link>, not on sockets.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>fd</parameter>&nbsp;:</term>
<listitem><simpara> file descriptor
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>buf</parameter>&nbsp;:</term>
<listitem><simpara> buffer to write
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>n</parameter>&nbsp;:</term>
<listitem><simpara> number of bytes of <parameter>buf</parameter> to write
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara>number of bytes written or -1 on fail. On failure, errno will
be set appropriately.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-read-socket" role="function">
<title>camel_read_socket ()</title>
<indexterm zone="camel-read-socket"><primary>camel_read_socket</primary></indexterm><programlisting><link linkend="ssize-t">ssize_t</link>             camel_read_socket                   (<link linkend="int">int</link> fd,
                                                         <link linkend="char">char</link> *buf,
                                                         <link linkend="size-t">size_t</link> n);</programlisting>
<para>
Cancellable <link linkend="read"><function>read()</function></link> replacement for sockets. Code that intends to be
portable to Win32 should call this function only on sockets
returned from <link linkend="socket"><function>socket()</function></link>, or <link linkend="accept"><function>accept()</function></link>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>fd</parameter>&nbsp;:</term>
<listitem><simpara> a socket
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>buf</parameter>&nbsp;:</term>
<listitem><simpara> buffer to fill
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>n</parameter>&nbsp;:</term>
<listitem><simpara> number of bytes to read into <parameter>buf</parameter>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara>number of bytes read or -1 on fail. On failure, errno will
be set appropriately. If the socket is nonblocking
<link linkend="camel-read-socket"><function>camel_read_socket()</function></link> will retry the read until it gets something.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-write-socket" role="function">
<title>camel_write_socket ()</title>
<indexterm zone="camel-write-socket"><primary>camel_write_socket</primary></indexterm><programlisting><link linkend="ssize-t">ssize_t</link>             camel_write_socket                  (<link linkend="int">int</link> fd,
                                                         const <link linkend="char">char</link> *buf,
                                                         <link linkend="size-t">size_t</link> n);</programlisting>
<para>
Cancellable <link linkend="write"><function>write()</function></link> replacement for sockets. Code that intends to
be portable to Win32 should call this function only on sockets
returned from <link linkend="socket"><function>socket()</function></link> or <link linkend="accept"><function>accept()</function></link>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>fd</parameter>&nbsp;:</term>
<listitem><simpara> file descriptor
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>buf</parameter>&nbsp;:</term>
<listitem><simpara> buffer to write
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>n</parameter>&nbsp;:</term>
<listitem><simpara> number of bytes of <parameter>buf</parameter> to write
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara>number of bytes written or -1 on fail. On failure, errno will
be set appropriately.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-file-util-savename" role="function">
<title>camel_file_util_savename ()</title>
<indexterm zone="camel-file-util-savename"><primary>camel_file_util_savename</primary></indexterm><programlisting><link linkend="char">char</link>*               camel_file_util_savename            (const <link linkend="char">char</link> *filename);</programlisting>
<para>
Builds a pathname where the basename is of the form ".#" + the
basename of <parameter>filename</parameter>, for instance used in a two-stage commit file
write.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>filename</parameter>&nbsp;:</term>
<listitem><simpara> a pathname
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> The new pathname.  It must be free'd with <link linkend="g-free"><function>g_free()</function></link>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>




</refentry>
