util.c revision 6f15570e3adc0faf87bf55f70857028276fc9e32
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina/* ====================================================================
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * The Apache Software License, Version 1.1
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * Redistribution and use in source and binary forms, with or without
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * modification, are permitted provided that the following conditions
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * 1. Redistributions of source code must retain the above copyright
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * notice, this list of conditions and the following disclaimer.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * 2. Redistributions in binary form must reproduce the above copyright
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * notice, this list of conditions and the following disclaimer in
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * the documentation and/or other materials provided with the
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * distribution.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * 3. The end-user documentation included with the redistribution,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * if any, must include the following acknowledgment:
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * "This product includes software developed by the
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * Apache Software Foundation (http://www.apache.org/)."
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * Alternately, this acknowledgment may appear in the software itself,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * if and wherever such third-party acknowledgments normally appear.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * 4. The names "Apache" and "Apache Software Foundation" must
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * not be used to endorse or promote products derived from this
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * software without prior written permission. For written
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * permission, please contact apache@apache.org.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * 5. Products derived from this software may not be called "Apache",
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * nor may "Apache" appear in their name, without prior written
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * permission of the Apache Software Foundation.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * SUCH DAMAGE.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * ====================================================================
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * This software consists of voluntary contributions made by many
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * individuals on behalf of the Apache Software Foundation. For more
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * information on the Apache Software Foundation, please see
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina** DAV extension module for Apache 2.0.*
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina** - various utilities, repository-independent
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel BřezinaDAV_DECLARE(dav_error*) dav_new_error(apr_pool_t *p, int status,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina dav_error *err = apr_pcalloc(p, sizeof(*err));
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* DBG3("dav_new_error: %d %d %s", status, error_id, desc ? desc : "(no desc)"); */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel BřezinaDAV_DECLARE(dav_error*) dav_new_error_tag(apr_pool_t *p, int status,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina dav_error *err = dav_new_error(p, status, error_id, desc);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel BřezinaDAV_DECLARE(dav_error*) dav_push_error(apr_pool_t *p, int status,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina dav_error *err = apr_pcalloc(p, sizeof(*err));
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel BřezinaDAV_DECLARE(void) dav_check_bufsize(apr_pool_t * p, dav_buffer *pbuf,
35fa5a83ce8badf6bc868937047f44c3f32b7c28Sumit Bose /* grow the buffer if necessary */
35fa5a83ce8badf6bc868937047f44c3f32b7c28Sumit Bose if (pbuf->cur_len + extra_needed > pbuf->alloc_len) {
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina pbuf->alloc_len += extra_needed + DAV_BUFFER_PAD;
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel BřezinaDAV_DECLARE(void) dav_set_bufsize(apr_pool_t * p, dav_buffer *pbuf,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* NOTE: this does not retain prior contents */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* NOTE: this function is used to init the first pointer, too, since
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina the PAD will be larger than alloc_len (0) for zeroed structures */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* grow if we don't have enough for the requested size plus padding */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina if (size + DAV_BUFFER_PAD > pbuf->alloc_len) {
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* set the new length; min of MINSIZE */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina/* initialize a buffer and copy the specified (null-term'd) string into it */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel BřezinaDAV_DECLARE(void) dav_buffer_init(apr_pool_t *p, dav_buffer *pbuf,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina const char *str)
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina/* append a string to the end of the buffer, adjust length */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel BřezinaDAV_DECLARE(void) dav_buffer_append(apr_pool_t *p, dav_buffer *pbuf,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina const char *str)
const char *str)
int must_be_absolute)
const char *scheme;
char *new_file;
const char *domain;
return result;
return result;
return result;
return result;
** http_vhost.c::matches_aliases function.
** For now, qualify unqualified comp.hostnames with
return result;
return result;
return child;
return NULL;
int strip_white)
char *cdata;
int found_count = 0;
++found_count;
++found_count;
if (len == 0)
if (!strip_white
return found_text;
s += tlen;
s += tlen;
if (strip_white) {
++cdata;
return cdata;
return xi;
const char *uri)
const char *prefix;
return prefix;
return prefix;
const char *prefix)
const char *uri)
const void *prefix;
void *uri;
return DAV_TIMEOUT_INFINITE;
return DAV_TIMEOUT_INFINITE;
return DAV_TIMEOUT_INFINITE;
return NULL;
return ih;
const char *state_token,
if (t == dav_if_opaquelock) {
return err;
return NULL;
char *sp;
char *token;
token++;
return NULL;
return token;
char *str;
char *list;
const char *state_token;
int condition;
return NULL;
while (*str) {
switch(*str) {
while (*list) {
switch (*list) {
return err;
return err;
list++;
str++;
return NULL;
int flags,
request_rec *r)
const char *uri;
const char *etag;
int num_matched;
int num_that_apply;
int seen_locktoken;
return dav_push_error(p,
err);
if (seen_locktoken)
return NULL;
return NULL;
num_that_apply = 0;
case dav_if_etag:
reason =
goto state_list_failed;
&& !mismatch) {
reason =
goto state_list_failed;
case dav_if_opaquelock:
reason =
goto state_list_failed;
num_matched = 0;
reason =
goto state_list_failed;
(!r->user ||
const char *errmsg;
r->user,
if (num_matched == 0
reason =
goto state_list_failed;
if (seen_locktoken) {
return NULL;
if (num_that_apply == 0) {
if (seen_locktoken)
return NULL;
locks_hooks)) {
return NULL;
apr_psprintf(p,
return NULL;
return NULL;
return err;
return NULL;
int result;
int lock_db_opened_locally = 0;
#if DAV_DEBUG
return err;
return err;
ctx.r = r;
&work_buf, r);
return err;
return err;
return NULL;
--idx;
return s2;
NULL);
request_rec *r,
int *auto_checkout)
*auto_checkout = 0;
err);
err);
return NULL;
/* see mod_dav.h for docco */
request_rec *r,
int parent_only,
return NULL;
goto done;
goto done;
int checkout_parent;
!= NULL) {
goto done;
if (!checkout_parent) {
goto done;
!= NULL)
err);
goto done;
if (parent_only)
goto done;
err);
goto done;
int checkout_resource;
goto done;
if (!checkout_resource) {
goto done;
!= NULL)
err);
goto done;
done:
return err;
return NULL;
/* see mod_dav.h for docco */
request_rec *r,
int undo,
int unlock,
return NULL;
if (undo) {
err);
err);
err);
return NULL;
!= NULL) {
err);
!= NULL) {
err);
return NULL;