📄 apr_buckets.h
字号:
* e = APR_BUCKET_NEXT(e); * } * OR * for (e = APR_BUCKET_FIRST(b); * e != APR_BRIGADE_SENTINEL(b); * e = APR_BUCKET_NEXT(e)) { * ... * } * </pre> * @deffunc void APR_BRIGADE_FOREACH(apr_bucket *e, apr_bucket_brigade *b) */#define APR_BRIGADE_FOREACH(e, b) \ APR_RING_FOREACH((e), &(b)->list, apr_bucket, link)/** * Insert a list of buckets at the front of a brigade * @param b The brigade to add to * @param e The first bucket in a list of buckets to insert * @deffunc void APR_BRIGADE_INSERT_HEAD(apr_bucket_brigade *b, apr_bucket *e) */#define APR_BRIGADE_INSERT_HEAD(b, e) do { \ apr_bucket *ap__b = (e); \ APR_RING_INSERT_HEAD(&(b)->list, ap__b, apr_bucket, link); \ } while (0)/** * Insert a list of buckets at the end of a brigade * @param b The brigade to add to * @param e The first bucket in a list of buckets to insert * @deffunc void APR_BRIGADE_INSERT_HEAD(apr_bucket_brigade *b, apr_bucket *e) */#define APR_BRIGADE_INSERT_TAIL(b, e) do { \ apr_bucket *ap__b = (e); \ APR_RING_INSERT_TAIL(&(b)->list, ap__b, apr_bucket, link); \ } while (0)/** * Concatenate two brigades together * @param a The first brigade * @param b The second brigade * @deffunc void APR_BRIGADE_CONCAT(apr_bucket_brigade *a, apr_bucket_brigade *b) */#define APR_BRIGADE_CONCAT(a, b) \ APR_RING_CONCAT(&(a)->list, &(b)->list, apr_bucket, link)/** * Insert a list of buckets before a specified bucket * @param a The bucket to insert before * @param b The buckets to insert * @deffunc void APR_BUCKET_INSERT_BEFORE(apr_bucket *a, apr_bucket *b) */#define APR_BUCKET_INSERT_BEFORE(a, b) do { \ apr_bucket *ap__a = (a), *ap__b = (b); \ APR_RING_INSERT_BEFORE(ap__a, ap__b, link); \ } while (0)/** * Insert a list of buckets after a specified bucket * @param a The bucket to insert after * @param b The buckets to insert * @deffunc void APR_BUCKET_INSERT_AFTER(apr_bucket *a, apr_bucket *b) */#define APR_BUCKET_INSERT_AFTER(a, b) do { \ apr_bucket *ap__a = (a), *ap__b = (b); \ APR_RING_INSERT_AFTER(ap__a, ap__b, link); \ } while (0)/** * Get the next bucket in the list * @param e The current bucket * @return The next bucket * @deffunc apr_bucket *APR_BUCKET_NEXT(apr_bucket *e) */#define APR_BUCKET_NEXT(e) APR_RING_NEXT((e), link)/** * Get the previous bucket in the list * @param e The current bucket * @return The previous bucket * @deffunc apr_bucket *APR_BUCKET_PREV(apr_bucket *e) */#define APR_BUCKET_PREV(e) APR_RING_PREV((e), link)/** * Remove a bucket from its bucket brigade * @param e The bucket to remove * @deffunc void APR_BUCKET_REMOVE(apr_bucket *e) */#define APR_BUCKET_REMOVE(e) APR_RING_REMOVE((e), link)/** * Determine if a bucket is a FLUSH bucket * @param e The bucket to inspect * @return true or false * @deffunc int APR_BUCKET_IS_FLUSH(apr_bucket *e) */#define APR_BUCKET_IS_FLUSH(e) (e->type == &apr_bucket_type_flush)/** * Determine if a bucket is an EOS bucket * @param e The bucket to inspect * @return true or false * @deffunc int APR_BUCKET_IS_EOS(apr_bucket *e) */#define APR_BUCKET_IS_EOS(e) (e->type == &apr_bucket_type_eos)/** * Determine if a bucket is a FILE bucket * @param e The bucket to inspect * @return true or false * @deffunc int APR_BUCKET_IS_FILE(apr_bucket *e) */#define APR_BUCKET_IS_FILE(e) (e->type == &apr_bucket_type_file)/** * Determine if a bucket is a PIPE bucket * @param e The bucket to inspect * @return true or false * @deffunc int APR_BUCKET_IS_PIPE(apr_bucket *e) */#define APR_BUCKET_IS_PIPE(e) (e->type == &apr_bucket_type_pipe)/** * Determine if a bucket is a SOCKET bucket * @param e The bucket to inspect * @return true or false * @deffunc int APR_BUCKET_IS_SOCKET(apr_bucket *e) */#define APR_BUCKET_IS_SOCKET(e) (e->type == &apr_bucket_type_socket)/** * Determine if a bucket is a HEAP bucket * @param e The bucket to inspect * @return true or false * @deffunc int APR_BUCKET_IS_HEAP(apr_bucket *e) */#define APR_BUCKET_IS_HEAP(e) (e->type == &apr_bucket_type_heap)/** * Determine if a bucket is a TRANSIENT bucket * @param e The bucket to inspect * @return true or false * @deffunc int APR_BUCKET_IS_TRANSIENT(apr_bucket *e) */#define APR_BUCKET_IS_TRANSIENT(e) (e->type == &apr_bucket_type_transient)/** * Determine if a bucket is a IMMORTAL bucket * @param e The bucket to inspect * @return true or false * @deffunc int APR_BUCKET_IS_IMMORTAL(apr_bucket *e) */#define APR_BUCKET_IS_IMMORTAL(e) (e->type == &apr_bucket_type_immortal)#if APR_HAS_MMAP/** * Determine if a bucket is a MMAP bucket * @param e The bucket to inspect * @return true or false * @deffunc int APR_BUCKET_IS_MMAP(apr_bucket *e) */#define APR_BUCKET_IS_MMAP(e) (e->type == &apr_bucket_type_mmap)#endif/** * Determine if a bucket is a POOL bucket * @param e The bucket to inspect * @return true or false * @deffunc int APR_BUCKET_IS_POOL(apr_bucket *e) */#define APR_BUCKET_IS_POOL(e) (e->type == &apr_bucket_type_pool)/* * General-purpose reference counting for the varous bucket types. * * Any bucket type that keeps track of the resources it uses (i.e. * most of them except for IMMORTAL, TRANSIENT, and EOS) needs to * attach a reference count to the resource so that it can be freed * when the last bucket that uses it goes away. Resource-sharing may * occur because of bucket splits or buckets that refer to globally * cached data. */typedef struct apr_bucket_refcount apr_bucket_refcount;/** * The structure used to manage the shared resource must start with an * apr_bucket_refcount which is updated by the general-purpose refcount * code. A pointer to the bucket-type-dependent private data structure * can be cast to a pointer to an apr_bucket_refcount and vice versa. */struct apr_bucket_refcount { /** The number of references to this bucket */ int refcount;};/* ***** Reference-counted bucket types ***** */typedef struct apr_bucket_heap apr_bucket_heap;/** * A bucket referring to data allocated off the heap. */struct apr_bucket_heap { /** Number of buckets using this memory */ apr_bucket_refcount refcount; /** The start of the data actually allocated. This should never be * modified, it is only used to free the bucket. */ char *base; /** how much memory was allocated */ size_t alloc_len;};typedef struct apr_bucket_pool apr_bucket_pool;/** * A bucket referring to data allocated from a pool */struct apr_bucket_pool { /** The pool bucket must be able to be easily morphed to a heap * bucket if the pool gets cleaned up before all references are * destroyed. This apr_bucket_heap structure is populated automatically * when the pool gets cleaned up, and subsequent calls to pool_read() * will result in the apr_bucket in question being morphed into a * regular heap bucket. (To avoid having to do many extra refcount * manipulations and b->data manipulations, the apr_bucket_pool * struct actually *contains* the apr_bucket_heap struct that it * will become as its first element; the two share their * apr_bucket_refcount members.) */ apr_bucket_heap heap; /** The block of data actually allocated from the pool. * Segments of this block are referenced by adjusting * the start and length of the apr_bucket accordingly. * This will be NULL after the pool gets cleaned up. */ const char *base; /** The pool the data was allocated from. When the pool * is cleaned up, this gets set to NULL as an indicator * to pool_read() that the data is now on the heap and * so it should morph the bucket into a regular heap * bucket before continuing. */ apr_pool_t *pool;};#if APR_HAS_MMAPtypedef struct apr_bucket_mmap apr_bucket_mmap;/** * A bucket referring to an mmap()ed file */struct apr_bucket_mmap { /** Number of buckets using this memory */ apr_bucket_refcount refcount; /** The mmap this sub_bucket refers to */ apr_mmap_t *mmap;};#endiftypedef struct apr_bucket_file apr_bucket_file;/** * A bucket referring to an file */struct apr_bucket_file { /** Number of buckets using this memory */ apr_bucket_refcount refcount; /** The file this bucket refers to */ apr_file_t *fd;};/* ***** Bucket Brigade Functions ***** *//** * Create a new bucket brigade. The bucket brigade is originally empty. * @param The pool to associate with the brigade. Data is not allocated out * of the pool, but a cleanup is registered. * @return The empty bucket brigade * @deffunc apr_bucket_brigade *apr_brigade_create(apr_pool_t *p) */APU_DECLARE(apr_bucket_brigade *) apr_brigade_create(apr_pool_t *p);/** * destroy an entire bucket brigade. This includes destroying all of the * buckets within the bucket brigade's bucket list. * @param b The bucket brigade to destroy * @deffunc apr_status_t apr_brigade_destroy(apr_bucket_brigade *b) */APU_DECLARE(apr_status_t) apr_brigade_destroy(apr_bucket_brigade *b);/** * Split a bucket brigade into two, such that the given bucket is the * first in the new bucket brigade. This function is useful when a * filter wants to pass only the initial part of a brigade to the next * filter. * @param b The brigade to split * @param e The first element of the new brigade * @return The new brigade * @deffunc apr_bucket_brigade *apr_brigade_split(apr_bucket_brigade *b, apr_bucket *e) */APU_DECLARE(apr_bucket_brigade *) apr_brigade_split(apr_bucket_brigade *b, apr_bucket *e);/** * Partition a bucket brigade at a given offset (in bytes from the start of * the brigade). This is useful whenever a filter wants to use known ranges * of bytes from the brigade; the ranges can even overlap. * @param b The brigade to partition * @param point The offset at which to partition the brigade * @return A pointer to the first bucket after the partition; * or NULL in any error condition (including partition past the end) * @deffunc apr_bucket *apr_brigade_partition(apr_bucket_brigade *b, apr_off_t point) */APU_DECLARE(apr_bucket *) apr_brigade_partition(apr_bucket_brigade *b, apr_off_t point);#if APR_NOT_DONE_YET/** * consume nbytes from beginning of b -- call apr_bucket_destroy as * appropriate, and/or modify start on last element * @param b The brigade to consume data from * @param nbytes The number of bytes to consume * @deffunc void apr_brigade_consume(apr_bucket_brigade *b, int nbytes) */APU_DECLARE(void) apr_brigade_consume(apr_bucket_brigade *b, int nbytes);#endif/** * Return the total length of the brigade.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -