Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-release > by-pkgid > 7c006d54dcff4666525b05af2c364234 > files > 76

lib64prelude-devel-0.9.16.2-2mdv2008.1.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>prelude-connection-pool</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="index.html" title="Prelude library Reference Manual">
<link rel="up" href="pt03.html" title="Part&#160;III.&#160;Reading events from the collector">
<link rel="prev" href="libprelude-idmef-message-read.html" title="idmef-message-read">
<link rel="next" href="pt04.html" title="Part&#160;IV.&#160;Filtering operation on IDMEF messages">
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="part" href="pt01.html" title="Part&#160;I.&#160;Using libprelude to interoperate with prelude-manager">
<link rel="part" href="pt02.html" title="Part&#160;II.&#160;Sending events with libprelude">
<link rel="chapter" href="ch01.html" title="The low level IDMEF API">
<link rel="chapter" href="ch02.html" title="The high level IDMEF API">
<link rel="part" href="pt03.html" title="Part&#160;III.&#160;Reading events from the collector">
<link rel="part" href="pt04.html" title="Part&#160;IV.&#160;Filtering operation on IDMEF messages">
<link rel="chapter" href="ch03.html" title="Utility functions">
<link rel="chapter" href="ch04.html" title="Others">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="libprelude-idmef-message-read.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="pt03.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">Prelude library Reference Manual</th>
<td><a accesskey="n" href="pt04.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id385308" class="shortcut">Top</a>
                  &#160;|&#160;
                  <a href="#id473453" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="libprelude-prelude-connection-pool"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id385308"></a><span class="refentrytitle">prelude-connection-pool</span>
</h2>
<p>prelude-connection-pool &#8212; 
Pool of connection handling</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">



enum                <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-flags-t">prelude_connection_pool_flags_t</a>;
enum                <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-event-t">prelude_connection_pool_event_t</a>;
typedef             <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a>;
void                <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-broadcast">prelude_connection_pool_broadcast</a>   (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-msg.html#prelude-msg-t">prelude_msg_t</a> *msg);
void                <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-broadcast-async">prelude_connection_pool_broadcast_async</a>
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-msg.html#prelude-msg-t">prelude_msg_t</a> *msg);
int                 <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-init">prelude_connection_pool_init</a>        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool);
int                 <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-new">prelude_connection_pool_new</a>         (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> **ret,
                                                         <a class="link" href="libprelude-prelude-client-profile.html#prelude-client-profile-t">prelude_client_profile_t</a> *cp,
                                                         <a class="link" href="libprelude-prelude-connection.html#prelude-connection-permission-t">prelude_connection_permission_t</a> permission);
<a class="link" href="libprelude-prelude-list.html#prelude-list-t">prelude_list_t</a>*     <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-get-connection-list">prelude_connection_pool_get_connection_list</a>
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool);
int                 <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-add-connection">prelude_connection_pool_add_connection</a>
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-connection.html#prelude-connection-t">prelude_connection_t</a> *cnx);
int                 <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-set-connection-dead">prelude_connection_pool_set_connection_dead</a>
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-connection.html#prelude-connection-t">prelude_connection_t</a> *cnx);
int                 <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-set-connection-alive">prelude_connection_pool_set_connection_alive</a>
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-connection.html#prelude-connection-t">prelude_connection_t</a> *cnx);
int                 <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-set-connection-string">prelude_connection_pool_set_connection_string</a>
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         const char *cfgstr);
const char*         <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-get-connection-string">prelude_connection_pool_get_connection_string</a>
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool);
void                <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-destroy">prelude_connection_pool_destroy</a>     (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool);
<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-flags-t">prelude_connection_pool_flags_t</a> <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-get-flags">prelude_connection_pool_get_flags</a>
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool);
void                <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-set-flags">prelude_connection_pool_set_flags</a>   (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-flags-t">prelude_connection_pool_flags_t</a> flags);
void                <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-set-required-permission">prelude_connection_pool_set_required_permission</a>
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-connection.html#prelude-connection-permission-t">prelude_connection_permission_t</a> req_perm);
void                <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-set-data">prelude_connection_pool_set_data</a>    (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         void *data);
void*               <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-get-data">prelude_connection_pool_get_data</a>    (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool);
int                 <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-recv">prelude_connection_pool_recv</a>        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         int timeout,
                                                         <a class="link" href="libprelude-prelude-connection.html#prelude-connection-t">prelude_connection_t</a> **outconn,
                                                         <a class="link" href="libprelude-prelude-msg.html#prelude-msg-t">prelude_msg_t</a> **outmsg);
int                 <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-check-event">prelude_connection_pool_check_event</a> (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         int timeout,
                                                         int (event_cbprelude_connection_pool_t *pool,prelude_connection_pool_event_t event,prelude_connection_t *cnx, void *extra) (),
                                                         void *extra);
void                <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-set-global-event-handler">prelude_connection_pool_set_global_event_handler</a>
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-event-t">prelude_connection_pool_event_t</a> wanted_events,
                                                         int (callbackprelude_connection_pool_t *pool,prelude_connection_pool_event_t events) ());
void                <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-set-event-handler">prelude_connection_pool_set_event_handler</a>
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-event-t">prelude_connection_pool_event_t</a> wanted_events,
                                                         int (callbackprelude_connection_pool_t *pool,prelude_connection_pool_event_t events,prelude_connection_t *cnx) ());
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id473453"></a><h2>Description</h2>
<p>
This API handle pool of connection, allowing to address a set of connection using only one object.
</p>
<p>
AND &amp; OR of connection are supported, so that it is possible to
address several connection at once, or to only address a set of connection 
if another connection went down.
</p>
<p>
Additionally it provide failover in case one of the connection in
the pool goes down, and automatic reconnection and flushing of the
information that could not be sent due to the connection status.
</p>
<p>
It is usually not necessary to access this API directly, however if 
you are looking at how to read events from a pool of connection, you're most 
probably looking for the <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-check-event"><code class="function">prelude_connection_pool_check_event()</code></a> function.
</p>
<p>
If this is the case, use <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-check-event"><code class="function">prelude_connection_pool_check_event()</code></a> for polling the
pool or <code class="function">prelude_connection_set_event_handler()</code> / <code class="function">prelude_connection_set_global_event_handler()</code>
if you want asynchronous notification of event.
</p>
<p>
Note that <code class="function">prelude_connection_set_event_handler()</code> and <code class="function">prelude_connection_set_global_event_handler()</code>
are only asynchronous if timer are running in asynchronous mode. Otherwise, the callback for theses
function might be called when you call the <a class="link" href="libprelude-prelude-timer.html#prelude-timer-wake-up"><code class="function">prelude_timer_wake_up()</code></a> function.
</p>
<p>
In the provided callback, you might use <a class="link" href="libprelude-prelude-connection.html#prelude-connection-recv"><code class="function">prelude_connection_recv()</code></a> to retrieve an event of type
<span class="type">PRELUDE_CONNECTION_POOL_EVENT_INPUT</span>. And, you could, for example, if the retrieved message has
the <span class="type">PRELUDE_MSG_ID_IDMEF</span> tag, provide the returned <a class="link" href="libprelude-prelude-msg.html#prelude-msg-t"><span class="type">prelude_msg_t</span></a> object to <a class="link" href="libprelude-idmef-message-read.html#idmef-message-read"><code class="function">idmef_message_read()</code></a> 
in order to convert the received message to a <a class="link" href="libprelude-idmef-tree-wrap.html#idmef-message-t"><span class="type">idmef_message_t</span></a> object.
</p>
</div>
<div class="refsect1" lang="en">
<a name="id354428"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id354438"></a><h3>
<a name="prelude-connection-pool-flags-t"></a>enum prelude_connection_pool_flags_t</h3>
<a class="indexterm" name="id347743"></a><pre class="programlisting">typedef enum {
        PRELUDE_CONNECTION_POOL_FLAGS_RECONNECT        = 0x01,
        PRELUDE_CONNECTION_POOL_FLAGS_FAILOVER         = 0x02
} prelude_connection_pool_flags_t;
</pre>
<p>

</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id347759"></a><h3>
<a name="prelude-connection-pool-event-t"></a>enum prelude_connection_pool_event_t</h3>
<a class="indexterm" name="id347772"></a><pre class="programlisting">typedef enum {
        PRELUDE_CONNECTION_POOL_EVENT_INPUT            = 0x01,
        PRELUDE_CONNECTION_POOL_EVENT_DEAD             = 0x02,
        PRELUDE_CONNECTION_POOL_EVENT_ALIVE            = 0x04
} prelude_connection_pool_event_t;
</pre>
<p>

</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id347789"></a><h3>
<a name="prelude-connection-pool-t"></a>prelude_connection_pool_t</h3>
<a class="indexterm" name="id347802"></a><pre class="programlisting">typedef struct prelude_connection_pool prelude_connection_pool_t;
</pre>
<p>

</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id347818"></a><h3>
<a name="prelude-connection-pool-broadcast"></a>prelude_connection_pool_broadcast ()</h3>
<a class="indexterm" name="id347830"></a><pre class="programlisting">void                prelude_connection_pool_broadcast   (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-msg.html#prelude-msg-t">prelude_msg_t</a> *msg);</pre>
<p>
Sends the message contained in <em class="parameter"><code>msg</code></em> to all the connection in <em class="parameter"><code>pool</code></em>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>msg</code></em>&#160;:</span></p></td>
<td> Pointer on a <a class="link" href="libprelude-prelude-msg.html#prelude-msg-t"><span class="type">prelude_msg_t</span></a> object.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id358265"></a><h3>
<a name="prelude-connection-pool-broadcast-async"></a>prelude_connection_pool_broadcast_async ()</h3>
<a class="indexterm" name="id356919"></a><pre class="programlisting">void                prelude_connection_pool_broadcast_async
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-msg.html#prelude-msg-t">prelude_msg_t</a> *msg);</pre>
<p>
Sends the message contained in <em class="parameter"><code>msg</code></em> to all connections
in <em class="parameter"><code>pool</code></em> asynchronously. After the request is processed,
the <em class="parameter"><code>msg</code></em> message will be freed.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>msg</code></em>&#160;:</span></p></td>
<td> Pointer on a <a class="link" href="libprelude-prelude-msg.html#prelude-msg-t"><span class="type">prelude_msg_t</span></a> object.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id377380"></a><h3>
<a name="prelude-connection-pool-init"></a>prelude_connection_pool_init ()</h3>
<a class="indexterm" name="id377392"></a><pre class="programlisting">int                 prelude_connection_pool_init        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool);</pre>
<p>
Initializes <em class="parameter"><code>pool</code></em>. This means that connection associated
with <em class="parameter"><code>pool</code></em> using <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-set-connection-string"><code class="function">prelude_connection_pool_set_connection_string()</code></a>
will be established.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> 0 on success, a negative value on error.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id465712"></a><h3>
<a name="prelude-connection-pool-new"></a>prelude_connection_pool_new ()</h3>
<a class="indexterm" name="id465725"></a><pre class="programlisting">int                 prelude_connection_pool_new         (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> **ret,
                                                         <a class="link" href="libprelude-prelude-client-profile.html#prelude-client-profile-t">prelude_client_profile_t</a> *cp,
                                                         <a class="link" href="libprelude-prelude-connection.html#prelude-connection-permission-t">prelude_connection_permission_t</a> permission);</pre>
<p>
<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-new"><code class="function">prelude_connection_pool_new()</code></a> initializes a new Connection Manager object.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>ret</code></em>&#160;:</span></p></td>
<td> Pointer to an address where to store the created <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cp</code></em>&#160;:</span></p></td>
<td> The <a class="link" href="libprelude-prelude-client-profile.html#prelude-client-profile-t"><span class="type">prelude_client_profile_t</span></a> to use for connection.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>permission</code></em>&#160;:</span></p></td>
<td> Permission the connection in this connection-pool will require.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> 0 on success or a negative value if an error occured.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id446472"></a><h3>
<a name="prelude-connection-pool-get-connection-list"></a>prelude_connection_pool_get_connection_list ()</h3>
<a class="indexterm" name="id446483"></a><pre class="programlisting"><a class="link" href="libprelude-prelude-list.html#prelude-list-t">prelude_list_t</a>*     prelude_connection_pool_get_connection_list
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool);</pre>
<p>
</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> The list of connections handled by <em class="parameter"><code>pool</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id446557"></a><h3>
<a name="prelude-connection-pool-add-connection"></a>prelude_connection_pool_add_connection ()</h3>
<a class="indexterm" name="id446569"></a><pre class="programlisting">int                 prelude_connection_pool_add_connection
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-connection.html#prelude-connection-t">prelude_connection_t</a> *cnx);</pre>
<p>
Adds <em class="parameter"><code>cnx</code></em> to <em class="parameter"><code>pool</code></em> set of connections.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cnx</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection.html#prelude-connection-t"><span class="type">prelude_connection_t</span></a> object to add to <em class="parameter"><code>pool</code></em>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> 0 on success, a negative value if an error occured.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id438747"></a><h3>
<a name="prelude-connection-pool-set-connection-dead"></a>prelude_connection_pool_set_connection_dead ()</h3>
<a class="indexterm" name="id438759"></a><pre class="programlisting">int                 prelude_connection_pool_set_connection_dead
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-connection.html#prelude-connection-t">prelude_connection_t</a> *cnx);</pre>
<p>
Notifies <em class="parameter"><code>pool</code></em> that the connection identified by <em class="parameter"><code>cnx</code></em> is dead.
</p>
<p>
Usually, this function should not be used since <em class="parameter"><code>pool</code></em> is
self sufficient, and handles connections issues internally. However,
it is sometime useful when the user has several mechanisms using the
connection, and that its own mechanism detects a connection problem
before <em class="parameter"><code>pool</code></em> notice.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cnx</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection.html#prelude-connection-t"><span class="type">prelude_connection_t</span></a> object used within <em class="parameter"><code>pool</code></em>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> 0 on success, a negative value if an error occured.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id473655"></a><h3>
<a name="prelude-connection-pool-set-connection-alive"></a>prelude_connection_pool_set_connection_alive ()</h3>
<a class="indexterm" name="id440055"></a><pre class="programlisting">int                 prelude_connection_pool_set_connection_alive
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-connection.html#prelude-connection-t">prelude_connection_t</a> *cnx);</pre>
<p>
Notifies <em class="parameter"><code>pool</code></em> that the connection identified by <em class="parameter"><code>cnx</code></em> went back alive.
</p>
<p>
Usually, this function should not be used since <em class="parameter"><code>pool</code></em> is
self sufficient, and handles connection issues internally. However,
it is sometime useful when the user has several mechanisms using the
connection, and that its own mechanism detects a connection problem
before <em class="parameter"><code>pool</code></em> notice.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cnx</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection.html#prelude-connection-t"><span class="type">prelude_connection_t</span></a> object used within <em class="parameter"><code>pool</code></em>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> 0 on success, a negative value if an error occured.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id420345"></a><h3>
<a name="prelude-connection-pool-set-connection-string"></a>prelude_connection_pool_set_connection_string ()</h3>
<a class="indexterm" name="id420356"></a><pre class="programlisting">int                 prelude_connection_pool_set_connection_string
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         const char *cfgstr);</pre>
<p>
Sets the connection string for <em class="parameter"><code>pool</code></em>. The connection string should be
in the form of : "address". Special operand like || (OR) and &amp;&amp; (AND),
are also accepted: "address &amp;&amp; address".
</p>
<p>
Where &amp;&amp; means that alert sent using <em class="parameter"><code>pool</code></em> will go to both configured
addresses, and || means that if the left address fails, the right address
will be used.
</p>
<p>
<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-init"><code class="function">prelude_connection_pool_init()</code></a> should be used to initiates the connection.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cfgstr</code></em>&#160;:</span></p></td>
<td> Connection string.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> 0 on success, a negative value if an error occured.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id447561"></a><h3>
<a name="prelude-connection-pool-get-connection-string"></a>prelude_connection_pool_get_connection_string ()</h3>
<a class="indexterm" name="id447572"></a><pre class="programlisting">const char*         prelude_connection_pool_get_connection_string
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool);</pre>
<p>
Used to query the connection string used by <em class="parameter"><code>pool</code></em>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> The connection string.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id447646"></a><h3>
<a name="prelude-connection-pool-destroy"></a>prelude_connection_pool_destroy ()</h3>
<a class="indexterm" name="id447659"></a><pre class="programlisting">void                prelude_connection_pool_destroy     (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool);</pre>
<p>
Destroys <em class="parameter"><code>pool</code></em> and all connections handled.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id452014"></a><h3>
<a name="prelude-connection-pool-get-flags"></a>prelude_connection_pool_get_flags ()</h3>
<a class="indexterm" name="id452027"></a><pre class="programlisting"><a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-flags-t">prelude_connection_pool_flags_t</a> prelude_connection_pool_get_flags
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool);</pre>
<p>
</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> the <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-flags-t"><span class="type">prelude_connection_pool_flags_t</span></a> used in <em class="parameter"><code>pool</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id452108"></a><h3>
<a name="prelude-connection-pool-set-flags"></a>prelude_connection_pool_set_flags ()</h3>
<a class="indexterm" name="id449295"></a><pre class="programlisting">void                prelude_connection_pool_set_flags   (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-flags-t">prelude_connection_pool_flags_t</a> flags);</pre>
<p>
Sets <em class="parameter"><code>flags</code></em> within <em class="parameter"><code>pools</code></em>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>flags</code></em>&#160;:</span></p></td>
<td> Flags to use for <em class="parameter"><code>pool</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id449390"></a><h3>
<a name="prelude-connection-pool-set-required-permission"></a>prelude_connection_pool_set_required_permission ()</h3>
<a class="indexterm" name="id449402"></a><pre class="programlisting">void                prelude_connection_pool_set_required_permission
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-connection.html#prelude-connection-permission-t">prelude_connection_permission_t</a> req_perm);</pre>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>req_perm</code></em>&#160;:</span></p></td>
<td>


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id448663"></a><h3>
<a name="prelude-connection-pool-set-data"></a>prelude_connection_pool_set_data ()</h3>
<a class="indexterm" name="id448675"></a><pre class="programlisting">void                prelude_connection_pool_set_data    (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         void *data);</pre>
<p>
The user might use this function to associate data with <em class="parameter"><code>pool</code></em>.
The data associated might be retrieved using <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-get-data"><code class="function">prelude_connection_pool_get_data()</code></a>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></p></td>
<td> Pointer to user specific data.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id438121"></a><h3>
<a name="prelude-connection-pool-get-data"></a>prelude_connection_pool_get_data ()</h3>
<a class="indexterm" name="id438134"></a><pre class="programlisting">void*               prelude_connection_pool_get_data    (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool);</pre>
<p>
The user might use this function to query data associated with
<em class="parameter"><code>pool</code></em> using <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-set-data"><code class="function">prelude_connection_pool_set_data()</code></a>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> the user data associated to <em class="parameter"><code>pool</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id438222"></a><h3>
<a name="prelude-connection-pool-recv"></a>prelude_connection_pool_recv ()</h3>
<a class="indexterm" name="id454945"></a><pre class="programlisting">int                 prelude_connection_pool_recv        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         int timeout,
                                                         <a class="link" href="libprelude-prelude-connection.html#prelude-connection-t">prelude_connection_t</a> **outconn,
                                                         <a class="link" href="libprelude-prelude-msg.html#prelude-msg-t">prelude_msg_t</a> **outmsg);</pre>
<p>
This function queries the set of connections available in <em class="parameter"><code>pool</code></em> to see if
events are waiting to be handled. If timeout is zero, then this function
will return immediatly in case there is no event to be handled.
</p>
<p>
If timeout is -1, this function won't return until an event is available.
Otherwise this function will return if there is no event after the specified
number of second.
</p>
<p>
If an event is available, it will be read and store the <a class="link" href="libprelude-prelude-connection.html#prelude-connection-t"><span class="type">prelude_connection_t</span></a>
object in the <em class="parameter"><code>outconn</code></em> pointer. If <em class="parameter"><code>outmsg</code></em> was specified, the message will be
read and stored in there.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>timeout</code></em>&#160;:</span></p></td>
<td> Time to wait for an event.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>outconn</code></em>&#160;:</span></p></td>
<td> Pointer where the connection where an event happened should be stored.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>outmsg</code></em>&#160;:</span></p></td>
<td> Pointer where the next message that will be read should be stored.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> The number of handled events (0 or 1) or a negative value if an error occured.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id454651"></a><h3>
<a name="prelude-connection-pool-check-event"></a>prelude_connection_pool_check_event ()</h3>
<a class="indexterm" name="id454663"></a><pre class="programlisting">int                 prelude_connection_pool_check_event (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         int timeout,
                                                         int (event_cbprelude_connection_pool_t *pool,prelude_connection_pool_event_t event,prelude_connection_t *cnx, void *extra) (),
                                                         void *extra);</pre>
<p>
This function queries the set of connections available in <em class="parameter"><code>pool</code></em> to see if
events are waiting to be handled. If timeout is zero, then this function
will return immediatly in case there is no event to be handled.
</p>
<p>
If timeout is -1, this function won't return until an event is available.
Otherwise this function will return if there is no event after the specified
number of second.
</p>
<p>
For each event, <em class="parameter"><code>event_cb</code></em> is called with the concerned <em class="parameter"><code>pool</code></em>, the provided
<em class="parameter"><code>extra</code></em> data, and the <em class="parameter"><code>cnx</code></em> where an event has occured.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>timeout</code></em>&#160;:</span></p></td>
<td> Time to wait for an event.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>event_cb</code></em>&#160;:</span></p></td>
<td> User provided callback function to call on received events.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>extra</code></em>&#160;:</span></p></td>
<td> Pointer to user specific data provided to <em class="parameter"><code>event_cb</code></em>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> The number of handled events, or a negative value if an error occured.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id473412"></a><h3>
<a name="prelude-connection-pool-set-global-event-handler"></a>prelude_connection_pool_set_global_event_handler ()</h3>
<a class="indexterm" name="id473423"></a><pre class="programlisting">void                prelude_connection_pool_set_global_event_handler
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-event-t">prelude_connection_pool_event_t</a> wanted_events,
                                                         int (callbackprelude_connection_pool_t *pool,prelude_connection_pool_event_t events) ());</pre>
<p>
<em class="parameter"><code>callback</code></em> will be called each time one of the event specified in
<em class="parameter"><code>wanted_events</code></em> happen to <em class="parameter"><code>pool</code></em>. However, contrary to
<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-set-event-handler"><code class="function">prelude_connection_pool_set_event_handler()</code></a>, the callback will be called
only once per set of event.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>wanted_events</code></em>&#160;:</span></p></td>
<td> Event the user want to be notified about.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>callback</code></em>&#160;:</span></p></td>
<td> User specific callback to call when an event is available.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id472412"></a><h3>
<a name="prelude-connection-pool-set-event-handler"></a>prelude_connection_pool_set_event_handler ()</h3>
<a class="indexterm" name="id472423"></a><pre class="programlisting">void                prelude_connection_pool_set_event_handler
                                                        (<a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t">prelude_connection_pool_t</a> *pool,
                                                         <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-event-t">prelude_connection_pool_event_t</a> wanted_events,
                                                         int (callbackprelude_connection_pool_t *pool,prelude_connection_pool_event_t events,prelude_connection_t *cnx) ());</pre>
<p>
<em class="parameter"><code>callback</code></em> will be called each time one of the event specified in
<em class="parameter"><code>wanted_events</code></em> happens to <em class="parameter"><code>pool</code></em>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pool</code></em>&#160;:</span></p></td>
<td> Pointer to a <a class="link" href="libprelude-prelude-connection-pool.html#prelude-connection-pool-t"><span class="type">prelude_connection_pool_t</span></a> object.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>wanted_events</code></em>&#160;:</span></p></td>
<td> Event the user want to be notified about.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>callback</code></em>&#160;:</span></p></td>
<td> User specific callback to call when an event is available.
</td>
</tr>
</tbody>
</table></div>
</div>
</div>
<div class="refsect1" lang="en">
<a name="id469984"></a><h2>See Also</h2>
<p>
<a class="link" href="libprelude-prelude-connection.html#prelude-connection-t"><span class="type">prelude_connection_t</span></a>
<a class="link" href="libprelude-idmef-message-read.html#idmef-message-read"><code class="function">idmef_message_read()</code></a>
</p>
</div>
<div class="refsect1" lang="en">
<a name="id467225"></a><div class="refsect2" lang="en"><a name="id467226"></a></div>
<hr>
<div class="refsect2" lang="en"><a name="id467227"></a></div>
</div>
</div>
</body>
</html>