Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/include/event2
File: buffer.h
/*
[0] Fix | Delete
* Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
[1] Fix | Delete
*
[2] Fix | Delete
* Redistribution and use in source and binary forms, with or without
[3] Fix | Delete
* modification, are permitted provided that the following conditions
[4] Fix | Delete
* are met:
[5] Fix | Delete
* 1. Redistributions of source code must retain the above copyright
[6] Fix | Delete
* notice, this list of conditions and the following disclaimer.
[7] Fix | Delete
* 2. Redistributions in binary form must reproduce the above copyright
[8] Fix | Delete
* notice, this list of conditions and the following disclaimer in the
[9] Fix | Delete
* documentation and/or other materials provided with the distribution.
[10] Fix | Delete
* 3. The name of the author may not be used to endorse or promote products
[11] Fix | Delete
* derived from this software without specific prior written permission.
[12] Fix | Delete
*
[13] Fix | Delete
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
[14] Fix | Delete
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
[15] Fix | Delete
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
[16] Fix | Delete
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
[17] Fix | Delete
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
[18] Fix | Delete
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
[19] Fix | Delete
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
[20] Fix | Delete
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
[21] Fix | Delete
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
[22] Fix | Delete
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[23] Fix | Delete
*/
[24] Fix | Delete
#ifndef EVENT2_BUFFER_H_INCLUDED_
[25] Fix | Delete
#define EVENT2_BUFFER_H_INCLUDED_
[26] Fix | Delete
[27] Fix | Delete
/** @file event2/buffer.h
[28] Fix | Delete
[29] Fix | Delete
Functions for buffering data for network sending or receiving.
[30] Fix | Delete
[31] Fix | Delete
An evbuffer can be used for preparing data before sending it to
[32] Fix | Delete
the network or conversely for reading data from the network.
[33] Fix | Delete
Evbuffers try to avoid memory copies as much as possible. As a
[34] Fix | Delete
result, evbuffers can be used to pass data around without actually
[35] Fix | Delete
incurring the overhead of copying the data.
[36] Fix | Delete
[37] Fix | Delete
A new evbuffer can be allocated with evbuffer_new(), and can be
[38] Fix | Delete
freed with evbuffer_free(). Most users will be using evbuffers via
[39] Fix | Delete
the bufferevent interface. To access a bufferevent's evbuffers, use
[40] Fix | Delete
bufferevent_get_input() and bufferevent_get_output().
[41] Fix | Delete
[42] Fix | Delete
There are several guidelines for using evbuffers.
[43] Fix | Delete
[44] Fix | Delete
- if you already know how much data you are going to add as a result
[45] Fix | Delete
of calling evbuffer_add() multiple times, it makes sense to use
[46] Fix | Delete
evbuffer_expand() first to make sure that enough memory is allocated
[47] Fix | Delete
before hand.
[48] Fix | Delete
[49] Fix | Delete
- evbuffer_add_buffer() adds the contents of one buffer to the other
[50] Fix | Delete
without incurring any unnecessary memory copies.
[51] Fix | Delete
[52] Fix | Delete
- evbuffer_add() and evbuffer_add_buffer() do not mix very well:
[53] Fix | Delete
if you use them, you will wind up with fragmented memory in your
[54] Fix | Delete
buffer.
[55] Fix | Delete
[56] Fix | Delete
- For high-performance code, you may want to avoid copying data into and out
[57] Fix | Delete
of buffers. You can skip the copy step by using
[58] Fix | Delete
evbuffer_reserve_space()/evbuffer_commit_space() when writing into a
[59] Fix | Delete
buffer, and evbuffer_peek() when reading.
[60] Fix | Delete
[61] Fix | Delete
In Libevent 2.0 and later, evbuffers are represented using a linked
[62] Fix | Delete
list of memory chunks, with pointers to the first and last chunk in
[63] Fix | Delete
the chain.
[64] Fix | Delete
[65] Fix | Delete
As the contents of an evbuffer can be stored in multiple different
[66] Fix | Delete
memory blocks, it cannot be accessed directly. Instead, evbuffer_pullup()
[67] Fix | Delete
can be used to force a specified number of bytes to be contiguous. This
[68] Fix | Delete
will cause memory reallocation and memory copies if the data is split
[69] Fix | Delete
across multiple blocks. It is more efficient, however, to use
[70] Fix | Delete
evbuffer_peek() if you don't require that the memory to be contiguous.
[71] Fix | Delete
*/
[72] Fix | Delete
[73] Fix | Delete
#include <event2/visibility.h>
[74] Fix | Delete
[75] Fix | Delete
#ifdef __cplusplus
[76] Fix | Delete
extern "C" {
[77] Fix | Delete
#endif
[78] Fix | Delete
[79] Fix | Delete
#include <event2/event-config.h>
[80] Fix | Delete
#include <stdarg.h>
[81] Fix | Delete
#ifdef EVENT__HAVE_SYS_TYPES_H
[82] Fix | Delete
#include <sys/types.h>
[83] Fix | Delete
#endif
[84] Fix | Delete
#ifdef EVENT__HAVE_SYS_UIO_H
[85] Fix | Delete
#include <sys/uio.h>
[86] Fix | Delete
#endif
[87] Fix | Delete
#include <event2/util.h>
[88] Fix | Delete
[89] Fix | Delete
/**
[90] Fix | Delete
An evbuffer is an opaque data type for efficiently buffering data to be
[91] Fix | Delete
sent or received on the network.
[92] Fix | Delete
[93] Fix | Delete
@see event2/event.h for more information
[94] Fix | Delete
*/
[95] Fix | Delete
struct evbuffer
[96] Fix | Delete
#ifdef EVENT_IN_DOXYGEN_
[97] Fix | Delete
{}
[98] Fix | Delete
#endif
[99] Fix | Delete
;
[100] Fix | Delete
[101] Fix | Delete
/**
[102] Fix | Delete
Pointer to a position within an evbuffer.
[103] Fix | Delete
[104] Fix | Delete
Used when repeatedly searching through a buffer. Calling any function
[105] Fix | Delete
that modifies or re-packs the buffer contents may invalidate all
[106] Fix | Delete
evbuffer_ptrs for that buffer. Do not modify or contruct these values
[107] Fix | Delete
except with evbuffer_ptr_set.
[108] Fix | Delete
[109] Fix | Delete
An evbuffer_ptr can represent any position from the start of a buffer up
[110] Fix | Delete
to a position immediately after the end of a buffer.
[111] Fix | Delete
[112] Fix | Delete
@see evbuffer_ptr_set()
[113] Fix | Delete
*/
[114] Fix | Delete
struct evbuffer_ptr {
[115] Fix | Delete
ev_ssize_t pos;
[116] Fix | Delete
[117] Fix | Delete
/* Do not alter or rely on the values of fields: they are for internal
[118] Fix | Delete
* use */
[119] Fix | Delete
struct {
[120] Fix | Delete
void *chain;
[121] Fix | Delete
size_t pos_in_chain;
[122] Fix | Delete
} internal_;
[123] Fix | Delete
};
[124] Fix | Delete
[125] Fix | Delete
/** Describes a single extent of memory inside an evbuffer. Used for
[126] Fix | Delete
direct-access functions.
[127] Fix | Delete
[128] Fix | Delete
@see evbuffer_reserve_space, evbuffer_commit_space, evbuffer_peek
[129] Fix | Delete
*/
[130] Fix | Delete
#ifdef EVENT__HAVE_SYS_UIO_H
[131] Fix | Delete
#define evbuffer_iovec iovec
[132] Fix | Delete
/* Internal use -- defined only if we are using the native struct iovec */
[133] Fix | Delete
#define EVBUFFER_IOVEC_IS_NATIVE_
[134] Fix | Delete
#else
[135] Fix | Delete
struct evbuffer_iovec {
[136] Fix | Delete
/** The start of the extent of memory. */
[137] Fix | Delete
void *iov_base;
[138] Fix | Delete
/** The length of the extent of memory. */
[139] Fix | Delete
size_t iov_len;
[140] Fix | Delete
};
[141] Fix | Delete
#endif
[142] Fix | Delete
[143] Fix | Delete
/**
[144] Fix | Delete
Allocate storage for a new evbuffer.
[145] Fix | Delete
[146] Fix | Delete
@return a pointer to a newly allocated evbuffer struct, or NULL if an error
[147] Fix | Delete
occurred
[148] Fix | Delete
*/
[149] Fix | Delete
EVENT2_EXPORT_SYMBOL
[150] Fix | Delete
struct evbuffer *evbuffer_new(void);
[151] Fix | Delete
/**
[152] Fix | Delete
Deallocate storage for an evbuffer.
[153] Fix | Delete
[154] Fix | Delete
@param buf pointer to the evbuffer to be freed
[155] Fix | Delete
*/
[156] Fix | Delete
EVENT2_EXPORT_SYMBOL
[157] Fix | Delete
void evbuffer_free(struct evbuffer *buf);
[158] Fix | Delete
[159] Fix | Delete
/**
[160] Fix | Delete
Enable locking on an evbuffer so that it can safely be used by multiple
[161] Fix | Delete
threads at the same time.
[162] Fix | Delete
[163] Fix | Delete
NOTE: when locking is enabled, the lock will be held when callbacks are
[164] Fix | Delete
invoked. This could result in deadlock if you aren't careful. Plan
[165] Fix | Delete
accordingly!
[166] Fix | Delete
[167] Fix | Delete
@param buf An evbuffer to make lockable.
[168] Fix | Delete
@param lock A lock object, or NULL if we should allocate our own.
[169] Fix | Delete
@return 0 on success, -1 on failure.
[170] Fix | Delete
*/
[171] Fix | Delete
EVENT2_EXPORT_SYMBOL
[172] Fix | Delete
int evbuffer_enable_locking(struct evbuffer *buf, void *lock);
[173] Fix | Delete
[174] Fix | Delete
/**
[175] Fix | Delete
Acquire the lock on an evbuffer. Has no effect if locking was not enabled
[176] Fix | Delete
with evbuffer_enable_locking.
[177] Fix | Delete
*/
[178] Fix | Delete
EVENT2_EXPORT_SYMBOL
[179] Fix | Delete
void evbuffer_lock(struct evbuffer *buf);
[180] Fix | Delete
[181] Fix | Delete
/**
[182] Fix | Delete
Release the lock on an evbuffer. Has no effect if locking was not enabled
[183] Fix | Delete
with evbuffer_enable_locking.
[184] Fix | Delete
*/
[185] Fix | Delete
EVENT2_EXPORT_SYMBOL
[186] Fix | Delete
void evbuffer_unlock(struct evbuffer *buf);
[187] Fix | Delete
[188] Fix | Delete
[189] Fix | Delete
/** If this flag is set, then we will not use evbuffer_peek(),
[190] Fix | Delete
* evbuffer_remove(), evbuffer_remove_buffer(), and so on to read bytes
[191] Fix | Delete
* from this buffer: we'll only take bytes out of this buffer by
[192] Fix | Delete
* writing them to the network (as with evbuffer_write_atmost), by
[193] Fix | Delete
* removing them without observing them (as with evbuffer_drain),
[194] Fix | Delete
* or by copying them all out at once (as with evbuffer_add_buffer).
[195] Fix | Delete
*
[196] Fix | Delete
* Using this option allows the implementation to use sendfile-based
[197] Fix | Delete
* operations for evbuffer_add_file(); see that function for more
[198] Fix | Delete
* information.
[199] Fix | Delete
*
[200] Fix | Delete
* This flag is on by default for bufferevents that can take advantage
[201] Fix | Delete
* of it; you should never actually need to set it on a bufferevent's
[202] Fix | Delete
* output buffer.
[203] Fix | Delete
*/
[204] Fix | Delete
#define EVBUFFER_FLAG_DRAINS_TO_FD 1
[205] Fix | Delete
[206] Fix | Delete
/** Change the flags that are set for an evbuffer by adding more.
[207] Fix | Delete
*
[208] Fix | Delete
* @param buffer the evbuffer that the callback is watching.
[209] Fix | Delete
* @param cb the callback whose status we want to change.
[210] Fix | Delete
* @param flags One or more EVBUFFER_FLAG_* options
[211] Fix | Delete
* @return 0 on success, -1 on failure.
[212] Fix | Delete
*/
[213] Fix | Delete
EVENT2_EXPORT_SYMBOL
[214] Fix | Delete
int evbuffer_set_flags(struct evbuffer *buf, ev_uint64_t flags);
[215] Fix | Delete
/** Change the flags that are set for an evbuffer by removing some.
[216] Fix | Delete
*
[217] Fix | Delete
* @param buffer the evbuffer that the callback is watching.
[218] Fix | Delete
* @param cb the callback whose status we want to change.
[219] Fix | Delete
* @param flags One or more EVBUFFER_FLAG_* options
[220] Fix | Delete
* @return 0 on success, -1 on failure.
[221] Fix | Delete
*/
[222] Fix | Delete
EVENT2_EXPORT_SYMBOL
[223] Fix | Delete
int evbuffer_clear_flags(struct evbuffer *buf, ev_uint64_t flags);
[224] Fix | Delete
[225] Fix | Delete
/**
[226] Fix | Delete
Returns the total number of bytes stored in the evbuffer
[227] Fix | Delete
[228] Fix | Delete
@param buf pointer to the evbuffer
[229] Fix | Delete
@return the number of bytes stored in the evbuffer
[230] Fix | Delete
*/
[231] Fix | Delete
EVENT2_EXPORT_SYMBOL
[232] Fix | Delete
size_t evbuffer_get_length(const struct evbuffer *buf);
[233] Fix | Delete
[234] Fix | Delete
/**
[235] Fix | Delete
Returns the number of contiguous available bytes in the first buffer chain.
[236] Fix | Delete
[237] Fix | Delete
This is useful when processing data that might be split into multiple
[238] Fix | Delete
chains, or that might all be in the first chain. Calls to
[239] Fix | Delete
evbuffer_pullup() that cause reallocation and copying of data can thus be
[240] Fix | Delete
avoided.
[241] Fix | Delete
[242] Fix | Delete
@param buf pointer to the evbuffer
[243] Fix | Delete
@return 0 if no data is available, otherwise the number of available bytes
[244] Fix | Delete
in the first buffer chain.
[245] Fix | Delete
*/
[246] Fix | Delete
EVENT2_EXPORT_SYMBOL
[247] Fix | Delete
size_t evbuffer_get_contiguous_space(const struct evbuffer *buf);
[248] Fix | Delete
[249] Fix | Delete
/**
[250] Fix | Delete
Expands the available space in an evbuffer.
[251] Fix | Delete
[252] Fix | Delete
Expands the available space in the evbuffer to at least datlen, so that
[253] Fix | Delete
appending datlen additional bytes will not require any new allocations.
[254] Fix | Delete
[255] Fix | Delete
@param buf the evbuffer to be expanded
[256] Fix | Delete
@param datlen the new minimum length requirement
[257] Fix | Delete
@return 0 if successful, or -1 if an error occurred
[258] Fix | Delete
*/
[259] Fix | Delete
EVENT2_EXPORT_SYMBOL
[260] Fix | Delete
int evbuffer_expand(struct evbuffer *buf, size_t datlen);
[261] Fix | Delete
[262] Fix | Delete
/**
[263] Fix | Delete
Reserves space in the last chain or chains of an evbuffer.
[264] Fix | Delete
[265] Fix | Delete
Makes space available in the last chain or chains of an evbuffer that can
[266] Fix | Delete
be arbitrarily written to by a user. The space does not become
[267] Fix | Delete
available for reading until it has been committed with
[268] Fix | Delete
evbuffer_commit_space().
[269] Fix | Delete
[270] Fix | Delete
The space is made available as one or more extents, represented by
[271] Fix | Delete
an initial pointer and a length. You can force the memory to be
[272] Fix | Delete
available as only one extent. Allowing more extents, however, makes the
[273] Fix | Delete
function more efficient.
[274] Fix | Delete
[275] Fix | Delete
Multiple subsequent calls to this function will make the same space
[276] Fix | Delete
available until evbuffer_commit_space() has been called.
[277] Fix | Delete
[278] Fix | Delete
It is an error to do anything that moves around the buffer's internal
[279] Fix | Delete
memory structures before committing the space.
[280] Fix | Delete
[281] Fix | Delete
NOTE: The code currently does not ever use more than two extents.
[282] Fix | Delete
This may change in future versions.
[283] Fix | Delete
[284] Fix | Delete
@param buf the evbuffer in which to reserve space.
[285] Fix | Delete
@param size how much space to make available, at minimum. The
[286] Fix | Delete
total length of the extents may be greater than the requested
[287] Fix | Delete
length.
[288] Fix | Delete
@param vec an array of one or more evbuffer_iovec structures to
[289] Fix | Delete
hold pointers to the reserved extents of memory.
[290] Fix | Delete
@param n_vec The length of the vec array. Must be at least 1;
[291] Fix | Delete
2 is more efficient.
[292] Fix | Delete
@return the number of provided extents, or -1 on error.
[293] Fix | Delete
@see evbuffer_commit_space()
[294] Fix | Delete
*/
[295] Fix | Delete
EVENT2_EXPORT_SYMBOL
[296] Fix | Delete
int
[297] Fix | Delete
evbuffer_reserve_space(struct evbuffer *buf, ev_ssize_t size,
[298] Fix | Delete
struct evbuffer_iovec *vec, int n_vec);
[299] Fix | Delete
[300] Fix | Delete
/**
[301] Fix | Delete
Commits previously reserved space.
[302] Fix | Delete
[303] Fix | Delete
Commits some of the space previously reserved with
[304] Fix | Delete
evbuffer_reserve_space(). It then becomes available for reading.
[305] Fix | Delete
[306] Fix | Delete
This function may return an error if the pointer in the extents do
[307] Fix | Delete
not match those returned from evbuffer_reserve_space, or if data
[308] Fix | Delete
has been added to the buffer since the space was reserved.
[309] Fix | Delete
[310] Fix | Delete
If you want to commit less data than you got reserved space for,
[311] Fix | Delete
modify the iov_len pointer of the appropriate extent to a smaller
[312] Fix | Delete
value. Note that you may have received more space than you
[313] Fix | Delete
requested if it was available!
[314] Fix | Delete
[315] Fix | Delete
@param buf the evbuffer in which to reserve space.
[316] Fix | Delete
@param vec one or two extents returned by evbuffer_reserve_space.
[317] Fix | Delete
@param n_vecs the number of extents.
[318] Fix | Delete
@return 0 on success, -1 on error
[319] Fix | Delete
@see evbuffer_reserve_space()
[320] Fix | Delete
*/
[321] Fix | Delete
EVENT2_EXPORT_SYMBOL
[322] Fix | Delete
int evbuffer_commit_space(struct evbuffer *buf,
[323] Fix | Delete
struct evbuffer_iovec *vec, int n_vecs);
[324] Fix | Delete
[325] Fix | Delete
/**
[326] Fix | Delete
Append data to the end of an evbuffer.
[327] Fix | Delete
[328] Fix | Delete
@param buf the evbuffer to be appended to
[329] Fix | Delete
@param data pointer to the beginning of the data buffer
[330] Fix | Delete
@param datlen the number of bytes to be copied from the data buffer
[331] Fix | Delete
@return 0 on success, -1 on failure.
[332] Fix | Delete
*/
[333] Fix | Delete
EVENT2_EXPORT_SYMBOL
[334] Fix | Delete
int evbuffer_add(struct evbuffer *buf, const void *data, size_t datlen);
[335] Fix | Delete
[336] Fix | Delete
[337] Fix | Delete
/**
[338] Fix | Delete
Read data from an evbuffer and drain the bytes read.
[339] Fix | Delete
[340] Fix | Delete
If more bytes are requested than are available in the evbuffer, we
[341] Fix | Delete
only extract as many bytes as were available.
[342] Fix | Delete
[343] Fix | Delete
@param buf the evbuffer to be read from
[344] Fix | Delete
@param data the destination buffer to store the result
[345] Fix | Delete
@param datlen the maximum size of the destination buffer
[346] Fix | Delete
@return the number of bytes read, or -1 if we can't drain the buffer.
[347] Fix | Delete
*/
[348] Fix | Delete
EVENT2_EXPORT_SYMBOL
[349] Fix | Delete
int evbuffer_remove(struct evbuffer *buf, void *data, size_t datlen);
[350] Fix | Delete
[351] Fix | Delete
/**
[352] Fix | Delete
Read data from an evbuffer, and leave the buffer unchanged.
[353] Fix | Delete
[354] Fix | Delete
If more bytes are requested than are available in the evbuffer, we
[355] Fix | Delete
only extract as many bytes as were available.
[356] Fix | Delete
[357] Fix | Delete
@param buf the evbuffer to be read from
[358] Fix | Delete
@param data_out the destination buffer to store the result
[359] Fix | Delete
@param datlen the maximum size of the destination buffer
[360] Fix | Delete
@return the number of bytes read, or -1 if we can't drain the buffer.
[361] Fix | Delete
*/
[362] Fix | Delete
EVENT2_EXPORT_SYMBOL
[363] Fix | Delete
ev_ssize_t evbuffer_copyout(struct evbuffer *buf, void *data_out, size_t datlen);
[364] Fix | Delete
[365] Fix | Delete
/**
[366] Fix | Delete
Read data from the middle of an evbuffer, and leave the buffer unchanged.
[367] Fix | Delete
[368] Fix | Delete
If more bytes are requested than are available in the evbuffer, we
[369] Fix | Delete
only extract as many bytes as were available.
[370] Fix | Delete
[371] Fix | Delete
@param buf the evbuffer to be read from
[372] Fix | Delete
@param pos the position to start reading from
[373] Fix | Delete
@param data_out the destination buffer to store the result
[374] Fix | Delete
@param datlen the maximum size of the destination buffer
[375] Fix | Delete
@return the number of bytes read, or -1 if we can't drain the buffer.
[376] Fix | Delete
*/
[377] Fix | Delete
EVENT2_EXPORT_SYMBOL
[378] Fix | Delete
ev_ssize_t evbuffer_copyout_from(struct evbuffer *buf, const struct evbuffer_ptr *pos, void *data_out, size_t datlen);
[379] Fix | Delete
[380] Fix | Delete
/**
[381] Fix | Delete
Read data from an evbuffer into another evbuffer, draining
[382] Fix | Delete
the bytes from the source buffer. This function avoids copy
[383] Fix | Delete
operations to the extent possible.
[384] Fix | Delete
[385] Fix | Delete
If more bytes are requested than are available in src, the src
[386] Fix | Delete
buffer is drained completely.
[387] Fix | Delete
[388] Fix | Delete
@param src the evbuffer to be read from
[389] Fix | Delete
@param dst the destination evbuffer to store the result into
[390] Fix | Delete
@param datlen the maximum numbers of bytes to transfer
[391] Fix | Delete
@return the number of bytes read
[392] Fix | Delete
*/
[393] Fix | Delete
EVENT2_EXPORT_SYMBOL
[394] Fix | Delete
int evbuffer_remove_buffer(struct evbuffer *src, struct evbuffer *dst,
[395] Fix | Delete
size_t datlen);
[396] Fix | Delete
[397] Fix | Delete
/** Used to tell evbuffer_readln what kind of line-ending to look for.
[398] Fix | Delete
*/
[399] Fix | Delete
enum evbuffer_eol_style {
[400] Fix | Delete
/** Any sequence of CR and LF characters is acceptable as an
[401] Fix | Delete
* EOL.
[402] Fix | Delete
*
[403] Fix | Delete
* Note that this style can produce ambiguous results: the
[404] Fix | Delete
* sequence "CRLF" will be treated as a single EOL if it is
[405] Fix | Delete
* all in the buffer at once, but if you first read a CR from
[406] Fix | Delete
* the network and later read an LF from the network, it will
[407] Fix | Delete
* be treated as two EOLs.
[408] Fix | Delete
*/
[409] Fix | Delete
EVBUFFER_EOL_ANY,
[410] Fix | Delete
/** An EOL is an LF, optionally preceded by a CR. This style is
[411] Fix | Delete
* most useful for implementing text-based internet protocols. */
[412] Fix | Delete
EVBUFFER_EOL_CRLF,
[413] Fix | Delete
/** An EOL is a CR followed by an LF. */
[414] Fix | Delete
EVBUFFER_EOL_CRLF_STRICT,
[415] Fix | Delete
/** An EOL is a LF. */
[416] Fix | Delete
EVBUFFER_EOL_LF,
[417] Fix | Delete
/** An EOL is a NUL character (that is, a single byte with value 0) */
[418] Fix | Delete
EVBUFFER_EOL_NUL
[419] Fix | Delete
};
[420] Fix | Delete
[421] Fix | Delete
/**
[422] Fix | Delete
* Read a single line from an evbuffer.
[423] Fix | Delete
*
[424] Fix | Delete
* Reads a line terminated by an EOL as determined by the evbuffer_eol_style
[425] Fix | Delete
* argument. Returns a newly allocated nul-terminated string; the caller must
[426] Fix | Delete
* free the returned value. The EOL is not included in the returned string.
[427] Fix | Delete
*
[428] Fix | Delete
* @param buffer the evbuffer to read from
[429] Fix | Delete
* @param n_read_out if non-NULL, points to a size_t that is set to the
[430] Fix | Delete
* number of characters in the returned string. This is useful for
[431] Fix | Delete
* strings that can contain NUL characters.
[432] Fix | Delete
* @param eol_style the style of line-ending to use.
[433] Fix | Delete
* @return pointer to a single line, or NULL if an error occurred
[434] Fix | Delete
*/
[435] Fix | Delete
EVENT2_EXPORT_SYMBOL
[436] Fix | Delete
char *evbuffer_readln(struct evbuffer *buffer, size_t *n_read_out,
[437] Fix | Delete
enum evbuffer_eol_style eol_style);
[438] Fix | Delete
[439] Fix | Delete
/**
[440] Fix | Delete
Move all data from one evbuffer into another evbuffer.
[441] Fix | Delete
[442] Fix | Delete
This is a destructive add. The data from one buffer moves into
[443] Fix | Delete
the other buffer. However, no unnecessary memory copies occur.
[444] Fix | Delete
[445] Fix | Delete
@param outbuf the output buffer
[446] Fix | Delete
@param inbuf the input buffer
[447] Fix | Delete
@return 0 if successful, or -1 if an error occurred
[448] Fix | Delete
[449] Fix | Delete
@see evbuffer_remove_buffer()
[450] Fix | Delete
*/
[451] Fix | Delete
EVENT2_EXPORT_SYMBOL
[452] Fix | Delete
int evbuffer_add_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf);
[453] Fix | Delete
[454] Fix | Delete
/**
[455] Fix | Delete
Copy data from one evbuffer into another evbuffer.
[456] Fix | Delete
[457] Fix | Delete
This is a non-destructive add. The data from one buffer is copied
[458] Fix | Delete
into the other buffer. However, no unnecessary memory copies occur.
[459] Fix | Delete
[460] Fix | Delete
Note that buffers already containing buffer references can't be added
[461] Fix | Delete
to other buffers.
[462] Fix | Delete
[463] Fix | Delete
@param outbuf the output buffer
[464] Fix | Delete
@param inbuf the input buffer
[465] Fix | Delete
@return 0 if successful, or -1 if an error occurred
[466] Fix | Delete
*/
[467] Fix | Delete
EVENT2_EXPORT_SYMBOL
[468] Fix | Delete
int evbuffer_add_buffer_reference(struct evbuffer *outbuf,
[469] Fix | Delete
struct evbuffer *inbuf);
[470] Fix | Delete
[471] Fix | Delete
/**
[472] Fix | Delete
A cleanup function for a piece of memory added to an evbuffer by
[473] Fix | Delete
reference.
[474] Fix | Delete
[475] Fix | Delete
@see evbuffer_add_reference()
[476] Fix | Delete
*/
[477] Fix | Delete
typedef void (*evbuffer_ref_cleanup_cb)(const void *data,
[478] Fix | Delete
size_t datalen, void *extra);
[479] Fix | Delete
[480] Fix | Delete
/**
[481] Fix | Delete
Reference memory into an evbuffer without copying.
[482] Fix | Delete
[483] Fix | Delete
The memory needs to remain valid until all the added data has been
[484] Fix | Delete
read. This function keeps just a reference to the memory without
[485] Fix | Delete
actually incurring the overhead of a copy.
[486] Fix | Delete
[487] Fix | Delete
@param outbuf the output buffer
[488] Fix | Delete
@param data the memory to reference
[489] Fix | Delete
@param datlen how memory to reference
[490] Fix | Delete
@param cleanupfn callback to be invoked when the memory is no longer
[491] Fix | Delete
referenced by this evbuffer.
[492] Fix | Delete
@param cleanupfn_arg optional argument to the cleanup callback
[493] Fix | Delete
@return 0 if successful, or -1 if an error occurred
[494] Fix | Delete
*/
[495] Fix | Delete
EVENT2_EXPORT_SYMBOL
[496] Fix | Delete
int evbuffer_add_reference(struct evbuffer *outbuf,
[497] Fix | Delete
const void *data, size_t datlen,
[498] Fix | Delete
evbuffer_ref_cleanup_cb cleanupfn, void *cleanupfn_arg);
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function