NetIO API Functions
pr_netio_t *pr_alloc_netio(pool *pool); int pr_register_netio(pr_netio_t *netio, int strm_types); int pr_unregister_netio(int strm_types);
The pr_alloc_netio()
function allocates a
pr_netio_stream_t
object from the given pool, and returns
a pointer to that object. The callback pointers for this object will all be
initialized to the system default callbacks.
The pr_register_netio()
function sets the given netio
object as a stream to use from that point on, after verifying that the
given netio has valid pointers for all of its callbacks. If
NULL
is given as a argument, this function will automatically
instantiate a pr_netio_stream_t
object and register it. The
strm_types parameter is used to signal for which types of streams
this object should be used; strm_types may be one of the following flags:
PR_NETIO_STRM_CTRL
PR_NETIO_STRM_DATA
PR_NETIO_STRM_OTHR
OR
'd together to signal that the given
stream is to be used for different stream types. If no custom object has
been registered to handle a given stream type, the default stream type is
used.
The pr_unregister_netio()
function removes any custom objects
that have been registered for the given strm_types. The default
objects cannot be unregistered.
Custom NetIO Functions
The following are the function prototypes to which any custom NetIO functions
must adhere:
void (*abort)(pr_netio_stream_t *nstrm); int (*close)(pr_netio_stream_t *nstrm); pr_netio_stream_t *(*open)(pr_netio_stream_t *nstrm, int fd, int mode); int (*poll)(pr_netio_stream_t *nstrm); int (*postopen)(pr_netio_stream_t *nstrm); int (*read)(pr_netio_stream_t *nstrm, char *buf, size_t buflen); pr_netio_stream_t *(*reopen)(pr_netio_stream_t *nstrm, int fd, int mode); int (*shutdown)(pr_netio_stream_t *nstrm, int how); int (*write)(pr_netio_stream_t *nstrm, char *buf, size_t buflen);