Subversion Repositories

?revision_form?Rev ?revision_input??revision_submit??revision_endform?

Blame | Last modification | View Log | RSS feed

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html><head>
<title>liboop: on_fd(), cancel_fd()</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head><body>

<h2>on_fd(), cancel_fd()</h2>

<pre>
#include &lt;oop.h&gt;

/* <em>Types of file descriptor activity.</em> */
typedef enum {
        OOP_READ,
        OOP_WRITE,
        OOP_EXCEPTION<a href="#note-exception">*</a>,
} oop_event;

/* <em>Callback function prototype.</em> */
typedef void *oop_call_fd(oop_source *source,int fd,oop_event event,void *user);

/* <em>Register and unregister file descriptor activity event sinks.</em> */
void (*on_fd)(oop_source *source,int fd,oop_event event,oop_call_fd *call,void *user);
void (*cancel_fd)(oop_source *source,int fd,oop_event event);
</pre>

<h3>Arguments.</h3>

<dl>
<dt><b>oop_source *source</b>
<dd>The event source to register or unregister the event sink with.  This must 
be the same event source you got the function pointer from: 
"src-&gt;on_fd(src,...);".<p>

<dt><b>int fd</b>
<dd>The file descriptor to watch (or stop watching).<p>

<dt><b>oop_event event</b>
<dd>The kind of activity to watch for (or stop watching for).  Must be one of
OOP_READ (triggered when data is available for reading on the specified file
descriptor), OOP_WRITE (triggered when buffer space is available to write on
the specified file descriptor), or OOP_EXCEPTION<a href="#note-exception">*</a>
(triggered on any number of "exceptional" events, such as TCP urgent data 
or system error).<p>

<dt><b>oop_call_fd *call</b>
<dd>The callback function (event sink) to add (or remove).<p>

<dt><b>void *user</b>
<dd>User data passed through to the callback function.<p>
</dl>

<h3>Description.</h3>

Note that these are not global functions, but function pointers supplied
by the event source (in the <em>oop_source</em> structure) or by the user.

<dl>
<dt><b>on_fd</b>
<dd>After this function is called, whenever the source's event loop detects
the condition indicated by <em>event</em> (OOP_READ, OOP_WRITE, or 
OOP_EXCEPTION<a href="#note-exception">*</a>) on the file descriptor 
<em>fd</em>, it will call the function 
<em>call</em>, passing it a pointer to the event source, the file descriptor, 
the event type, and the same opaque <em>user</em> pointer passed to on_fd.  
This callback will be called repeatedly as long as the condition persists and 
it is not deactivated (see below).  Only one callback may be registered per 
(event,fd) pair.<p>

<dt><b>cancel_fd</b>
<dd>Deactivate an event sink callback registered using on_fd (above).  
Any callback associated with the (event,fd) pair in question is removed.<p>

<dt><b>oop_call_fd</b>
<dd>Called when the event is triggered.  Performs a user_specific action.
Should return OOP_CONTINUE if the event loop should continue operating; any
other value (including OOP_HALT) will cause termination of the event loop.
</dl>

<hr>
<p><a name="note-exception">*</a> <b>Compatibility note:</b> OOP_EXCEPTION 
is only available in version 0.7 or newer.</p>

<hr><a href="ref">liboop reference</a></body></html>