util_lock.c revision 866b521be8a30b2798ad3c3b73de5e965edd7c2f
8a3a703eae0e35f674b189181609545c6fc77a09rbb/* ====================================================================
8a3a703eae0e35f674b189181609545c6fc77a09rbb * The Apache Software License, Version 1.1
8a3a703eae0e35f674b189181609545c6fc77a09rbb * Copyright (c) 2000 The Apache Software Foundation. All rights
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * reserved.
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * Redistribution and use in source and binary forms, with or without
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick * modification, are permitted provided that the following conditions
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin * 1. Redistributions of source code must retain the above copyright
8a3a703eae0e35f674b189181609545c6fc77a09rbb * notice, this list of conditions and the following disclaimer.
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * 2. Redistributions in binary form must reproduce the above copyright
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * notice, this list of conditions and the following disclaimer in
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * the documentation and/or other materials provided with the
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * distribution.
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * 3. The end-user documentation included with the redistribution,
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * if any, must include the following acknowledgment:
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * "This product includes software developed by the
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick * Apache Software Foundation (http://www.apache.org/)."
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick * Alternately, this acknowledgment may appear in the software itself,
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick * if and wherever such third-party acknowledgments normally appear.
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * 4. The names "Apache" and "Apache Software Foundation" must
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * not be used to endorse or promote products derived from this
8a3a703eae0e35f674b189181609545c6fc77a09rbb * software without prior written permission. For written
e379fc6d7f79163700290d92ce75deb4f3005301jerenkrantz * permission, please contact apache@apache.org.
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * 5. Products derived from this software may not be called "Apache",
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * nor may "Apache" appear in their name, without prior written
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * permission of the Apache Software Foundation.
8a3a703eae0e35f674b189181609545c6fc77a09rbb * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
8a3a703eae0e35f674b189181609545c6fc77a09rbb * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
8a3a703eae0e35f674b189181609545c6fc77a09rbb * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
e379fc6d7f79163700290d92ce75deb4f3005301jerenkrantz * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
8a3a703eae0e35f674b189181609545c6fc77a09rbb * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
8a3a703eae0e35f674b189181609545c6fc77a09rbb * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
8a3a703eae0e35f674b189181609545c6fc77a09rbb * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
8a3a703eae0e35f674b189181609545c6fc77a09rbb * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
8a3a703eae0e35f674b189181609545c6fc77a09rbb * SUCH DAMAGE.
e379fc6d7f79163700290d92ce75deb4f3005301jerenkrantz * ====================================================================
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * This software consists of voluntary contributions made by many
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * individuals on behalf of the Apache Software Foundation. For more
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron * information on the Apache Software Foundation, please see
e379fc6d7f79163700290d92ce75deb4f3005301jerenkrantz** DAV repository-independent lock functions
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron/* ---------------------------------------------------------------
8a3a703eae0e35f674b189181609545c6fc77a09rbb** Property-related lock functions
8a3a703eae0e35f674b189181609545c6fc77a09rbb** dav_lock_get_activelock: Returns a <lockdiscovery> containing
8a3a703eae0e35f674b189181609545c6fc77a09rbb** an activelock element for every item in the lock_discovery tree
3fd3bfa088552c272fe6e3ff7f86b07db81d8351trawickconst char *dav_lock_get_activelock(request_rec *r, dav_lock *lock,
fb50cf6056a42f94cc9e8eeabea1eb8d05e0aefcaaron const dav_hooks_locks *hooks = DAV_GET_HOOKS_LOCKS(r);
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick /* If no locks or no lock provider, there are no locks */
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick ** Since resourcediscovery is defined with (activelock)*,
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick ** <D:activelock/> shouldn't be necessary for an empty lock.
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick ** Note: it could be interesting to sum the lengths of the owners
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick ** and locktokens during this loop. However, the buffer
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick ** mechanism provides some rough padding so that we don't
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick ** really need to have an exact size. Further, constructing
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick ** locktoken strings could be relatively expensive.
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick for (lock_scan = lock; lock_scan != NULL; lock_scan = lock_scan->next)
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick /* if a buffer was not provided, then use an internal buffer */
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick /* reset the length before we start appending stuff */
9a60abfb324ea66f9d7089b856f315efeb7056b4trawick /* prep the buffer with a "good" size */
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin if (lock->rectype == DAV_LOCKREC_INDIRECT_PARTIAL) {
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin /* ### crap. design error */
41b22313b4c3a954f09962390d3d989c4040feabtrawick "DESIGN ERROR: attempted to product an "
41b22313b4c3a954f09962390d3d989c4040feabtrawick "activelock element from a partial, indirect "
41b22313b4c3a954f09962390d3d989c4040feabtrawick "lock record. Creating an XML parsing error "
41b22313b4c3a954f09962390d3d989c4040feabtrawick "to ease detection of this situation: <");
41b22313b4c3a954f09962390d3d989c4040feabtrawick dav_buffer_append(p, pbuf, "<D:activelock>" DEBUG_CR "<D:locktype>");
41b22313b4c3a954f09962390d3d989c4040feabtrawick /* ### internal error. log something? */
7f124220a03771db40bfb8b81211e5871508d42dtrawick dav_buffer_append(p, pbuf, "</D:locktype>" DEBUG_CR "<D:lockscope>");
7f124220a03771db40bfb8b81211e5871508d42dtrawick /* ### internal error. log something? */
4fdee331ff7bf6cdf171092d70a95334335fdd7btrawick dav_buffer_append(p, pbuf, "</D:lockscope>" DEBUG_CR);
err);
const char *text;
apr_psprintf(p,
return NULL;
return NULL;
return err;
return NULL;
depth = 0;
return err;
if (depth > 0) {
ctx.r = r;
return err;
return NULL;
return NULL;
locks);
return err;
return NULL;
return err;
return NULL;
return err;
int result;
return HTTP_INTERNAL_SERVER_ERROR;
return HTTP_INTERNAL_SERVER_ERROR;
/* At this point, lock_resource/locktoken refers to a direct lock (key), ie
return HTTP_INTERNAL_SERVER_ERROR;
ctx.r = r;
return result;
return NULL;
** locks on the collection should be inherited to the resource/collection.
int use_parent)
if (use_parent) {
return err;
return err;
return NULL;
ctx.r = r;
return DAV_RESOURCE_EXISTS;
int locks_present;
** Apache sets r->filename to known-dir/unknown-file and r->path_info
return DAV_RESOURCE_NULL;
r->filename);
return DAV_RESOURCE_ERROR;
if (locks_present)
return DAV_RESOURCE_LOCK_NULL;
return DAV_RESOURCE_NULL;
int resource_state,
int depth)
if (depth > 0 &&
return err;
err);
return err;
return NULL;