Subversion Repositories

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

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 magnus 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
<html><head>
3
<title>liboop: on_fd(), cancel_fd()</title>
4
<link rel="stylesheet" type="text/css" href="style.css">
5
</head><body>
6
 
7
<h2>on_fd(), cancel_fd()</h2>
8
 
9
<pre>
10
#include &lt;oop.h&gt;
11
 
12
/* <em>Types of file descriptor activity.</em> */
13
typedef enum {
14
        OOP_READ,
15
        OOP_WRITE,
16
        OOP_EXCEPTION<a href="#note-exception">*</a>,
17
} oop_event;
18
 
19
/* <em>Callback function prototype.</em> */
20
typedef void *oop_call_fd(oop_source *source,int fd,oop_event event,void *user);
21
 
22
/* <em>Register and unregister file descriptor activity event sinks.</em> */
23
void (*on_fd)(oop_source *source,int fd,oop_event event,oop_call_fd *call,void *user);
24
void (*cancel_fd)(oop_source *source,int fd,oop_event event);
25
</pre>
26
 
27
<h3>Arguments.</h3>
28
 
29
<dl>
30
<dt><b>oop_source *source</b>
31
<dd>The event source to register or unregister the event sink with.  This must
32
be the same event source you got the function pointer from:
33
"src-&gt;on_fd(src,...);".<p>
34
 
35
<dt><b>int fd</b>
36
<dd>The file descriptor to watch (or stop watching).<p>
37
 
38
<dt><b>oop_event event</b>
39
<dd>The kind of activity to watch for (or stop watching for).  Must be one of
40
OOP_READ (triggered when data is available for reading on the specified file
41
descriptor), OOP_WRITE (triggered when buffer space is available to write on
42
the specified file descriptor), or OOP_EXCEPTION<a href="#note-exception">*</a>
43
(triggered on any number of "exceptional" events, such as TCP urgent data
44
or system error).<p>
45
 
46
<dt><b>oop_call_fd *call</b>
47
<dd>The callback function (event sink) to add (or remove).<p>
48
 
49
<dt><b>void *user</b>
50
<dd>User data passed through to the callback function.<p>
51
</dl>
52
 
53
<h3>Description.</h3>
54
 
55
Note that these are not global functions, but function pointers supplied
56
by the event source (in the <em>oop_source</em> structure) or by the user.
57
 
58
<dl>
59
<dt><b>on_fd</b>
60
<dd>After this function is called, whenever the source's event loop detects
61
the condition indicated by <em>event</em> (OOP_READ, OOP_WRITE, or
62
OOP_EXCEPTION<a href="#note-exception">*</a>) on the file descriptor
63
<em>fd</em>, it will call the function
64
<em>call</em>, passing it a pointer to the event source, the file descriptor,
65
the event type, and the same opaque <em>user</em> pointer passed to on_fd.
66
This callback will be called repeatedly as long as the condition persists and
67
it is not deactivated (see below).  Only one callback may be registered per
68
(event,fd) pair.<p>
69
 
70
<dt><b>cancel_fd</b>
71
<dd>Deactivate an event sink callback registered using on_fd (above).
72
Any callback associated with the (event,fd) pair in question is removed.<p>
73
 
74
<dt><b>oop_call_fd</b>
75
<dd>Called when the event is triggered.  Performs a user_specific action.
76
Should return OOP_CONTINUE if the event loop should continue operating; any
77
other value (including OOP_HALT) will cause termination of the event loop.
78
</dl>
79
 
80
<hr>
81
<p><a name="note-exception">*</a> <b>Compatibility note:</b> OOP_EXCEPTION
82
is only available in version 0.7 or newer.</p>
83
 
84
<hr><a href="ref">liboop reference</a></body></html>