1275970Scy/* 2275970Scy * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu> 3275970Scy * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 4275970Scy * 5275970Scy * Redistribution and use in source and binary forms, with or without 6275970Scy * modification, are permitted provided that the following conditions 7275970Scy * are met: 8275970Scy * 1. Redistributions of source code must retain the above copyright 9275970Scy * notice, this list of conditions and the following disclaimer. 10275970Scy * 2. Redistributions in binary form must reproduce the above copyright 11275970Scy * notice, this list of conditions and the following disclaimer in the 12275970Scy * documentation and/or other materials provided with the distribution. 13275970Scy * 3. The name of the author may not be used to endorse or promote products 14275970Scy * derived from this software without specific prior written permission. 15275970Scy * 16275970Scy * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17275970Scy * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18275970Scy * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19275970Scy * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20275970Scy * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21275970Scy * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22275970Scy * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23275970Scy * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24275970Scy * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25275970Scy * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26275970Scy */ 27275970Scy#ifndef EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ 28275970Scy#define EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ 29275970Scy 30275970Scy/** @file event2/bufferevent_struct.h 31275970Scy 32275970Scy Data structures for bufferevents. Using these structures may hurt forward 33275970Scy compatibility with later versions of Libevent: be careful! 34275970Scy 35275970Scy @deprecated Use of bufferevent_struct.h is completely deprecated; these 36275970Scy structures are only exposed for backward compatibility with programs 37275970Scy written before Libevent 2.0 that used them. 38275970Scy */ 39275970Scy 40275970Scy#ifdef __cplusplus 41275970Scyextern "C" { 42275970Scy#endif 43275970Scy 44275970Scy#include <event2/event-config.h> 45275970Scy#ifdef EVENT__HAVE_SYS_TYPES_H 46275970Scy#include <sys/types.h> 47275970Scy#endif 48275970Scy#ifdef EVENT__HAVE_SYS_TIME_H 49275970Scy#include <sys/time.h> 50275970Scy#endif 51275970Scy 52275970Scy/* For int types. */ 53275970Scy#include <event2/util.h> 54275970Scy/* For struct event */ 55275970Scy#include <event2/event_struct.h> 56275970Scy 57275970Scystruct event_watermark { 58275970Scy size_t low; 59275970Scy size_t high; 60275970Scy}; 61275970Scy 62275970Scy/** 63275970Scy Shared implementation of a bufferevent. 64275970Scy 65275970Scy This type is exposed only because it was exposed in previous versions, 66275970Scy and some people's code may rely on manipulating it. Otherwise, you 67275970Scy should really not rely on the layout, size, or contents of this structure: 68275970Scy it is fairly volatile, and WILL change in future versions of the code. 69275970Scy**/ 70275970Scystruct bufferevent { 71275970Scy /** Event base for which this bufferevent was created. */ 72275970Scy struct event_base *ev_base; 73275970Scy /** Pointer to a table of function pointers to set up how this 74275970Scy bufferevent behaves. */ 75275970Scy const struct bufferevent_ops *be_ops; 76275970Scy 77275970Scy /** A read event that triggers when a timeout has happened or a socket 78275970Scy is ready to read data. Only used by some subtypes of 79275970Scy bufferevent. */ 80275970Scy struct event ev_read; 81275970Scy /** A write event that triggers when a timeout has happened or a socket 82275970Scy is ready to write data. Only used by some subtypes of 83275970Scy bufferevent. */ 84275970Scy struct event ev_write; 85275970Scy 86275970Scy /** An input buffer. Only the bufferevent is allowed to add data to 87275970Scy this buffer, though the user is allowed to drain it. */ 88275970Scy struct evbuffer *input; 89275970Scy 90275970Scy /** An input buffer. Only the bufferevent is allowed to drain data 91275970Scy from this buffer, though the user is allowed to add it. */ 92275970Scy struct evbuffer *output; 93275970Scy 94275970Scy struct event_watermark wm_read; 95275970Scy struct event_watermark wm_write; 96275970Scy 97275970Scy bufferevent_data_cb readcb; 98275970Scy bufferevent_data_cb writecb; 99275970Scy /* This should be called 'eventcb', but renaming it would break 100275970Scy * backward compatibility */ 101275970Scy bufferevent_event_cb errorcb; 102275970Scy void *cbarg; 103275970Scy 104275970Scy struct timeval timeout_read; 105275970Scy struct timeval timeout_write; 106275970Scy 107275970Scy /** Events that are currently enabled: currently EV_READ and EV_WRITE 108275970Scy are supported. */ 109275970Scy short enabled; 110275970Scy}; 111275970Scy 112275970Scy#ifdef __cplusplus 113275970Scy} 114275970Scy#endif 115275970Scy 116275970Scy#endif /* EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ */ 117