?? apr_buckets.h
字號:
#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
*/
APU_DECLARE(void) apr_brigade_consume(apr_bucket_brigade *b,
apr_off_t nbytes);
#endif
/**
* Return the total length of the brigade.
* @param bb The brigade to compute the length of
* @param read_all Read unknown-length buckets to force a size
* @param length Returns the length of the brigade, or -1 if the brigade has
* buckets of indeterminate length and read_all is 0.
*/
APU_DECLARE(apr_status_t) apr_brigade_length(apr_bucket_brigade *bb,
int read_all,
apr_off_t *length);
/**
* Take a bucket brigade and store the data in a flat char*
* @param bb The bucket brigade to create the char* from
* @param c The char* to write into
* @param len The maximum length of the char array. On return, it is the
* actual length of the char array.
*/
APU_DECLARE(apr_status_t) apr_brigade_flatten(apr_bucket_brigade *bb,
char *c,
apr_size_t *len);
/**
* Creates a pool-allocated string representing a flat bucket brigade
* @param bb The bucket brigade to create the char array from
* @param c On return, the allocated char array
* @param len On return, the length of the char array.
* @param pool The pool to allocate the string from.
*/
APU_DECLARE(apr_status_t) apr_brigade_pflatten(apr_bucket_brigade *bb,
char **c,
apr_size_t *len,
apr_pool_t *pool);
/**
* Split a brigade to represent one LF line.
* @param bbOut The bucket brigade that will have the LF line appended to.
* @param bbIn The input bucket brigade to search for a LF-line.
* @param block The blocking mode to be used to split the line.
* @param maxbytes The maximum bytes to read. If this many bytes are seen
* without a LF, the brigade will contain a partial line.
*/
APU_DECLARE(apr_status_t) apr_brigade_split_line(apr_bucket_brigade *bbOut,
apr_bucket_brigade *bbIn,
apr_read_type_e block,
apr_off_t maxbytes);
/**
* create an iovec of the elements in a bucket_brigade... return number
* of elements used. This is useful for writing to a file or to the
* network efficiently.
* @param b The bucket brigade to create the iovec from
* @param vec The iovec to create
* @param nvec The number of elements in the iovec. On return, it is the
* number of iovec elements actually filled out.
*/
APU_DECLARE(apr_status_t) apr_brigade_to_iovec(apr_bucket_brigade *b,
struct iovec *vec, int *nvec);
/**
* This function writes a list of strings into a bucket brigade.
* @param b The bucket brigade to add to
* @param flush The flush function to use if the brigade is full
* @param ctx The structure to pass to the flush function
* @param va A list of strings to add
* @return APR_SUCCESS or error code.
*/
APU_DECLARE(apr_status_t) apr_brigade_vputstrs(apr_bucket_brigade *b,
apr_brigade_flush flush,
void *ctx,
va_list va);
/**
* This function writes a string into a bucket brigade.
* @param b The bucket brigade to add to
* @param flush The flush function to use if the brigade is full
* @param ctx The structure to pass to the flush function
* @param str The string to add
* @param nbyte The number of bytes to write
* @return APR_SUCCESS or error code
*/
APU_DECLARE(apr_status_t) apr_brigade_write(apr_bucket_brigade *b,
apr_brigade_flush flush, void *ctx,
const char *str, apr_size_t nbyte);
/**
* This function writes multiple strings into a bucket brigade.
* @param b The bucket brigade to add to
* @param flush The flush function to use if the brigade is full
* @param ctx The structure to pass to the flush function
* @param vec The strings to add (address plus length for each)
* @param nvec The number of entries in iovec
* @return APR_SUCCESS or error code
*/
APU_DECLARE(apr_status_t) apr_brigade_writev(apr_bucket_brigade *b,
apr_brigade_flush flush,
void *ctx,
const struct iovec *vec,
apr_size_t nvec);
/**
* This function writes a string into a bucket brigade.
* @param bb The bucket brigade to add to
* @param flush The flush function to use if the brigade is full
* @param ctx The structure to pass to the flush function
* @param str The string to add
* @return APR_SUCCESS or error code
*/
APU_DECLARE(apr_status_t) apr_brigade_puts(apr_bucket_brigade *bb,
apr_brigade_flush flush, void *ctx,
const char *str);
/**
* This function writes a character into a bucket brigade.
* @param b The bucket brigade to add to
* @param flush The flush function to use if the brigade is full
* @param ctx The structure to pass to the flush function
* @param c The character to add
* @return APR_SUCCESS or error code
*/
APU_DECLARE(apr_status_t) apr_brigade_putc(apr_bucket_brigade *b,
apr_brigade_flush flush, void *ctx,
const char c);
/**
* This function writes an unspecified number of strings into a bucket brigade.
* @param b The bucket brigade to add to
* @param flush The flush function to use if the brigade is full
* @param ctx The structure to pass to the flush function
* @param ... The strings to add
* @return APR_SUCCESS or error code
*/
APU_DECLARE_NONSTD(apr_status_t) apr_brigade_putstrs(apr_bucket_brigade *b,
apr_brigade_flush flush,
void *ctx, ...);
/**
* Evaluate a printf and put the resulting string at the end
* of the bucket brigade.
* @param b The brigade to write to
* @param flush The flush function to use if the brigade is full
* @param ctx The structure to pass to the flush function
* @param fmt The format of the string to write
* @param ... The arguments to fill out the format
* @return APR_SUCCESS or error code
*/
APU_DECLARE_NONSTD(apr_status_t) apr_brigade_printf(apr_bucket_brigade *b,
apr_brigade_flush flush,
void *ctx,
const char *fmt, ...)
__attribute__((format(printf,4,5)));
/**
* Evaluate a printf and put the resulting string at the end
* of the bucket brigade.
* @param b The brigade to write to
* @param flush The flush function to use if the brigade is full
* @param ctx The structure to pass to the flush function
* @param fmt The format of the string to write
* @param va The arguments to fill out the format
* @return APR_SUCCESS or error code
*/
APU_DECLARE(apr_status_t) apr_brigade_vprintf(apr_bucket_brigade *b,
apr_brigade_flush flush,
void *ctx,
const char *fmt, va_list va);
/* ***** Bucket freelist functions ***** */
/**
* Create a bucket allocator.
* @param p This pool's underlying apr_allocator_t is used to allocate memory
* for the bucket allocator. When the pool is destroyed, the bucket
* allocator's cleanup routine will free all memory that has been
* allocated from it.
* @remark The reason the allocator gets its memory from the pool's
* apr_allocator_t rather than from the pool itself is because
* the bucket allocator will free large memory blocks back to the
* allocator when it's done with them, thereby preventing memory
* footprint growth that would occur if we allocated from the pool.
* @warning The allocator must never be used by more than one thread at a time.
*/
APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create(apr_pool_t *p);
/**
* Create a bucket allocator.
* @param allocator This apr_allocator_t is used to allocate both the bucket
* allocator and all memory handed out by the bucket allocator. The
* caller is responsible for destroying the bucket allocator and the
* apr_allocator_t -- no automatic cleanups will happen.
* @warning The allocator must never be used by more than one thread at a time.
*/
APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create_ex(apr_allocator_t *allocator);
/**
* Destroy a bucket allocator.
* @param list The allocator to be destroyed
*/
APU_DECLARE_NONSTD(void) apr_bucket_alloc_destroy(apr_bucket_alloc_t *list);
/**
* Allocate memory for use by the buckets.
* @param size The amount to allocate.
* @param list The allocator from which to allocate the memory.
*/
APU_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t size, apr_bucket_alloc_t *list);
/**
* Free memory previously allocated with apr_bucket_alloc().
* @param block The block of memory to be freed.
*/
APU_DECLARE_NONSTD(void) apr_bucket_free(void *block);
/* ***** Bucket Functions ***** */
/**
* Free the resources used by a bucket. If multiple buckets refer to
* the same resource it is freed when the last one goes away.
* @see apr_bucket_delete()
* @param e The bucket to destroy
*/
#define apr_bucket_destroy(e) do { \
(e)->type->destroy((e)->data); \
(e)->free(e); \
} while (0)
/**
* Delete a bucket by removing it from its brigade (if any) and then
* destroying it.
* @remark This mainly acts as an aid in avoiding code verbosity. It is
* the preferred exact equivalent to:
* <pre>
* APR_BUCKET_REMOVE(e);
* apr_bucket_destroy(e);
* </pre>
* @param e The bucket to delete
*/
#define apr_bucket_delete(e) do { \
APR_BUCKET_REMOVE(e); \
apr_bucket_destroy(e); \
} while (0)
/**
* read the data from the bucket
* @param e The bucket to read from
* @param str The location to store the data in
* @param len The amount of data read
* @param block Whether the read function blocks
*/
#define apr_bucket_read(e,str,len,block) (e)->type->read(e, str, len, block)
/**
* Setaside data so that stack data is not destroyed on returning from
* the function
* @param e The bucket to setaside
* @param p The pool to setaside into
*/
#define apr_bucket_setaside(e,p) (e)->type->setaside(e,p)
/**
* Split one bucket in two.
* @param e The bucket to split
* @param point The offset to split the bucket at
*/
#define apr_bucket_split(e,point) (e)->type->split(e, point)
/**
* Copy a bucket.
* @param e The bucket to copy
* @param c Returns a pointer to the new bucket
*/
#define apr_bucket_copy(e,c) (e)->type->copy(e, c)
/* Bucket type handling */
/**
* This function simply returns APR_SUCCESS to denote that the bucket does
* not require anything to happen for its setaside() function. This is
* appropriate for buckets that have "immortal" data -- the data will live
* at least as long as the bucket.
* @param data The bucket to setaside
* @param pool The pool defining the desired lifetime of the bucket data
* @return APR_SUCCESS
*/
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_noop(apr_bucket *data,
apr_pool_t *pool);
/**
* A place holder function that signifies that the setaside function was not
* implemented for this bucket
* @param data The bucket to setaside
* @param pool The pool defining the desired lifetime of the bucket data
* @return APR_ENOTIMPL
*/
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_notimpl(apr_bucket *data,
apr_pool_t *pool);
/**
* A place holder function that signifies that the split function was not
* implemented for this bucket
* @param data The bucket to split
* @param point The location to split the bucket
* @return APR_ENOTIMPL
*/
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_split_notimpl(apr_bucket *data,
apr_size_t point);
/**
* A place holder function that signifies that the copy function was not
* implemented for this bucket
* @param e The bucket to copy
* @param c Returns a pointer to the new bucket
* @return APR_ENOTIMPL
*/
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_copy_notimpl(apr_bucket *e,
apr_bucket **c);
/**
* A place holder function that signifies that this bucket does not need
* to do anything special to be destroyed. That's only the case for buckets
* that either have no data (metadata buckets) or buckets whose data pointer
* points to something that's not a bucket-type-specific structure, as with
* simple buckets where data points to a string and pipe buckets where data
* points directly to the apr_file_t.
* @param data The bucket data to destroy
*/
APU_DECLARE_NONSTD(void) apr_bucket_destroy_noop(void *data);
/**
* There is no apr_bucket_destroy_notimpl, because destruction is required
* to be implemented (it could be a noop, but only if that makes sense for
* the bucket type)
*/
/* There is no apr_bucket_read_notimpl, because it is a required function
*/
/* All of the bucket types implemented by the core */
/**
* The flush bucket type. This signifies that all data should be flushed to
* the next filter. The flush bucket should be sent with the other buckets.
*/
APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_flush;
/**
* The EOS bucket type. This signifies that there will be no more data, ever.
* All filters MUST send all data to the next filter when they receive a
* bucket of this type
*/
APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_eos;
/**
* The FILE bucket type. This bucket represents a file on disk
*/
APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_file;
/**
* The HEAP bucket type. This bucket represents a data allocated from the
* heap.
*/
APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_heap;
#if APR_HAS_MMAP
/**
* The MMAP bucket type. This bucket represents an MMAP'ed file
*/
APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_mmap;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -