?? apr_buckets.h
字號:
#endif
/**
* The POOL bucket type. This bucket represents a data that was allocated
* from a pool. IF this bucket is still available when the pool is cleared,
* the data is copied on to the heap.
*/
APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_pool;
/**
* The PIPE bucket type. This bucket represents a pipe to another program.
*/
APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_pipe;
/**
* The IMMORTAL bucket type. This bucket represents a segment of data that
* the creator is willing to take responsibility for. The core will do
* nothing with the data in an immortal bucket
*/
APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_immortal;
/**
* The TRANSIENT bucket type. This bucket represents a data allocated off
* the stack. When the setaside function is called, this data is copied on
* to the heap
*/
APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_transient;
/**
* The SOCKET bucket type. This bucket represents a socket to another machine
*/
APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_socket;
/* ***** Simple buckets ***** */
/**
* Split a simple bucket into two at the given point. Most non-reference
* counting buckets that allow multiple references to the same block of
* data (eg transient and immortal) will use this as their split function
* without any additional type-specific handling.
* @param b The bucket to be split
* @param point The offset of the first byte in the new bucket
* @return APR_EINVAL if the point is not within the bucket;
* APR_ENOMEM if allocation failed;
* or APR_SUCCESS
*/
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_split(apr_bucket *b,
apr_size_t point);
/**
* Copy a simple bucket. Most non-reference-counting buckets that allow
* multiple references to the same block of data (eg transient and immortal)
* will use this as their copy function without any additional type-specific
* handling.
* @param a The bucket to copy
* @param b Returns a pointer to the new bucket
* @return APR_ENOMEM if allocation failed;
* or APR_SUCCESS
*/
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_copy(apr_bucket *a,
apr_bucket **b);
/* ***** Shared, reference-counted buckets ***** */
/**
* Initialize a bucket containing reference-counted data that may be
* shared. The caller must allocate the bucket if necessary and
* initialize its type-dependent fields, and allocate and initialize
* its own private data structure. This function should only be called
* by type-specific bucket creation functions.
* @param b The bucket to initialize
* @param data A pointer to the private data structure
* with the reference count at the start
* @param start The start of the data in the bucket
* relative to the private base pointer
* @param length The length of the data in the bucket
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_shared_make(apr_bucket *b, void *data,
apr_off_t start,
apr_size_t length);
/**
* Decrement the refcount of the data in the bucket. This function
* should only be called by type-specific bucket destruction functions.
* @param data The private data pointer from the bucket to be destroyed
* @return TRUE or FALSE; TRUE if the reference count is now
* zero, indicating that the shared resource itself can
* be destroyed by the caller.
*/
APU_DECLARE(int) apr_bucket_shared_destroy(void *data);
/**
* Split a bucket into two at the given point, and adjust the refcount
* to the underlying data. Most reference-counting bucket types will
* be able to use this function as their split function without any
* additional type-specific handling.
* @param b The bucket to be split
* @param point The offset of the first byte in the new bucket
* @return APR_EINVAL if the point is not within the bucket;
* APR_ENOMEM if allocation failed;
* or APR_SUCCESS
*/
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_split(apr_bucket *b,
apr_size_t point);
/**
* Copy a refcounted bucket, incrementing the reference count. Most
* reference-counting bucket types will be able to use this function
* as their copy function without any additional type-specific handling.
* @param a The bucket to copy
* @param b Returns a pointer to the new bucket
* @return APR_ENOMEM if allocation failed;
or APR_SUCCESS
*/
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_copy(apr_bucket *a,
apr_bucket **b);
/* ***** Functions to Create Buckets of varying types ***** */
/*
* Each bucket type foo has two initialization functions:
* apr_bucket_foo_make which sets up some already-allocated memory as a
* bucket of type foo; and apr_bucket_foo_create which allocates memory
* for the bucket, calls apr_bucket_make_foo, and initializes the
* bucket's list pointers. The apr_bucket_foo_make functions are used
* inside the bucket code to change the type of buckets in place;
* other code should call apr_bucket_foo_create. All the initialization
* functions change nothing if they fail.
*/
/**
* Create an End of Stream bucket. This indicates that there is no more data
* coming from down the filter stack. All filters should flush at this point.
* @param list The freelist from which this bucket should be allocated
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_eos_create(apr_bucket_alloc_t *list);
/**
* Make the bucket passed in an EOS bucket. This indicates that there is no
* more data coming from down the filter stack. All filters should flush at
* this point.
* @param b The bucket to make into an EOS bucket
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_eos_make(apr_bucket *b);
/**
* Create a flush bucket. This indicates that filters should flush their
* data. There is no guarantee that they will flush it, but this is the
* best we can do.
* @param list The freelist from which this bucket should be allocated
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_flush_create(apr_bucket_alloc_t *list);
/**
* Make the bucket passed in a FLUSH bucket. This indicates that filters
* should flush their data. There is no guarantee that they will flush it,
* but this is the best we can do.
* @param b The bucket to make into a FLUSH bucket
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_flush_make(apr_bucket *b);
/**
* Create a bucket referring to long-lived data.
* @param buf The data to insert into the bucket
* @param nbyte The size of the data to insert.
* @param list The freelist from which this bucket should be allocated
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_immortal_create(const char *buf,
apr_size_t nbyte,
apr_bucket_alloc_t *list);
/**
* Make the bucket passed in a bucket refer to long-lived data
* @param b The bucket to make into a IMMORTAL bucket
* @param buf The data to insert into the bucket
* @param nbyte The size of the data to insert.
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_immortal_make(apr_bucket *b,
const char *buf,
apr_size_t nbyte);
/**
* Create a bucket referring to data on the stack.
* @param buf The data to insert into the bucket
* @param nbyte The size of the data to insert.
* @param list The freelist from which this bucket should be allocated
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_transient_create(const char *buf,
apr_size_t nbyte,
apr_bucket_alloc_t *list);
/**
* Make the bucket passed in a bucket refer to stack data
* @param b The bucket to make into a TRANSIENT bucket
* @param buf The data to insert into the bucket
* @param nbyte The size of the data to insert.
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_transient_make(apr_bucket *b,
const char *buf,
apr_size_t nbyte);
/**
* Create a bucket referring to memory on the heap. If the caller asks
* for the data to be copied, this function always allocates 4K of
* memory so that more data can be added to the bucket without
* requiring another allocation. Therefore not all the data may be put
* into the bucket. If copying is not requested then the bucket takes
* over responsibility for free()ing the memory.
* @param buf The buffer to insert into the bucket
* @param nbyte The size of the buffer to insert.
* @param free_func Function to use to free the data; NULL indicates that the
* bucket should make a copy of the data
* @param list The freelist from which this bucket should be allocated
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_heap_create(const char *buf,
apr_size_t nbyte,
void (*free_func)(void *data),
apr_bucket_alloc_t *list);
/**
* Make the bucket passed in a bucket refer to heap data
* @param b The bucket to make into a HEAP bucket
* @param buf The buffer to insert into the bucket
* @param nbyte The size of the buffer to insert.
* @param free_func Function to use to free the data; NULL indicates that the
* bucket should make a copy of the data
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_heap_make(apr_bucket *b, const char *buf,
apr_size_t nbyte,
void (*free_func)(void *data));
/**
* Create a bucket referring to memory allocated from a pool.
*
* @param buf The buffer to insert into the bucket
* @param length The number of bytes referred to by this bucket
* @param pool The pool the memory was allocated from
* @param list The freelist from which this bucket should be allocated
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_pool_create(const char *buf,
apr_size_t length,
apr_pool_t *pool,
apr_bucket_alloc_t *list);
/**
* Make the bucket passed in a bucket refer to pool data
* @param b The bucket to make into a pool bucket
* @param buf The buffer to insert into the bucket
* @param length The number of bytes referred to by this bucket
* @param pool The pool the memory was allocated from
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_pool_make(apr_bucket *b, const char *buf,
apr_size_t length,
apr_pool_t *pool);
#if APR_HAS_MMAP
/**
* Create a bucket referring to mmap()ed memory.
* @param mm The mmap to insert into the bucket
* @param start The offset of the first byte in the mmap
* that this bucket refers to
* @param length The number of bytes referred to by this bucket
* @param list The freelist from which this bucket should be allocated
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_mmap_create(apr_mmap_t *mm,
apr_off_t start,
apr_size_t length,
apr_bucket_alloc_t *list);
/**
* Make the bucket passed in a bucket refer to an MMAP'ed file
* @param b The bucket to make into a MMAP bucket
* @param mm The mmap to insert into the bucket
* @param start The offset of the first byte in the mmap
* that this bucket refers to
* @param length The number of bytes referred to by this bucket
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_mmap_make(apr_bucket *b, apr_mmap_t *mm,
apr_off_t start,
apr_size_t length);
#endif
/**
* Create a bucket referring to a socket.
* @param thissock The socket to put in the bucket
* @param list The freelist from which this bucket should be allocated
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_socket_create(apr_socket_t *thissock,
apr_bucket_alloc_t *list);
/**
* Make the bucket passed in a bucket refer to a socket
* @param b The bucket to make into a SOCKET bucket
* @param thissock The socket to put in the bucket
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_socket_make(apr_bucket *b,
apr_socket_t *thissock);
/**
* Create a bucket referring to a pipe.
* @param thispipe The pipe to put in the bucket
* @param list The freelist from which this bucket should be allocated
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_pipe_create(apr_file_t *thispipe,
apr_bucket_alloc_t *list);
/**
* Make the bucket passed in a bucket refer to a pipe
* @param b The bucket to make into a PIPE bucket
* @param thispipe The pipe to put in the bucket
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(apr_bucket *) apr_bucket_pipe_make(apr_bucket *b,
apr_file_t *thispipe);
/**
* Create a bucket referring to a file.
* @param fd The file to put in the bucket
* @param offset The offset where the data of interest begins in the file
* @param len The amount of data in the file we are interested in
* @param p The pool into which any needed structures should be created
* while reading from this file bucket
* @param list The freelist from which this bucket should be allocated
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(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);
/**
* Make the bucket passed in a bucket refer to a file
* @param b The bucket to make into a FILE bucket
* @param fd The file to put in the bucket
* @param offset The offset where the data of interest begins in the file
* @param len The amount of data in the file we are interested in
* @param p The pool into which any needed structures should be created
* while reading from this file bucket
* @return The new bucket, or NULL if allocation failed
*/
APU_DECLARE(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);
/**
* Enable or disable memory-mapping for a FILE bucket (default is enabled)
* @param b The bucket
* @param enabled Whether memory-mapping should be enabled
* @return APR_SUCCESS normally, or an error code if the operation fails
*/
APU_DECLARE(apr_status_t) apr_bucket_file_enable_mmap(apr_bucket *b,
int enabled);
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* !APR_BUCKETS_H */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -