repos.c revision 1f6e6566a4ce31a0b95d5400c36d0aaff7a6e94a
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd/* ====================================================================
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * The Apache Software License, Version 1.1
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * Copyright (c) 2000 The Apache Software Foundation. All rights
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * reserved.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * Redistribution and use in source and binary forms, with or without
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * modification, are permitted provided that the following conditions
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * are met:
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * 1. Redistributions of source code must retain the above copyright
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * notice, this list of conditions and the following disclaimer.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * 2. Redistributions in binary form must reproduce the above copyright
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * notice, this list of conditions and the following disclaimer in
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * the documentation and/or other materials provided with the
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * distribution.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * 3. The end-user documentation included with the redistribution,
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * if any, must include the following acknowledgment:
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * "This product includes software developed by the
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * Apache Software Foundation (http://www.apache.org/)."
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd * Alternately, this acknowledgment may appear in the software itself,
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd * if and wherever such third-party acknowledgments normally appear.
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd * 4. The names "Apache" and "Apache Software Foundation" must
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd * not be used to endorse or promote products derived from this
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * software without prior written permission. For written
a76bfec941c4c5e3e1e24d7007108f4d3dac91a5nd * permission, please contact apache@apache.org.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * 5. Products derived from this software may not be called "Apache",
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * nor may "Apache" appear in their name, without prior written
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * permission of the Apache Software Foundation.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * SUCH DAMAGE.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * ====================================================================
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * This software consists of voluntary contributions made by many
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * individuals on behalf of the Apache Software Foundation. For more
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd * information on the Apache Software Foundation, please see
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd** DAV filesystem-based repository provider
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd#include "http_protocol.h" /* for ap_set_* (in dav_fs_set_headers) */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd/* to assist in debugging mod_dav's GET handling */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd#define DAV_FS_COPY_BLOCKSIZE 16384 /* copy 16k at a time */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd/* context needed to identify a resource */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd ap_pool_t *pool; /* memory storage pool associated with request */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd/* private context for doing a filesystem walk */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5ndtypedef struct {
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd/* pull this in from the other source file */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd/* forward-declare this sucker */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5ndstatic const dav_hooks_repository dav_hooks_repository_fs;
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd** The Provider ID is used to differentiate "logical" providers that use
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd** the same set of hook functions. Essentially, the ID is an instance
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd** handle and the hooks are a vtable.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd** In this module, we only have a single provider for each type, so we
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd** actually ignore the Provider ID.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd** The namespace URIs that we use. This list and the enumeration must
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd** stay in sync.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5ndstatic const char * const dav_fs_namespace_uris[] =
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd DAV_FS_URI_MYPROPS /* the namespace URI for our custom props */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd** The properties that we define.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd /* using DAV_FS_URI_DAV */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd /* using DAV_FS_URI_MYPROPS */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd/* NOTE: the magic "200" is derived from the ranges in mod_dav.h */
71fccc298df6a1540d408151a26aa22beed55d0bnd#define DAV_PROPID_FS_OURS(id) (DAV_PROPID_FS <= (id) && \
6116c12fdd3ed06d388fe6572e50a22e9320dfa5ndtypedef struct {
71fccc298df6a1540d408151a26aa22beed55d0bnd const char * name;
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd { DAV_FS_URI_DAV, "creationdate", DAV_PROPID_FS_creationdate },
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd { DAV_FS_URI_DAV, "getcontentlength", DAV_PROPID_FS_getcontentlength },
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd { DAV_FS_URI_DAV, "getlastmodified", DAV_PROPID_FS_getlastmodified },
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd { DAV_FS_URI_MYPROPS, "executable", DAV_PROPID_FS_executable },
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd /* ### these aren't FS specific */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd { DAV_FS_URI_DAV, "displayname", DAV_PROPID_FS_displayname },
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd { 0 } /* sentinel */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd/* define the dav_stream structure for our use */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd const char *pathname; /* we may need to remove it at close time */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd/* forward declaration for internal treewalkers */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5ndstatic dav_error * dav_fs_walk(dav_walker_ctx *wctx, int depth);
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd/* --------------------------------------------------------------------
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd** PRIVATE REPOSITORY FUNCTIONS
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd const char **dirpath_p,
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd const char **fname_p)
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd char *dirpath = ap_make_dirstr_parent(ctx->pool, ctx->pathname);
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd /* remove trailing slash from dirpath, unless it's the root dir */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd /* ### Win32 check */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd/* Note: picked up from ap_gm_timestr_822() */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd/* NOTE: buf must be at least DAV_TIMEBUF_SIZE chars in size */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5ndstatic void dav_format_time(int style, ap_time_t sec, char *buf)
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd /* ### what to do if fails? */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd /* ### should we use "-00:00" instead of "Z" ?? */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd /* 20 chars plus null term */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd /* RFC 822 date format; as strftime '%a, %d %b %Y %T GMT' */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd /* 29 chars plus null term */
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd "%s, %.2d %s %d %.2d:%.2d:%.2d GMT",
6116c12fdd3ed06d388fe6572e50a22e9320dfa5ndstatic ap_status_t dav_sync_write(ap_file_t *f, const char *buf,
return status;
int is_move,
ap_pool_t * p,
const char *src,
const char *dst,
!= APR_SUCCESS) {
return err;
return NULL;
int is_move,
ap_pool_t * p,
const char *src;
const char *dst;
return NULL;
return NULL;
const char *src_dir;
const char *src_file;
const char *src_state1;
const char *src_state2;
const char *dst_dir;
const char *dst_file;
const char *dst_state1;
const char *dst_state2;
#if DAV_DEBUG
pbuf);
pbuf);
return err;
const char *dirpath;
const char *fname;
const char *state1;
const char *state2;
const char *pathname;
NULL);
NULL);
return NULL;
request_rec *r,
const char *root_dir,
const char *workspace)
char *filename;
return resource;
char *dirpath;
#ifdef WIN32
return NULL;
return parent_resource;
static int dav_fs_is_same_resource(
#ifdef WIN32
static int dav_fs_is_parent_resource(
switch (mode) {
case DAV_MODE_READ:
case DAV_MODE_READ_SEEKABLE:
case DAV_MODE_WRITE_TRUNC:
case DAV_MODE_WRITE_SEEKABLE:
ds->p = p;
return NULL;
if (!commit) {
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
ap_set_etag(r);
return NULL;
static const char * dav_fs_get_pathname(
void **free_handle_p)
return NULL;
!= APR_SUCCESS) {
return NULL;
return err;
int is_move,
int depth,
return err;
return NULL;
return err;
int depth,
#if DAV_DEBUG
return err;
int can_rename = 0;
#if DAV_DEBUG
const char *dirpath;
if (!can_rename) {
return err;
return NULL;
err);
err);
int result;
if (result != 0) {
return NULL;
return err;
return NULL;
return err;
return NULL;
char *name;
return err;
return err;
return err;
return err;
return NULL;
#if DAV_DEBUG
int ns;
const int *ns_map,
const char *value;
int ns;
return DAV_PROP_INSERT_NOTME;
** properties; the NOTDEF return code indicates that dav_props.c should
return DAV_PROP_INSERT_NOTDEF;
switch (propid) {
buf);
return DAV_PROP_INSERT_NOTDEF;
case DAV_PROPID_FS_getetag:
buf);
case DAV_PROPID_FS_executable:
#ifdef WIN32
return DAV_PROP_INSERT_NOTDEF;
return DAV_PROP_INSERT_NOTDEF;
case DAV_PROPID_FS_source:
return DAV_PROP_INSERT_NOTDEF;
if (insvalue) {
return which;
#ifndef WIN32
int propid)
return DAV_PROP_RW_NOTME;
#ifndef WIN32
return DAV_PROP_RW_YES;
return DAV_PROP_RW_NO;
int operation,
void **context,
int *defer_to_dead)
char value;
return NULL;
? NULL
/* DBG3("name=%s cdata=%s f_cdata=%s",elem->name,cdata ? cdata->text : "[null]",f_cdata ? f_cdata->text : "[null]"); */
goto too_long;
goto too_long;
return NULL;
int operation,
void *context,
return NULL;
if (value)
return NULL;
int operation,
void *context,
int operation,
void *context,
if (value)
return NULL;
#ifdef WIN32
NULL,