📄 apr_tables.h
字号:
/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */#ifndef APR_TABLES_H#define APR_TABLES_H#include "apr.h"#include "apr_pools.h"#if APR_HAVE_STDARG_H#include <stdarg.h> /* for va_list */#endif#ifdef __cplusplusextern "C" {#endif /* __cplusplus *//* * Define the structures used by the APR general-purpose library. *//** * @package APR Table library *//* * Memory allocation stuff, like pools, arrays, and tables. Pools * and tables are opaque structures to applications, but arrays are * published. */typedef struct apr_table_t apr_table_t;typedef struct apr_array_header_t apr_array_header_t;/** An opaque array type */struct apr_array_header_t { /** The pool the array is allocated out of */ apr_pool_t *cont; /** The amount of memory allocated for each element of the array */ int elt_size; /** The number of active elements in the array */ int nelts; /** The number of elements allocated in the array */ int nalloc; /** The elements in the array */ char *elts;};/** The opaque string-content table type */struct apr_table_t { /* This has to be first to promote backwards compatibility with * older modules which cast a apr_table_t * to an apr_array_header_t *... * they should use the table_elts() function for most of the * cases they do this for. */ /** The underlying array for the table */ apr_array_header_t a;#ifdef MAKE_TABLE_PROFILE /** Who created the array. */ void *creator;#endif};/** * The (opaque) structure for string-content tables. */typedef struct apr_table_entry_t apr_table_entry_t;/** The type for each entry in a string-content table */struct apr_table_entry_t { /** The key for the current table entry */ char *key; /* maybe NULL in future; * check when iterating thru table_elts */ /** The value for the current table entry */ char *val;};/** * Get the elements from a table * @param t The table * @return An array containing the contents of the table * @deffunc apr_array_header_t *apr_table_elts(apr_table_t *t) */#define apr_table_elts(t) ((apr_array_header_t *)(t))/** * Determine if the table is empty * @param t The table to check * @return True if empty, Falso otherwise * @deffunc int apr_is_empty_table(apr_table_t *t) */#define apr_is_empty_table(t) (((t) == NULL) \ || (((apr_array_header_t *)(t))->nelts == 0))/** * Create an array * @param p The pool to allocate the memory out of * @param nelts the number of elements in the initial array * @param elt_size The size of each element in the array. * @return The new array * @deffunc apr_array_header_t *apr_array_make(struct apr_pool_t *p, int nelts, int elt_size) */APR_DECLARE(apr_array_header_t *) apr_array_make(struct apr_pool_t *p, int nelts, int elt_size);/** * Add a new element to an array * @param arr The array to add an element to. * @return Location for the new element in the array. * @tip If there are no free spots in the array, then this function will * allocate new space for the new element. * @deffunc void *apr_array_push(apr_array_header_t *arr) */APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr);/** * Concatenate two arrays together * @param dst The destination array, and the one to go first in the combined * array * @param src The source array to add to the destination array * @deffunc void apr_array_cat(apr_array_header_t *dst, const apr_array_header_t *src) */APR_DECLARE(void) apr_array_cat(apr_array_header_t *dst, const apr_array_header_t *src);/** * Copy the entire array * @param p The pool to allocate the copy of the array out of * @param arr The array to copy * @return An exact copy of the array passed in * @deffunc apr_array_header_t *apr_array_copy(apr_pool_t *p, const apr_array_header_t *arr) * @tip The alternate apr_array_copy_hdr copies only the header, and arranges * for the elements to be copied if (and only if) the code subsequently does * a push or arraycat. */APR_DECLARE(apr_array_header_t *) apr_array_copy(struct apr_pool_t *p, const apr_array_header_t *arr);/** * Copy the headers of the array, and arrange for the elements to be copied if * and only if the code subsequently does a push or arraycat. * @param p The pool to allocate the copy of the array out of * @param arr The array to copy * @return An exact copy of the array passed in * @deffunc apr_array_header_t *apr_array_copy_hdr(apr_pool_t *p, const apr_array_header_t *arr) * @tip The alternate apr_array_copy copies the *entire* array. */APR_DECLARE(apr_array_header_t *) apr_array_copy_hdr(struct apr_pool_t *p, const apr_array_header_t *arr);/** * Append one array to the end of another, creating a new array in the process. * @param p The pool to allocate the new array out of * @param first The array to put first in the new array. * @param second The array to put second in the new array. * @param return A new array containing the data from the two arrays passed in. * @deffunc apr_array_header_t *apr_array_append(apr_pool_t *p, const apr_array_header_t *first, const apr_array_header_t *second)*/APR_DECLARE(apr_array_header_t *) apr_array_append(struct apr_pool_t *p, const apr_array_header_t *first, const apr_array_header_t *second);/** * Generates a new string from the apr_pool_t containing the concatenated * sequence of substrings referenced as elements within the array. The string * will be empty if all substrings are empty or null, or if there are no * elements in the array. If sep is non-NUL, it will be inserted between * elements as a separator. * @param p The pool to allocate the string out of * @param arr The array to generate the string from * @param sep The separator to use
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -