|
||||
File indexing completed on 2025-01-18 09:57:11
0001 /* 0002 * Copyright (c) 2007-2012 Niels Provos, Nick Mathewson 0003 * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu> 0004 * All rights reserved. 0005 * 0006 * Redistribution and use in source and binary forms, with or without 0007 * modification, are permitted provided that the following conditions 0008 * are met: 0009 * 1. Redistributions of source code must retain the above copyright 0010 * notice, this list of conditions and the following disclaimer. 0011 * 2. Redistributions in binary form must reproduce the above copyright 0012 * notice, this list of conditions and the following disclaimer in the 0013 * documentation and/or other materials provided with the distribution. 0014 * 3. The name of the author may not be used to endorse or promote products 0015 * derived from this software without specific prior written permission. 0016 * 0017 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0018 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0019 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0020 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0021 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0022 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0023 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0024 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0025 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0026 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0027 */ 0028 #ifndef EVENT2_BUFFEREVENT_COMPAT_H_INCLUDED_ 0029 #define EVENT2_BUFFEREVENT_COMPAT_H_INCLUDED_ 0030 0031 #include <event2/visibility.h> 0032 0033 #define evbuffercb bufferevent_data_cb 0034 #define everrorcb bufferevent_event_cb 0035 0036 /** 0037 Create a new bufferevent for an fd. 0038 0039 This function is deprecated. Use bufferevent_socket_new and 0040 bufferevent_set_callbacks instead. 0041 0042 Libevent provides an abstraction on top of the regular event callbacks. 0043 This abstraction is called a buffered event. A buffered event provides 0044 input and output buffers that get filled and drained automatically. The 0045 user of a buffered event no longer deals directly with the I/O, but 0046 instead is reading from input and writing to output buffers. 0047 0048 Once initialized, the bufferevent structure can be used repeatedly with 0049 bufferevent_enable() and bufferevent_disable(). 0050 0051 When read enabled the bufferevent will try to read from the file descriptor 0052 and call the read callback. The write callback is executed whenever the 0053 output buffer is drained below the write low watermark, which is 0 by 0054 default. 0055 0056 If multiple bases are in use, bufferevent_base_set() must be called before 0057 enabling the bufferevent for the first time. 0058 0059 @deprecated This function is deprecated because it uses the current 0060 event base, and as such can be error prone for multithreaded programs. 0061 Use bufferevent_socket_new() instead. 0062 0063 @param fd the file descriptor from which data is read and written to. 0064 This file descriptor is not allowed to be a pipe(2). 0065 @param readcb callback to invoke when there is data to be read, or NULL if 0066 no callback is desired 0067 @param writecb callback to invoke when the file descriptor is ready for 0068 writing, or NULL if no callback is desired 0069 @param errorcb callback to invoke when there is an error on the file 0070 descriptor 0071 @param cbarg an argument that will be supplied to each of the callbacks 0072 (readcb, writecb, and errorcb) 0073 @return a pointer to a newly allocated bufferevent struct, or NULL if an 0074 error occurred 0075 @see bufferevent_base_set(), bufferevent_free() 0076 */ 0077 EVENT2_EXPORT_SYMBOL 0078 struct bufferevent *bufferevent_new(evutil_socket_t fd, 0079 evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg); 0080 0081 0082 /** 0083 Set the read and write timeout for a buffered event. 0084 0085 @param bufev the bufferevent to be modified 0086 @param timeout_read the read timeout 0087 @param timeout_write the write timeout 0088 */ 0089 EVENT2_EXPORT_SYMBOL 0090 void bufferevent_settimeout(struct bufferevent *bufev, 0091 int timeout_read, int timeout_write); 0092 0093 #define EVBUFFER_READ BEV_EVENT_READING 0094 #define EVBUFFER_WRITE BEV_EVENT_WRITING 0095 #define EVBUFFER_EOF BEV_EVENT_EOF 0096 #define EVBUFFER_ERROR BEV_EVENT_ERROR 0097 #define EVBUFFER_TIMEOUT BEV_EVENT_TIMEOUT 0098 0099 /** macro for getting access to the input buffer of a bufferevent */ 0100 #define EVBUFFER_INPUT(x) bufferevent_get_input(x) 0101 /** macro for getting access to the output buffer of a bufferevent */ 0102 #define EVBUFFER_OUTPUT(x) bufferevent_get_output(x) 0103 0104 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |