util.c revision 01e8aca9299a0b872414c24c8b7724d6f88ae665
842ae4bd224140319ae7feec1872b93dfd491143fielding/* ====================================================================
842ae4bd224140319ae7feec1872b93dfd491143fielding * The Apache Software License, Version 1.1
842ae4bd224140319ae7feec1872b93dfd491143fielding * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
842ae4bd224140319ae7feec1872b93dfd491143fielding * reserved.
2d2eda71267231c2526be701fe655db125852c1ffielding * Redistribution and use in source and binary forms, with or without
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * modification, are permitted provided that the following conditions
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * 1. Redistributions of source code must retain the above copyright
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * notice, this list of conditions and the following disclaimer.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * 2. Redistributions in binary form must reproduce the above copyright
2d2eda71267231c2526be701fe655db125852c1ffielding * notice, this list of conditions and the following disclaimer in
2d2eda71267231c2526be701fe655db125852c1ffielding * the documentation and/or other materials provided with the
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * distribution.
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * 3. The end-user documentation included with the redistribution,
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * if any, must include the following acknowledgment:
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * "This product includes software developed by the
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * Apache Software Foundation (http://www.apache.org/)."
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * Alternately, this acknowledgment may appear in the software itself,
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * if and wherever such third-party acknowledgments normally appear.
2d2eda71267231c2526be701fe655db125852c1ffielding * 4. The names "Apache" and "Apache Software Foundation" must
2d2eda71267231c2526be701fe655db125852c1ffielding * not be used to endorse or promote products derived from this
2d2eda71267231c2526be701fe655db125852c1ffielding * software without prior written permission. For written
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb * permission, please contact apache@apache.org.
92f3af936ce61f25358a3ee4f28df2f6d62040dfdreid * 5. Products derived from this software may not be called "Apache",
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb * nor may "Apache" appear in their name, without prior written
c9a95767fbf0f5fb0976a06b97a256033925e433rbb * permission of the Apache Software Foundation.
2d2eda71267231c2526be701fe655db125852c1ffielding * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
2d2eda71267231c2526be701fe655db125852c1ffielding * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2d2eda71267231c2526be701fe655db125852c1ffielding * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2d2eda71267231c2526be701fe655db125852c1ffielding * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
52de7a47876ce1748910cf3a0ee97f78842fab54rederpj * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52de7a47876ce1748910cf3a0ee97f78842fab54rederpj * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
52de7a47876ce1748910cf3a0ee97f78842fab54rederpj * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
52de7a47876ce1748910cf3a0ee97f78842fab54rederpj * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
52de7a47876ce1748910cf3a0ee97f78842fab54rederpj * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
52de7a47876ce1748910cf3a0ee97f78842fab54rederpj * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
52de7a47876ce1748910cf3a0ee97f78842fab54rederpj * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * SUCH DAMAGE.
fd492f9543f14fb5bae78e04b135c3448eb9cc56rbb * ====================================================================
fd492f9543f14fb5bae78e04b135c3448eb9cc56rbb * This software consists of voluntary contributions made by many
fd492f9543f14fb5bae78e04b135c3448eb9cc56rbb * individuals on behalf of the Apache Software Foundation. For more
2d2eda71267231c2526be701fe655db125852c1ffielding * information on the Apache Software Foundation, please see
2d2eda71267231c2526be701fe655db125852c1ffielding * Portions of this software are based upon public domain software
2d2eda71267231c2526be701fe655db125852c1ffielding * originally written at the National Center for Supercomputing Applications,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * University of Illinois, Urbana-Champaign.
742318b93e89c311f66b55f426c4d9cf2c14628bjim * util.c: string utility things
2d2eda71267231c2526be701fe655db125852c1ffielding * 3/21/93 Rob McCool
8af88bd6958b80c224e964892b8237720b13ab1ajerenkrantz * 1995-96 Many changes by the Apache Software Foundation
50e60f30bdc074fbc887f0b98f4d570457ac97c9brianp/* Debugging aid:
50e60f30bdc074fbc887f0b98f4d570457ac97c9brianp * #define DEBUG to trace all cfg_open*()/cfg_closefile() calls
50e60f30bdc074fbc887f0b98f4d570457ac97c9brianp * #define DEBUG_CFG_LINES to trace every line read from the config files
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* A bunch of functions in util.c scan strings looking for certain characters.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * To make that more efficient we encode a lookup table. The test_char_table
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * is generated automatically by gen_test_char.c.
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein/* we assume the folks using this ensure 0 <= c < 256... which means
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * you need a cast to (unsigned char) first, you can't just plug a
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * char in here and get it to work, because if char is signed then it
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * will first be sign extended.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define TEST_CHAR(c, f) (test_char_table[(unsigned)(c)] & (f))
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * Examine a field value (such as a media-/content-type) string and return
742318b93e89c311f66b55f426c4d9cf2c14628bjim * it sans any parameters; e.g., strip off any ';charset=foo' and the like.
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAP_DECLARE(char *) ap_field_noparam(apr_pool_t *p, const char *intype)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb const char *semi;
d82d78a97558238d16c52ec5278fe921bb7d7ec3brianpAP_DECLARE(char *) ap_ht_time(apr_pool_t *p, apr_time_t t, const char *fmt, int gmt)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb const char *f;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* Convert %Z to "GMT" and %z to "+0000";
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * on hosts that do not have a time zone string in struct tm,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * strftime must assume its argument is local time.
3d96ee83babeec32482c9082c9426340cee8c44dwrowe for(strp = tf, f = fmt; strp < tf + sizeof(tf) - 6 && (*strp = *f)
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein ; f++, strp++) {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb if (*f != '%') continue;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb switch (f[1]) {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb *++strp = *++f;
2d2eda71267231c2526be701fe655db125852c1ffielding /* check return code? */
2d2eda71267231c2526be701fe655db125852c1ffielding apr_strftime(ts, &retcode, MAX_STRING_LEN, fmt, &xt);
742318b93e89c311f66b55f426c4d9cf2c14628bjim/* Roy owes Rob beer. */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* Rob owes Roy dinner. */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* These legacy comments would make a lot more sense if Roy hadn't
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * replaced the old later_than() routine with util_date.c.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * Well, okay, they still wouldn't make any sense.
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm/* Match = 0, NoMatch = 1, Abort = -1
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein * Based loosely on sections of wildmat.c by Rich Salz
23ff73a56371e21f16744cb94d06399b877829f1rbb * Hmmm... shouldn't this really go component by component?
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAP_DECLARE(int) ap_strcmp_match(const char *str, const char *exp)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb for (x = 0, y = 0; exp[y]; ++y, ++x) {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb return -1;
23ff73a56371e21f16744cb94d06399b877829f1rbb while (str[x]) {
62db15de4c1f335a64d45821796ae197cff94ef8rbb return -1;
62db15de4c1f335a64d45821796ae197cff94ef8rbbAP_DECLARE(int) ap_strcasecmp_match(const char *str, const char *exp)
62db15de4c1f335a64d45821796ae197cff94ef8rbb for (x = 0, y = 0; exp[y]; ++y, ++x) {
62db15de4c1f335a64d45821796ae197cff94ef8rbb return -1;
48d2edbfb84e5559b5da0f8d614ccab805cc67a8rbb while (str[x]) {
62db15de4c1f335a64d45821796ae197cff94ef8rbb if ((ret = ap_strcasecmp_match(&str[x++], &exp[y])) != 1)
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar return -1;
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar else if ((exp[y] != '?') && (apr_tolower(str[x]) != apr_tolower(exp[y])))
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh/* We actually compare the canonical root to this root, (but we don't
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * waste time checking the case), since every use of this function in
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * httpd-2.0 tests if the path is 'proper', meaning we've already passed
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * it through apr_filepath_merge, or we haven't.
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianhAP_DECLARE(int) ap_os_is_path_absolute(apr_pool_t *p, const char *dir)
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh const char *newpath;
11e076839c8d5a82d55e710194d0daac51390dbdsf if (apr_filepath_root(&newpath, &dir, 0, p) != APR_SUCCESS
599c5abcc7fec60611956f56b732eca033c287d2pquerna || strncmp(newpath, ourdir, strlen(newpath)) != 0) {
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar register int x;
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar for (x = 0; str[x]; x++)
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar * Here's a pool-based interface to POSIX regex's regcomp().
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar * Note that we return regex_t instead of being passed one.
3d96ee83babeec32482c9082c9426340cee8c44dwrowe * The reason is that if you use an already-used regex_t structure,
742318b93e89c311f66b55f426c4d9cf2c14628bjim * the memory that you've already allocated gets forgotten, and
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar * regfree() doesn't clear it. So we don't allow it.
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coarAP_DECLARE(regex_t *) ap_pregcomp(apr_pool_t *p, const char *pattern,
2864362ca8266097928e84f101010bdf814ffa08stoddard apr_pool_cleanup_register(p, (void *) preg, regex_cleanup, regex_cleanup);
bf648cbfa4a723c9c02fe8444103cd41ed8642d0wroweAP_DECLARE(void) ap_pregfree(apr_pool_t *p, regex_t * reg)
2864362ca8266097928e84f101010bdf814ffa08stoddard apr_pool_cleanup_kill(p, (void *) reg, regex_cleanup);
af7cd2711a9737c0a2aa1b8475455a7dd8ce6113covener * Similar to standard strstr() but we ignore case in this version.
af7cd2711a9737c0a2aa1b8475455a7dd8ce6113covener * Based on the strstr() implementation further below.
af7cd2711a9737c0a2aa1b8475455a7dd8ce6113covenerAP_DECLARE(char *) ap_strcasestr(const char *s1, const char *s2)
2d2eda71267231c2526be701fe655db125852c1ffielding /* an empty s2 */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb return((char *)s1);
61fd0cab072a05b855cbef9c585702401ac5ae29rbb while(1) {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb for ( ; (*s1 != '\0') && (apr_tolower(*s1) != apr_tolower(*s2)); s1++);
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* found first character of s2, see if the rest matches */
b5c963a560a55d08763229330dc661b16b726da0sf /* both strings ended together */
b5c963a560a55d08763229330dc661b16b726da0sf return((char *)s1);
b5c963a560a55d08763229330dc661b16b726da0sf /* second string ended, a match */
b5c963a560a55d08763229330dc661b16b726da0sf /* didn't find a match here, try starting at next character in s1 */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb return((char *)s1);
b5c963a560a55d08763229330dc661b16b726da0sf * Returns an offsetted pointer in bigstring immediately after
b5c963a560a55d08763229330dc661b16b726da0sf * prefix. Returns bigstring if bigstring doesn't start with
b5c963a560a55d08763229330dc661b16b726da0sf * prefix or if prefix is longer than bigstring while still matching.
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein * NOTE: pointer returned is relative to bigstring, so we
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * can use standard pointer comparisons in the calling function
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * (eg: test if ap_stripprefix(a,b) == a)
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAP_DECLARE(const char *) ap_stripprefix(const char *bigstring,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb const char *prefix)
64945a581b504264270920efbad4f6af0d5a1978sf const char *p1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* hit the end of bigstring! */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * Apache stub function for the regex libraries regexec() to make sure the
aecb17a45c6d3ee4729ed5f68dc4270f211ee7a8fielding * whole regex(3) API is available through the Apache (exported) namespace.
11e076839c8d5a82d55e710194d0daac51390dbdsf * This is especially important for the DSO situations of modules.
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * DO NOT MAKE A MACRO OUT OF THIS FUNCTION!
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAP_DECLARE(int) ap_regexec(regex_t *preg, const char *string,
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAP_DECLARE(size_t) ap_regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
2d2eda71267231c2526be701fe655db125852c1ffielding return regerror(errcode, preg, errbuf, errbuf_size);
3d96ee83babeec32482c9082c9426340cee8c44dwrowe/* This function substitutes for $0-$9, filling in regular expression
2d2eda71267231c2526be701fe655db125852c1ffielding * submatches. Pass it the same nmatch and pmatch arguments that you
742318b93e89c311f66b55f426c4d9cf2c14628bjim * passed ap_regexec(). pmatch should not be greater than the maximum number
d839a9822ee53ce00da24c15f2d9fe054233d342gstein * of subexpressions - i.e. one more than the re_nsub member of regex_t.
742318b93e89c311f66b55f426c4d9cf2c14628bjim * input should be the string with the $-expressions, source should be the
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * string that was matched against.
d839a9822ee53ce00da24c15f2d9fe054233d342gstein * It returns the substituted string, or NULL on error.
d839a9822ee53ce00da24c15f2d9fe054233d342gstein * Parts of this code are based on Henry Spencer's regsub(), from his
2d2eda71267231c2526be701fe655db125852c1ffielding * AT&T V8 regexp package.
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input, const char *source,
face099b681c052cb1f52176a5499661c44b2982trawick /* First pass, find the size */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb if (c == '&')
aecb17a45c6d3ee4729ed5f68dc4270f211ee7a8fielding else if (no < nmatch && pmatch[no].rm_so < pmatch[no].rm_eo) {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* Now actually fill in the string */
2d2eda71267231c2526be701fe655db125852c1ffielding if (c == '&')
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein else if (no < nmatch && pmatch[no].rm_so < pmatch[no].rm_eo) {
a44d29a3794110c558c940bd903a1930d717a7d7sf * Parse .. so we don't compromise security
742318b93e89c311f66b55f426c4d9cf2c14628bjim /* Four paseses, as per RFC 1808 */
742318b93e89c311f66b55f426c4d9cf2c14628bjim /* a) remove ./ path segments */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb if (name[l] == '.' && name[l + 1] == '/' && (l == 0 || name[l - 1] == '/'))
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh /* b) remove trailing . path, segment */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb else if (w > 1 && name[w - 1] == '.' && name[w - 2] == '/')
2d2eda71267231c2526be701fe655db125852c1ffielding /* c) remove all xx/../ segments. (including leading ../ and /../) */
fd8b91502bc200ed4cca3810560a2a570522b3debrianp if (name[l] == '.' && name[l + 1] == '.' && name[l + 2] == '/' &&
fd8b91502bc200ed4cca3810560a2a570522b3debrianp register int m = l + 3, n;
fd8b91502bc200ed4cca3810560a2a570522b3debrianp if (l >= 0) {
742318b93e89c311f66b55f426c4d9cf2c14628bjim (++n, ++m);
fd8b91502bc200ed4cca3810560a2a570522b3debrianp /* d) remove trailing xx/.. segment. */
45613d36b9466a48def0498cffa07f48980720f8jerenkrantz else if (l > 2 && name[l - 1] == '.' && name[l - 2] == '.' && name[l - 3] == '/') {
fd8b91502bc200ed4cca3810560a2a570522b3debrianp if (l >= 0) {
50e60f30bdc074fbc887f0b98f4d570457ac97c9brianp char *d, *s;
4111de96e9f75c58e77c2bdda23be83b8ebf81ccgregames /* Check for UNC names. Leave leading two slashes. */
50e60f30bdc074fbc887f0b98f4d570457ac97c9brianp *d++ = *s++;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb while (*s) {
2d2eda71267231c2526be701fe655db125852c1ffielding if ((*d++ = *s) == '/') {
2d2eda71267231c2526be701fe655db125852c1ffielding } while (*s == '/');
344f3bc38dfccf6261d5bb8d689794cde113b3d6coar * copy at most n leading directories of s into d
d5df46b7972c0c4a5ca0ba5068e238f6053c2e6ftrawick * d should be at least as large as s plus 1 extra byte
a2930b0b01bfdbaa9e5c3324266bce9ef74158c2jim * assumes n > 0
a2930b0b01bfdbaa9e5c3324266bce9ef74158c2jim * the return value is the ever useful pointer to the trailing \0 of d
a2930b0b01bfdbaa9e5c3324266bce9ef74158c2jim * MODIFIED FOR HAVE_DRIVE_LETTERS and NETWARE environments,
a2930b0b01bfdbaa9e5c3324266bce9ef74158c2jim * so that if n == 0, "/" is returned in d with n == 1
a2930b0b01bfdbaa9e5c3324266bce9ef74158c2jim * and s == "e:/test.html", "e:/" is returned in d
a2930b0b01bfdbaa9e5c3324266bce9ef74158c2jim * *** See also directory_walk in modules/http/http_request.c
a2930b0b01bfdbaa9e5c3324266bce9ef74158c2jim * examples:
a2930b0b01bfdbaa9e5c3324266bce9ef74158c2jim * /a/b, 0 ==> / (true for all platforms)
a2930b0b01bfdbaa9e5c3324266bce9ef74158c2jim * /a/b, 1 ==> /
a2930b0b01bfdbaa9e5c3324266bce9ef74158c2jim * /a/b, 2 ==> /a/
a2930b0b01bfdbaa9e5c3324266bce9ef74158c2jim * /a/b, 3 ==> /a/b/
a2930b0b01bfdbaa9e5c3324266bce9ef74158c2jim * /a/b, 4 ==> /a/b/
a2930b0b01bfdbaa9e5c3324266bce9ef74158c2jim * c:/a/b 0 ==> /
a2930b0b01bfdbaa9e5c3324266bce9ef74158c2jim * c:/a/b 1 ==> c:/
a2930b0b01bfdbaa9e5c3324266bce9ef74158c2jim * c:/a/b 2 ==> c:/a/
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * c:/a/b 3 ==> c:/a/b
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * c:/a/b 4 ==> c:/a/b
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAP_DECLARE(char *) ap_make_dirstr_prefix(char *d, const char *s, int n)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb if (n < 1) {
42ce672c516baf6e4eaed18ccc1647de2d456d8edougm *++d = '\0';
742318b93e89c311f66b55f426c4d9cf2c14628bjim return (d);
61fd0cab072a05b855cbef9c585702401ac5ae29rbb for (;;) {
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein *d++ = *s++;
7b6ba9c468f26bdb3492d5e8cb79628a3b04e8c8wrowe return (d);
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein * return the parent directory name including trailing / of the file s
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAP_DECLARE(char *) ap_make_dirstr_parent(apr_pool_t *p, const char *s)
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb return (d);
0de8f88b22d24dd57ed10b96fb594e69b6aa0072jwoolley register int x, n;
8b7047e519340545e6807c9749576a40a76b6d3frbb for (x = 0, n = 0; path[x]; x++)
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianhAP_DECLARE(char *) ap_getword_nc(apr_pool_t *atrans, char **line, char stop)
2e75499d05677dd589f7ce6b5139ae15ba049419jerenkrantzAP_DECLARE(char *) ap_getword(apr_pool_t *atrans, const char **line, char stop)
2fc50921b88defeb7127985dfe4b4130175e069ejwoolleyAP_DECLARE(char *) ap_getword_white_nc(apr_pool_t *atrans, char **line)
c9a95767fbf0f5fb0976a06b97a256033925e433rbbAP_DECLARE(char *) ap_getword_white(apr_pool_t *atrans, const char **line)
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh for (x = 0; (*line)[x]; x++) {
11e076839c8d5a82d55e710194d0daac51390dbdsfAP_DECLARE(char *) ap_getword_nulls_nc(apr_pool_t *atrans, char **line, char stop)
char *res;
if (!pos) {
return res;
++pos;
return res;
for (i = 0; i < len; ++i) {
return result;
char *res;
char quote;
++str;
if (!*str) {
++strend;
++strend;
++strend;
++strend;
return res;
return word;
const char *e2 = e;
#ifdef DEBUG
char ch;
return ch;
return (int)EOF;
return buf;
return NULL;
AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg, apr_pool_t *p, const char *name)
#ifdef DEBUG
return APR_EBADF;
#ifdef DEBUG
return status;
return status;
name);
return APR_EBADF;
return APR_SUCCESS;
void *param,
#ifdef DEBUG
return new_cfg;
return ch;
char *cp;
cp++;
cp--;
cp--;
cp--;
++src;
#ifdef DEBUG_CFG_LINES
register size_t i = 0;
if (c == EOF)
if (c == CR) {
if (c == LF) {
#ifdef DEBUG_CFG_LINES
buf[i] = c;
const unsigned char *token;
++ptr;
++ptr) {
if (in_qpair) {
in_qpair = 0;
switch (*ptr) {
++in_com;
--in_com;
return NULL;
++ptr;
return (const char *)token;
const char *tok_start;
const unsigned char *ptr;
unsigned char *pos;
char *token;
return NULL;
++ptr) {
if (in_qpair) {
in_qpair = 0;
switch (*ptr) {
addspace = 0;
addspace = 0;
++in_com;
addspace = 0;
--in_com;
addspace = 0;
addspace = 0;
return token;
const unsigned char *pos;
++ptr;
if (*ptr)
++ptr) {
if (in_qpair) {
in_qpair = 0;
if (good)
switch (*ptr) {
addspace = 0;
addspace = 0;
++in_com;
addspace = 0;
--in_com;
addspace = 0;
default : if (!good)
addspace = 0;
return good;
const char *tok_start;
char *token;
int tok_len;
++ptr;
while (*ptr)
++ptr;
return token;
const unsigned char *start_token;
if (!line)
s = (const unsigned char *)line;
start_token = s;
if (!line)
if ((lidx < 0) ||
char *cmd;
d = (unsigned char *)cmd;
s = (const unsigned char *)str;
return cmd;
register char digit;
#if !APR_CHARSET_EBCDIC
return (digit);
badesc = 0;
badpath = 0;
if (y == NULL) {
return OK;
if (badesc)
return HTTP_BAD_REQUEST;
else if (badpath)
return HTTP_NOT_FOUND;
return OK;
return where;
const unsigned char *s = (const unsigned char *)segment;
unsigned char *d = (unsigned char *)copy;
d = c2x(c, d);
return copy;
const unsigned char *s = (const unsigned char *)path;
unsigned char *d = (unsigned char *)copy;
if (!partial) {
d = c2x(c, d);
return copy;
return apr_pstrmemdup(p, s, i);
const char *src2)
char *path;
if (len1 == 0) {
char *next;
return path;
const char *p = ap_strchr_c(s, c);
if (p == NULL)
const char *p = ap_strrchr_c(s, c);
if (p == NULL)
while (*str) {
++str;
for (x = 0; p->h_aliases[x]; ++x) {
return NULL;
#ifndef MAXHOSTNAMELEN
struct hostent *p;
#ifdef BEOS_R5
if (p && p->h_addr_list[0]) {
return server_hostname;
if (!server_hostname)
return server_hostname;
/* simple 'pool' alloc()ing glue to apr_base64.c
char *decoded;
return decoded;
char *encoded;
return encoded;
char *semi;
if (semi) {
while (*str) {
++str;
if (semi) {
int newlen = 0;
newlen++;
newlen++;
inchr++;
newlen++;
inchr++;
return outstring;