1290001Sglebius/* 2290001Sglebius * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu> 3290001Sglebius * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 4290001Sglebius * 5290001Sglebius * Redistribution and use in source and binary forms, with or without 6290001Sglebius * modification, are permitted provided that the following conditions 7290001Sglebius * are met: 8290001Sglebius * 1. Redistributions of source code must retain the above copyright 9290001Sglebius * notice, this list of conditions and the following disclaimer. 10290001Sglebius * 2. Redistributions in binary form must reproduce the above copyright 11290001Sglebius * notice, this list of conditions and the following disclaimer in the 12290001Sglebius * documentation and/or other materials provided with the distribution. 13290001Sglebius * 3. The name of the author may not be used to endorse or promote products 14290001Sglebius * derived from this software without specific prior written permission. 15290001Sglebius * 16290001Sglebius * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17290001Sglebius * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18290001Sglebius * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19290001Sglebius * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20290001Sglebius * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21290001Sglebius * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22290001Sglebius * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23290001Sglebius * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24290001Sglebius * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25290001Sglebius * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26290001Sglebius */ 27290001Sglebius#ifndef EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ 28290001Sglebius#define EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ 29290001Sglebius 30290001Sglebius/** @file event2/bufferevent_struct.h 31290001Sglebius 32290001Sglebius Data structures for bufferevents. Using these structures may hurt forward 33290001Sglebius compatibility with later versions of Libevent: be careful! 34290001Sglebius 35290001Sglebius @deprecated Use of bufferevent_struct.h is completely deprecated; these 36290001Sglebius structures are only exposed for backward compatibility with programs 37290001Sglebius written before Libevent 2.0 that used them. 38290001Sglebius */ 39290001Sglebius 40290001Sglebius#ifdef __cplusplus 41290001Sglebiusextern "C" { 42290001Sglebius#endif 43290001Sglebius 44290001Sglebius#include <event2/event-config.h> 45290001Sglebius#ifdef EVENT__HAVE_SYS_TYPES_H 46290001Sglebius#include <sys/types.h> 47290001Sglebius#endif 48290001Sglebius#ifdef EVENT__HAVE_SYS_TIME_H 49290001Sglebius#include <sys/time.h> 50290001Sglebius#endif 51290001Sglebius 52290001Sglebius/* For int types. */ 53290001Sglebius#include <event2/util.h> 54290001Sglebius/* For struct event */ 55290001Sglebius#include <event2/event_struct.h> 56290001Sglebius 57290001Sglebiusstruct event_watermark { 58290001Sglebius size_t low; 59290001Sglebius size_t high; 60290001Sglebius}; 61290001Sglebius 62290001Sglebius/** 63290001Sglebius Shared implementation of a bufferevent. 64290001Sglebius 65290001Sglebius This type is exposed only because it was exposed in previous versions, 66290001Sglebius and some people's code may rely on manipulating it. Otherwise, you 67290001Sglebius should really not rely on the layout, size, or contents of this structure: 68290001Sglebius it is fairly volatile, and WILL change in future versions of the code. 69290001Sglebius**/ 70290001Sglebiusstruct bufferevent { 71290001Sglebius /** Event base for which this bufferevent was created. */ 72290001Sglebius struct event_base *ev_base; 73290001Sglebius /** Pointer to a table of function pointers to set up how this 74290001Sglebius bufferevent behaves. */ 75290001Sglebius const struct bufferevent_ops *be_ops; 76290001Sglebius 77290001Sglebius /** A read event that triggers when a timeout has happened or a socket 78290001Sglebius is ready to read data. Only used by some subtypes of 79290001Sglebius bufferevent. */ 80290001Sglebius struct event ev_read; 81290001Sglebius /** A write event that triggers when a timeout has happened or a socket 82290001Sglebius is ready to write data. Only used by some subtypes of 83290001Sglebius bufferevent. */ 84290001Sglebius struct event ev_write; 85290001Sglebius 86290001Sglebius /** An input buffer. Only the bufferevent is allowed to add data to 87290001Sglebius this buffer, though the user is allowed to drain it. */ 88290001Sglebius struct evbuffer *input; 89290001Sglebius 90290001Sglebius /** An input buffer. Only the bufferevent is allowed to drain data 91290001Sglebius from this buffer, though the user is allowed to add it. */ 92290001Sglebius struct evbuffer *output; 93290001Sglebius 94290001Sglebius struct event_watermark wm_read; 95290001Sglebius struct event_watermark wm_write; 96290001Sglebius 97290001Sglebius bufferevent_data_cb readcb; 98290001Sglebius bufferevent_data_cb writecb; 99290001Sglebius /* This should be called 'eventcb', but renaming it would break 100290001Sglebius * backward compatibility */ 101290001Sglebius bufferevent_event_cb errorcb; 102290001Sglebius void *cbarg; 103290001Sglebius 104290001Sglebius struct timeval timeout_read; 105290001Sglebius struct timeval timeout_write; 106290001Sglebius 107290001Sglebius /** Events that are currently enabled: currently EV_READ and EV_WRITE 108290001Sglebius are supported. */ 109290001Sglebius short enabled; 110290001Sglebius}; 111290001Sglebius 112290001Sglebius#ifdef __cplusplus 113290001Sglebius} 114290001Sglebius#endif 115290001Sglebius 116290001Sglebius#endif /* EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ */ 117