24 #if defined(APR_BUCKET_DEBUG) && !defined(APR_RING_DEBUG)
25 #define APR_RING_DEBUG
29 #include "apr_network_io.h"
30 #include "apr_file_io.h"
31 #include "apr_general.h"
33 #include "apr_errno.h"
36 #if APR_HAVE_SYS_UIO_H
54 #define APR_BUCKET_BUFF_SIZE 8000
289 #ifdef APR_BUCKET_DEBUG
291 #define APR_BRIGADE_CHECK_CONSISTENCY(b) \
292 APR_RING_CHECK_CONSISTENCY(&(b)->list, apr_bucket, link)
294 #define APR_BUCKET_CHECK_CONSISTENCY(e) \
295 APR_RING_CHECK_ELEM_CONSISTENCY((e), apr_bucket, link)
304 #define APR_BRIGADE_CHECK_CONSISTENCY(b)
311 #define APR_BUCKET_CHECK_CONSISTENCY(e)
331 #define APR_BRIGADE_SENTINEL(b) APR_RING_SENTINEL(&(b)->list, apr_bucket, link)
338 #define APR_BRIGADE_EMPTY(b) APR_RING_EMPTY(&(b)->list, apr_bucket, link)
345 #define APR_BRIGADE_FIRST(b) APR_RING_FIRST(&(b)->list)
351 #define APR_BRIGADE_LAST(b) APR_RING_LAST(&(b)->list)
358 #define APR_BRIGADE_INSERT_HEAD(b, e) do { \
359 apr_bucket *ap__b = (e); \
360 APR_RING_INSERT_HEAD(&(b)->list, ap__b, apr_bucket, link); \
361 APR_BRIGADE_CHECK_CONSISTENCY((b)); \
369 #define APR_BRIGADE_INSERT_TAIL(b, e) do { \
370 apr_bucket *ap__b = (e); \
371 APR_RING_INSERT_TAIL(&(b)->list, ap__b, apr_bucket, link); \
372 APR_BRIGADE_CHECK_CONSISTENCY((b)); \
380 #define APR_BRIGADE_CONCAT(a, b) do { \
381 APR_RING_CONCAT(&(a)->list, &(b)->list, apr_bucket, link); \
382 APR_BRIGADE_CHECK_CONSISTENCY((a)); \
390 #define APR_BRIGADE_PREPEND(a, b) do { \
391 APR_RING_PREPEND(&(a)->list, &(b)->list, apr_bucket, link); \
392 APR_BRIGADE_CHECK_CONSISTENCY((a)); \
400 #define APR_BUCKET_INSERT_BEFORE(a, b) do { \
401 apr_bucket *ap__a = (a), *ap__b = (b); \
402 APR_RING_INSERT_BEFORE(ap__a, ap__b, link); \
403 APR_BUCKET_CHECK_CONSISTENCY(ap__a); \
411 #define APR_BUCKET_INSERT_AFTER(a, b) do { \
412 apr_bucket *ap__a = (a), *ap__b = (b); \
413 APR_RING_INSERT_AFTER(ap__a, ap__b, link); \
414 APR_BUCKET_CHECK_CONSISTENCY(ap__a); \
422 #define APR_BUCKET_NEXT(e) APR_RING_NEXT((e), link)
428 #define APR_BUCKET_PREV(e) APR_RING_PREV((e), link)
434 #define APR_BUCKET_REMOVE(e) APR_RING_REMOVE((e), link)
440 #define APR_BUCKET_INIT(e) APR_RING_ELEM_INIT((e), link)
448 #define APR_BUCKET_IS_METADATA(e) ((e)->type->is_metadata)
455 #define APR_BUCKET_IS_FLUSH(e) ((e)->type == &apr_bucket_type_flush)
461 #define APR_BUCKET_IS_EOS(e) ((e)->type == &apr_bucket_type_eos)
467 #define APR_BUCKET_IS_FILE(e) ((e)->type == &apr_bucket_type_file)
473 #define APR_BUCKET_IS_PIPE(e) ((e)->type == &apr_bucket_type_pipe)
479 #define APR_BUCKET_IS_SOCKET(e) ((e)->type == &apr_bucket_type_socket)
485 #define APR_BUCKET_IS_HEAP(e) ((e)->type == &apr_bucket_type_heap)
491 #define APR_BUCKET_IS_TRANSIENT(e) ((e)->type == &apr_bucket_type_transient)
497 #define APR_BUCKET_IS_IMMORTAL(e) ((e)->type == &apr_bucket_type_immortal)
504 #define APR_BUCKET_IS_MMAP(e) ((e)->type == &apr_bucket_type_mmap)
511 #define APR_BUCKET_IS_POOL(e) ((e)->type == &apr_bucket_type_pool)
553 void (*free_func)(
void *data);
648 #define APR_BUCKET_ALLOC_SIZE APR_ALIGN_DEFAULT(2*sizeof(apr_bucket_structs))
788 struct iovec *vec,
int *nvec);
828 const
char *str, apr_size_t nbyte);
842 const struct iovec *vec,
894 const
char *fmt, ...)
895 __attribute__((format(printf,4,5)));
910 const
char *fmt, va_list va);
985 #define apr_bucket_destroy(e) do { \
986 (e)->type->destroy((e)->data); \
1001 #define apr_bucket_delete(e) do { \
1002 APR_BUCKET_REMOVE(e); \
1003 apr_bucket_destroy(e); \
1073 #define apr_bucket_read(e,str,len,block) (e)->type->read(e, str, len, block)
1081 #define apr_bucket_setaside(e,p) (e)->type->setaside(e,p)
1093 #define apr_bucket_split(e,point) (e)->type->split(e, point)
1100 #define apr_bucket_copy(e,c) (e)->type->copy(e, c)
1416 void (*free_func)(
void *data),
1429 void (*free_func)(
void *data));
1501 apr_socket_t *thissock);
1519 apr_file_t *thispipe);
1555 apr_size_t len, apr_pool_t *p);
apr_bucket * apr_bucket_flush_create(apr_bucket_alloc_t *list)
apr_status_t apr_brigade_split_line(apr_bucket_brigade *bbOut, apr_bucket_brigade *bbIn, apr_read_type_e block, apr_off_t maxbytes)
apr_file_t * fd
Definition: apr_buckets.h:616
apr_status_t apr_bucket_copy_notimpl(apr_bucket *e, apr_bucket **c)
Definition: apr_buckets.h:543
apr_status_t apr_brigade_putstrs(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx,...)
apr_status_t apr_bucket_setaside_notimpl(apr_bucket *data, apr_pool_t *pool)
apr_bucket * apr_bucket_immortal_make(apr_bucket *b, const char *buf, apr_size_t nbyte)
char * base
Definition: apr_buckets.h:549
apr_status_t apr_brigade_printf(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, const char *fmt,...)
void * data
Definition: apr_buckets.h:244
apr_bucket * apr_bucket_eos_create(apr_bucket_alloc_t *list)
const apr_bucket_type_t apr_bucket_type_pool
apr_status_t apr_brigade_vprintf(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, const char *fmt, va_list va)
APR_RING_ENTRY(apr_bucket) link
int can_mmap
Definition: apr_buckets.h:623
const apr_bucket_type_t apr_bucket_type_pipe
apr_status_t apr_brigade_write(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, const char *str, apr_size_t nbyte)
enum apr_bucket_type_t::@0 is_metadata
apr_status_t(* setaside)(apr_bucket *e, apr_pool_t *pool)
Definition: apr_buckets.h:192
Definition: apr_buckets.h:612
apr_status_t apr_brigade_vputstrs(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, va_list va)
apr_bucket * apr_bucket_eos_make(apr_bucket *b)
apr_status_t(* read)(apr_bucket *b, const char **str, apr_size_t *len, apr_read_type_e block)
Definition: apr_buckets.h:176
apr_bucket_alloc_t * bucket_alloc
Definition: apr_buckets.h:275
apr_status_t(* split)(apr_bucket *e, apr_size_t point)
Definition: apr_buckets.h:203
apr_pool_t * readpool
Definition: apr_buckets.h:619
apr_bucket * apr_bucket_heap_create(const char *buf, apr_size_t nbyte, void(*free_func)(void *data), apr_bucket_alloc_t *list)
void apr_bucket_free(void *block)
apr_bucket * apr_bucket_socket_create(apr_socket_t *thissock, apr_bucket_alloc_t *list)
const apr_bucket_type_t apr_bucket_type_transient
apr_read_type_e
Definition: apr_buckets.h:57
apr_bucket * apr_bucket_shared_make(apr_bucket *b, void *data, apr_off_t start, apr_size_t length)
apr_pool_t * p
Definition: apr_buckets.h:264
apr_status_t apr_brigade_length(apr_bucket_brigade *bb, int read_all, apr_off_t *length)
apr_status_t apr_brigade_writev(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, const struct iovec *vec, apr_size_t nvec)
apr_bucket * apr_bucket_file_create(apr_file_t *fd, apr_off_t offset, apr_size_t len, apr_pool_t *p, apr_bucket_alloc_t *list)
apr_bucket_refcount refcount
Definition: apr_buckets.h:545
apr_bucket b
Definition: apr_buckets.h:634
Definition: apr_buckets.h:258
apr_bucket_alloc_t * apr_bucket_alloc_create_ex(apr_allocator_t *allocator)
apr_bucket * apr_bucket_flush_make(apr_bucket *b)
apr_size_t alloc_len
Definition: apr_buckets.h:551
struct apr_bucket_alloc_t apr_bucket_alloc_t
Definition: apr_buckets.h:123
apr_bucket_refcount refcount
Definition: apr_buckets.h:601
apr_status_t apr_bucket_shared_split(apr_bucket *b, apr_size_t point)
const apr_bucket_type_t apr_bucket_type_eos
void(* free)(void *e)
Definition: apr_buckets.h:252
apr_bucket_file file
Definition: apr_buckets.h:640
const char * base
Definition: apr_buckets.h:579
int apr_bucket_shared_destroy(void *data)
apr_status_t apr_bucket_file_enable_mmap(apr_bucket *b, int enabled)
apr_status_t apr_bucket_simple_copy(apr_bucket *a, apr_bucket **b)
APR_RING_HEAD(apr_bucket_list, apr_bucket) list
apr_pool_t * pool
Definition: apr_buckets.h:586
apr_bucket * apr_bucket_mmap_make(apr_bucket *b, apr_mmap_t *mm, apr_off_t start, apr_size_t length)
const apr_bucket_type_t apr_bucket_type_immortal
apr_bucket * apr_bucket_heap_make(apr_bucket *b, const char *buf, apr_size_t nbyte, void(*free_func)(void *data))
const apr_bucket_type_t apr_bucket_type_mmap
Definition: apr_buckets.h:224
Definition: apr_buckets.h:633
apr_bucket * apr_bucket_pipe_make(apr_bucket *b, apr_file_t *thispipe)
apr_status_t apr_brigade_to_iovec(apr_bucket_brigade *b, struct iovec *vec, int *nvec)
apr_status_t apr_brigade_puts(apr_bucket_brigade *bb, apr_brigade_flush flush, void *ctx, const char *str)
apr_bucket * apr_bucket_mmap_create(apr_mmap_t *mm, apr_off_t start, apr_size_t length, apr_bucket_alloc_t *list)
apr_status_t apr_brigade_cleanup(void *data)
Definition: apr_buckets.h:561
apr_bucket * apr_brigade_insert_file(apr_bucket_brigade *bb, apr_file_t *f, apr_off_t start, apr_off_t len, apr_pool_t *p)
apr_bucket * apr_bucket_immortal_create(const char *buf, apr_size_t nbyte, apr_bucket_alloc_t *list)
apr_status_t(* apr_brigade_flush)(apr_bucket_brigade *bb, void *ctx)
Definition: apr_buckets.h:282
Definition: apr_buckets.h:531
apr_status_t(* copy)(apr_bucket *e, apr_bucket **c)
Definition: apr_buckets.h:211
const apr_bucket_type_t apr_bucket_type_flush
const apr_bucket_type_t apr_bucket_type_heap
apr_status_t apr_brigade_pflatten(apr_bucket_brigade *bb, char **c, apr_size_t *len, apr_pool_t *pool)
apr_bucket_brigade * apr_brigade_split_ex(apr_bucket_brigade *b, apr_bucket *e, apr_bucket_brigade *a)
int num_func
Definition: apr_buckets.h:140
void apr_bucket_alloc_destroy(apr_bucket_alloc_t *list)
const apr_bucket_type_t apr_bucket_type_socket
apr_bucket * apr_bucket_pool_create(const char *buf, apr_size_t length, apr_pool_t *pool, apr_bucket_alloc_t *list)
apr_status_t apr_brigade_partition(apr_bucket_brigade *b, apr_off_t point, apr_bucket **after_point)
apr_status_t apr_bucket_shared_copy(apr_bucket *a, apr_bucket **b)
apr_bucket * apr_bucket_socket_make(apr_bucket *b, apr_socket_t *thissock)
apr_off_t start
Definition: apr_buckets.h:242
apr_bucket_brigade * apr_brigade_split(apr_bucket_brigade *b, apr_bucket *e)
int refcount
Definition: apr_buckets.h:533
apr_bucket * apr_bucket_pool_make(apr_bucket *b, const char *buf, apr_size_t length, apr_pool_t *pool)
void apr_bucket_destroy_noop(void *data)
Definition: apr_buckets.h:131
void(* destroy)(void *data)
Definition: apr_buckets.h:164
apr_bucket * apr_bucket_transient_create(const char *buf, apr_size_t nbyte, apr_bucket_alloc_t *list)
Definition: apr_buckets.h:58
Definition: apr_buckets.h:153
apr_bucket_alloc_t * list
Definition: apr_buckets.h:590
apr_bucket * apr_bucket_file_make(apr_bucket *b, apr_file_t *fd, apr_off_t offset, apr_size_t len, apr_pool_t *p)
const apr_bucket_type_t * type
Definition: apr_buckets.h:228
apr_status_t apr_bucket_split_notimpl(apr_bucket *data, apr_size_t point)
apr_bucket_refcount refcount
Definition: apr_buckets.h:614
apr_bucket_mmap mmap
Definition: apr_buckets.h:638
apr_bucket_brigade * apr_brigade_create(apr_pool_t *p, apr_bucket_alloc_t *list)
apr_bucket_pool pool
Definition: apr_buckets.h:636
Definition: apr_buckets.h:599
apr_status_t apr_bucket_setaside_noop(apr_bucket *data, apr_pool_t *pool)
void * apr_bucket_alloc(apr_size_t size, apr_bucket_alloc_t *list)
apr_bucket * apr_bucket_pipe_create(apr_file_t *thispipe, apr_bucket_alloc_t *list)
apr_bucket * apr_bucket_transient_make(apr_bucket *b, const char *buf, apr_size_t nbyte)
apr_bucket_alloc_t * list
Definition: apr_buckets.h:254
apr_status_t apr_brigade_flatten(apr_bucket_brigade *bb, char *c, apr_size_t *len)
Definition: apr_buckets.h:59
apr_bucket_heap heap
Definition: apr_buckets.h:635
apr_size_t length
Definition: apr_buckets.h:234
apr_status_t apr_brigade_destroy(apr_bucket_brigade *b)
apr_status_t apr_bucket_simple_split(apr_bucket *b, apr_size_t point)
const apr_bucket_type_t apr_bucket_type_file
apr_bucket_heap heap
Definition: apr_buckets.h:573
apr_status_t apr_brigade_putc(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, const char c)
Definition: apr_buckets.h:155
const char * name
Definition: apr_buckets.h:135
apr_mmap_t * mmap
Definition: apr_buckets.h:603
apr_bucket_alloc_t * apr_bucket_alloc_create(apr_pool_t *p)