on_fd(), cancel_fd()

#include <oop.h>

/* Types of file descriptor activity. */
typedef enum {
} oop_event;

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

/* Register and unregister file descriptor activity event sinks. */
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);


oop_source *source
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->on_fd(src,...);".

int fd
The file descriptor to watch (or stop watching).

oop_event event
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* (triggered on any number of "exceptional" events, such as TCP urgent data or system error).

oop_call_fd *call
The callback function (event sink) to add (or remove).

void *user
User data passed through to the callback function.


Note that these are not global functions, but function pointers supplied by the event source (in the oop_source structure) or by the user.
After this function is called, whenever the source's event loop detects the condition indicated by event (OOP_READ, OOP_WRITE, or OOP_EXCEPTION*) on the file descriptor fd, it will call the function call, passing it a pointer to the event source, the file descriptor, the event type, and the same opaque user 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.

Deactivate an event sink callback registered using on_fd (above). Any callback associated with the (event,fd) pair in question is removed.

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.

* Compatibility note: OOP_EXCEPTION is only available in version 0.7 or newer.

liboop reference