mod_dav.h revision 78b8e4dd910f03af0a602bc4b63ad7bc69868ee3
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file mod_dav.h
* @brief DAV extension module for Apache 2.0.*
*
* @defgroup MOD_DAV mod_dav
* @ingroup APACHE_MODS
* @{
*/
#ifndef _MOD_DAV_H_
#define _MOD_DAV_H_
#include "apr_hooks.h"
#include "apr_hash.h"
#include "apr_dbm.h"
#include "apr_tables.h"
#include "httpd.h"
#include "util_filter.h"
#include "util_xml.h"
#include <limits.h> /* for INT_MAX */
#include <time.h> /* for time_t */
#ifdef __cplusplus
extern "C" {
#endif
#define DAV_VERSION AP_SERVER_BASEREVISION
#define DAV_XML_HEADER "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
#define DAV_XML_CONTENT_TYPE "text/xml; charset=\"utf-8\""
#define DAV_RESPONSE_BODY_1 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>"
#define DAV_RESPONSE_BODY_2 "</title>\n</head><body>\n<h1>"
#define DAV_RESPONSE_BODY_3 "</h1>\n<p>"
#define DAV_RESPONSE_BODY_4 "</p>\n"
#define DAV_RESPONSE_BODY_5 "</body></html>\n"
#define DAV_DO_COPY 0
#define DAV_DO_MOVE 1
#if 1
#define DAV_DEBUG 1
#define DEBUG_CR "\n"
#else
#define DEBUG_CR ""
#endif
/* Create a set of DAV_DECLARE(type), DAV_DECLARE_NONSTD(type) and
* DAV_DECLARE_DATA with appropriate export and import tags for the platform
*/
#if !defined(WIN32)
#define DAV_DECLARE_DATA
#elif defined(DAV_DECLARE_STATIC)
#define DAV_DECLARE_DATA
#elif defined(DAV_DECLARE_EXPORT)
#else
#endif
/* --------------------------------------------------------------------
**
** ERROR MANAGEMENT
*/
/*
** dav_error structure.
**
** In most cases, mod_dav uses a pointer to a dav_error structure. If the
** pointer is NULL, then no error has occurred.
**
** In certain cases, a dav_error structure is directly used. In these cases,
** a status value of 0 means that an error has not occurred.
**
** Note: this implies that status != 0 whenever an error occurs.
**
** The desc field is optional (it may be NULL). When NULL, it typically
** implies that Apache has a proper description for the specified status.
*/
typedef struct dav_error {
int status; /* suggested HTTP status (0 for no error) */
int error_id; /* DAV-specific error ID */
const char *desc; /* DAV:responsedescription and error log */
const char *namespace; /* [optional] namespace of error */
const char *tagname; /* name of error-tag */
} dav_error;
/*
** Create a new error structure. save_errno will be filled with the current
** errno value.
*/
const char *desc);
/*
** Create a new error structure with tagname and (optional) namespace;
** namespace may be NULL, which means "DAV:".
*/
const char *desc,
const char *namespace,
const char *tagname);
/*
** Push a new error description onto the stack of errors.
**
** This function is used to provide an additional description to an existing
** error.
**
** <status> should contain the caller's view of what the current status is,
** given the underlying error. If it doesn't have a better idea, then the
** caller should pass prev->status.
**
** <error_id> can specify a new error_id since the topmost description has
** changed.
*/
/* error ID values... */
/* IF: header errors */
/* Prop DB errors */
/* Predefined DB errors */
/* ### any to define?? */
/* Predefined locking system errors */
/*
** Some comments on Error ID values:
**
** The numbers do not necessarily need to be unique. Uniqueness simply means
** that two errors that have not been predefined above can be distinguished
** from each other. At the moment, mod_dav does not use this distinguishing
** feature, but it could be used in the future to collapse <response> elements
** into groups based on the error ID (and associated responsedescription).
**
** If a compute_desc is provided, then the error ID should be unique within
** the context of the compute_desc function (so the function can figure out
** what to filled into the desc).
**
** Basically, subsystems can ignore defining new error ID values if they want
** to. The subsystems *do* need to return the predefined errors when
** appropriate, so that mod_dav can figure out what to do. Subsystems can
** simply leave the error ID field unfilled (zero) if there isn't an error
** that must be placed there.
*/
/* --------------------------------------------------------------------
**
** HOOK STRUCTURES
**
** These are here for forward-declaration purposes. For more info, see
** the section title "HOOK HANDLING" for more information, plus each
** structure definition.
*/
/* forward-declare this structure */
typedef struct dav_hooks_propdb dav_hooks_propdb;
typedef struct dav_hooks_locks dav_hooks_locks;
typedef struct dav_hooks_vsn dav_hooks_vsn;
typedef struct dav_hooks_repository dav_hooks_repository;
typedef struct dav_hooks_liveprop dav_hooks_liveprop;
typedef struct dav_hooks_binding dav_hooks_binding;
typedef struct dav_hooks_search dav_hooks_search;
/* ### deprecated name */
typedef dav_hooks_propdb dav_hooks_db;
/* --------------------------------------------------------------------
**
** RESOURCE HANDLING
*/
/*
** Resource Types:
** The base protocol defines only file and collection resources.
** The versioning protocol defines several additional resource types
** to represent artifacts of a version control system.
**
** This enumeration identifies the type of URL used to identify the
** resource. Since the same resource may have more than one type of
** URL which can identify it, dav_resource_type cannot be used
** alone to determine the type of the resource; attributes of the
** dav_resource object must also be consulted.
*/
typedef enum {
DAV_RESOURCE_TYPE_REGULAR, /* file or collection; could be
* unversioned, or version selector,
* or baseline selector */
DAV_RESOURCE_TYPE_VERSION, /* version or baseline URL */
DAV_RESOURCE_TYPE_HISTORY, /* version or baseline history URL */
DAV_RESOURCE_TYPE_WORKING, /* working resource URL */
DAV_RESOURCE_TYPE_WORKSPACE, /* workspace URL */
DAV_RESOURCE_TYPE_ACTIVITY, /* activity URL */
DAV_RESOURCE_TYPE_PRIVATE /* repository-private type */
/*
** Opaque, repository-specific information for a resource.
*/
typedef struct dav_resource_private dav_resource_private;
/*
** Resource descriptor, generated by a repository provider.
**
** Note: the lock-null state is not explicitly represented here,
** since it may be expensive to compute. Use dav_get_resource_state()
** to determine whether a non-existent resource is a lock-null resource.
**
** A quick explanation of how the flags can apply to different resources:
**
** unversioned file or collection:
** type = DAV_RESOURCE_TYPE_REGULAR
** exists = ? (1 if exists)
** collection = ? (1 if collection)
** versioned = 0
** baselined = 0
** working = 0
**
** version-controlled resource or configuration:
** type = DAV_RESOURCE_TYPE_REGULAR
** exists = 1
** collection = ? (1 if collection)
** versioned = 1
** baselined = ? (1 if configuration)
** working = ? (1 if checked out)
**
** type = DAV_RESOURCE_TYPE_HISTORY
** exists = 1
** collection = 0
** versioned = 0
** baselined = 0
** working = 0
**
** type = DAV_RESOURCE_TYPE_VERSION
** exists = 1
** collection = ? (1 if collection)
** versioned = 1
** baselined = ? (1 if baseline)
** working = 0
**
** working resource:
** type = DAV_RESOURCE_TYPE_WORKING
** exists = 1
** collection = ? (1 if collection)
** versioned = 1
** baselined = 0
** working = 1
**
** workspace:
** type = DAV_RESOURCE_TYPE_WORKSPACE
** exists = ? (1 if exists)
** collection = 1
** versioned = ? (1 if version-controlled)
** baselined = ? (1 if baseline-controlled)
** working = ? (1 if checked out)
**
** activity:
** type = DAV_RESOURCE_TYPE_ACTIVITY
** exists = ? (1 if exists)
** collection = 0
** versioned = 0
** baselined = 0
** working = 0
*/
typedef struct dav_resource {
int exists; /* 0 => null resource */
int collection; /* 0 => file; can be 1 for
* REGULAR, VERSION, and WORKING resources,
* and is always 1 for WORKSPACE */
int versioned; /* 0 => unversioned; can be 1 for
* REGULAR and WORKSPACE resources,
* and is always 1 for VERSION and WORKING */
int baselined; /* 0 => not baselined; can be 1 for
* REGULAR, VERSION, and WORKSPACE resources;
* versioned == 1 when baselined == 1 */
int working; /* 0 => not checked out; can be 1 for
* REGULAR and WORKSPACE resources,
* and is always 1 for WORKING */
const char *uri; /* the URI for this resource */
/* When allocating items related specifically to this resource, the
following pool should be used. Its lifetime will be at least as
long as the dav_resource structure. */
} dav_resource;
/*
** Lock token type. Lock providers define the details of a lock token.
** However, all providers are expected to at least be able to parse
** the "opaquelocktoken" scheme, which is represented by a uuid_t.
*/
typedef struct dav_locktoken dav_locktoken;
/* --------------------------------------------------------------------
**
** BUFFER HANDLING
**
** These buffers are used as a lightweight buffer reuse mechanism. Apache
** provides sub-pool creation and destruction to much the same effect, but
** the sub-pools are a bit more general and heavyweight than these buffers.
*/
/* buffer for reuse; can grow to accomodate needed size */
typedef struct
{
char *buf; /* buffer contents */
} dav_buffer;
/* set the cur_len to the given size and ensure space is available */
/* initialize a buffer and copy the specified (null-term'd) string into it */
const char *str);
/* check that the buffer can accomodate <extra_needed> more bytes */
/* append a string to the end of the buffer, adjust length */
const char *str);
/* place a string on the end of the buffer, do NOT adjust length */
const char *str);
/* place some memory on the end of a buffer; do NOT adjust length */
/* --------------------------------------------------------------------
**
** HANDY UTILITIES
*/
/* contains results from one of the getprop functions */
typedef struct
{
/* holds the contents of a <response> element */
typedef struct dav_response
{
const char *href; /* always */
const char *desc; /* optional description at <response> level */
/* use status if propresult.propstats is NULL. */
int status;
struct dav_response *next;
} dav_response;
typedef struct
{
int must_be_absolute);
/* defines type of property info a provider is to return */
typedef enum {
DAV_PROP_INSERT_NOTDEF, /* property is defined by this provider,
but nothing was inserted because the
(live) property is not defined for this
resource (it may be present as a dead
property). */
DAV_PROP_INSERT_NOTSUPP, /* property is recognized by this provider,
but it is not supported, and cannot be
treated as a dead property */
DAV_PROP_INSERT_NAME, /* a property name (empty elem) was
inserted into the text block */
DAV_PROP_INSERT_VALUE, /* a property name/value pair was inserted
into the text block */
DAV_PROP_INSERT_SUPPORTED /* a supported live property was added to
the text block as a
<DAV:supported-live-property> element */
/* format a time string (buf must be at least DAV_TIMEBUF_SIZE chars) */
#define DAV_STYLE_ISO8601 1
#define DAV_STYLE_RFC822 2
#define DAV_TIMEBUF_SIZE 30
const char *tagname);
const char *tagname);
/* gather up all the CDATA into a single string */
int strip_white);
/*
** XML namespace handling
**
** This structure tracks namespace declarations (xmlns:prefix="URI").
** It maintains a one-to-many relationship of URIs-to-prefixes. In other
** words, one URI may be defined by many prefixes, but any specific
** prefix will specify only one URI.
**
** Prefixes using the "g###" pattern can be generated automatically if
** the caller does not have specific prefix requirements.
*/
typedef struct {
int count; /* counter for "g###" prefixes */
/* create an empty dav_xmlns_info structure */
at least that of xmlns->pool */
/* add a URI (if not present); any prefix is acceptable and is returned.
the uri should have a lifetime at least that xmlns->pool */
const char *uri);
/* return the URI for a specified prefix (or NULL if the prefix is unknown) */
const char *prefix);
/* return an available prefix for a specified URI (or NULL if the URI
is unknown) */
const char *uri);
/* generate xmlns declarations (appending into the given text) */
/* --------------------------------------------------------------------
**
** DAV PLUGINS
*/
/* ### docco ... */
/*
** dav_provider
**
** This structure wraps up all of the hooks that a mod_dav provider can
** supply. The provider MUST supply <repos> and <propdb>. The rest are
** optional and should contain NULL if that feature is not supplied.
**
** Note that a provider cannot pick and choose portions from various
** underlying implementations (which was theoretically possible in
** mod_dav 1.0). There are too many dependencies between a dav_resource
** (defined by <repos>) and the other functionality.
**
** Live properties are not part of the dav_provider structure because they
** are handled through the APR_HOOK interface (to allow for multiple liveprop
** providers). The core always provides some properties, and then a given
** provider will add more properties.
**
** Some providers may need to associate a context with the dav_provider
** structure -- the ctx field is available for storing this context. Just
** leave it NULL if it isn't required.
*/
typedef struct {
const dav_hooks_repository *repos;
const dav_hooks_propdb *propdb;
const dav_hooks_locks *locks;
const dav_hooks_vsn *vsn;
const dav_hooks_binding *binding;
const dav_hooks_search *search;
void *ctx;
} dav_provider;
/*
** gather_propsets: gather all live property propset-URIs
**
** The hook implementor should push one or more URIs into the specified
** array. These URIs are returned in the DAV: header to let clients know
** what sets of live properties are supported by the installation. mod_dav
** a Coded-URL); quotes and brackets should not be in the value.
**
** Example: http://apache.org/dav/props/
**
** (of course, use your own domain to ensure a unique value)
*/
/*
** find_liveprop: find a live property, returning a non-zero, unique,
** opaque identifier.
**
** one of its properties, then it should fill in HOOKS and return a
** non-zero value. The returned value is the "property ID" and will
** be passed to the various liveprop hook functions.
**
** Return 0 if the property is not defined by the hook implementor.
*/
(const dav_resource *resource,
const dav_hooks_liveprop **hooks))
/*
**
** The hook implementor should append XML text to PHDR, containing liveprop
** names. If INSVALUE is true, then the property values should also be
** inserted into the output XML stream.
**
** The liveprop provider should insert *all* known and *defined* live
** properties on the specified resource. If a particular liveprop is
** not defined for this resource, then it should not be inserted.
*/
const dav_provider *hooks);
/* ### deprecated */
#define DAV_GET_HOOKS_PROPDB(r) dav_get_propdb_hooks(r)
#define DAV_GET_HOOKS_LOCKS(r) dav_get_lock_hooks(r)
#define DAV_GET_HOOKS_VSN(r) dav_get_vsn_hooks(r)
#define DAV_GET_HOOKS_BINDING(r) dav_get_binding_hooks(r)
#define DAV_GET_HOOKS_SEARCH(r) dav_get_search_hooks(r)
/* --------------------------------------------------------------------
**
** IF HEADER PROCESSING
**
** Here is the definition of the If: header from RFC 2518, S9.4:
**
** If = "If" ":" (1*No-tag-list | 1*Tagged-list)
** No-tag-list = List
** Tagged-list = Resource 1*List
** Resource = Coded-URL
** List = "(" 1*(["Not"](State-token | "[" entity-tag "]")) ")"
** State-token = Coded-URL
** Coded-URL = "<" absoluteURI ">" ; absoluteURI from RFC 2616
**
** List corresponds to dav_if_state_list. No-tag-list corresponds to
** dav_if_header with uri==NULL. Tagged-list corresponds to a sequence of
** dav_if_header structures with (duplicate) uri==Resource -- one
** dav_if_header per state_list. A second Tagged-list will start a new
** sequence of dav_if_header structures with the new URI.
**
** A summary of the semantics, mapped into our structures:
** - Chained dav_if_headers: OR
** - Chained dav_if_state_lists: AND
** - NULL uri matches all resources
*/
typedef enum
{
dav_if_unknown /* the "unknown" state type; always matches false. */
typedef struct dav_if_state_list
{
int condition;
#define DAV_IF_COND_NORMAL 0
const char *etag;
struct dav_if_state_list *next;
typedef struct dav_if_header
{
const char *uri;
struct dav_if_state_list *state;
struct dav_if_header *next;
int dummy_header; /* used internally by the lock/etag validation */
typedef struct dav_locktoken_list
{
struct dav_locktoken_list *next;
/* --------------------------------------------------------------------
**
** LIVE PROPERTY HANDLING
*/
/* opaque type for PROPPATCH rollback information */
typedef struct dav_liveprop_rollback dav_liveprop_rollback;
struct dav_hooks_liveprop
{
/*
** Insert property information into a text block. The property to
** insert is identified by the propid value. The information to insert
** is identified by the "what" argument, as follows:
** DAV_PROP_INSERT_NAME
** property name, as an empty XML element
** DAV_PROP_INSERT_VALUE
** DAV_PROP_INSERT_SUPPORTED
** if the property is defined on the resource, then
** a DAV:supported-live-property element, as defined
** by the DeltaV extensions to RFC2518.
**
** Providers should return DAV_PROP_INSERT_NOTDEF if the property is
** known and not defined for this resource, so should be handled as a
** dead property. If a provider recognizes, but does not support, a
** property, and does not want it handled as a dead property, it should
** return DAV_PROP_INSERT_NOTSUPP.
**
** Returns one of DAV_PROP_INSERT_* based on what happened.
**
** ### we may need more context... ie. the lock database
*/
/*
** Determine whether a given property is writable.
**
** ### we may want a different semantic. i.e. maybe it should be
** ### "can we write <value> into this property?"
**
** Returns 1 if the live property can be written, 0 if read-only.
*/
/*
** This member defines the set of namespace URIs that the provider
** uses for its properties. When insert_all is called, it will be
** passed a list of integers that map from indices into this list
** to namespace IDs for output generation.
**
** The last entry in this list should be a NULL value (sentinel).
*/
const char * const * namespace_uris;
/*
** ### this is not the final design. we want an open-ended way for
** ### liveprop providers to attach *new* properties. To this end,
** ### we'll have a "give me a list of the props you define", a way
*/
/*
** Validate that the live property can be assigned a value, and that
** the provided value is valid.
**
** elem will point to the XML element that names the property. For
** example:
** <lp1:executable>T</lp1:executable>
**
** The provider can access the cdata fields and the child elements
** to extract the relevant pieces.
**
** operation is one of DAV_PROP_OP_SET or _DELETE.
**
** The provider may return a value in *context which will be passed
** may contain an internal value which has been processed from the
** input element.
**
** The provider must set defer_to_dead to true (non-zero) or false.
** database. Note: it will be set to zero on entry.
*/
const apr_xml_elem *elem,
int operation,
void **context,
int *defer_to_dead);
/* ### doc... */
const apr_xml_elem *elem,
int operation,
void *context,
/* ### doc... */
int operation,
void *context,
/* ### doc... */
int operation,
void *context,
/*
** If a provider needs a context to associate with this hooks structure,
** then this field may be used. In most cases, it will just be NULL.
*/
void *ctx;
};
/*
** dav_liveprop_spec: specify a live property
**
** This structure is used as a standard way to determine if a particular
** property is a live property. Its use is not part of the mandated liveprop
** interface, but can be used by liveprop providers in conjuction with the
** utility routines below.
**
** spec->name == NULL is the defined end-sentinel for a list of specs.
*/
typedef struct {
int ns; /* provider-local namespace index */
const char *name; /* name of the property */
int propid; /* provider-local property ID */
int is_writable; /* is the property writable? */
/*
** dav_liveprop_group: specify a group of liveprops
**
** This structure specifies a group of live properties, their namespaces,
** and how to handle them.
*/
typedef struct {
const dav_liveprop_spec *specs;
const char * const *namespace_uris;
const dav_hooks_liveprop *hooks;
/* ### docco */
const dav_liveprop_group *group,
const dav_hooks_liveprop **hooks);
/* ### docco */
const dav_liveprop_group *group,
const dav_liveprop_spec **info);
/* ### docco */
const dav_liveprop_group *group);
/* ### docco */
/* ### docco */
DAV_DECLARE(long) dav_get_liveprop_ns_count(void);
/* ### docco */
/*
** The following three functions are part of mod_dav's internal handling
** for the core WebDAV properties. They are not part of mod_dav's API.
*/
const dav_resource *resource,
const char *ns_uri,
const char *name,
const dav_hooks_liveprop **hooks);
request_rec *r,
const dav_resource *resource,
/*
** Standard WebDAV Property Identifiers
**
** A live property provider does not need to use these; they are simply
** provided for convenience.
**
** Property identifiers need to be unique within a given provider, but not
** *across* providers (note: this uniqueness constraint was different in
** older versions of mod_dav).
**
** The identifiers start at 20000 to make it easier for providers to avoid
** conflicts with the standard properties. The properties are arranged
** alphabetically, and may be reordered from time to time (as properties
** are introduced).
**
** NOTE: there is no problem with reordering (e.g. binary compat) since the
** identifiers are only used within a given provider, which would pick up
** the entire set of changes upon a recompile.
*/
enum {
DAV_PROPID_BEGIN = 20000,
/* Standard WebDAV properties (RFC 2518) */
/* DeltaV properties (from the I-D (#14)) */
};
/*
** Property Identifier Registration
**
** At the moment, mod_dav requires live property providers to ensure that
** each property returned has a unique value. For now, this is done through
** central registration (there are no known providers other than the default,
** so this remains manageable).
**
** WARNING: the TEST ranges should never be "shipped".
*/
mod_dav filesystem provider. */
/* Next: 10600 */
/* --------------------------------------------------------------------
**
** DATABASE FUNCTIONS
*/
typedef struct dav_namespace_map dav_namespace_map;
typedef struct dav_deadprop_rollback dav_deadprop_rollback;
typedef struct {
const char *ns; /* "" signals "no namespace" */
const char *name;
/* hook functions to enable pluggable databases */
struct dav_hooks_propdb
{
/*
** In bulk, define any namespaces that the values and their name
** elements may need.
**
** Note: sometimes mod_dav will defer calling this until output_value
** returns found==1. If the output process needs the dav_xmlns_info
** filled for its work, then it will need to fill it on demand rather
** than depending upon this hook to fill in the structure.
**
** Note: this will *always* be called during an output sequence. Thus,
** the provider may rely solely on using this to fill the xmlns info.
*/
/*
** Output the value from the database (i.e. add an element name and
** was found in the propdb.
**
**
** The dav_xmlns_info passed to define_namespaces() is also passed to
** each output_value() call so that namespaces can be added on-demand.
** It can also be used to look up prefixes or URIs during the output
** process.
*/
/*
** Build a mapping from "global" namespaces (stored in apr_xml_*)
** into provider-local namespace identifiers.
**
** This mapping should be done once per set of namespaces, and the
** resulting mapping should be passed into the store() hook function.
**
** Note: usually, there is just a single document/namespaces for all
** elements passed. However, the generality of creating multiple
** mappings and passing them to store() is provided here.
**
** Note: this is only in preparation for a series of store() calls.
** this function is called.
*/
const apr_array_header_t *namespaces,
/*
** Store a property value for a given name. The value->combined field
** MUST be set for this call.
**
** ### WARNING: current providers will quote the text within ELEM.
** ### this implies you can call this function only once with a given
** ### element structure (a second time will quote it again).
*/
const apr_xml_elem *elem,
/* remove a given property */
/* returns 1 if the record specified by "key" exists; 0 otherwise */
/*
** Iterate over the property names in the database.
**
** iter->name.ns == iter->name.name == NULL when there are no more names.
**
** Note: only one iteration may occur over the propdb at a time.
*/
/*
** Rollback support: get rollback context, and apply it.
**
** struct dav_deadprop_rollback is a provider-private structure; it
** should remember the name, and the name's old value (or the fact that
** the value was not present, and should be deleted if a rollback occurs).
*/
/*
** If a provider needs a context to associate with this hooks structure,
** then this field may be used. In most cases, it will just be NULL.
*/
void *ctx;
};
/* --------------------------------------------------------------------
**
** LOCK FUNCTIONS
*/
/* Used to represent a Timeout header of "Infinity" */
#define DAV_TIMEOUT_INFINITE 0
/*
** Opaque, provider-specific information for a lock database.
*/
typedef struct dav_lockdb_private dav_lockdb_private;
/*
** Opaque, provider-specific information for a lock record.
*/
typedef struct dav_lock_private dav_lock_private;
/*
** Lock database type. Lock providers are urged to implement a "lazy" open, so
** doing an "open" is cheap until something is actually needed from the DB.
*/
typedef struct
{
int ro; /* was it opened readonly? */
} dav_lockdb;
typedef enum {
typedef enum {
typedef enum {
DAV_LOCKREC_DIRECT, /* lock asserted on this resource */
DAV_LOCKREC_INDIRECT, /* lock inherited from a parent */
DAV_LOCKREC_INDIRECT_PARTIAL /* most info is not filled in */
/*
** dav_lock: hold information about a lock on a resource.
**
** This structure is used for both direct and indirect locks. A direct lock
** is a lock applied to a specific resource by the client. An indirect lock
** is one that is inherited from a parent resource by virtue of a non-zero
** Depth: header when the lock was applied.
**
** mod_dav records both types of locks in the lock database, managing their
**
** Note that the lockdb is free to marshal this structure in any form that
** it likes.
**
** For a "partial" lock, the <rectype> and <locktoken> fields must be filled
** in. All other (user) fields should be zeroed. The lock provider will
** usually fill in the <info> field, and the <next> field may be used to
** construct a list of partial locks.
**
** The lock provider MUST use the info field to store a value such that a
** dav_lock structure can locate itself in the underlying lock database.
** This requirement is needed for refreshing: when an indirect dav_lock is
** refreshed, its reference to the direct lock does not specify the direct's
** resource, so the only way to locate the (refreshed, direct) lock in the
** database is to use the info field.
**
** Note that <is_locknull> only refers to the resource where this lock was
** found.
** ### hrm. that says the abstraction is wrong. is_locknull may disappear.
*/
typedef struct dav_lock
{
int is_locknull; /* lock establishes a locknull resource */
/* ### put the resource in here? */
int depth; /* depth of the lock */
const char *owner; /* (XML) owner of the lock */
const char *auth_user; /* auth'd username owning lock */
} dav_lock;
/* Property-related public lock functions */
dav_buffer *pbuf);
/* LockDB-related public lock functions */
const dav_resource *resrouce,
const apr_xml_doc *doc,
dav_lock **lock_request);
const dav_resource *resource,
const dav_locktoken *locktoken);
const dav_resource *resource,
dav_response **response);
const dav_resource *resource,
int resource_state,
int depth);
const dav_resource *resource,
int depth,
int flags,
dav_lockdb *lockdb);
/*
** flags:
** 0x0F -- reserved for <dav_lock_scope> values
**
** other flags, detailed below
*/
the 424 DAV:response */
/* Lock-null related public lock functions */
const dav_resource *resource);
/* Lock provider hooks. Locking is optional, so there may be no
* lock provider for a given repository.
*/
struct dav_hooks_locks
{
/* Return the supportedlock property for a resource */
const char * (*get_supportedlock)(
const dav_resource *resource
);
/* Parse a lock token URI, returning a lock token object allocated
* in the given pool.
*/
dav_error * (*parse_locktoken)(
apr_pool_t *p,
const char *char_token,
);
/* Format a lock token object into a URI string, allocated in
* the given pool.
*
* Always returns non-NULL.
*/
const char * (*format_locktoken)(
apr_pool_t *p,
const dav_locktoken *locktoken
);
/* Compare two lock tokens.
*
* Result < 0 => lt1 < lt2
* Result == 0 => lt1 == lt2
* Result > 0 => lt1 > lt2
*/
int (*compare_locktoken)(
const dav_locktoken *lt1,
const dav_locktoken *lt2
);
/* Open the provider's lock database.
*
* The provider may or may not use a "real" database for locks
* (a lock could be an attribute on a resource, for example).
*
* The provider may choose to use the value of the DAVLockDB directive
* (as returned by dav_get_lockdb_path()) to decide where to place
* any storage it may need.
*
* The request storage pool should be associated with the lockdb,
* so it can be used in subsequent operations.
*
* If ro != 0, only readonly operations will be performed.
* If force == 0, the open can be "lazy"; no subsequent locking operations
* may occur.
* If force != 0, locking operations will definitely occur.
*/
dav_error * (*open_lockdb)(
request_rec *r,
int ro,
int force,
);
/* Indicates completion of locking operations */
void (*close_lockdb)(
);
/* Take a resource out of the lock-null state. */
const dav_resource *resource
);
/*
** Create a (direct) lock structure for the given resource. A locktoken
** will be created.
**
** The lock provider may store private information into lock->info.
*/
const dav_resource *resource,
/*
** Get the locks associated with the specified resource.
**
** If resolve_locks is true (non-zero), then any indirect locks are
** resolved to their actual, direct lock (i.e. the reference to followed
** to the original lock).
**
** The locks, if any, are returned as a linked list in no particular
** order. If no locks are present, then *locks will be NULL.
*/
const dav_resource *resource,
int calltype,
#define DAV_GETLOCKS_RESOLVED 0 /* resolve indirects to directs */
/*
** Find a particular lock on a resource (specified by its locktoken).
**
** *lock will be set to NULL if the lock is not found.
**
** Note that the provider can optimize the unmarshalling -- only one
** lock (or none) must be constructed and returned.
**
** If partial_ok is true (non-zero), then an indirect lock can be
** partially filled in. Otherwise, another lookup is done and the
** lock structure will be filled out as a DAV_LOCKREC_INDIRECT.
*/
const dav_resource *resource,
const dav_locktoken *locktoken,
int partial_ok,
/*
** Quick test to see if the resource has *any* locks on it.
**
** This is typically used to determine if a non-existent resource
** has a lock and is (therefore) a locknull resource.
**
** WARNING: this function may return TRUE even when timed-out locks
** exist (i.e. it may not perform timeout checks).
*/
const dav_resource *resource,
int *locks_present);
/*
** Append the specified lock(s) to the set of locks on this resource.
**
** If "make_indirect" is true (non-zero), then the specified lock(s)
** should be converted to an indirect lock (if it is a direct lock)
** before appending. Note that the conversion to an indirect lock does
** not alter the passed-in lock -- the change is internal the
** append_locks function.
**
** Multiple locks are specified using the lock->next links.
*/
const dav_resource *resource,
int make_indirect,
/*
** Remove any lock that has the specified locktoken.
**
** If locktoken == NULL, then ALL locks are removed.
*/
const dav_resource *resource,
const dav_locktoken *locktoken);
/*
** Refresh all locks, found on the specified resource, which has a
** locktoken in the provided list.
**
** If the lock is indirect, then the direct lock is referenced and
** refreshed.
**
** Each lock that is updated is returned in the <locks> argument.
** Note that the locks will be fully resolved.
*/
const dav_resource *resource,
const dav_locktoken_list *ltl,
/*
** Look up the resource associated with a particular locktoken.
**
** The search begins at the specified <start_resource> and the lock
** specified by <locktoken>.
**
** lock will be looked up, and THAT resource will be returned. In other
** words, this function always returns the resource where a particular
** lock (token) was asserted.
**
** NOTE: this function pointer is allowed to be NULL, indicating that
** the provider does not support this type of functionality. The
** caller should then traverse up the repository hierarchy looking
** for the resource defining a lock with this locktoken.
*/
const dav_locktoken *locktoken,
const dav_resource *start_resource,
const dav_resource **resource);
/*
** If a provider needs a context to associate with this hooks structure,
** then this field may be used. In most cases, it will just be NULL.
*/
void *ctx;
};
/* what types of resources can be discovered by dav_get_resource_state() */
/* --------------------------------------------------------------------
**
** PROPERTY HANDLING
*/
typedef struct dav_propdb dav_propdb;
request_rec *r,
const dav_resource *resource,
int ro,
dav_propdb **propdb);
dav_propdb *db,
apr_xml_doc *doc);
dav_propdb *db,
const char *ns_uri,
const char *propname,
/*
** 3-phase property modification.
**
** 1) validate props. readable? unlocked? ACLs allow access?
** 3) commit or rollback
**
** ### eventually, auth must be available. a ref to the request_rec (which
** ### contains the auth info) should be in the shared context struct.
**
** Each function may alter the error values and information contained within
** the context record. This should be done as an "increasing" level of
** error, rather than overwriting any previous error.
**
** Note that commit() cannot generate errors. It should simply free the
** rollback information.
**
** rollback() may generate additional errors because the rollback operation
** can sometimes fail(!).
**
** The caller should allocate an array of these, one per operation. It should
** be zero-initialized, then the db, operation, and prop fields should be
** operations are order-dependent. For a given (logical) context, the same
** pointer must be passed to each phase.
**
** error_type is an internal value, but will have the same numeric value
** for each possible "desc" value. This allows the caller to group the
** descriptions via the error_type variable, rather than through string
** comparisons. Note that "status" does not provide enough granularity to
** differentiate/group the "desc" values.
**
** Note that the propdb will maintain some (global) context across all
** of the property change contexts. This implies that you can have only
** one open transaction per propdb.
*/
typedef struct dav_prop_ctx
{
int operation;
/* ### add a GET? */
/* private items to the propdb */
int is_liveprop;
void *liveprop_ctx;
/* private to mod_dav.c */
request_rec *r;
} dav_prop_ctx;
/* --------------------------------------------------------------------
**
** WALKER STRUCTURE
*/
enum {
DAV_CALLTYPE_COLLECTION, /* called for a collection */
DAV_CALLTYPE_LOCKNULL /* called for a locknull resource */
};
typedef struct
{
/* the client-provided context */
void *walk_ctx;
/* pool to use for allocations in the callback */
/* the current resource */
const dav_resource *resource;
/* OUTPUT: add responses to this */
typedef struct
{
int walk_type;
/* callback function and a client context for the walk */
void *walk_ctx;
/* what pool to use for allocations needed by walk logic */
/* beginning root of the walk */
const dav_resource *root;
/* lock database to enable walking LOCKNULL resources */
/* directory tree walking context */
typedef struct dav_walker_ctx
{
/* input: */
/* ### client data... phasing out this big glom */
/* this brigade buffers data being sent to r->output_filters */
/* a scratch pool, used to stream responses and iteratively cleared. */
request_rec *r; /* original request */
/* for PROPFIND operations */
int propfind_type;
#define DAV_PROPFIND_IS_ALLPROP 1
#define DAV_PROPFIND_IS_PROPNAME 2
#define DAV_PROPFIND_IS_PROP 3
int skip_root; /* for dav_inherit_locks() */
int flags;
int status,
/* --------------------------------------------------------------------
**
** "STREAM" STRUCTURE
**
** mod_dav uses this abstraction for interacting with the repository
** of bytes.
**
** Note that the structure is opaque -- it is private to the repository
** that created the stream in the repository's "open" function.
**
** ### having the provider jam stuff straight into the filter stack.
*/
typedef struct dav_stream dav_stream;
typedef enum {
DAV_MODE_WRITE_TRUNC, /* truncate and open for writing */
DAV_MODE_WRITE_SEEKABLE /* open for writing; random access */
/* --------------------------------------------------------------------
**
** REPOSITORY FUNCTIONS
*/
/* Repository provider hooks */
struct dav_hooks_repository
{
/* Flag for whether repository requires special GET handling.
* If resources in the repository are not visible in the
* filesystem location which URLs map to, then special handling
* is required to first fetch a resource from the repository,
* respond to the GET request, then free the resource copy.
*/
int handle_get;
/* Get a resource descriptor for the URI in a request. A descriptor
* should always be returned even if the resource does not exist. This
* repository has been identified as handling the resource given by
* the URI, so an answer must be given. If there is a problem with the
* URI or accessing the resource or whatever, then an error should be
* returned.
*
* root_dir:
* the root of the directory for which this repository is configured.
*
* label:
* if a Label: header is present (and allowed), this is the label
* to use to identify a version resource from the resource's
* corresponding version history. Otherwise, it will be NULL.
*
* use_checked_in:
* use the DAV:checked-in property of the resource identified by the
* Request-URI to identify and return a version resource
*
* The provider may associate the request storage pool with the resource
* (in the resource->pool field), to use in other operations on that
* resource.
*/
dav_error * (*get_resource)(
request_rec *r,
const char *root_dir,
const char *label,
int use_checked_in,
);
/* Get a resource descriptor for the parent of the given resource.
* The resources need not exist. NULL is returned if the resource
* is the root collection.
*
* An error should be returned only if there is a fatal error in
* fetching information about the parent resource.
*/
dav_error * (*get_parent_resource)(
const dav_resource *resource,
);
/* Determine whether two resource descriptors refer to the same resource.
*
* Result != 0 => the resources are the same.
*/
int (*is_same_resource)(
const dav_resource *res1,
const dav_resource *res2
);
/* Determine whether one resource is a parent (immediate or otherwise)
* of another.
*
* Result != 0 => res1 is a parent of res2.
*/
int (*is_parent_resource)(
const dav_resource *res1,
const dav_resource *res2
);
/*
** Open a stream for this resource, using the specified mode. The
** stream will be returned in *stream.
*/
dav_stream **stream);
/*
** Close the specified stream.
**
** mod_dav will (ideally) make sure to call this. For safety purposes,
** a provider should (ideally) register a cleanup function with the
** request pool to get this closed and cleaned up.
**
** Note the possibility of an error from the close -- it is entirely
** feasible that the close does a "commit" of some kind, which can
** produce an error.
**
** commit should be TRUE (non-zero) or FALSE (0) if the stream was
** opened for writing. This flag states whether to retain the file
** or not.
** Note: the commit flag is ignored for streams opened for reading.
*/
/*
** Write data to the stream.
**
** All of the bytes must be written, or an error should be returned.
*/
/*
** Seek to an absolute position in the stream. This is used to support
**
** NOTE: if this function is NULL (which is allowed), then any
** operations using Content-Range will be refused.
*/
/*
** If a GET is processed using a stream (open_stream, read_stream)
** rather than via a sub-request (on get_pathname), then this function
** is used to provide the repository with a way to set the headers
** in the response.
**
** This function may be called without a following deliver(), to
** handle a HEAD request.
**
** This may be NULL if handle_get is FALSE.
*/
const dav_resource *resource);
/*
** The provider should deliver the resource into the specified filter.
** Basically, this is the response to the GET method.
**
** Note that this is called for all resources, including collections.
** The provider should determine what has content to deliver or not.
**
** set_headers will be called prior to this function, allowing the
** provider to set the appropriate response headers.
**
** This may be NULL if handle_get is FALSE.
** ### maybe toss handle_get and just use this function as the marker
*/
/* Create a collection resource. The resource must not already exist.
*
* Result == NULL if the collection was created successfully. Also, the
* resource object is updated to reflect that the resource exists, and
* is a collection.
*/
dav_error * (*create_collection)(
);
/* Copy one resource to another. The destination may exist, if it is
* versioned.
* Handles both files and collections. Properties are copied as well.
* If the destination exists and is versioned, the provider must update
* the destination to have identical content to the source,
* recursively for collections.
* The depth argument is ignored for a file, and can be either 0 or
* DAV_INFINITY for a collection.
* If an error occurs in a child resource, then the return value is
* non-NULL, and *response is set to a multistatus response.
* If the copy is successful, the dst resource object is
* updated to reflect that the resource exists.
*/
dav_error * (*copy_resource)(
const dav_resource *src,
int depth,
);
/* Move one resource to another. The destination must not exist.
* Handles both files and collections. Properties are moved as well.
* If an error occurs in a child resource, then the return value is
* non-NULL, and *response is set to a multistatus response.
* If the move is successful, the src and dst resource objects are
* updated to reflect that the source no longer exists, and the
* destination does.
*/
dav_error * (*move_resource)(
);
/* Remove a resource. Handles both files and collections.
* Removes any associated properties as well.
* If an error occurs in a child resource, then the return value is
* non-NULL, and *response is set to a multistatus response.
* If the delete is successful, the resource object is updated to
* reflect that the resource no longer exists.
*/
dav_error * (*remove_resource)(
);
/* Walk a resource hierarchy.
*
* Iterates over the resource hierarchy specified by params->root.
* Control of the walk and the callback are specified by 'params'.
*
* An error may be returned. *response will contain multistatus
* responses (if any) suitable for the body of the error. It is also
* possible to return NULL, yet still have multistatus responses.
* In this case, typically the caller should return a 207 (Multistatus)
* and the responses (in the body) as the HTTP response.
*/
dav_response **response);
/* Get the entity tag for a resource */
/*
** If a provider needs a context to associate with this hooks structure,
** then this field may be used. In most cases, it will just be NULL.
*/
void *ctx;
/* Get the request rec for a resource */
/* Get the pathname for a resource */
};
/* --------------------------------------------------------------------
**
** VERSIONING FUNCTIONS
*/
/* dav_add_vary_header
*
* If there were any headers in the request which require a Vary header
* in the response, add it.
*/
const dav_resource *resource);
/*
** Flags specifying auto-versioning behavior, returned by
** the auto_versionable hook. The value returned depends
** on both the state of the resource and the value of the
** DAV:auto-versioning property for the resource.
**
** If the resource does not exist (null or lock-null),
** DAV_AUTO_VERSION_ALWAYS causes creation of a new version-controlled resource
**
** If the resource is checked in,
** DAV_AUTO_VERSION_ALWAYS causes it to be checked out always,
** DAV_AUTO_VERSION_LOCKED causes it to be checked out only when locked
**
** If the resource is checked out,
** DAV_AUTO_VERSION_ALWAYS causes it to be checked in always,
** DAV_AUTO_VERSION_LOCKED causes it to be checked in when unlocked
** (note: a provider should allow auto-checkin only for resources which
** were automatically checked out)
**
** In all cases, DAV_AUTO_VERSION_NEVER results in no auto-versioning behavior.
*/
typedef enum {
/*
** This structure is used to record what auto-versioning operations
** were done to make a resource writable, so that they can be undone
** at the end of a request.
*/
typedef struct {
int resource_versioned; /* 1 => resource was auto-version-controlled */
int resource_checkedout; /* 1 => resource was auto-checked-out */
int parent_checkedout; /* 1 => parent was auto-checked-out */
/* Ensure that a resource is writable. If there is no versioning
* provider, then this is essentially a no-op. Versioning repositories
* require explicit resource creation and checkout before they can
* be written to. If a new resource is to be created, or an existing
* resource deleted, the parent collection must be checked out as well.
*
* Set the parent_only flag to only make the parent collection writable.
* Otherwise, both parent and child are made writable as needed. If the
* child does not exist, then a new versioned resource is created and
* checked out.
*
* If auto-versioning is not enabled for a versioned resource, then an error is
* returned, since the resource cannot be modified.
*
* The dav_auto_version_info structure is filled in with enough information
* to restore both parent and child resources to the state they were in
* before the auto-versioning operations occurred.
*/
request_rec *r,
int parent_only,
/* Revert the writability of resources back to what they were
* before they were modified. If undo == 0, then the resource
* modifications are maintained (i.e. they are checked in).
* If undo != 0, then resource modifications are discarded
* (i.e. they are unchecked out).
*
* Set the unlock flag to indicate that the resource is about
* to be unlocked; it will be checked in if the resource
* auto-versioning property indicates it should be. In this case,
* av_info is ignored, so it can be NULL.
*
* The resource argument may be NULL if only the parent resource
* was checked out (i.e. the parent_only was != 0 in the
* dav_auto_checkout call).
*/
request_rec *r,
int undo,
int unlock,
/*
** This structure is used to describe available reports
**
** "nmspace" should be valid XML and URL-quoted. mod_dav will place
** double-quotes around it and use it in an xmlns declaration.
*/
typedef struct {
const char *nmspace; /* namespace of the XML report element */
const char *name; /* element name for the XML report */
/* Versioning provider hooks */
struct dav_hooks_vsn
{
/*
** MANDATORY HOOKS
** The following hooks are mandatory for all versioning providers;
** they define the functionality needed to implement "core" versioning.
*/
/* Return supported versioning options.
* Each dav_text item in the list will be returned as a separate
* DAV header. Providers are advised to limit the length of an
* individual text item to 63 characters, to conform to the limit
* used by MS Web Folders.
*/
/* Get the value of a specific option for an OPTIONS request.
* The option being requested is given by the parsed XML
* element object "elem". The value of the option should be
* appended to the "option" text object.
*/
const apr_xml_elem *elem,
/* Determine whether a non-versioned (or non-existent) resource
* is versionable. Returns != 0 if resource can be versioned.
*/
/* Determine whether auto-versioning is enabled for a resource
* (which may not exist, or may not be versioned). If the resource
* is a checked-out resource, the provider must only enable
* auto-checkin if the resource was automatically checked out.
*
* The value returned depends on both the state of the resource
* and the value of its DAV:auto-version property. See the description
* of the dav_auto_version enumeration above for the details.
*/
/* Put a resource under version control. If the resource already
* exists unversioned, then it becomes the initial version of the
* new version history, and it is replaced by a version selector
* which targets the new version.
*
* If the resource does not exist, then a new version-controlled
* resource is created which either targets an existing version (if the
* "target" argument is not NULL), or the initial, empty version
* in a new history resource (if the "target" argument is NULL).
*
* If successful, the resource object state is updated appropriately
* (that is, changed to refer to the new version-controlled resource).
*/
const char *target);
/* Checkout a resource. If successful, the resource
* object state is updated appropriately.
*
* The auto_checkout flag will be set if this checkout is being
* done automatically, as part of some method which modifies
* the resource. The provider must remember that the resource
* was automatically checked out, so it can determine whether it
* can be automatically checked in. (Auto-checkin should only be
* enabled for resources which were automatically checked out.)
*
* If the working resource has a different URL from the
* target resource, a dav_resource descriptor is returned
* for the new working resource. Otherwise, the original
* resource descriptor will refer to the working resource.
* The working_resource argument can be NULL if the caller
* is not interested in the working resource.
*
* If the client has specified DAV:unreserved or DAV:fork-ok in the
* checkout request, then the corresponding flags are set. If
* DAV:activity-set has been specified, then create_activity is set
* if DAV:new was specified; otherwise, the DAV:href elements' CDATA
* (the actual href text) is passed in the "activities" array (each
* element of the array is a const char *). activities will be NULL
* no DAV:activity-set was provided or when create_activity is set.
*/
int auto_checkout,
int is_unreserved, int is_fork_ok,
int create_activity,
/* Uncheckout a checked-out resource. If successful, the resource
* object state is updated appropriately.
*/
/* Checkin a checked-out resource. If successful, the resource
* object state is updated appropriately, and the
* version_resource descriptor will refer to the new version.
* The version_resource argument can be NULL if the caller
* is not interested in the new version resource.
*
* If the client has specified DAV:keep-checked-out in the checkin
* request, then the keep_checked_out flag is set. The provider
* should create a new version, but keep the resource in the
* checked-out state.
*/
int keep_checked_out,
/*
** Return the set of reports available at this resource.
**
** An array of report elements should be returned, with an end-marker
** element containing namespace==NULL. The value of the
** DAV:supported-report-set property will be constructed and
** returned.
*/
const dav_report_elem **reports);
/*
** Determine whether a Label header can be used
** with a particular report. The dav_xml_doc structure
** contains the parsed report request body.
** Returns 0 if the Label header is not allowed.
*/
/*
** Generate a report on a resource. Since a provider is free
** to define its own reports, and the value of request headers
** may affect the interpretation of a report, the request record
** must be passed to this routine.
**
** The dav_xml_doc structure contains the parsed report request
** body. The report response should be generated into the specified
** output filter.
**
** If an error occurs, and a response has not yet been generated,
** then an error can be returned from this function. mod_dav will
** construct an appropriate error response. Once some output has
** been placed into the filter, however, the provider should not
** return an error -- there is no way that mod_dav can deliver it
** properly.
**
** ### maybe we need a way to signal an error anyways, and then
** ### apache can abort the connection?
*/
const dav_resource *resource,
const apr_xml_doc *doc,
/*
** OPTIONAL HOOKS
** The following hooks are optional; if not defined, then the
** corresponding protocol methods will be unsupported.
*/
/*
** Set the state of a checked-in version-controlled resource.
**
** If the request specified a version, the version resource
** represents that version. If the request specified a label,
** then "version" is NULL, and "label" is the label.
**
** The depth argument is ignored for a file, and can be 0, 1, or
** DAV_INFINITY for a collection. The depth argument only applies
** with a label, not a version.
**
** If an error occurs in a child resource, then the return value is
** non-NULL, and *response is set to a multistatus response.
**
** This hook is optional; if not defined, then the UPDATE method
** will not be supported.
*/
const dav_resource *version,
const char *label,
int depth,
dav_response **response);
/*
** Add a label to a version. The resource is either a specific
** version, or a version selector, in which case the label should
** be added to the current target of the version selector. The
** version selector cannot be checked out.
**
** If replace != 0, any existing label by the same name is
** effectively deleted first. Otherwise, it is an error to
** attempt to add a label which already exists on some version
** of the same history resource.
**
** This hook is optional; if not defined, then the LABEL method
** will not be supported. If it is defined, then the remove_label
** hook must be defined also.
*/
const char *label,
int replace);
/*
** Remove a label from a version. The resource is either a specific
** version, or a version selector, in which case the label should
** be added to the current target of the version selector. The
** version selector cannot be checked out.
**
** It is an error if no such label exists on the specified version.
**
** This hook is optional, but if defined, the add_label hook
** must be defined also.
*/
const char *label);
/*
** Determine whether a null resource can be created as a workspace.
** The provider may restrict workspaces to certain locations.
** Returns 0 if the resource cannot be a workspace.
**
** This hook is optional; if the provider does not support workspaces,
** it should be set to NULL.
*/
/*
** Create a workspace resource. The resource must not already
** exist. Any <DAV:mkworkspace> element is passed to the provider
** in the "doc" structure; it may be empty.
**
** If workspace creation is succesful, the state of the resource
** object is updated appropriately.
**
** This hook is optional; if the provider does not support workspaces,
** it should be set to NULL.
*/
apr_xml_doc *doc);
/*
** Determine whether a null resource can be created as an activity.
** The provider may restrict activities to certain locations.
** Returns 0 if the resource cannot be an activity.
**
** This hook is optional; if the provider does not support activities,
** it should be set to NULL.
*/
/*
** Create an activity resource. The resource must not already
** exist.
**
** If activity creation is succesful, the state of the resource
** object is updated appropriately.
**
** This hook is optional; if the provider does not support activities,
** it should be set to NULL.
*/
/*
** Merge a resource (tree) into target resource (tree).
**
** ### more doc...
**
** This hook is optional; if the provider does not support merging,
** then this should be set to NULL.
*/
int no_auto_merge, int no_checkout,
/*
** If a provider needs a context to associate with this hooks structure,
** then this field may be used. In most cases, it will just be NULL.
*/
void *ctx;
};
/* --------------------------------------------------------------------
**
** BINDING FUNCTIONS
*/
/* binding provider hooks */
struct dav_hooks_binding {
/* Determine whether a resource can be the target of a binding.
* Returns 0 if the resource cannot be a binding target.
*/
/* Create a binding to a resource.
* The resource argument is the target of the binding;
* the binding argument must be a resource which does not already
* exist.
*/
/*
** If a provider needs a context to associate with this hooks structure,
** then this field may be used. In most cases, it will just be NULL.
*/
void *ctx;
};
/* --------------------------------------------------------------------
**
** SEARCH(DASL) FUNCTIONS
*/
/* search provider hooks */
struct dav_hooks_search {
/* Set header for a OPTION method
* An error may be returned.
* To set a hadder, this function might call
* apr_table_setn(r->headers_out, "DASL", dasl_optin1);
*
* Examples:
* DASL: <DAV:basicsearch>
* DASL: <http://foo.bar.com/syntax1>
* DASL: <http://akuma.com/syntax2>
*/
/* Search resources
* An error may be returned. *response will contain multistatus
* responses (if any) suitable for the body of the error. It is also
* possible to return NULL, yet still have multistatus responses.
* In this case, typically the caller should return a 207 (Multistatus)
* and the responses (in the body) as the HTTP response.
*/
dav_response **response);
/*
** If a provider needs a context to associate with this hooks structure,
** then this field may be used. In most cases, it will just be NULL.
*/
void *ctx;
};
/* --------------------------------------------------------------------
**
** MISCELLANEOUS STUFF
*/
/* fetch the "LimitXMLRequestBody" in force for this resource */
typedef struct {
int propid; /* live property ID */
/* --------------------------------------------------------------------
**
** DAV OPTIONS
*/
#define DAV_OPTIONS_EXTENSION_GROUP "dav_options"
typedef struct dav_options_provider
{
const dav_resource *resource,
const dav_resource *resource,
void *ctx;
const char *name,
const dav_options_provider *provider);
/* --------------------------------------------------------------------
**
** DAV RESOURCE TYPE HOOKS
*/
typedef struct dav_resource_type_provider
{
const char **name,
const char **uri);
#define DAV_RESOURCE_TYPE_GROUP "dav_resource_type"
const char *name,
const dav_resource_type_provider *provider);
#ifdef __cplusplus
}
#endif
#endif /* _MOD_DAV_H_ */
/** @} */