util_lock.c revision 99d46a23c6eac800f327b29f8009f7d7da986230
92adf051614160febf3e95c5b51ffd0a0908f052wrowe/* Licensed to the Apache Software Foundation (ASF) under one or more
92adf051614160febf3e95c5b51ffd0a0908f052wrowe * contributor license agreements. See the NOTICE file distributed with
a7ff1335befc75bdbfc0addba7306dec7bb6202ccolm * this work for additional information regarding copyright ownership.
92adf051614160febf3e95c5b51ffd0a0908f052wrowe * The ASF licenses this file to You under the Apache License, Version 2.0
92adf051614160febf3e95c5b51ffd0a0908f052wrowe * (the "License"); you may not use this file except in compliance with
92adf051614160febf3e95c5b51ffd0a0908f052wrowe * the License. You may obtain a copy of the License at
92adf051614160febf3e95c5b51ffd0a0908f052wrowe * Unless required by applicable law or agreed to in writing, software
92adf051614160febf3e95c5b51ffd0a0908f052wrowe * distributed under the License is distributed on an "AS IS" BASIS,
92adf051614160febf3e95c5b51ffd0a0908f052wrowe * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
92adf051614160febf3e95c5b51ffd0a0908f052wrowe * See the License for the specific language governing permissions and
92adf051614160febf3e95c5b51ffd0a0908f052wrowe * limitations under the License.
92adf051614160febf3e95c5b51ffd0a0908f052wrowe** DAV repository-independent lock functions
92adf051614160febf3e95c5b51ffd0a0908f052wrowe/* ---------------------------------------------------------------
92adf051614160febf3e95c5b51ffd0a0908f052wrowe** Property-related lock functions
92adf051614160febf3e95c5b51ffd0a0908f052wrowe** dav_lock_get_activelock: Returns a <lockdiscovery> containing
92adf051614160febf3e95c5b51ffd0a0908f052wrowe** an activelock element for every item in the lock_discovery tree
92adf051614160febf3e95c5b51ffd0a0908f052wroweDAV_DECLARE(const char *) dav_lock_get_activelock(request_rec *r,
92adf051614160febf3e95c5b51ffd0a0908f052wrowe const dav_hooks_locks *hooks = DAV_GET_HOOKS_LOCKS(r);
92adf051614160febf3e95c5b51ffd0a0908f052wrowe /* If no locks or no lock provider, there are no locks */
92adf051614160febf3e95c5b51ffd0a0908f052wrowe ** Since resourcediscovery is defined with (activelock)*,
92adf051614160febf3e95c5b51ffd0a0908f052wrowe ** <D:activelock/> shouldn't be necessary for an empty lock.
92adf051614160febf3e95c5b51ffd0a0908f052wrowe ** Note: it could be interesting to sum the lengths of the owners
92adf051614160febf3e95c5b51ffd0a0908f052wrowe ** and locktokens during this loop. However, the buffer
92adf051614160febf3e95c5b51ffd0a0908f052wrowe ** mechanism provides some rough padding so that we don't
92adf051614160febf3e95c5b51ffd0a0908f052wrowe ** really need to have an exact size. Further, constructing
92adf051614160febf3e95c5b51ffd0a0908f052wrowe ** locktoken strings could be relatively expensive.
695cbdea48fde06a0da432a4e3a4a316d7751d0achrisd for (lock_scan = lock; lock_scan != NULL; lock_scan = lock_scan->next)
a7ff1335befc75bdbfc0addba7306dec7bb6202ccolm /* if a buffer was not provided, then use an internal buffer */
92adf051614160febf3e95c5b51ffd0a0908f052wrowe /* reset the length before we start appending stuff */
92adf051614160febf3e95c5b51ffd0a0908f052wrowe /* prep the buffer with a "good" size */
92adf051614160febf3e95c5b51ffd0a0908f052wrowe /* ### crap. design error */
92adf051614160febf3e95c5b51ffd0a0908f052wrowe "DESIGN ERROR: attempted to product an "
92adf051614160febf3e95c5b51ffd0a0908f052wrowe "activelock element from a partial, indirect "
92adf051614160febf3e95c5b51ffd0a0908f052wrowe "lock record. Creating an XML parsing error "
92adf051614160febf3e95c5b51ffd0a0908f052wrowe "to ease detection of this situation: <");
92adf051614160febf3e95c5b51ffd0a0908f052wrowe dav_buffer_append(p, pbuf, "<D:activelock>" DEBUG_CR "<D:locktype>");
92adf051614160febf3e95c5b51ffd0a0908f052wrowe /* ### internal error. log something? */
92adf051614160febf3e95c5b51ffd0a0908f052wrowe dav_buffer_append(p, pbuf, "</D:locktype>" DEBUG_CR "<D:lockscope>");
92adf051614160febf3e95c5b51ffd0a0908f052wrowe /* ### internal error. log something? */
92adf051614160febf3e95c5b51ffd0a0908f052wrowe dav_buffer_append(p, pbuf, "</D:lockscope>" DEBUG_CR);
92adf051614160febf3e95c5b51ffd0a0908f052wrowe ** This contains a complete, self-contained <DAV:owner> element,
92adf051614160febf3e95c5b51ffd0a0908f052wrowe ** with namespace declarations and xml:lang handling. Just drop
92adf051614160febf3e95c5b51ffd0a0908f052wrowe sprintf(tmp, "Second-%lu", (long unsigned int)(lock->timeout - now));
92adf051614160febf3e95c5b51ffd0a0908f052wrowe "<D:href>");
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);
!= NULL) {
return err;
return err;
return NULL;
return err;
return NULL;
return err;
int result;
return OK;
return HTTP_INTERNAL_SERVER_ERROR;
/* At this point, lock_resource/locktoken refers to a direct lock (key), ie
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;