/* ========================================================================== * libevnet/src/bufio-pipe.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_PIPE_H #define EVNET_BUFIO_PIPE_H extern const struct bufio_pipe_options { int quick_notify; } bufio_pipe_defaults; struct bufio_pipe; struct bufio_pipe_frame { struct bufio_pipe **pp; #if defined SLIST_ENTRY && !_WIN32 SLIST_ENTRY(bufio_pipe_frame) sle; #else struct { struct bufio_pipe_frame *sle_next; } sle; #endif }; /* struct bufio_pipe_frame */ struct bufio_pipe { struct bufio_pipe_options opts; struct { struct bufio_source *next; bufio_source_poll_cb fn; void *arg; } src; struct { struct bufio_sink *next; bufio_sink_poll_cb fn; void *arg; } snk; #if defined SLIST_HEAD SLIST_HEAD(, bufio_pipe_frame) stack; #else struct { struct bufio_pipe_frame *slh_first; } stack; #endif BUFIO_IMPLEMENTS(bufio_pipe, bufio_source); BUFIO_IMPLEMENTS(bufio_pipe, bufio_sink); }; /* struct bufio_pipe */ struct bufio_pipe *bufio_pipe_init(struct bufio_pipe *, const struct bufio_pipe_options *); void bufio_pipe_destroy(struct bufio_pipe *); void bufio_pipe_notify(struct bufio_pipe *); void bufio_pipe_set_source(struct bufio_pipe *, struct bufio_source *); void bufio_pipe_set_sink(struct bufio_pipe *, struct bufio_sink *); struct bufio_sink *bufio_pipe_init_sink(struct bufio_pipe *, const struct bufio_pipe_options *); struct bufio_source *bufio_pipe_init_source(struct bufio_pipe *, const struct bufio_pipe_options *); struct bufio_source *bufio_pipe_to_source(struct bufio_pipe *); struct bufio_sink *bufio_pipe_to_sink(struct bufio_pipe *); void bufio_pipe_notify(struct bufio_pipe *p); #endif /* EVNET_BUFIO_PIPE_H */