libevent  2.2.1
Event notification library
buffer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. The name of the author may not be used to endorse or promote products
13  * derived from this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 #ifndef EVENT2_BUFFER_H_INCLUDED_
27 #define EVENT2_BUFFER_H_INCLUDED_
28 
75 #include <event2/visibility.h>
76 
77 #ifdef __cplusplus
78 extern "C" {
79 #endif
80 
81 #include <event2/event-config.h>
82 #include <stdarg.h>
83 #ifdef EVENT__HAVE_SYS_TYPES_H
84 #include <sys/types.h>
85 #endif
86 #ifdef EVENT__HAVE_SYS_UIO_H
87 #include <sys/uio.h>
88 #endif
89 #include <event2/util.h>
90 
97 struct evbuffer
98 #ifdef EVENT_IN_DOXYGEN_
99 {}
100 #endif
101 ;
102 
116 struct evbuffer_ptr {
117  ev_ssize_t pos;
118 
119  /* Do not alter or rely on the values of fields: they are for internal
120  * use */
121  struct {
122  void *chain;
123  size_t pos_in_chain;
124  } internal_;
125 };
126 
132 #ifdef EVENT__HAVE_SYS_UIO_H
133 #define evbuffer_iovec iovec
134 /* Internal use -- defined only if we are using the native struct iovec */
135 #define EVBUFFER_IOVEC_IS_NATIVE_
136 #else
139  void *iov_base;
141  size_t iov_len;
142 };
143 #endif
144 
151 EVENT2_EXPORT_SYMBOL
152 struct evbuffer *evbuffer_new(void);
158 EVENT2_EXPORT_SYMBOL
159 void evbuffer_free(struct evbuffer *buf);
160 
161 
174 EVENT2_EXPORT_SYMBOL
175 int evbuffer_set_max_read(struct evbuffer *buf, size_t max);
182 EVENT2_EXPORT_SYMBOL
183 size_t evbuffer_get_max_read(struct evbuffer *buf);
184 
197 EVENT2_EXPORT_SYMBOL
198 int evbuffer_enable_locking(struct evbuffer *buf, void *lock);
199 
204 EVENT2_EXPORT_SYMBOL
205 void evbuffer_lock(struct evbuffer *buf);
206 
211 EVENT2_EXPORT_SYMBOL
212 void evbuffer_unlock(struct evbuffer *buf);
213 
214 
230 #define EVBUFFER_FLAG_DRAINS_TO_FD 1
231 
238 EVENT2_EXPORT_SYMBOL
239 int evbuffer_set_flags(struct evbuffer *buf, ev_uint64_t flags);
246 EVENT2_EXPORT_SYMBOL
247 int evbuffer_clear_flags(struct evbuffer *buf, ev_uint64_t flags);
248 
255 EVENT2_EXPORT_SYMBOL
256 size_t evbuffer_get_length(const struct evbuffer *buf);
257 
270 EVENT2_EXPORT_SYMBOL
271 size_t evbuffer_get_contiguous_space(const struct evbuffer *buf);
272 
283 EVENT2_EXPORT_SYMBOL
284 int evbuffer_expand(struct evbuffer *buf, size_t datlen);
285 
319 EVENT2_EXPORT_SYMBOL
320 int
321 evbuffer_reserve_space(struct evbuffer *buf, ev_ssize_t size,
322  struct evbuffer_iovec *vec, int n_vec);
323 
345 EVENT2_EXPORT_SYMBOL
346 int evbuffer_commit_space(struct evbuffer *buf,
347  struct evbuffer_iovec *vec, int n_vecs);
348 
357 EVENT2_EXPORT_SYMBOL
358 int evbuffer_add(struct evbuffer *buf, const void *data, size_t datlen);
359 
360 
372 EVENT2_EXPORT_SYMBOL
373 int evbuffer_remove(struct evbuffer *buf, void *data, size_t datlen);
374 
386 EVENT2_EXPORT_SYMBOL
387 ev_ssize_t evbuffer_copyout(struct evbuffer *buf, void *data_out, size_t datlen);
388 
401 EVENT2_EXPORT_SYMBOL
402 ev_ssize_t evbuffer_copyout_from(struct evbuffer *buf, const struct evbuffer_ptr *pos, void *data_out, size_t datlen);
403 
417 EVENT2_EXPORT_SYMBOL
418 int evbuffer_remove_buffer(struct evbuffer *src, struct evbuffer *dst,
419  size_t datlen);
420 
443 };
444 
459 EVENT2_EXPORT_SYMBOL
460 char *evbuffer_readln(struct evbuffer *buffer, size_t *n_read_out,
461  enum evbuffer_eol_style eol_style);
462 
475 EVENT2_EXPORT_SYMBOL
476 int evbuffer_add_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf);
477 
491 EVENT2_EXPORT_SYMBOL
492 int evbuffer_add_buffer_reference(struct evbuffer *outbuf,
493  struct evbuffer *inbuf);
494 
505 typedef void (*evbuffer_ref_cleanup_cb)(const void *data,
506  size_t datalen, void *extra);
507 
523 EVENT2_EXPORT_SYMBOL
524 int evbuffer_add_reference(struct evbuffer *outbuf,
525  const void *data, size_t datlen,
526  evbuffer_ref_cleanup_cb cleanupfn, void *cleanupfn_arg);
527 
528 
545 EVENT2_EXPORT_SYMBOL
546 int evbuffer_add_reference_with_offset(struct evbuffer *outbuf, const void *data,
547  size_t offset, size_t datlen, evbuffer_ref_cleanup_cb cleanupfn,
548  void *cleanupfn_arg);
549 
574 EVENT2_EXPORT_SYMBOL
575 int evbuffer_add_file(struct evbuffer *outbuf, int fd, ev_off_t offset,
576  ev_off_t length);
577 
585 struct evbuffer_file_segment;
586 
592 #define EVBUF_FS_CLOSE_ON_FREE 0x01
593 
597 #define EVBUF_FS_DISABLE_MMAP 0x02
598 
607 #define EVBUF_FS_DISABLE_SENDFILE 0x04
608 
614 #define EVBUF_FS_DISABLE_LOCKING 0x08
615 
621  struct evbuffer_file_segment const* seg, int flags, void* arg);
622 
645 EVENT2_EXPORT_SYMBOL
646 struct evbuffer_file_segment *evbuffer_file_segment_new(
647  int fd, ev_off_t offset, ev_off_t length, unsigned flags);
648 
656 EVENT2_EXPORT_SYMBOL
657 void evbuffer_file_segment_free(struct evbuffer_file_segment *seg);
658 
666 EVENT2_EXPORT_SYMBOL
667 void evbuffer_file_segment_add_cleanup_cb(struct evbuffer_file_segment *seg,
668  evbuffer_file_segment_cleanup_cb cb, void* arg);
669 
692 EVENT2_EXPORT_SYMBOL
693 int evbuffer_add_file_segment(struct evbuffer *buf,
694  struct evbuffer_file_segment *seg, ev_off_t offset, ev_off_t length);
695 
708 EVENT2_EXPORT_SYMBOL
709 int evbuffer_add_printf(struct evbuffer *buf, const char *fmt, ...)
710 #ifdef __GNUC__
711  __attribute__((format(printf, 2, 3)))
712 #endif
713 ;
714 
723 EVENT2_EXPORT_SYMBOL
724 int evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap)
725 #ifdef __GNUC__
726  __attribute__((format(printf, 2, 0)))
727 #endif
728 ;
729 
730 
738 EVENT2_EXPORT_SYMBOL
739 int evbuffer_drain(struct evbuffer *buf, size_t len);
740 
741 
752 EVENT2_EXPORT_SYMBOL
753 int evbuffer_write(struct evbuffer *buffer, evutil_socket_t fd);
754 
767 EVENT2_EXPORT_SYMBOL
768 int evbuffer_write_atmost(struct evbuffer *buffer, evutil_socket_t fd,
769  ev_ssize_t howmuch);
770 
781 EVENT2_EXPORT_SYMBOL
782 int evbuffer_read(struct evbuffer *buffer, evutil_socket_t fd, int howmuch);
783 
795 EVENT2_EXPORT_SYMBOL
796 struct evbuffer_ptr evbuffer_search(struct evbuffer *buffer, const char *what, size_t len, const struct evbuffer_ptr *start);
797 
812 EVENT2_EXPORT_SYMBOL
813 struct evbuffer_ptr evbuffer_search_range(struct evbuffer *buffer, const char *what, size_t len, const struct evbuffer_ptr *start, const struct evbuffer_ptr *end);
814 
825 };
826 
848 EVENT2_EXPORT_SYMBOL
849 int
850 evbuffer_ptr_set(struct evbuffer *buffer, struct evbuffer_ptr *ptr,
851  size_t position, enum evbuffer_ptr_how how);
852 
867 EVENT2_EXPORT_SYMBOL
868 struct evbuffer_ptr evbuffer_search_eol(struct evbuffer *buffer,
869  struct evbuffer_ptr *start, size_t *eol_len_out,
870  enum evbuffer_eol_style eol_style);
871 
900 EVENT2_EXPORT_SYMBOL
901 int evbuffer_peek(struct evbuffer *buffer, ev_ssize_t len,
902  struct evbuffer_ptr *start_at,
903  struct evbuffer_iovec *vec_out, int n_vec);
904 
905 
913  size_t orig_size;
915  size_t n_added;
917  size_t n_deleted;
918 };
919 
939 typedef void (*evbuffer_cb_func)(struct evbuffer *buffer, const struct evbuffer_cb_info *info, void *arg);
940 
941 struct evbuffer_cb_entry;
953 EVENT2_EXPORT_SYMBOL
954 struct evbuffer_cb_entry *evbuffer_add_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg);
955 
964 EVENT2_EXPORT_SYMBOL
965 int evbuffer_remove_cb_entry(struct evbuffer *buffer,
966  struct evbuffer_cb_entry *ent);
967 
974 EVENT2_EXPORT_SYMBOL
975 int evbuffer_remove_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg);
976 
982 #define EVBUFFER_CB_ENABLED 1
983 
991 EVENT2_EXPORT_SYMBOL
992 int evbuffer_cb_set_flags(struct evbuffer *buffer,
993  struct evbuffer_cb_entry *cb, ev_uint32_t flags);
994 
1002 EVENT2_EXPORT_SYMBOL
1003 int evbuffer_cb_clear_flags(struct evbuffer *buffer,
1004  struct evbuffer_cb_entry *cb, ev_uint32_t flags);
1005 
1006 #if 0
1007 
1016 EVENT2_EXPORT_SYMBOL
1017 void evbuffer_cb_suspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb);
1026 EVENT2_EXPORT_SYMBOL
1027 void evbuffer_cb_unsuspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb);
1028 #endif
1029 
1040 EVENT2_EXPORT_SYMBOL
1041 unsigned char *evbuffer_pullup(struct evbuffer *buf, ev_ssize_t size);
1042 
1052 EVENT2_EXPORT_SYMBOL
1053 int evbuffer_prepend(struct evbuffer *buf, const void *data, size_t size);
1054 
1063 EVENT2_EXPORT_SYMBOL
1064 int evbuffer_prepend_buffer(struct evbuffer *dst, struct evbuffer* src);
1065 
1080 EVENT2_EXPORT_SYMBOL
1081 int evbuffer_freeze(struct evbuffer *buf, int at_front);
1090 EVENT2_EXPORT_SYMBOL
1091 int evbuffer_unfreeze(struct evbuffer *buf, int at_front);
1092 
1093 struct event_base;
1101 EVENT2_EXPORT_SYMBOL
1102 int evbuffer_defer_callbacks(struct evbuffer *buffer, struct event_base *base);
1103 
1117 EVENT2_EXPORT_SYMBOL
1118 size_t evbuffer_add_iovec(struct evbuffer * buffer, struct evbuffer_iovec * vec, int n_vec);
1119 
1120 #ifdef __cplusplus
1121 }
1122 #endif
1123 
1124 #endif /* EVENT2_BUFFER_H_INCLUDED_ */
evbuffer_enable_locking
EVENT2_EXPORT_SYMBOL int evbuffer_enable_locking(struct evbuffer *buf, void *lock)
Enable locking on an evbuffer so that it can safely be used by multiple threads at the same time.
evbuffer_get_length
EVENT2_EXPORT_SYMBOL size_t evbuffer_get_length(const struct evbuffer *buf)
Returns the total number of bytes stored in the evbuffer.
EVBUFFER_PTR_ADD
@ EVBUFFER_PTR_ADD
Advances the pointer by adding to the current position.
Definition: buffer.h:824
evbuffer_remove
EVENT2_EXPORT_SYMBOL int evbuffer_remove(struct evbuffer *buf, void *data, size_t datlen)
Read data from an evbuffer and drain the bytes read.
evbuffer_add_file
EVENT2_EXPORT_SYMBOL int evbuffer_add_file(struct evbuffer *outbuf, int fd, ev_off_t offset, ev_off_t length)
Copy data from a file into the evbuffer for writing to a socket.
evbuffer_add_reference_with_offset
EVENT2_EXPORT_SYMBOL int evbuffer_add_reference_with_offset(struct evbuffer *outbuf, const void *data, size_t offset, size_t datlen, evbuffer_ref_cleanup_cb cleanupfn, void *cleanupfn_arg)
Reference memory into an evbuffer without copying.
evbuffer_get_contiguous_space
EVENT2_EXPORT_SYMBOL size_t evbuffer_get_contiguous_space(const struct evbuffer *buf)
Returns the number of contiguous available bytes in the first buffer chain.
evbuffer_cb_info
Structure passed to an evbuffer_cb_func evbuffer callback.
Definition: buffer.h:910
evbuffer_add
EVENT2_EXPORT_SYMBOL int evbuffer_add(struct evbuffer *buf, const void *data, size_t datlen)
Append data to the end of an evbuffer.
EVBUFFER_EOL_CRLF
@ EVBUFFER_EOL_CRLF
An EOL is an LF, optionally preceded by a CR.
Definition: buffer.h:436
evbuffer_iovec::iov_base
void * iov_base
The start of the extent of memory.
Definition: buffer.h:139
evbuffer_add_iovec
EVENT2_EXPORT_SYMBOL size_t evbuffer_add_iovec(struct evbuffer *buffer, struct evbuffer_iovec *vec, int n_vec)
Append data from 1 or more iovec's to an evbuffer.
evbuffer_unfreeze
EVENT2_EXPORT_SYMBOL int evbuffer_unfreeze(struct evbuffer *buf, int at_front)
Re-enable calls that modify an evbuffer.
evbuffer_set_flags
EVENT2_EXPORT_SYMBOL int evbuffer_set_flags(struct evbuffer *buf, ev_uint64_t flags)
Change the flags that are set for an evbuffer by adding more.
evbuffer_peek
EVENT2_EXPORT_SYMBOL int evbuffer_peek(struct evbuffer *buffer, ev_ssize_t len, struct evbuffer_ptr *start_at, struct evbuffer_iovec *vec_out, int n_vec)
Function to peek at data inside an evbuffer without removing it or copying it out.
evbuffer_set_max_read
EVENT2_EXPORT_SYMBOL int evbuffer_set_max_read(struct evbuffer *buf, size_t max)
Set maximum read buffer size.
evbuffer_eol_style
evbuffer_eol_style
Used to tell evbuffer_readln what kind of line-ending to look for.
Definition: buffer.h:423
EVBUFFER_EOL_NUL
@ EVBUFFER_EOL_NUL
An EOL is a NUL character (that is, a single byte with value 0)
Definition: buffer.h:442
event_base
Structure to hold information and state for a Libevent dispatch loop.
Definition: event.h:219
evbuffer_lock
EVENT2_EXPORT_SYMBOL void evbuffer_lock(struct evbuffer *buf)
Acquire the lock on an evbuffer.
evbuffer_add_vprintf
EVENT2_EXPORT_SYMBOL int evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap)
Append a va_list formatted string to the end of an evbuffer.
evbuffer_pullup
EVENT2_EXPORT_SYMBOL unsigned char * evbuffer_pullup(struct evbuffer *buf, ev_ssize_t size)
Makes the data at the beginning of an evbuffer contiguous.
EVBUFFER_EOL_CRLF_STRICT
@ EVBUFFER_EOL_CRLF_STRICT
An EOL is a CR followed by an LF.
Definition: buffer.h:438
evbuffer_search
EVENT2_EXPORT_SYMBOL struct evbuffer_ptr evbuffer_search(struct evbuffer *buffer, const char *what, size_t len, const struct evbuffer_ptr *start)
Search for a string within an evbuffer.
evbuffer_defer_callbacks
EVENT2_EXPORT_SYMBOL int evbuffer_defer_callbacks(struct evbuffer *buffer, struct event_base *base)
Force all the callbacks on an evbuffer to be run, not immediately after the evbuffer is altered,...
evbuffer_prepend
EVENT2_EXPORT_SYMBOL int evbuffer_prepend(struct evbuffer *buf, const void *data, size_t size)
Prepends data to the beginning of the evbuffer.
evbuffer_read
EVENT2_EXPORT_SYMBOL int evbuffer_read(struct evbuffer *buffer, evutil_socket_t fd, int howmuch)
Read from a file descriptor and store the result in an evbuffer.
evbuffer_write_atmost
EVENT2_EXPORT_SYMBOL int evbuffer_write_atmost(struct evbuffer *buffer, evutil_socket_t fd, ev_ssize_t howmuch)
Write some of the contents of an evbuffer to a file descriptor.
evbuffer_ref_cleanup_cb
void(* evbuffer_ref_cleanup_cb)(const void *data, size_t datalen, void *extra)
A cleanup function for a piece of memory added to an evbuffer by reference.
Definition: buffer.h:505
evbuffer_copyout_from
EVENT2_EXPORT_SYMBOL ev_ssize_t evbuffer_copyout_from(struct evbuffer *buf, const struct evbuffer_ptr *pos, void *data_out, size_t datlen)
Read data from the middle of an evbuffer, and leave the buffer unchanged.
evbuffer_iovec
Describes a single extent of memory inside an evbuffer.
Definition: buffer.h:137
evbuffer_drain
EVENT2_EXPORT_SYMBOL int evbuffer_drain(struct evbuffer *buf, size_t len)
Remove a specified number of bytes data from the beginning of an evbuffer.
evbuffer_ptr
Pointer to a position within an evbuffer.
Definition: buffer.h:116
evbuffer_prepend_buffer
EVENT2_EXPORT_SYMBOL int evbuffer_prepend_buffer(struct evbuffer *dst, struct evbuffer *src)
Prepends all data from the src evbuffer to the beginning of the dst evbuffer.
evbuffer_remove_cb_entry
EVENT2_EXPORT_SYMBOL int evbuffer_remove_cb_entry(struct evbuffer *buffer, struct evbuffer_cb_entry *ent)
Remove a callback from an evbuffer, given a handle returned from evbuffer_add_cb.
evbuffer_ptr_set
EVENT2_EXPORT_SYMBOL int evbuffer_ptr_set(struct evbuffer *buffer, struct evbuffer_ptr *ptr, size_t position, enum evbuffer_ptr_how how)
Sets the search pointer in the buffer to position.
evbuffer
An evbuffer is an opaque data type for efficiently buffering data to be sent or received on the netwo...
Definition: buffer.h:97
evbuffer_cb_func
void(* evbuffer_cb_func)(struct evbuffer *buffer, const struct evbuffer_cb_info *info, void *arg)
Type definition for a callback that is invoked whenever data is added or removed from an evbuffer.
Definition: buffer.h:939
evbuffer_freeze
EVENT2_EXPORT_SYMBOL int evbuffer_freeze(struct evbuffer *buf, int at_front)
Prevent calls that modify an evbuffer from succeeding.
evbuffer_search_eol
EVENT2_EXPORT_SYMBOL struct evbuffer_ptr evbuffer_search_eol(struct evbuffer *buffer, struct evbuffer_ptr *start, size_t *eol_len_out, enum evbuffer_eol_style eol_style)
Search for an end-of-line string within an evbuffer.
evbuffer_add_cb
EVENT2_EXPORT_SYMBOL struct evbuffer_cb_entry * evbuffer_add_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg)
Add a new callback to an evbuffer.
evbuffer_file_segment_new
EVENT2_EXPORT_SYMBOL struct evbuffer_file_segment * evbuffer_file_segment_new(int fd, ev_off_t offset, ev_off_t length, unsigned flags)
Create and return a new evbuffer_file_segment for reading data from a file and sending it out via an ...
evbuffer_readln
EVENT2_EXPORT_SYMBOL char * evbuffer_readln(struct evbuffer *buffer, size_t *n_read_out, enum evbuffer_eol_style eol_style)
Read a single line from an evbuffer.
evbuffer_unlock
EVENT2_EXPORT_SYMBOL void evbuffer_unlock(struct evbuffer *buf)
Release the lock on an evbuffer.
evbuffer_cb_set_flags
EVENT2_EXPORT_SYMBOL int evbuffer_cb_set_flags(struct evbuffer *buffer, struct evbuffer_cb_entry *cb, ev_uint32_t flags)
Change the flags that are set for a callback on a buffer by adding more.
evbuffer_cb_info::n_deleted
size_t n_deleted
The number of bytes removed since callbacks were last invoked.
Definition: buffer.h:917
evbuffer_clear_flags
EVENT2_EXPORT_SYMBOL int evbuffer_clear_flags(struct evbuffer *buf, ev_uint64_t flags)
Change the flags that are set for an evbuffer by removing some.
evbuffer_ptr_how
evbuffer_ptr_how
Defines how to adjust an evbuffer_ptr by evbuffer_ptr_set()
Definition: buffer.h:819
evbuffer_cb_info::n_added
size_t n_added
The number of bytes added since callbacks were last invoked.
Definition: buffer.h:915
evbuffer_add_reference
EVENT2_EXPORT_SYMBOL int evbuffer_add_reference(struct evbuffer *outbuf, const void *data, size_t datlen, evbuffer_ref_cleanup_cb cleanupfn, void *cleanupfn_arg)
Reference memory into an evbuffer without copying.
evbuffer_add_buffer
EVENT2_EXPORT_SYMBOL int evbuffer_add_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf)
Move all data from one evbuffer into another evbuffer.
evbuffer_add_file_segment
EVENT2_EXPORT_SYMBOL int evbuffer_add_file_segment(struct evbuffer *buf, struct evbuffer_file_segment *seg, ev_off_t offset, ev_off_t length)
Insert some or all of an evbuffer_file_segment at the end of an evbuffer.
evbuffer_add_printf
EVENT2_EXPORT_SYMBOL int evbuffer_add_printf(struct evbuffer *buf, const char *fmt,...)
Append a formatted string to the end of an evbuffer.
EVBUFFER_EOL_LF
@ EVBUFFER_EOL_LF
An EOL is a LF.
Definition: buffer.h:440
evbuffer_commit_space
EVENT2_EXPORT_SYMBOL int evbuffer_commit_space(struct evbuffer *buf, struct evbuffer_iovec *vec, int n_vecs)
Commits previously reserved space.
evbuffer_write
EVENT2_EXPORT_SYMBOL int evbuffer_write(struct evbuffer *buffer, evutil_socket_t fd)
Write the contents of an evbuffer to a file descriptor.
evbuffer_remove_buffer
EVENT2_EXPORT_SYMBOL int evbuffer_remove_buffer(struct evbuffer *src, struct evbuffer *dst, size_t datlen)
Read data from an evbuffer into another evbuffer, draining the bytes from the source buffer.
evbuffer_search_range
EVENT2_EXPORT_SYMBOL struct evbuffer_ptr evbuffer_search_range(struct evbuffer *buffer, const char *what, size_t len, const struct evbuffer_ptr *start, const struct evbuffer_ptr *end)
Search for a string within part of an evbuffer.
evbuffer_free
EVENT2_EXPORT_SYMBOL void evbuffer_free(struct evbuffer *buf)
Deallocate storage for an evbuffer.
evbuffer_file_segment_cleanup_cb
void(* evbuffer_file_segment_cleanup_cb)(struct evbuffer_file_segment const *seg, int flags, void *arg)
A cleanup function for a evbuffer_file_segment added to an evbuffer for reference.
Definition: buffer.h:620
EVBUFFER_EOL_ANY
@ EVBUFFER_EOL_ANY
Any sequence of CR and LF characters is acceptable as an EOL.
Definition: buffer.h:433
evbuffer_cb_info::orig_size
size_t orig_size
The number of bytes in this evbuffer when callbacks were last invoked.
Definition: buffer.h:913
evbuffer_reserve_space
EVENT2_EXPORT_SYMBOL int evbuffer_reserve_space(struct evbuffer *buf, ev_ssize_t size, struct evbuffer_iovec *vec, int n_vec)
Reserves space in the last chain or chains of an evbuffer.
EVBUFFER_PTR_SET
@ EVBUFFER_PTR_SET
Sets the pointer to the position; can be called on with an uninitialized evbuffer_ptr.
Definition: buffer.h:822
evbuffer_iovec::iov_len
size_t iov_len
The length of the extent of memory.
Definition: buffer.h:141
evbuffer_add_buffer_reference
EVENT2_EXPORT_SYMBOL int evbuffer_add_buffer_reference(struct evbuffer *outbuf, struct evbuffer *inbuf)
Copy data from one evbuffer into another evbuffer.
evbuffer_remove_cb
EVENT2_EXPORT_SYMBOL int evbuffer_remove_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg)
Remove a callback from an evbuffer, given the function and argument used to add it.
evbuffer_new
EVENT2_EXPORT_SYMBOL struct evbuffer * evbuffer_new(void)
Allocate storage for a new evbuffer.
evbuffer_get_max_read
EVENT2_EXPORT_SYMBOL size_t evbuffer_get_max_read(struct evbuffer *buf)
Get maximum read buffer size.
evbuffer_file_segment_free
EVENT2_EXPORT_SYMBOL void evbuffer_file_segment_free(struct evbuffer_file_segment *seg)
Free an evbuffer_file_segment.
util.h
Common convenience functions for cross-platform portability and related socket manipulations.
evbuffer_copyout
EVENT2_EXPORT_SYMBOL ev_ssize_t evbuffer_copyout(struct evbuffer *buf, void *data_out, size_t datlen)
Read data from an evbuffer, and leave the buffer unchanged.
evbuffer_file_segment_add_cleanup_cb
EVENT2_EXPORT_SYMBOL void evbuffer_file_segment_add_cleanup_cb(struct evbuffer_file_segment *seg, evbuffer_file_segment_cleanup_cb cb, void *arg)
Add cleanup callback and argument for the callback to an evbuffer_file_segment.
evbuffer_expand
EVENT2_EXPORT_SYMBOL int evbuffer_expand(struct evbuffer *buf, size_t datlen)
Expands the available space in an evbuffer.
evbuffer_cb_clear_flags
EVENT2_EXPORT_SYMBOL int evbuffer_cb_clear_flags(struct evbuffer *buffer, struct evbuffer_cb_entry *cb, ev_uint32_t flags)
Change the flags that are set for a callback on a buffer by removing some.
evutil_socket_t
#define evutil_socket_t
A type wide enough to hold the output of "socket()" or "accept()".
Definition: util.h:325