/* ==========================================================================
* libevnet/src/bufio-drain.h - Network server library for libevent.
* --------------------------------------------------------------------------
* Copyright (c) 2006 William Ahern
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
* ==========================================================================
*/
#ifndef EVNET_BUFIO_DRAIN_H
#define EVNET_BUFIO_DRAIN_H
extern const struct bufio_drain_options {
int flags;
} bufio_drain_defaults;
struct bufio_drain;
struct bufio_drain_frame {
struct bufio_drain **dp;
#if defined SLIST_ENTRY && !_WIN32
SLIST_ENTRY(bufio_drain_frame) sle;
#else
struct { struct bufio_drain_frame *sle_next; } sle;
#endif
}; /* struct bufio_drain_frame */
struct bufio_drain {
struct bufio_drain_options opts;
struct bufio_source *src;
int src_pending;
struct bufio_sink *snk;
int snk_pending;
struct {
void (*fn)(struct bufio_drain *, enum bufio_errno, void *);
void *arg;
} cb;
#if defined SLIST_HEAD
SLIST_HEAD(, bufio_drain_frame) stack;
#else
struct { struct bufio_drain_frame *slh_first; } stack;
#endif
}; /* struct bufio_drain */
struct bufio_drain *bufio_drain_init(struct bufio_drain *, const struct bufio_drain_options *, struct bufio_sink *, struct bufio_source *);
void bufio_drain_destroy(struct bufio_drain *);
void bufio_drain_start(struct bufio_drain *, void (*)(struct bufio_drain *, enum bufio_errno, void *));
void bufio_drain_stop(struct bufio_drain *);
#endif /* EVNET_BUFIO_DRAIN_H */
syntax highlighted by Code2HTML, v. 0.9.1