Annotation of parser3/src/lib/sdbm/apr-include/apr_strings.h, revision 1.1
1.1 ! paf 1: /**@TODO paf remove unneeded functions */
! 2:
! 3: /* ====================================================================
! 4: * The Apache Software License, Version 1.1
! 5: *
! 6: * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
! 7: * reserved.
! 8: *
! 9: * Redistribution and use in source and binary forms, with or without
! 10: * modification, are permitted provided that the following conditions
! 11: * are met:
! 12: *
! 13: * 1. Redistributions of source code must retain the above copyright
! 14: * notice, this list of conditions and the following disclaimer.
! 15: *
! 16: * 2. Redistributions in binary form must reproduce the above copyright
! 17: * notice, this list of conditions and the following disclaimer in
! 18: * the documentation and/or other materials provided with the
! 19: * distribution.
! 20: *
! 21: * 3. The end-user documentation included with the redistribution,
! 22: * if any, must include the following acknowledgment:
! 23: * "This product includes software developed by the
! 24: * Apache Software Foundation (http://www.apache.org/)."
! 25: * Alternately, this acknowledgment may appear in the software itself,
! 26: * if and wherever such third-party acknowledgments normally appear.
! 27: *
! 28: * 4. The names "Apache" and "Apache Software Foundation" must
! 29: * not be used to endorse or promote products derived from this
! 30: * software without prior written permission. For written
! 31: * permission, please contact apache@apache.org.
! 32: *
! 33: * 5. Products derived from this software may not be called "Apache",
! 34: * nor may "Apache" appear in their name, without prior written
! 35: * permission of the Apache Software Foundation.
! 36: *
! 37: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
! 38: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 39: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
! 40: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
! 41: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
! 42: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
! 43: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
! 44: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
! 45: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
! 46: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
! 47: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 48: * SUCH DAMAGE.
! 49: * ====================================================================
! 50: *
! 51: * This software consists of voluntary contributions made by many
! 52: * individuals on behalf of the Apache Software Foundation. For more
! 53: * information on the Apache Software Foundation, please see
! 54: * <http://www.apache.org/>.
! 55: */
! 56:
! 57: /* Portions of this file are covered by */
! 58: /* -*- mode: c; c-file-style: "k&r" -*-
! 59:
! 60: strnatcmp.c -- Perform 'natural order' comparisons of strings in C.
! 61: Copyright (C) 2000 by Martin Pool <mbp@humbug.org.au>
! 62:
! 63: This software is provided 'as-is', without any express or implied
! 64: warranty. In no event will the authors be held liable for any damages
! 65: arising from the use of this software.
! 66:
! 67: Permission is granted to anyone to use this software for any purpose,
! 68: including commercial applications, and to alter it and redistribute it
! 69: freely, subject to the following restrictions:
! 70:
! 71: 1. The origin of this software must not be misrepresented; you must not
! 72: claim that you wrote the original software. If you use this software
! 73: in a product, an acknowledgment in the product documentation would be
! 74: appreciated but is not required.
! 75: 2. Altered source versions must be plainly marked as such, and must not be
! 76: misrepresented as being the original software.
! 77: 3. This notice may not be removed or altered from any source distribution.
! 78: */
! 79:
! 80: #ifndef APR_STRINGS_H
! 81: #define APR_STRINGS_H
! 82:
! 83: #include "apr.h"
! 84: #include "apr_errno.h"
! 85: #include "apr_pools.h"
! 86:
! 87: #define HAVE_STDARG_H 1
! 88: #if HAVE_STDARG_H
! 89: #include <stdarg.h>
! 90: #endif
! 91:
! 92:
! 93: #ifdef __cplusplus
! 94: extern "C" {
! 95: #endif /* __cplusplus */
! 96: /**
! 97: * @file apr_strings.h
! 98: * @brief APR Strings library
! 99: */
! 100: /**
! 101: * @defgroup APR_Strings String routines
! 102: * @ingroup APR
! 103: * @{
! 104: */
! 105: /**
! 106: * Do a natural order comparison of two strings.
! 107: * @param a The first string to compare
! 108: * @param b The second string to compare
! 109: * @return Either <0, 0, or >0. If the first string is less than the second
! 110: * this returns <0, if they are equivalent it returns 0, and if the
! 111: * first string is greater than second string it retuns >0.
! 112: */
! 113: APR_DECLARE(int) apr_strnatcmp(char const *a, char const *b);
! 114:
! 115: /**
! 116: * Do a natural order comparison of two strings ignoring the case of the
! 117: * strings.
! 118: * @param a The first string to compare
! 119: * @param b The second string to compare
! 120: * @return Either <0, 0, or >0. If the first string is less than the second
! 121: * this returns <0, if they are equivalent it returns 0, and if the
! 122: * first string is greater than second string it retuns >0.
! 123: */
! 124: APR_DECLARE(int) apr_strnatcasecmp(char const *a, char const *b);
! 125:
! 126: /**
! 127: * duplicate a string into memory allocated out of a pool
! 128: * @param p The pool to allocate out of
! 129: * @param s The string to duplicate
! 130: * @return The new string
! 131: */
! 132: APR_DECLARE(char *) apr_pstrdup(apr_pool_t *p, const char *s);
! 133:
! 134: /**
! 135: * Create a null-terminated string by making a copy of a sequence
! 136: * of characters and appending a null byte
! 137: * @param p The pool to allocate out of
! 138: * @param s The block of characters to duplicate
! 139: * @param n The number of characters to duplicate
! 140: * @return The new string
! 141: * @remark This is a faster alternative to apr_pstrndup, for use
! 142: * when you know that the string being duplicated really
! 143: * has 'n' or more characters. If the string might contain
! 144: * fewer characters, use apr_pstrndup.
! 145: */
! 146: APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *p, const char *s, apr_size_t n);
! 147:
! 148: /**
! 149: * duplicate the first n characters of a string into memory allocated
! 150: * out of a pool; the new string will be '\0'-terminated
! 151: * @param p The pool to allocate out of
! 152: * @param s The string to duplicate
! 153: * @param n The number of characters to duplicate
! 154: * @return The new string
! 155: */
! 156: APR_DECLARE(char *) apr_pstrndup(apr_pool_t *p, const char *s, apr_size_t n);
! 157:
! 158: /**
! 159: * Duplicate a block of memory.
! 160: *
! 161: * @param p The pool to allocate from
! 162: * @param m The memory to duplicate
! 163: * @param n The number of bytes to duplicate
! 164: * @return The new block of memory
! 165: */
! 166: APR_DECLARE(void *) apr_pmemdup(apr_pool_t *p, const void *m, apr_size_t n);
! 167:
! 168: /**
! 169: * Concatenate multiple strings, allocating memory out a pool
! 170: * @param p The pool to allocate out of
! 171: * @param ... The strings to concatenate. The final string must be NULL
! 172: * @return The new string
! 173: */
! 174: APR_DECLARE_NONSTD(char *) apr_pstrcat(apr_pool_t *p, ...);
! 175:
! 176: /**
! 177: * Concatenate multiple strings specified in a writev-style vector
! 178: * @param p The pool from which to allocate
! 179: * @param vec The strings to concatenate
! 180: * @param nvec The number of strings to concatenate
! 181: * @param nbytes (output) strlen of new string (pass in NULL to omit)
! 182: * @return The new string
! 183: */
! 184: APR_DECLARE(char *) apr_pstrcatv(apr_pool_t *p, const struct iovec *vec,
! 185: apr_size_t nvec, apr_size_t *nbytes);
! 186:
! 187: /**
! 188: * printf-style style printing routine. The data is output to a string
! 189: * allocated from a pool
! 190: * @param p The pool to allocate out of
! 191: * @param fmt The format of the string
! 192: * @param ap The arguments to use while printing the data
! 193: * @return The new string
! 194: */
! 195: APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *p, const char *fmt, va_list ap);
! 196:
! 197: /**
! 198: * copy n characters from src to dst
! 199: * @param dst The destination string
! 200: * @param src The source string
! 201: * @param dst_size The space available in dst; dst always receives
! 202: * null-termination, so if src is longer than
! 203: * dst_size, the actual number of characters copied is
! 204: * dst_size - 1.
! 205: * @remark
! 206: * <PRE>
! 207: * We re-implement this function to implement these specific changes:
! 208: * 1) strncpy() doesn't always null terminate and we want it to.
! 209: * 2) strncpy() null fills, which is bogus, esp. when copy 8byte strings
! 210: * into 8k blocks.
! 211: * 3) Instead of returning the pointer to the beginning of the
! 212: * destination string, we return a pointer to the terminating '\0'
! 213: * to allow us to check for truncation.
! 214: * </PRE>
! 215: */
! 216: APR_DECLARE(char *) apr_cpystrn(char *dst, const char *src,
! 217: apr_size_t dst_size);
! 218:
! 219: /**
! 220: * Strip spaces from a string
! 221: * @param dest The destination string. It is okay to modify the string
! 222: * in place. Namely dest == src
! 223: * @param src The string to rid the spaces from.
! 224: */
! 225: APR_DECLARE(char *) apr_collapse_spaces(char *dest, const char *src);
! 226:
! 227: /**
! 228: * Convert the arguments to a program from one string to an array of
! 229: * strings terminated by a NULL pointer
! 230: * @param str The arguments to convert
! 231: * @param argv_out Output location. This is a pointer to an array of strings.
! 232: * @param token_context Pool to use.
! 233: */
! 234: APR_DECLARE(apr_status_t) apr_tokenize_to_argv(const char *arg_str,
! 235: char ***argv_out,
! 236: apr_pool_t *token_context);
! 237:
! 238: /**
! 239: * Split a string into separate '\0'-terminated tokens. The tokens are
! 240: * delimited in the string by one or more characters from the sep
! 241: * argument.
! 242: * @param str The string to separate; this should be specified on the
! 243: * first call to apr_strtok() for a given string, and NULL
! 244: * on subsequent calls.
! 245: * @param sep The set of delimiters
! 246: * @param last Internal state saved by apr_strtok() between calls.
! 247: * @return The next token from the string
! 248: */
! 249: APR_DECLARE(char *) apr_strtok(char *str, const char *sep, char **last);
! 250:
! 251: /**
! 252: * @defgroup APR_Strings_Snprintf snprintf implementations
! 253: *
! 254: * @warning
! 255: * These are snprintf implementations based on apr_vformatter().
! 256: *
! 257: * Note that various standards and implementations disagree on the return
! 258: * value of snprintf, and side-effects due to %n in the formatting string.
! 259: * apr_snprintf (and apr_vsnprintf) behaves as follows:
! 260: *
! 261: * Process the format string until the entire string is exhausted, or
! 262: * the buffer fills. If the buffer fills then stop processing immediately
! 263: * (so no further %n arguments are processed), and return the buffer
! 264: * length. In all cases the buffer is NUL terminated. It will return the
! 265: * number of characters inserted into the buffer, not including the
! 266: * terminating NUL. As a special case, if len is 0, apr_snprintf will
! 267: * return the number of characters that would have been inserted if
! 268: * the buffer had been infinite (in this case, *buffer can be NULL)
! 269: *
! 270: * In no event does apr_snprintf return a negative number.
! 271: * @{
! 272: */
! 273:
! 274: /**
! 275: * vsnprintf routine based on apr_vformatter. This means it understands the
! 276: * same extensions.
! 277: * @param buf The buffer to write to
! 278: * @param len The size of the buffer
! 279: * @param format The format string
! 280: * @param ap The arguments to use to fill out the format string.
! 281: */
! 282: APR_DECLARE(int) apr_vsnprintf(char *buf, apr_size_t len, const char *format,
! 283: va_list ap);
! 284:
! 285: /** @} */
! 286: /**
! 287: * create a string representation of an int, allocated from a pool
! 288: * @param p The pool from which to allocate
! 289: * @param n The number to format
! 290: * @return The string representation of the number
! 291: */
! 292: APR_DECLARE(char *) apr_itoa(apr_pool_t *p, int n);
! 293:
! 294: /**
! 295: * create a string representation of a long, allocated from a pool
! 296: * @param p The pool from which to allocate
! 297: * @param n The number to format
! 298: * @return The string representation of the number
! 299: */
! 300: APR_DECLARE(char *) apr_ltoa(apr_pool_t *p, long n);
! 301:
! 302: /**
! 303: * create a string representation of an apr_off_t, allocated from a pool
! 304: * @param p The pool from which to allocate
! 305: * @param n The number to format
! 306: * @return The string representation of the number
! 307: */
! 308: APR_DECLARE(char *) apr_off_t_toa(apr_pool_t *p, apr_off_t n);
! 309:
! 310: /**
! 311: * Format a binary size (magnitiudes are 2^10 rather than 10^3) from an apr_off_t,
! 312: * as bytes, K, M, T, etc, to a four character compacted human readable string.
! 313: * @param size The size to format
! 314: * @param buf The 5 byte text buffer (counting the trailing null)
! 315: * @return The buf passed to apr_strfsize()
! 316: * @remark All negative sizes report ' - ', apr_strfsize only formats positive values.
! 317: */
! 318: APR_DECLARE(char *) apr_strfsize(apr_off_t size, char *buf);
! 319: /** @} */
! 320: #ifdef __cplusplus
! 321: }
! 322: #endif
! 323:
! 324: #endif /* !APR_STRINGS_H */
E-mail: