Apache2
mod_dav.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
26 #ifndef _MOD_DAV_H_
27 #define _MOD_DAV_H_
28 
29 #include "apr_hooks.h"
30 #include "apr_hash.h"
31 #include "apr_dbm.h"
32 #include "apr_tables.h"
33 
34 #include "httpd.h"
35 #include "util_filter.h"
36 #include "util_xml.h"
37 
38 #include <limits.h> /* for INT_MAX */
39 #include <time.h> /* for time_t */
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 
46 #define DAV_VERSION AP_SERVER_BASEREVISION
47 
48 #define DAV_XML_HEADER "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
49 #define DAV_XML_CONTENT_TYPE "text/xml; charset=\"utf-8\""
50 
51 #define DAV_READ_BLOCKSIZE 2048 /* used for reading input blocks */
52 
53 #define DAV_RESPONSE_BODY_1 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n<title>"
54 #define DAV_RESPONSE_BODY_2 "</title>\n</head><body>\n<h1>"
55 #define DAV_RESPONSE_BODY_3 "</h1>\n<p>"
56 #define DAV_RESPONSE_BODY_4 "</p>\n"
57 #define DAV_RESPONSE_BODY_5 "</body></html>\n"
58 
59 #define DAV_DO_COPY 0
60 #define DAV_DO_MOVE 1
61 
62 
63 #if 1
64 #define DAV_DEBUG 1
65 #define DEBUG_CR "\n"
66 #define DBG0(f) ap_log_error(APLOG_MARK, \
67  APLOG_ERR, 0, NULL, (f))
68 #define DBG1(f,a1) ap_log_error(APLOG_MARK, \
69  APLOG_ERR, 0, NULL, f, a1)
70 #define DBG2(f,a1,a2) ap_log_error(APLOG_MARK, \
71  APLOG_ERR, 0, NULL, f, a1, a2)
72 #define DBG3(f,a1,a2,a3) ap_log_error(APLOG_MARK, \
73  APLOG_ERR, 0, NULL, f, a1, a2, a3)
74 #else
75 #undef DAV_DEBUG
76 #define DEBUG_CR ""
77 #endif
78 
79 #define DAV_INFINITY INT_MAX /* for the Depth: header */
80 
81 /* Create a set of DAV_DECLARE(type), DAV_DECLARE_NONSTD(type) and
82  * DAV_DECLARE_DATA with appropriate export and import tags for the platform
83  */
84 #if !defined(WIN32)
85 #define DAV_DECLARE(type) type
86 #define DAV_DECLARE_NONSTD(type) type
87 #define DAV_DECLARE_DATA
88 #elif defined(DAV_DECLARE_STATIC)
89 #define DAV_DECLARE(type) type __stdcall
90 #define DAV_DECLARE_NONSTD(type) type
91 #define DAV_DECLARE_DATA
92 #elif defined(DAV_DECLARE_EXPORT)
93 #define DAV_DECLARE(type) __declspec(dllexport) type __stdcall
94 #define DAV_DECLARE_NONSTD(type) __declspec(dllexport) type
95 #define DAV_DECLARE_DATA __declspec(dllexport)
96 #else
97 #define DAV_DECLARE(type) __declspec(dllimport) type __stdcall
98 #define DAV_DECLARE_NONSTD(type) __declspec(dllimport) type
99 #define DAV_DECLARE_DATA __declspec(dllimport)
100 #endif
101 
102 /* --------------------------------------------------------------------
103 **
104 ** ERROR MANAGEMENT
105 */
106 
107 /*
108 ** dav_error structure.
109 **
110 ** In most cases, mod_dav uses a pointer to a dav_error structure. If the
111 ** pointer is NULL, then no error has occurred.
112 **
113 ** In certain cases, a dav_error structure is directly used. In these cases,
114 ** a status value of 0 means that an error has not occurred.
115 **
116 ** Note: this implies that status != 0 whenever an error occurs.
117 **
118 ** The desc field is optional (it may be NULL). When NULL, it typically
119 ** implies that Apache has a proper description for the specified status.
120 */
121 typedef struct dav_error {
122  int status; /* suggested HTTP status (0 for no error) */
123  int error_id; /* DAV-specific error ID */
124  const char *desc; /* DAV:responsedescription and error log */
125 
126  apr_status_t aprerr; /* APR error if any, or 0/APR_SUCCESS */
127 
128  const char *namespace; /* [optional] namespace of error */
129  const char *tagname; /* name of error-tag */
130 
131  struct dav_error *prev; /* previous error (in stack) */
132 
133  const char *childtags; /* error-tag may have children */
134 
136 
137 /*
138 ** Create a new error structure. save_errno will be filled with the current
139 ** errno value.
140 */
141 DAV_DECLARE(dav_error*) dav_new_error(apr_pool_t *p, int status,
143  const char *desc);
144 
145 
146 /*
147 ** Create a new error structure with tagname and (optional) namespace;
148 ** namespace may be NULL, which means "DAV:".
149 */
150 DAV_DECLARE(dav_error*) dav_new_error_tag(apr_pool_t *p, int status,
152  const char *desc,
153  const char *namespace,
154  const char *tagname);
155 
156 
157 /*
158 ** Push a new error description onto the stack of errors.
159 **
160 ** This function is used to provide an additional description to an existing
161 ** error.
162 **
163 ** <status> should contain the caller's view of what the current status is,
164 ** given the underlying error. If it doesn't have a better idea, then the
165 ** caller should pass prev->status.
166 **
167 ** <error_id> can specify a new error_id since the topmost description has
168 ** changed.
169 */
170 DAV_DECLARE(dav_error*) dav_push_error(apr_pool_t *p, int status, int error_id,
171  const char *desc, dav_error *prev);
172 
173 
174 /*
175 ** Join two errors together.
176 **
177 ** This function is used to add a new error stack onto an existing error so
178 ** that subsequent errors can be reported after the first error. It returns
179 ** the correct error stack to use so that the caller can blindly call it
180 ** without checking that both dest and src are not NULL.
181 **
182 ** <dest> is the error stack that the error will be added to.
183 **
184 ** <src> is the error stack that will be appended.
185 */
186 DAV_DECLARE(dav_error*) dav_join_error(dav_error* dest, dav_error* src);
187 
188 typedef struct dav_response dav_response;
189 
190 /*
191 ** dav_handle_err()
192 **
193 ** Handle the standard error processing. <err> must be non-NULL.
194 **
195 ** <response> is set by the following:
196 ** - dav_validate_request()
197 ** - dav_add_lock()
198 ** - repos_hooks->remove_resource
199 ** - repos_hooks->move_resource
200 ** - repos_hooks->copy_resource
201 ** - vsn_hooks->update
202 */
203 DAV_DECLARE(int) dav_handle_err(request_rec *r, dav_error *err,
205 
206 /* error ID values... */
207 
208 /* IF: header errors */
209 #define DAV_ERR_IF_PARSE 100 /* general parsing error */
210 #define DAV_ERR_IF_MULTIPLE_NOT 101 /* multiple "Not" found */
211 #define DAV_ERR_IF_UNK_CHAR 102 /* unknown char in header */
212 #define DAV_ERR_IF_ABSENT 103 /* no locktokens given */
213 #define DAV_ERR_IF_TAGGED 104 /* in parsing tagged-list */
214 #define DAV_ERR_IF_UNCLOSED_PAREN 105 /* in no-tagged-list */
215 
216 /* Prop DB errors */
217 #define DAV_ERR_PROP_BAD_MAJOR 200 /* major version was wrong */
218 #define DAV_ERR_PROP_READONLY 201 /* prop is read-only */
219 #define DAV_ERR_PROP_NO_DATABASE 202 /* writable db not avail */
220 #define DAV_ERR_PROP_NOT_FOUND 203 /* prop not found */
221 #define DAV_ERR_PROP_BAD_LOCKDB 204 /* could not open lockdb */
222 #define DAV_ERR_PROP_OPENING 205 /* problem opening propdb */
223 #define DAV_ERR_PROP_EXEC 206 /* problem exec'ing patch */
224 
225 /* Predefined DB errors */
226 /* ### any to define?? */
227 
228 /* Predefined locking system errors */
229 #define DAV_ERR_LOCK_OPENDB 400 /* could not open lockdb */
230 #define DAV_ERR_LOCK_NO_DB 401 /* no database defined */
231 #define DAV_ERR_LOCK_CORRUPT_DB 402 /* DB is corrupt */
232 #define DAV_ERR_LOCK_UNK_STATE_TOKEN 403 /* unknown State-token */
233 #define DAV_ERR_LOCK_PARSE_TOKEN 404 /* bad opaquelocktoken */
234 #define DAV_ERR_LOCK_SAVE_LOCK 405 /* err saving locks */
235 
236 /*
237 ** Some comments on Error ID values:
238 **
239 ** The numbers do not necessarily need to be unique. Uniqueness simply means
240 ** that two errors that have not been predefined above can be distinguished
241 ** from each other. At the moment, mod_dav does not use this distinguishing
242 ** feature, but it could be used in the future to collapse <response> elements
243 ** into groups based on the error ID (and associated responsedescription).
244 **
245 ** If a compute_desc is provided, then the error ID should be unique within
246 ** the context of the compute_desc function (so the function can figure out
247 ** what to filled into the desc).
248 **
249 ** Basically, subsystems can ignore defining new error ID values if they want
250 ** to. The subsystems *do* need to return the predefined errors when
251 ** appropriate, so that mod_dav can figure out what to do. Subsystems can
252 ** simply leave the error ID field unfilled (zero) if there isn't an error
253 ** that must be placed there.
254 */
255 
256 
257 /* --------------------------------------------------------------------
258 **
259 ** HOOK STRUCTURES
260 **
261 ** These are here for forward-declaration purposes. For more info, see
262 ** the section title "HOOK HANDLING" for more information, plus each
263 ** structure definition.
264 */
265 
266 /* forward-declare this structure */
267 typedef struct dav_hooks_propdb dav_hooks_propdb;
268 typedef struct dav_hooks_locks dav_hooks_locks;
269 typedef struct dav_hooks_vsn dav_hooks_vsn;
272 typedef struct dav_hooks_binding dav_hooks_binding;
273 typedef struct dav_hooks_search dav_hooks_search;
274 
275 /* ### deprecated name */
277 
278 
279 /* --------------------------------------------------------------------
280 **
281 ** RESOURCE HANDLING
282 */
283 
284 /*
285 ** Resource Types:
286 ** The base protocol defines only file and collection resources.
287 ** The versioning protocol defines several additional resource types
288 ** to represent artifacts of a version control system.
289 **
290 ** This enumeration identifies the type of URL used to identify the
291 ** resource. Since the same resource may have more than one type of
292 ** URL which can identify it, dav_resource_type cannot be used
293 ** alone to determine the type of the resource; attributes of the
294 ** dav_resource object must also be consulted.
295 */
296 typedef enum {
298 
299  DAV_RESOURCE_TYPE_REGULAR, /* file or collection; could be
300  * unversioned, or version selector,
301  * or baseline selector */
302 
303  DAV_RESOURCE_TYPE_VERSION, /* version or baseline URL */
304 
305  DAV_RESOURCE_TYPE_HISTORY, /* version or baseline history URL */
306 
307  DAV_RESOURCE_TYPE_WORKING, /* working resource URL */
308 
309  DAV_RESOURCE_TYPE_WORKSPACE, /* workspace URL */
310 
311  DAV_RESOURCE_TYPE_ACTIVITY, /* activity URL */
312 
313  DAV_RESOURCE_TYPE_PRIVATE /* repository-private type */
314 
316 
317 /*
318 ** Opaque, repository-specific information for a resource.
319 */
321 
322 typedef struct dav_acl_provider dav_acl_provider;
323 
324 /*
325 ** Resource descriptor, generated by a repository provider.
326 **
327 ** Note: the lock-null state is not explicitly represented here,
328 ** since it may be expensive to compute. Use dav_get_resource_state()
329 ** to determine whether a non-existent resource is a lock-null resource.
330 **
331 ** A quick explanation of how the flags can apply to different resources:
332 **
333 ** unversioned file or collection:
334 ** type = DAV_RESOURCE_TYPE_REGULAR
335 ** exists = ? (1 if exists)
336 ** collection = ? (1 if collection)
337 ** versioned = 0
338 ** baselined = 0
339 ** working = 0
340 **
341 ** version-controlled resource or configuration:
342 ** type = DAV_RESOURCE_TYPE_REGULAR
343 ** exists = 1
344 ** collection = ? (1 if collection)
345 ** versioned = 1
346 ** baselined = ? (1 if configuration)
347 ** working = ? (1 if checked out)
348 **
349 ** version/baseline history:
350 ** type = DAV_RESOURCE_TYPE_HISTORY
351 ** exists = 1
352 ** collection = 0
353 ** versioned = 0
354 ** baselined = 0
355 ** working = 0
356 **
357 ** version/baseline:
358 ** type = DAV_RESOURCE_TYPE_VERSION
359 ** exists = 1
360 ** collection = ? (1 if collection)
361 ** versioned = 1
362 ** baselined = ? (1 if baseline)
363 ** working = 0
364 **
365 ** working resource:
366 ** type = DAV_RESOURCE_TYPE_WORKING
367 ** exists = 1
368 ** collection = ? (1 if collection)
369 ** versioned = 1
370 ** baselined = 0
371 ** working = 1
372 **
373 ** workspace:
374 ** type = DAV_RESOURCE_TYPE_WORKSPACE
375 ** exists = ? (1 if exists)
376 ** collection = 1
377 ** versioned = ? (1 if version-controlled)
378 ** baselined = ? (1 if baseline-controlled)
379 ** working = ? (1 if checked out)
380 **
381 ** activity:
382 ** type = DAV_RESOURCE_TYPE_ACTIVITY
383 ** exists = ? (1 if exists)
384 ** collection = 0
385 ** versioned = 0
386 ** baselined = 0
387 ** working = 0
388 */
389 typedef struct dav_resource {
391 
392  int exists; /* 0 => null resource */
393 
394  int collection; /* 0 => file; can be 1 for
395  * REGULAR, VERSION, and WORKING resources,
396  * and is always 1 for WORKSPACE */
397 
398  int versioned; /* 0 => unversioned; can be 1 for
399  * REGULAR and WORKSPACE resources,
400  * and is always 1 for VERSION and WORKING */
401 
402  int baselined; /* 0 => not baselined; can be 1 for
403  * REGULAR, VERSION, and WORKSPACE resources;
404  * versioned == 1 when baselined == 1 */
405 
406  int working; /* 0 => not checked out; can be 1 for
407  * REGULAR and WORKSPACE resources,
408  * and is always 1 for WORKING */
409 
410  const char *uri; /* the URI for this resource;
411  * currently has an ABI flaw where sometimes it is
412  * assumed to be encoded and sometimes not */
413 
414  dav_resource_private *info; /* the provider's private info */
415 
416  const dav_hooks_repository *hooks; /* hooks used for this resource */
417 
418  /* When allocating items related specifically to this resource, the
419  following pool should be used. Its lifetime will be at least as
420  long as the dav_resource structure. */
422 
423  const dav_acl_provider *acls; /* acls used for this resource */
424 
425  void *ctx; /* additional parameter */
426 
428 
429 /*
430 ** Lock token type. Lock providers define the details of a lock token.
431 ** However, all providers are expected to at least be able to parse
432 ** the "opaquelocktoken" scheme, which is represented by a uuid_t.
433 */
434 typedef struct dav_locktoken dav_locktoken;
435 
436 DAV_DECLARE(dav_error *) dav_get_resource(request_rec *r, int label_allowed,
438 
439 
440 /* --------------------------------------------------------------------
441 **
442 ** BUFFER HANDLING
443 **
444 ** These buffers are used as a lightweight buffer reuse mechanism. Apache
445 ** provides sub-pool creation and destruction to much the same effect, but
446 ** the sub-pools are a bit more general and heavyweight than these buffers.
447 */
448 
449 /* buffer for reuse; can grow to accommodate needed size */
450 typedef struct
451 {
452  apr_size_t alloc_len; /* how much has been allocated */
453  apr_size_t cur_len; /* how much is currently being used */
454  char *buf; /* buffer contents */
455 } dav_buffer;
456 #define DAV_BUFFER_MINSIZE 256 /* minimum size for buffer */
457 #define DAV_BUFFER_PAD 64 /* amount of pad when growing */
458 
459 /* set the cur_len to the given size and ensure space is available */
460 DAV_DECLARE(void) dav_set_bufsize(apr_pool_t *p, dav_buffer *pbuf,
462 
463 /* initialize a buffer and copy the specified (null-term'd) string into it */
464 DAV_DECLARE(void) dav_buffer_init(apr_pool_t *p, dav_buffer *pbuf,
465  const char *str);
466 
467 /* check that the buffer can accommodate <extra_needed> more bytes */
468 DAV_DECLARE(void) dav_check_bufsize(apr_pool_t *p, dav_buffer *pbuf,
470 
471 /* append a string to the end of the buffer, adjust length */
472 DAV_DECLARE(void) dav_buffer_append(apr_pool_t *p, dav_buffer *pbuf,
473  const char *str);
474 
475 /* place a string on the end of the buffer, do NOT adjust length */
476 DAV_DECLARE(void) dav_buffer_place(apr_pool_t *p, dav_buffer *pbuf,
477  const char *str);
478 
479 /* place some memory on the end of a buffer; do NOT adjust length */
480 DAV_DECLARE(void) dav_buffer_place_mem(apr_pool_t *p, dav_buffer *pbuf,
481  const void *mem, apr_size_t amt,
483 
484 
485 /* --------------------------------------------------------------------
486 **
487 ** HANDY UTILITIES
488 */
489 
490 /* contains results from one of the getprop functions */
491 typedef struct
492 {
493  apr_text * propstats; /* <propstat> element text */
494  apr_text * xmlns; /* namespace decls for <response> elem */
496 
497 /* holds the contents of a <response> element */
499 {
500  const char *href; /* always */
501  const char *desc; /* optional description at <response> level */
502 
503  /* use status if propresult.propstats is NULL. */
505 
506  int status;
507 
509 };
510 
511 typedef struct
512 {
513  request_rec *rnew; /* new subrequest */
514  dav_error err; /* potential error response */
516 
517 
518 DAV_DECLARE(dav_lookup_result) dav_lookup_uri(const char *uri, request_rec *r,
520 
521 /* defines type of property info a provider is to return */
522 typedef enum {
523  DAV_PROP_INSERT_NOTDEF, /* property is defined by this provider,
524  but nothing was inserted because the
525  (live) property is not defined for this
526  resource (it may be present as a dead
527  property). */
528  DAV_PROP_INSERT_NOTSUPP, /* property is recognized by this provider,
529  but it is not supported, and cannot be
530  treated as a dead property */
531  DAV_PROP_INSERT_NAME, /* a property name (empty elem) was
532  inserted into the text block */
533  DAV_PROP_INSERT_VALUE, /* a property name/value pair was inserted
534  into the text block */
535  DAV_PROP_INSERT_SUPPORTED /* a supported live property was added to
536  the text block as a
537  <DAV:supported-live-property> element */
539 
540 /* ### this stuff is private to dav/fs/repos.c; move it... */
541 /* format a time string (buf must be at least DAV_TIMEBUF_SIZE chars) */
542 #define DAV_STYLE_ISO8601 1
543 #define DAV_STYLE_RFC822 2
544 #define DAV_TIMEBUF_SIZE 30
545 
546 /* Write a complete RESPONSE object out as a <DAV:response> xml
547  * element. Data is sent into brigade BB, which is auto-flushed into
548  * the output filter stack for request R. Use POOL for any temporary
549  * allocations.
550  *
551  * [Presumably the <multistatus> tag has already been written; this
552  * routine is shared by dav_send_multistatus and dav_stream_response.]
553  */
554 DAV_DECLARE(void) dav_send_one_response(dav_response *response,
556  request_rec *r,
558 
559 /* Factorized helper function: prep request_rec R for a multistatus
560  * response and write <multistatus> tag into BB, destined for
561  * R->output_filters. Use xml NAMESPACES in initial tag, if
562  * non-NULL.
563  */
564 DAV_DECLARE(void) dav_begin_multistatus(apr_bucket_brigade *bb,
565  request_rec *r, int status,
567 
568 /* Finish a multistatus response started by dav_begin_multistatus: */
569 DAV_DECLARE(apr_status_t) dav_finish_multistatus(request_rec *r,
571 
572 /* Send a multistatus response */
573 DAV_DECLARE(void) dav_send_multistatus(request_rec *r, int status,
576 
577 DAV_DECLARE(apr_text *) dav_failed_proppatch(apr_pool_t *p,
579 DAV_DECLARE(apr_text *) dav_success_proppatch(apr_pool_t *p,
581 
582 DAV_DECLARE(int) dav_get_depth(request_rec *r, int def_depth);
583 
584 DAV_DECLARE(int) dav_validate_root(const apr_xml_doc *doc,
585  const char *tagname);
586 DAV_DECLARE(int) dav_validate_root_ns(const apr_xml_doc *doc,
587  int ns, const char *tagname);
588 DAV_DECLARE(apr_xml_elem *) dav_find_child(const apr_xml_elem *elem,
589  const char *tagname);
590 DAV_DECLARE(apr_xml_elem *) dav_find_child_ns(const apr_xml_elem *elem,
591  int ns, const char *tagname);
592 DAV_DECLARE(apr_xml_elem *) dav_find_next_ns(const apr_xml_elem *elem,
593  int ns, const char *tagname);
594 
595 /* find and return the attribute with a name in the given namespace */
596 DAV_DECLARE(apr_xml_attr *) dav_find_attr_ns(const apr_xml_elem *elem,
597  int ns, const char *attrname);
598 
599 /* find and return the attribute with a given DAV: tagname */
600 DAV_DECLARE(apr_xml_attr *) dav_find_attr(const apr_xml_elem *elem,
601  const char *attrname);
602 
603 /* gather up all the CDATA into a single string */
604 DAV_DECLARE(const char *) dav_xml_get_cdata(const apr_xml_elem *elem, apr_pool_t *pool,
606 
607 /*
608 ** XML namespace handling
609 **
610 ** This structure tracks namespace declarations (xmlns:prefix="URI").
611 ** It maintains a one-to-many relationship of URIs-to-prefixes. In other
612 ** words, one URI may be defined by many prefixes, but any specific
613 ** prefix will specify only one URI.
614 **
615 ** Prefixes using the "g###" pattern can be generated automatically if
616 ** the caller does not have specific prefix requirements.
617 */
618 typedef struct {
620  apr_hash_t *uri_prefix; /* map URIs to an available prefix */
621  apr_hash_t *prefix_uri; /* map all prefixes to their URIs */
622  int count; /* counter for "g###" prefixes */
624 
625 /* create an empty dav_xmlns_info structure */
627 
628 /* add a specific prefix/URI pair. the prefix/uri should have a lifetime
629  at least that of xmlns->pool */
630 DAV_DECLARE(void) dav_xmlns_add(dav_xmlns_info *xi,
631  const char *prefix, const char *uri);
632 
633 /* add a URI (if not present); any prefix is acceptable and is returned.
634  the uri should have a lifetime at least that xmlns->pool */
635 DAV_DECLARE(const char *) dav_xmlns_add_uri(dav_xmlns_info *xi,
636  const char *uri);
637 
638 /* return the URI for a specified prefix (or NULL if the prefix is unknown) */
639 DAV_DECLARE(const char *) dav_xmlns_get_uri(dav_xmlns_info *xi,
640  const char *prefix);
641 
642 /* return an available prefix for a specified URI (or NULL if the URI
643  is unknown) */
644 DAV_DECLARE(const char *) dav_xmlns_get_prefix(dav_xmlns_info *xi,
645  const char *uri);
646 
647 /* generate xmlns declarations (appending into the given text) */
648 DAV_DECLARE(void) dav_xmlns_generate(dav_xmlns_info *xi,
650 
651 /* --------------------------------------------------------------------
652 **
653 ** DAV PLUGINS
654 */
655 
656 /* ### docco ... */
657 
658 /*
659 ** dav_provider
660 **
661 ** This structure wraps up all of the hooks that a mod_dav provider can
662 ** supply. The provider MUST supply <repos> and <propdb>. The rest are
663 ** optional and should contain NULL if that feature is not supplied.
664 **
665 ** Note that a provider cannot pick and choose portions from various
666 ** underlying implementations (which was theoretically possible in
667 ** mod_dav 1.0). There are too many dependencies between a dav_resource
668 ** (defined by <repos>) and the other functionality.
669 **
670 ** Live properties and report extensions are not part of the dav_provider
671 ** structure because they are handled through the APR_HOOK interface (to
672 ** allow for multiple providers). The core always provides some
673 ** properties, and then a given provider will add more properties.
674 **
675 ** Some providers may need to associate a context with the dav_provider
676 ** structure -- the ctx field is available for storing this context. Just
677 ** leave it NULL if it isn't required.
678 */
679 typedef struct {
686 
687  void *ctx;
688 } dav_provider;
689 
690 /*
691 ** gather_propsets: gather all live property propset-URIs
692 **
693 ** The hook implementor should push one or more URIs into the specified
694 ** array. These URIs are returned in the DAV: header to let clients know
695 ** what sets of live properties are supported by the installation. mod_dav
696 ** will place open/close angle brackets around each value (much like
697 ** a Coded-URL); quotes and brackets should not be in the value.
698 **
699 ** Example: http://apache.org/dav/props/
700 **
701 ** (of course, use your own domain to ensure a unique value)
702 */
703 APR_DECLARE_EXTERNAL_HOOK(dav, DAV, void, gather_propsets,
705 
706 /*
707 ** find_liveprop: find a live property, returning a non-zero, unique,
708 ** opaque identifier.
709 **
710 ** If the hook implementor determines the specified URI/name refers to
711 ** one of its properties, then it should fill in HOOKS and return a
712 ** non-zero value. The returned value is the "property ID" and will
713 ** be passed to the various liveprop hook functions.
714 **
715 ** Return 0 if the property is not defined by the hook implementor.
716 */
717 APR_DECLARE_EXTERNAL_HOOK(dav, DAV, int, find_liveprop,
718  (const dav_resource *resource,
719  const char *ns_uri, const char *name,
721 
722 /*
723 ** insert_all_liveprops: insert all (known) live property names/values.
724 **
725 ** The hook implementor should append XML text to PHDR, containing liveprop
726 ** names. If INSVALUE is true, then the property values should also be
727 ** inserted into the output XML stream.
728 **
729 ** The liveprop provider should insert *all* known and *defined* live
730 ** properties on the specified resource. If a particular liveprop is
731 ** not defined for this resource, then it should not be inserted.
732 */
733 APR_DECLARE_EXTERNAL_HOOK(dav, DAV, void, insert_all_liveprops,
736 
737 /*
738 ** deliver_report: given a parsed report request, process the request
739 ** an deliver the resulting report.
740 **
741 ** The hook implementer should decide whether it should handle the given
742 ** report, and if so, write the response to the output filter. If the
743 ** report is not relevant, return DECLINED.
744 */
745 APR_DECLARE_EXTERNAL_HOOK(dav, DAV, int, deliver_report,
746  (request_rec *r,
747  const dav_resource *resource,
748  const apr_xml_doc *doc,
749  ap_filter_t *output, dav_error **err))
750 
751 /*
752 ** gather_reports: get all reports.
753 **
754 ** The hook implementor should push one or more dav_report_elem structures
755 ** containing report names into the specified array. These names are returned
756 ** in the DAV:supported-reports-set property to let clients know
757 ** what reports are supported by the installation.
758 **
759 */
760 APR_DECLARE_EXTERNAL_HOOK(dav, DAV, void, gather_reports,
763 
764 /*
765  ** method_precondition: check method preconditions.
766  **
767  ** If a WebDAV extension needs to set any preconditions on a method, this
768  ** hook is where to do it. If the precondition fails, return an error
769  ** response with the tagname set to the value of the failed precondition.
770  **
771  ** If the method requires an XML body, this will be read and provided as
772  ** the doc value. If not, doc is NULL. An extension that needs to verify
773  ** the non-XML body of a request should register an input filter to do so
774  ** within this hook.
775  **
776  ** Methods like PUT will supply a single src resource, and the dst will
777  ** be NULL.
778  **
779  ** Methods like COPY or MOVE will trigger this hook twice. The first
780  ** invocation will supply just the source resource. The second invocation
781  ** will supply a source and destination. This allows preconditions on the
782  ** source resource to be verified before making an attempt to get the
783  ** destination resource.
784  **
785  ** Methods like PROPFIND and LABEL will trigger this hook initially for
786  ** the src resource, and then subsequently for each resource that has
787  ** been walked during processing, with the walked resource passed in dst,
788  ** and NULL passed in src.
789  **
790  ** As a rule, the src resource originates from a request that has passed
791  ** through httpd's authn/authz hooks, while the dst resource has not.
792  */
793 APR_DECLARE_EXTERNAL_HOOK(dav, DAV, int, method_precondition,
794  (request_rec *r,
795  dav_resource *src, const dav_resource *dst,
797 
798 
799 DAV_DECLARE(const dav_hooks_locks *) dav_get_lock_hooks(request_rec *r);
800 DAV_DECLARE(const dav_hooks_propdb *) dav_get_propdb_hooks(request_rec *r);
801 DAV_DECLARE(const dav_hooks_vsn *) dav_get_vsn_hooks(request_rec *r);
802 DAV_DECLARE(const dav_hooks_binding *) dav_get_binding_hooks(request_rec *r);
803 DAV_DECLARE(const dav_hooks_search *) dav_get_search_hooks(request_rec *r);
804 
805 DAV_DECLARE(void) dav_register_provider(apr_pool_t *p, const char *name,
807 DAV_DECLARE(const dav_provider *) dav_lookup_provider(const char *name);
808 DAV_DECLARE(const char *) dav_get_provider_name(request_rec *r);
809 DAV_DECLARE(const dav_provider *) dav_get_provider(request_rec *r);
810 
811 
812 /* ### deprecated */
813 #define DAV_GET_HOOKS_PROPDB(r) dav_get_propdb_hooks(r)
814 #define DAV_GET_HOOKS_LOCKS(r) dav_get_lock_hooks(r)
815 #define DAV_GET_HOOKS_VSN(r) dav_get_vsn_hooks(r)
816 #define DAV_GET_HOOKS_BINDING(r) dav_get_binding_hooks(r)
817 #define DAV_GET_HOOKS_SEARCH(r) dav_get_search_hooks(r)
818 
819 
820 /* --------------------------------------------------------------------
821 **
822 ** IF HEADER PROCESSING
823 **
824 ** Here is the definition of the If: header from RFC 2518, S9.4:
825 **
826 ** If = "If" ":" (1*No-tag-list | 1*Tagged-list)
827 ** No-tag-list = List
828 ** Tagged-list = Resource 1*List
829 ** Resource = Coded-URL
830 ** List = "(" 1*(["Not"](State-token | "[" entity-tag "]")) ")"
831 ** State-token = Coded-URL
832 ** Coded-URL = "<" absoluteURI ">" ; absoluteURI from RFC 2616
833 **
834 ** List corresponds to dav_if_state_list. No-tag-list corresponds to
835 ** dav_if_header with uri==NULL. Tagged-list corresponds to a sequence of
836 ** dav_if_header structures with (duplicate) uri==Resource -- one
837 ** dav_if_header per state_list. A second Tagged-list will start a new
838 ** sequence of dav_if_header structures with the new URI.
839 **
840 ** A summary of the semantics, mapped into our structures:
841 ** - Chained dav_if_headers: OR
842 ** - Chained dav_if_state_lists: AND
843 ** - NULL uri matches all resources
844 */
845 
846 typedef enum
847 {
850  dav_if_unknown /* the "unknown" state type; always matches false. */
852 
853 typedef struct dav_if_state_list
854 {
856 
858 #define DAV_IF_COND_NORMAL 0
859 #define DAV_IF_COND_NOT 1 /* "Not" was applied */
860 
861  const char *etag;
863 
866 
867 typedef struct dav_if_header
868 {
869  const char *uri;
873 
874  int dummy_header; /* used internally by the lock/etag validation */
876 
877 typedef struct dav_locktoken_list
878 {
882 
883 DAV_DECLARE(dav_error *) dav_get_locktoken_list(request_rec *r,
885 
886 
887 /* --------------------------------------------------------------------
888 **
889 ** LIVE PROPERTY HANDLING
890 */
891 
892 /* opaque type for PROPPATCH rollback information */
894 
896 {
897  /*
898  ** Insert property information into a text block. The property to
899  ** insert is identified by the propid value. The information to insert
900  ** is identified by the "what" argument, as follows:
901  ** DAV_PROP_INSERT_NAME
902  ** property name, as an empty XML element
903  ** DAV_PROP_INSERT_VALUE
904  ** property name/value, as an XML element
905  ** DAV_PROP_INSERT_SUPPORTED
906  ** if the property is defined on the resource, then
907  ** a DAV:supported-live-property element, as defined
908  ** by the DeltaV extensions to RFC2518.
909  **
910  ** Providers should return DAV_PROP_INSERT_NOTDEF if the property is
911  ** known and not defined for this resource, so should be handled as a
912  ** dead property. If a provider recognizes, but does not support, a
913  ** property, and does not want it handled as a dead property, it should
914  ** return DAV_PROP_INSERT_NOTSUPP.
915  **
916  ** Some DAV extensions, like CalDAV, specify both document elements
917  ** and property elements that need to be taken into account when
918  ** generating a property. The document element and property element
919  ** are made available in the dav_liveprop_elem structure under the
920  ** resource, accessible as follows:
921  **
922  ** dav_get_liveprop_element(resource);
923  **
924  ** Returns one of DAV_PROP_INSERT_* based on what happened.
925  **
926  ** ### we may need more context... ie. the lock database
927  */
929  int propid, dav_prop_insert what,
931 
932  /*
933  ** Determine whether a given property is writable.
934  **
935  ** ### we may want a different semantic. i.e. maybe it should be
936  ** ### "can we write <value> into this property?"
937  **
938  ** Returns 1 if the live property can be written, 0 if read-only.
939  */
940  int (*is_writable)(const dav_resource *resource, int propid);
941 
942  /*
943  ** This member defines the set of namespace URIs that the provider
944  ** uses for its properties. When insert_all is called, it will be
945  ** passed a list of integers that map from indices into this list
946  ** to namespace IDs for output generation.
947  **
948  ** The last entry in this list should be a NULL value (sentinel).
949  */
950  const char * const * namespace_uris;
951 
952  /*
953  ** ### this is not the final design. we want an open-ended way for
954  ** ### liveprop providers to attach *new* properties. To this end,
955  ** ### we'll have a "give me a list of the props you define", a way
956  ** ### to check for a prop's existence, a way to validate a set/remove
957  ** ### of a prop, and a way to execute/commit/rollback that change.
958  */
959 
960  /*
961  ** Validate that the live property can be assigned a value, and that
962  ** the provided value is valid.
963  **
964  ** elem will point to the XML element that names the property. For
965  ** example:
966  ** <lp1:executable>T</lp1:executable>
967  **
968  ** The provider can access the cdata fields and the child elements
969  ** to extract the relevant pieces.
970  **
971  ** operation is one of DAV_PROP_OP_SET or _DELETE.
972  **
973  ** The provider may return a value in *context which will be passed
974  ** to each of the exec/commit/rollback functions. For example, this
975  ** may contain an internal value which has been processed from the
976  ** input element.
977  **
978  ** The provider must set defer_to_dead to true (non-zero) or false.
979  ** If true, then the set/remove is deferred to the dead property
980  ** database. Note: it will be set to zero on entry.
981  */
982  dav_error * (*patch_validate)(const dav_resource *resource,
983  const apr_xml_elem *elem,
984  int operation,
985  void **context,
986  int *defer_to_dead);
987 
988  /* ### doc... */
989  dav_error * (*patch_exec)(const dav_resource *resource,
990  const apr_xml_elem *elem,
991  int operation,
992  void *context,
993  dav_liveprop_rollback **rollback_ctx);
994 
995  /* ### doc... */
997  int operation,
998  void *context,
999  dav_liveprop_rollback *rollback_ctx);
1000 
1001  /* ### doc... */
1002  dav_error * (*patch_rollback)(const dav_resource *resource,
1003  int operation,
1004  void *context,
1005  dav_liveprop_rollback *rollback_ctx);
1006 
1007  /*
1008  ** If a provider needs a context to associate with this hooks structure,
1009  ** then this field may be used. In most cases, it will just be NULL.
1010  */
1011  void *ctx;
1012 };
1013 
1014 /*
1015 ** dav_liveprop_spec: specify a live property
1016 **
1017 ** This structure is used as a standard way to determine if a particular
1018 ** property is a live property. Its use is not part of the mandated liveprop
1019 ** interface, but can be used by liveprop providers in conjunction with the
1020 ** utility routines below.
1021 **
1022 ** spec->name == NULL is the defined end-sentinel for a list of specs.
1023 */
1024 typedef struct {
1025  int ns; /* provider-local namespace index */
1026  const char *name; /* name of the property */
1027 
1028  int propid; /* provider-local property ID */
1029 
1030  int is_writable; /* is the property writable? */
1031 
1033 
1034 /*
1035 ** dav_liveprop_group: specify a group of liveprops
1036 **
1037 ** This structure specifies a group of live properties, their namespaces,
1038 ** and how to handle them.
1039 */
1040 typedef struct {
1042  const char * const *namespace_uris;
1044 
1046 
1047 /* ### docco */
1048 DAV_DECLARE(int) dav_do_find_liveprop(const char *ns_uri, const char *name,
1050  const dav_hooks_liveprop **hooks);
1051 
1052 /* ### docco */
1053 DAV_DECLARE(long) dav_get_liveprop_info(int propid,
1054  const dav_liveprop_group *group,
1056 
1057 /* ### docco */
1058 DAV_DECLARE(void) dav_register_liveprop_group(apr_pool_t *pool,
1059  const dav_liveprop_group *group);
1060 
1061 /* ### docco */
1062 DAV_DECLARE(long) dav_get_liveprop_ns_index(const char *uri);
1063 
1064 /* ### docco */
1065 DAV_DECLARE(long) dav_get_liveprop_ns_count(void);
1066 
1067 /* ### docco */
1068 DAV_DECLARE(void) dav_add_all_liveprop_xmlns(apr_pool_t *p,
1070 
1071 typedef struct {
1075 
1076 /*
1077  ** When calling insert_prop(), the associated request element and
1078  ** document is accessible using the following call.
1079  */
1080 DAV_DECLARE(dav_liveprop_elem *) dav_get_liveprop_element(const dav_resource
1081  *resource);
1082 
1083 /*
1084 ** The following three functions are part of mod_dav's internal handling
1085 ** for the core WebDAV properties. They are not part of mod_dav's API.
1086 */
1087 DAV_DECLARE_NONSTD(int) dav_core_find_liveprop(
1088  const dav_resource *resource,
1089  const char *ns_uri,
1090  const char *name,
1091  const dav_hooks_liveprop **hooks);
1092 DAV_DECLARE_NONSTD(void) dav_core_insert_all_liveprops(
1093  request_rec *r,
1097 DAV_DECLARE_NONSTD(void) dav_core_register_uris(apr_pool_t *p);
1098 
1099 
1100 /*
1101 ** Standard WebDAV Property Identifiers
1102 **
1103 ** A live property provider does not need to use these; they are simply
1104 ** provided for convenience.
1105 **
1106 ** Property identifiers need to be unique within a given provider, but not
1107 ** *across* providers (note: this uniqueness constraint was different in
1108 ** older versions of mod_dav).
1109 **
1110 ** The identifiers start at 20000 to make it easier for providers to avoid
1111 ** conflicts with the standard properties. The properties are arranged
1112 ** alphabetically, and may be reordered from time to time (as properties
1113 ** are introduced).
1114 **
1115 ** NOTE: there is no problem with reordering (e.g. binary compat) since the
1116 ** identifiers are only used within a given provider, which would pick up
1117 ** the entire set of changes upon a recompile.
1118 */
1119 enum {
1121 
1122  /* Standard WebDAV properties (RFC 2518) */
1134 
1135  /* DeltaV properties (from the I-D (#14)) */
1174 
1175  /* RFC 4331 quotas */
1178 
1180 };
1181 
1182 /*
1183 ** Property Identifier Registration
1184 **
1185 ** At the moment, mod_dav requires live property providers to ensure that
1186 ** each property returned has a unique value. For now, this is done through
1187 ** central registration (there are no known providers other than the default,
1188 ** so this remains manageable).
1189 **
1190 ** WARNING: the TEST ranges should never be "shipped".
1191 */
1192 #define DAV_PROPID_CORE 10000 /* ..10099. defined by mod_dav */
1193 #define DAV_PROPID_FS 10100 /* ..10299.
1194  mod_dav filesystem provider. */
1195 #define DAV_PROPID_TEST1 10300 /* ..10399 */
1196 #define DAV_PROPID_TEST2 10400 /* ..10499 */
1197 #define DAV_PROPID_TEST3 10500 /* ..10599 */
1198 /* Next: 10600 */
1199 
1200 
1201 /* --------------------------------------------------------------------
1202 **
1203 ** DATABASE FUNCTIONS
1204 */
1205 
1206 typedef struct dav_db dav_db;
1207 typedef struct dav_namespace_map dav_namespace_map;
1210 typedef struct {
1211  const char *ns; /* "" signals "no namespace" */
1212  const char *name;
1213 } dav_prop_name;
1214 
1215 /* hook functions to enable pluggable databases */
1216 struct dav_hooks_propdb
1218  dav_error * (*open)(apr_pool_t *p, const dav_resource *resource, int ro,
1219  dav_db **pdb);
1220  void (*close)(dav_db *db);
1221 
1222  /*
1223  ** In bulk, define any namespaces that the values and their name
1224  ** elements may need.
1225  **
1226  ** Note: sometimes mod_dav will defer calling this until output_value
1227  ** returns found==1. If the output process needs the dav_xmlns_info
1228  ** filled for its work, then it will need to fill it on demand rather
1229  ** than depending upon this hook to fill in the structure.
1230  **
1231  ** Note: this will *always* be called during an output sequence. Thus,
1232  ** the provider may rely solely on using this to fill the xmlns info.
1233  */
1234  dav_error * (*define_namespaces)(dav_db *db, dav_xmlns_info *xi);
1235 
1236  /*
1237  ** Output the value from the database (i.e. add an element name and
1238  ** the value into *phdr). Set *found based on whether the name/value
1239  ** was found in the propdb.
1240  **
1241  ** Note: it is NOT an error for the key/value pair to not exist.
1242  **
1243  ** The dav_xmlns_info passed to define_namespaces() is also passed to
1244  ** each output_value() call so that namespaces can be added on-demand.
1245  ** It can also be used to look up prefixes or URIs during the output
1246  ** process.
1247  */
1248  dav_error * (*output_value)(dav_db *db, const dav_prop_name *name,
1249  dav_xmlns_info *xi,
1250  apr_text_header *phdr, int *found);
1251 
1252  /*
1253  ** Build a mapping from "global" namespaces (stored in apr_xml_*)
1254  ** into provider-local namespace identifiers.
1255  **
1256  ** This mapping should be done once per set of namespaces, and the
1257  ** resulting mapping should be passed into the store() hook function.
1258  **
1259  ** Note: usually, there is just a single document/namespaces for all
1260  ** elements passed. However, the generality of creating multiple
1261  ** mappings and passing them to store() is provided here.
1262  **
1263  ** Note: this is only in preparation for a series of store() calls.
1264  ** As a result, the propdb must be open for read/write access when
1265  ** this function is called.
1266  */
1267  dav_error * (*map_namespaces)(dav_db *db,
1269  dav_namespace_map **mapping);
1270 
1271  /*
1272  ** Store a property value for a given name. The value->combined field
1273  ** MUST be set for this call.
1274  **
1275  ** ### WARNING: current providers will quote the text within ELEM.
1276  ** ### this implies you can call this function only once with a given
1277  ** ### element structure (a second time will quote it again).
1278  */
1279  dav_error * (*store)(dav_db *db, const dav_prop_name *name,
1280  const apr_xml_elem *elem,
1281  dav_namespace_map *mapping);
1282 
1283  /* remove a given property */
1284  dav_error * (*remove)(dav_db *db, const dav_prop_name *name);
1285 
1286  /* returns 1 if the record specified by "key" exists; 0 otherwise */
1287  int (*exists)(dav_db *db, const dav_prop_name *name);
1288 
1289  /*
1290  ** Iterate over the property names in the database.
1291  **
1292  ** iter->name.ns == iter->name.name == NULL when there are no more names.
1293  **
1294  ** Note: only one iteration may occur over the propdb at a time.
1295  */
1296  dav_error * (*first_name)(dav_db *db, dav_prop_name *pname);
1297  dav_error * (*next_name)(dav_db *db, dav_prop_name *pname);
1298 
1299  /*
1300  ** Rollback support: get rollback context, and apply it.
1301  **
1302  ** struct dav_deadprop_rollback is a provider-private structure; it
1303  ** should remember the name, and the name's old value (or the fact that
1304  ** the value was not present, and should be deleted if a rollback occurs).
1305  */
1306  dav_error * (*get_rollback)(dav_db *db, const dav_prop_name *name,
1308  dav_error * (*apply_rollback)(dav_db *db,
1309  dav_deadprop_rollback *rollback);
1310 
1311  /*
1312  ** If a provider needs a context to associate with this hooks structure,
1313  ** then this field may be used. In most cases, it will just be NULL.
1314  */
1315  void *ctx;
1316 };
1317 
1318 
1319 /* --------------------------------------------------------------------
1320 **
1321 ** LOCK FUNCTIONS
1322 */
1323 
1324 /* Used to represent a Timeout header of "Infinity" */
1325 #define DAV_TIMEOUT_INFINITE 0
1327 DAV_DECLARE(time_t) dav_get_timeout(request_rec *r);
1328 DAV_DECLARE(time_t) dav_get_timeout_string(request_rec *r, const char *s);
1329 
1330 /*
1331 ** Opaque, provider-specific information for a lock database.
1332 */
1333 typedef struct dav_lockdb_private dav_lockdb_private;
1334 
1335 /*
1336 ** Opaque, provider-specific information for a lock record.
1337 */
1338 typedef struct dav_lock_private dav_lock_private;
1339 
1340 /*
1341 ** Lock database type. Lock providers are urged to implement a "lazy" open, so
1342 ** doing an "open" is cheap until something is actually needed from the DB.
1343 */
1344 typedef struct
1346  const dav_hooks_locks *hooks; /* the hooks used for this lockdb */
1347  int ro; /* was it opened readonly? */
1350 
1351 } dav_lockdb;
1353 typedef enum {
1357 } dav_lock_scope;
1359 typedef enum {
1362 } dav_lock_type;
1364 typedef enum {
1365  DAV_LOCKREC_DIRECT, /* lock asserted on this resource */
1366  DAV_LOCKREC_INDIRECT, /* lock inherited from a parent */
1367  DAV_LOCKREC_INDIRECT_PARTIAL /* most info is not filled in */
1369 
1370 /*
1371 ** dav_lock: hold information about a lock on a resource.
1372 **
1373 ** This structure is used for both direct and indirect locks. A direct lock
1374 ** is a lock applied to a specific resource by the client. An indirect lock
1375 ** is one that is inherited from a parent resource by virtue of a non-zero
1376 ** Depth: header when the lock was applied.
1377 **
1378 ** mod_dav records both types of locks in the lock database, managing their
1379 ** addition/removal as resources are moved about the namespace.
1380 **
1381 ** Note that the lockdb is free to marshal this structure in any form that
1382 ** it likes.
1383 **
1384 ** For a "partial" lock, the <rectype> and <locktoken> fields must be filled
1385 ** in. All other (user) fields should be zeroed. The lock provider will
1386 ** usually fill in the <info> field, and the <next> field may be used to
1387 ** construct a list of partial locks.
1388 **
1389 ** The lock provider MUST use the info field to store a value such that a
1390 ** dav_lock structure can locate itself in the underlying lock database.
1391 ** This requirement is needed for refreshing: when an indirect dav_lock is
1392 ** refreshed, its reference to the direct lock does not specify the direct's
1393 ** resource, so the only way to locate the (refreshed, direct) lock in the
1394 ** database is to use the info field.
1395 **
1396 ** Note that <is_locknull> only refers to the resource where this lock was
1397 ** found.
1398 ** ### hrm. that says the abstraction is wrong. is_locknull may disappear.
1399 */
1400 typedef struct dav_lock
1402  dav_lock_rectype rectype; /* type of lock record */
1403  int is_locknull; /* lock establishes a locknull resource */
1404 
1405  /* ### put the resource in here? */
1407  dav_lock_scope scope; /* scope of the lock */
1408  dav_lock_type type; /* type of lock */
1409  int depth; /* depth of the lock */
1410  time_t timeout; /* when the lock will timeout */
1412  const dav_locktoken *locktoken; /* the token that was issued */
1414  const char *owner; /* (XML) owner of the lock */
1415  const char *auth_user; /* auth'd username owning lock */
1417  dav_lock_private *info; /* private to the lockdb */
1419  struct dav_lock *next; /* for managing a list of locks */
1420 } dav_lock;
1421 
1422 /* Property-related public lock functions */
1423 DAV_DECLARE(const char *)dav_lock_get_activelock(request_rec *r,
1424  dav_lock *locks,
1425  dav_buffer *pbuf);
1426 
1427 /* LockDB-related public lock functions */
1428 DAV_DECLARE(dav_error *) dav_open_lockdb(request_rec *r,
1429  int ro,
1430  dav_lockdb **lockdb);
1431 DAV_DECLARE(void) dav_close_lockdb(dav_lockdb *lockdb);
1432 DAV_DECLARE(dav_error *) dav_lock_parse_lockinfo(request_rec *r,
1433  const dav_resource *resource,
1437 DAV_DECLARE(int) dav_unlock(request_rec *r,
1439  const dav_locktoken *locktoken);
1440 DAV_DECLARE(dav_error *) dav_add_lock(request_rec *r,
1444 DAV_DECLARE(dav_error *) dav_notify_created(request_rec *r,
1445  dav_lockdb *lockdb,
1448  int depth);
1449 
1450 DAV_DECLARE(dav_error*) dav_lock_query(dav_lockdb *lockdb,
1451  const dav_resource *resource,
1452  dav_lock **locks);
1453 
1454 DAV_DECLARE(dav_error *) dav_validate_request(request_rec *r,
1456  int depth,
1459  int flags,
1460  dav_lockdb *lockdb);
1461 /*
1462 ** flags:
1463 ** 0x0F -- reserved for <dav_lock_scope> values
1464 **
1465 ** other flags, detailed below
1466 */
1467 #define DAV_VALIDATE_RESOURCE 0x0010 /* validate just the resource */
1468 #define DAV_VALIDATE_PARENT 0x0020 /* validate resource AND its parent */
1469 #define DAV_VALIDATE_ADD_LD 0x0040 /* add DAV:lockdiscovery into
1470  the 424 DAV:response */
1471 #define DAV_VALIDATE_USE_424 0x0080 /* return 424 status, not 207 */
1472 #define DAV_VALIDATE_IS_PARENT 0x0100 /* for internal use */
1473 #define DAV_VALIDATE_NO_MODIFY 0x0200 /* resource is not being modified
1474  so allow even if lock token
1475  is not provided */
1476 
1477 /* Lock-null related public lock functions */
1478 DAV_DECLARE(int) dav_get_resource_state(request_rec *r,
1479  const dav_resource *resource);
1481 /* Lock provider hooks. Locking is optional, so there may be no
1482  * lock provider for a given repository.
1483  */
1484 struct dav_hooks_locks
1485 {
1486  /* Return the supportedlock property for a resource */
1487  const char * (*get_supportedlock)(
1488  const dav_resource *resource
1489  );
1491  /* Parse a lock token URI, returning a lock token object allocated
1492  * in the given pool.
1493  */
1494  dav_error * (*parse_locktoken)(
1495  apr_pool_t *p,
1496  const char *char_token,
1497  dav_locktoken **locktoken_p
1498  );
1499 
1500  /* Format a lock token object into a URI string, allocated in
1501  * the given pool.
1502  *
1503  * Always returns non-NULL.
1504  */
1505  const char * (*format_locktoken)(
1506  apr_pool_t *p,
1507  const dav_locktoken *locktoken
1508  );
1509 
1510  /* Compare two lock tokens.
1511  *
1512  * Result < 0 => lt1 < lt2
1513  * Result == 0 => lt1 == lt2
1514  * Result > 0 => lt1 > lt2
1515  */
1517  const dav_locktoken *lt1,
1518  const dav_locktoken *lt2
1519  );
1520 
1521  /* Open the provider's lock database.
1522  *
1523  * The provider may or may not use a "real" database for locks
1524  * (a lock could be an attribute on a resource, for example).
1525  *
1526  * The provider may choose to use the value of the DAVLockDB directive
1527  * (as returned by dav_get_lockdb_path()) to decide where to place
1528  * any storage it may need.
1529  *
1530  * The request storage pool should be associated with the lockdb,
1531  * so it can be used in subsequent operations.
1532  *
1533  * If ro != 0, only readonly operations will be performed.
1534  * If force == 0, the open can be "lazy"; no subsequent locking operations
1535  * may occur.
1536  * If force != 0, locking operations will definitely occur.
1537  */
1538  dav_error * (*open_lockdb)(
1539  request_rec *r,
1540  int ro,
1541  int force,
1543  );
1544 
1545  /* Indicates completion of locking operations */
1546  void (*close_lockdb)(
1548  );
1549 
1550  /* Take a resource out of the lock-null state. */
1551  dav_error * (*remove_locknull_state)(
1552  dav_lockdb *lockdb,
1553  const dav_resource *resource
1554  );
1555 
1556  /*
1557  ** Create a (direct) lock structure for the given resource. A locktoken
1558  ** will be created.
1559  **
1560  ** The lock provider may store private information into lock->info.
1561  */
1562  dav_error * (*create_lock)(dav_lockdb *lockdb,
1563  const dav_resource *resource,
1564  dav_lock **lock);
1565 
1566  /*
1567  ** Get the locks associated with the specified resource.
1568  **
1569  ** If resolve_locks is true (non-zero), then any indirect locks are
1570  ** resolved to their actual, direct lock (i.e. the reference to followed
1571  ** to the original lock).
1572  **
1573  ** The locks, if any, are returned as a linked list in no particular
1574  ** order. If no locks are present, then *locks will be NULL.
1575  */
1576  dav_error * (*get_locks)(dav_lockdb *lockdb,
1578  int calltype,
1580 
1581 #define DAV_GETLOCKS_RESOLVED 0 /* resolve indirects to directs */
1582 #define DAV_GETLOCKS_PARTIAL 1 /* leave indirects partially filled */
1583 #define DAV_GETLOCKS_COMPLETE 2 /* fill out indirect locks */
1584 
1585  /*
1586  ** Find a particular lock on a resource (specified by its locktoken).
1587  **
1588  ** *lock will be set to NULL if the lock is not found.
1589  **
1590  ** Note that the provider can optimize the unmarshalling -- only one
1591  ** lock (or none) must be constructed and returned.
1592  **
1593  ** If partial_ok is true (non-zero), then an indirect lock can be
1594  ** partially filled in. Otherwise, another lookup is done and the
1595  ** lock structure will be filled out as a DAV_LOCKREC_INDIRECT.
1596  */
1597  dav_error * (*find_lock)(dav_lockdb *lockdb,
1598  const dav_resource *resource,
1599  const dav_locktoken *locktoken,
1600  int partial_ok,
1601  dav_lock **lock);
1602 
1603  /*
1604  ** Quick test to see if the resource has *any* locks on it.
1605  **
1606  ** This is typically used to determine if a non-existent resource
1607  ** has a lock and is (therefore) a locknull resource.
1608  **
1609  ** WARNING: this function may return TRUE even when timed-out locks
1610  ** exist (i.e. it may not perform timeout checks).
1611  */
1612  dav_error * (*has_locks)(dav_lockdb *lockdb,
1613  const dav_resource *resource,
1614  int *locks_present);
1615 
1616  /*
1617  ** Append the specified lock(s) to the set of locks on this resource.
1618  **
1619  ** If "make_indirect" is true (non-zero), then the specified lock(s)
1620  ** should be converted to an indirect lock (if it is a direct lock)
1621  ** before appending. Note that the conversion to an indirect lock does
1622  ** not alter the passed-in lock -- the change is internal the
1623  ** append_locks function.
1624  **
1625  ** Multiple locks are specified using the lock->next links.
1626  */
1627  dav_error * (*append_locks)(dav_lockdb *lockdb,
1628  const dav_resource *resource,
1629  int make_indirect,
1630  const dav_lock *lock);
1631 
1632  /*
1633  ** Remove any lock that has the specified locktoken.
1634  **
1635  ** If locktoken == NULL, then ALL locks are removed.
1636  */
1637  dav_error * (*remove_lock)(dav_lockdb *lockdb,
1638  const dav_resource *resource,
1639  const dav_locktoken *locktoken);
1640 
1641  /*
1642  ** Refresh all locks, found on the specified resource, which has a
1643  ** locktoken in the provided list.
1644  **
1645  ** If the lock is indirect, then the direct lock is referenced and
1646  ** refreshed.
1647  **
1648  ** Each lock that is updated is returned in the <locks> argument.
1649  ** Note that the locks will be fully resolved.
1650  */
1651  dav_error * (*refresh_locks)(dav_lockdb *lockdb,
1652  const dav_resource *resource,
1653  const dav_locktoken_list *ltl,
1654  time_t new_time,
1655  dav_lock **locks);
1656 
1657  /*
1658  ** Look up the resource associated with a particular locktoken.
1659  **
1660  ** The search begins at the specified <start_resource> and the lock
1661  ** specified by <locktoken>.
1662  **
1663  ** If the resource/token specifies an indirect lock, then the direct
1664  ** lock will be looked up, and THAT resource will be returned. In other
1665  ** words, this function always returns the resource where a particular
1666  ** lock (token) was asserted.
1667  **
1668  ** NOTE: this function pointer is allowed to be NULL, indicating that
1669  ** the provider does not support this type of functionality. The
1670  ** caller should then traverse up the repository hierarchy looking
1671  ** for the resource defining a lock with this locktoken.
1672  */
1673  dav_error * (*lookup_resource)(dav_lockdb *lockdb,
1674  const dav_locktoken *locktoken,
1675  const dav_resource *start_resource,
1676  const dav_resource **resource);
1677 
1678  /*
1679  ** If a provider needs a context to associate with this hooks structure,
1680  ** then this field may be used. In most cases, it will just be NULL.
1681  */
1682  void *ctx;
1683 };
1685 /* what types of resources can be discovered by dav_get_resource_state() */
1686 #define DAV_RESOURCE_LOCK_NULL 10 /* resource lock-null */
1687 #define DAV_RESOURCE_NULL 11 /* resource null */
1688 #define DAV_RESOURCE_EXISTS 12 /* resource exists */
1689 #define DAV_RESOURCE_ERROR 13 /* an error occurred */
1690 
1691 
1692 /* --------------------------------------------------------------------
1693 **
1694 ** PROPERTY HANDLING
1695 */
1697 typedef struct dav_propdb dav_propdb;
1698 
1699 #define DAV_PROPDB_NONE 0
1700 #define DAV_PROPDB_RO 1
1701 #define DAV_PROPDB_DISABLE_LOCKDISCOVERY 2
1702 
1703 DAV_DECLARE(dav_error *) dav_open_propdb(
1706  const dav_resource *resource,
1707  int flags,
1709  dav_propdb **propdb);
1710 
1711 DAV_DECLARE(dav_error *) dav_popen_propdb(
1712  apr_pool_t *p,
1713  request_rec *r,
1714  dav_lockdb *lockdb,
1715  const dav_resource *resource,
1716  int flags,
1718  dav_propdb **propdb);
1720 
1721 DAV_DECLARE(void) dav_close_propdb(dav_propdb *db);
1722 
1723 DAV_DECLARE(dav_get_props_result) dav_get_props(
1724  dav_propdb *db,
1725  apr_xml_doc *doc);
1726 
1727 DAV_DECLARE(dav_get_props_result) dav_get_allprops(
1728  dav_propdb *db,
1731 DAV_DECLARE(void) dav_get_liveprop_supported(
1732  dav_propdb *propdb,
1733  const char *ns_uri,
1734  const char *propname,
1736 
1737 /*
1738 ** 3-phase property modification.
1739 **
1740 ** 1) validate props. readable? unlocked? ACLs allow access?
1741 ** 2) execute operation (set/delete)
1742 ** 3) commit or rollback
1743 **
1744 ** ### eventually, auth must be available. a ref to the request_rec (which
1745 ** ### contains the auth info) should be in the shared context struct.
1746 **
1747 ** Each function may alter the error values and information contained within
1748 ** the context record. This should be done as an "increasing" level of
1749 ** error, rather than overwriting any previous error.
1750 **
1751 ** Note that commit() cannot generate errors. It should simply free the
1752 ** rollback information.
1753 **
1754 ** rollback() may generate additional errors because the rollback operation
1755 ** can sometimes fail(!).
1756 **
1757 ** The caller should allocate an array of these, one per operation. It should
1758 ** be zero-initialized, then the db, operation, and prop fields should be
1759 ** filled in before calling dav_prop_validate. Note that the set/delete
1760 ** operations are order-dependent. For a given (logical) context, the same
1761 ** pointer must be passed to each phase.
1762 **
1763 ** error_type is an internal value, but will have the same numeric value
1764 ** for each possible "desc" value. This allows the caller to group the
1765 ** descriptions via the error_type variable, rather than through string
1766 ** comparisons. Note that "status" does not provide enough granularity to
1767 ** differentiate/group the "desc" values.
1768 **
1769 ** Note that the propdb will maintain some (global) context across all
1770 ** of the property change contexts. This implies that you can have only
1771 ** one open transaction per propdb.
1772 */
1773 typedef struct dav_prop_ctx
1774 {
1777  apr_xml_elem *prop; /* property to affect */
1778 
1779  int operation;
1780 #define DAV_PROP_OP_SET 1 /* set a property value */
1781 #define DAV_PROP_OP_DELETE 2 /* delete a prop value */
1782 /* ### add a GET? */
1784  /* private items to the propdb */
1786  void *liveprop_ctx;
1787  struct dav_rollback_item *rollback; /* optional rollback info */
1789  dav_error *err; /* error (if any) */
1791  /* private to mod_dav.c */
1792  request_rec *r;
1793 
1794 } dav_prop_ctx;
1795 
1796 DAV_DECLARE_NONSTD(void) dav_prop_validate(dav_prop_ctx *ctx);
1797 DAV_DECLARE_NONSTD(void) dav_prop_exec(dav_prop_ctx *ctx);
1798 DAV_DECLARE_NONSTD(void) dav_prop_commit(dav_prop_ctx *ctx);
1799 DAV_DECLARE_NONSTD(void) dav_prop_rollback(dav_prop_ctx *ctx);
1800 
1801 #define DAV_PROP_CTX_HAS_ERR(dpc) ((dpc).err && (dpc).err->status >= 300)
1802 
1803 
1804 /* --------------------------------------------------------------------
1805 **
1806 ** WALKER STRUCTURE
1807 */
1808 
1809 enum {
1810  DAV_CALLTYPE_MEMBER = 1, /* called for a member resource */
1811  DAV_CALLTYPE_COLLECTION, /* called for a collection */
1812  DAV_CALLTYPE_LOCKNULL /* called for a locknull resource */
1813 };
1815 typedef struct
1816 {
1817  /* the client-provided context */
1818  void *walk_ctx;
1819 
1820  /* pool to use for allocations in the callback */
1821  apr_pool_t *pool;
1822 
1823  /* the current resource */
1824  const dav_resource *resource;
1825 
1826  /* OUTPUT: add responses to this */
1828 
1831 typedef struct
1833  int walk_type;
1834 #define DAV_WALKTYPE_AUTH 0x0001 /* limit to authorized files */
1835 #define DAV_WALKTYPE_NORMAL 0x0002 /* walk normal files */
1836 #define DAV_WALKTYPE_LOCKNULL 0x0004 /* walk locknull resources */
1837 #define DAV_WALKTYPE_TOLERANT 0x0008 /* tolerate non-fatal errors */
1838 
1839  /* callback function and a client context for the walk */
1840  dav_error * (*func)(dav_walk_resource *wres, int calltype);
1841  void *walk_ctx;
1842 
1843  /* what pool to use for allocations needed by walk logic */
1844  apr_pool_t *pool;
1845 
1846  /* beginning root of the walk */
1847  const dav_resource *root;
1848 
1849  /* lock database to enable walking LOCKNULL resources */
1850  dav_lockdb *lockdb;
1852 } dav_walk_params;
1853 
1854 /* directory tree walking context */
1855 typedef struct dav_walker_ctx
1856 {
1857  /* input: */
1859 
1861  /* ### client data... phasing out this big glom */
1862 
1863  /* this brigade buffers data being sent to r->output_filters */
1866  /* a scratch pool, used to stream responses and iteratively cleared. */
1869  request_rec *r; /* original request */
1871  /* for PROPFIND operations */
1873  int propfind_type;
1874 #define DAV_PROPFIND_IS_ALLPROP 1
1875 #define DAV_PROPFIND_IS_PROPNAME 2
1876 #define DAV_PROPFIND_IS_PROP 3
1878  apr_text *propstat_404; /* (cached) propstat giving a 404 error */
1880  const dav_if_header *if_header; /* for validation */
1881  const dav_locktoken *locktoken; /* for UNLOCK */
1882  const dav_lock *lock; /* for LOCK */
1883  int skip_root; /* for dav_inherit_locks() */
1884 
1885  int flags;
1886 
1887  dav_buffer work_buf; /* for dav_validate_request() */
1888 
1890 
1891 DAV_DECLARE(void) dav_add_response(dav_walk_resource *wres,
1892  int status,
1894 
1895 
1896 /* --------------------------------------------------------------------
1897 **
1898 ** "STREAM" STRUCTURE
1899 **
1900 ** mod_dav uses this abstraction for interacting with the repository
1901 ** while fetching/storing resources. mod_dav views resources as a stream
1902 ** of bytes.
1903 **
1904 ** Note that the structure is opaque -- it is private to the repository
1905 ** that created the stream in the repository's "open" function.
1906 **
1907 ** ### THIS STUFF IS GOING AWAY ... GET/read requests are handled by
1908 ** ### having the provider jam stuff straight into the filter stack.
1909 ** ### this is only left for handling PUT/write requests.
1910 */
1912 typedef struct dav_stream dav_stream;
1914 typedef enum {
1915  DAV_MODE_WRITE_TRUNC, /* truncate and open for writing */
1916  DAV_MODE_WRITE_SEEKABLE /* open for writing; random access */
1917 } dav_stream_mode;
1918 
1919 
1920 /* --------------------------------------------------------------------
1921 **
1922 ** REPOSITORY FUNCTIONS
1923 */
1924 
1925 /* Repository provider hooks */
1926 struct dav_hooks_repository
1927 {
1928  /* Flag for whether repository requires special GET handling.
1929  * If resources in the repository are not visible in the
1930  * filesystem location which URLs map to, then special handling
1931  * is required to first fetch a resource from the repository,
1932  * respond to the GET request, then free the resource copy.
1933  */
1934  int handle_get;
1935 
1936  /* Get a resource descriptor for the URI in a request. A descriptor
1937  * should always be returned even if the resource does not exist. This
1938  * repository has been identified as handling the resource given by
1939  * the URI, so an answer must be given. If there is a problem with the
1940  * URI or accessing the resource or whatever, then an error should be
1941  * returned.
1942  *
1943  * root_dir:
1944  * the root of the directory for which this repository is configured.
1945  *
1946  * label:
1947  * if a Label: header is present (and allowed), this is the label
1948  * to use to identify a version resource from the resource's
1949  * corresponding version history. Otherwise, it will be NULL.
1950  *
1951  * use_checked_in:
1952  * use the DAV:checked-in property of the resource identified by the
1953  * Request-URI to identify and return a version resource
1954  *
1955  * The provider may associate the request storage pool with the resource
1956  * (in the resource->pool field), to use in other operations on that
1957  * resource.
1958  */
1959  dav_error * (*get_resource)(
1960  request_rec *r,
1961  const char *root_dir,
1962  const char *label,
1963  int use_checked_in,
1965  );
1966 
1967  /* Get a resource descriptor for the parent of the given resource.
1968  * The resources need not exist. NULL is returned if the resource
1969  * is the root collection.
1970  *
1971  * An error should be returned only if there is a fatal error in
1972  * fetching information about the parent resource.
1973  */
1974  dav_error * (*get_parent_resource)(
1975  const dav_resource *resource,
1976  dav_resource **parent_resource
1977  );
1978 
1979  /* Determine whether two resource descriptors refer to the same resource.
1980  *
1981  * Result != 0 => the resources are the same.
1982  */
1983  int (*is_same_resource)(
1984  const dav_resource *res1,
1985  const dav_resource *res2
1986  );
1987 
1988  /* Determine whether one resource is a parent (immediate or otherwise)
1989  * of another.
1990  *
1991  * Result != 0 => res1 is a parent of res2.
1992  */
1994  const dav_resource *res1,
1995  const dav_resource *res2
1996  );
1997 
1998  /*
1999  ** Open a stream for this resource, using the specified mode. The
2000  ** stream will be returned in *stream.
2001  */
2002  dav_error * (*open_stream)(const dav_resource *resource,
2004  dav_stream **stream);
2005 
2006  /*
2007  ** Close the specified stream.
2008  **
2009  ** mod_dav will (ideally) make sure to call this. For safety purposes,
2010  ** a provider should (ideally) register a cleanup function with the
2011  ** request pool to get this closed and cleaned up.
2012  **
2013  ** Note the possibility of an error from the close -- it is entirely
2014  ** feasible that the close does a "commit" of some kind, which can
2015  ** produce an error.
2016  **
2017  ** commit should be TRUE (non-zero) or FALSE (0) if the stream was
2018  ** opened for writing. This flag states whether to retain the file
2019  ** or not.
2020  ** Note: the commit flag is ignored for streams opened for reading.
2021  */
2022  dav_error * (*close_stream)(dav_stream *stream, int commit);
2023 
2024  /*
2025  ** Write data to the stream.
2026  **
2027  ** All of the bytes must be written, or an error should be returned.
2028  */
2029  dav_error * (*write_stream)(dav_stream *stream,
2030  const void *buf, apr_size_t bufsize);
2031 
2032  /*
2033  ** Seek to an absolute position in the stream. This is used to support
2034  ** Content-Range in a GET/PUT.
2035  **
2036  ** NOTE: if this function is NULL (which is allowed), then any
2037  ** operations using Content-Range will be refused.
2038  */
2039  dav_error * (*seek_stream)(dav_stream *stream, apr_off_t abs_position);
2040 
2041  /*
2042  ** If a GET is processed using a stream (open_stream, read_stream)
2043  ** rather than via a sub-request (on get_pathname), then this function
2044  ** is used to provide the repository with a way to set the headers
2045  ** in the response.
2046  **
2047  ** This function may be called without a following deliver(), to
2048  ** handle a HEAD request.
2049  **
2050  ** This may be NULL if handle_get is FALSE.
2051  */
2052  dav_error * (*set_headers)(request_rec *r,
2053  const dav_resource *resource);
2054 
2055  /*
2056  ** The provider should deliver the resource into the request's output
2057  ** filter stack. Basically, this is the response to the GET method.
2058  **
2059  ** Note that this is called for all resources, including collections.
2060  ** The provider should determine what has content to deliver or not.
2061  **
2062  ** set_headers will be called prior to this function, allowing the
2063  ** provider to set the appropriate response headers.
2064  **
2065  ** This may be NULL if handle_get is FALSE.
2066  ** ### maybe toss handle_get and just use this function as the marker
2067  **
2068  ** API ISSUE: don't use the passed-in 'output' filter.
2069  **
2070  ** Instead, generate the response into the output filter stack for the
2071  ** request (r->output_filters). An implementation can use the request_rec
2072  ** that was passed to get_resource() for this purpose. Using 'output'
2073  ** filter for the response can cause unbounded memory usage.
2074  **
2075  ** See https://mail-archives.apache.org/mod_mbox/httpd-dev/201608.mbox/%3C20160822151917.GA22369%40redhat.com%3E
2076  */
2077  dav_error * (*deliver)(const dav_resource *resource,
2078  ap_filter_t *output);
2079 
2080  /* Create a collection resource. The resource must not already exist.
2081  *
2082  * Result == NULL if the collection was created successfully. Also, the
2083  * resource object is updated to reflect that the resource exists, and
2084  * is a collection.
2085  */
2086  dav_error * (*create_collection)(
2088  );
2089 
2090  /* Copy one resource to another. The destination may exist, if it is
2091  * versioned.
2092  * Handles both files and collections. Properties are copied as well.
2093  * If the destination exists and is versioned, the provider must update
2094  * the destination to have identical content to the source,
2095  * recursively for collections.
2096  * The depth argument is ignored for a file, and can be either 0 or
2097  * DAV_INFINITY for a collection.
2098  * If an error occurs in a child resource, then the return value is
2099  * non-NULL, and *response is set to a multistatus response.
2100  * If the copy is successful, the dst resource object is
2101  * updated to reflect that the resource exists.
2102  */
2103  dav_error * (*copy_resource)(
2104  const dav_resource *src,
2105  dav_resource *dst,
2106  int depth,
2108  );
2109 
2110  /* Move one resource to another. The destination must not exist.
2111  * Handles both files and collections. Properties are moved as well.
2112  * If an error occurs in a child resource, then the return value is
2113  * non-NULL, and *response is set to a multistatus response.
2114  * If the move is successful, the src and dst resource objects are
2115  * updated to reflect that the source no longer exists, and the
2116  * destination does.
2117  */
2118  dav_error * (*move_resource)(
2119  dav_resource *src,
2120  dav_resource *dst,
2122  );
2123 
2124  /* Remove a resource. Handles both files and collections.
2125  * Removes any associated properties as well.
2126  * If an error occurs in a child resource, then the return value is
2127  * non-NULL, and *response is set to a multistatus response.
2128  * If the delete is successful, the resource object is updated to
2129  * reflect that the resource no longer exists.
2130  */
2131  dav_error * (*remove_resource)(
2134  );
2135 
2136  /* Walk a resource hierarchy.
2137  *
2138  * Iterates over the resource hierarchy specified by params->root.
2139  * Control of the walk and the callback are specified by 'params'.
2140  *
2141  * An error may be returned. *response will contain multistatus
2142  * responses (if any) suitable for the body of the error. It is also
2143  * possible to return NULL, yet still have multistatus responses.
2144  * In this case, typically the caller should return a 207 (Multistatus)
2145  * and the responses (in the body) as the HTTP response.
2146  */
2147  dav_error * (*walk)(const dav_walk_params *params, int depth,
2149 
2150  /* Get the entity tag for a resource */
2151  const char * (*getetag)(const dav_resource *resource);
2152 
2153  /*
2154  ** If a provider needs a context to associate with this hooks structure,
2155  ** then this field may be used. In most cases, it will just be NULL.
2156  */
2157  void *ctx;
2158 
2159  /* Get the request rec for a resource */
2160  request_rec * (*get_request_rec)(const dav_resource *resource);
2161 
2162  /* Get the pathname for a resource */
2163  const char * (*get_pathname)(const dav_resource *resource);
2164 };
2165 
2166 
2167 /* --------------------------------------------------------------------
2168 **
2169 ** VERSIONING FUNCTIONS
2170 */
2171 
2172 
2173 /* dav_add_vary_header
2174  *
2175  * If there were any headers in the request which require a Vary header
2176  * in the response, add it.
2177  */
2178 DAV_DECLARE(void) dav_add_vary_header(request_rec *in_req,
2180  const dav_resource *resource);
2181 
2182 /*
2183 ** Flags specifying auto-versioning behavior, returned by
2184 ** the auto_versionable hook. The value returned depends
2185 ** on both the state of the resource and the value of the
2186 ** DAV:auto-versioning property for the resource.
2187 **
2188 ** If the resource does not exist (null or lock-null),
2189 ** DAV_AUTO_VERSION_ALWAYS causes creation of a new version-controlled resource
2190 **
2191 ** If the resource is checked in,
2192 ** DAV_AUTO_VERSION_ALWAYS causes it to be checked out always,
2193 ** DAV_AUTO_VERSION_LOCKED causes it to be checked out only when locked
2194 **
2195 ** If the resource is checked out,
2196 ** DAV_AUTO_VERSION_ALWAYS causes it to be checked in always,
2197 ** DAV_AUTO_VERSION_LOCKED causes it to be checked in when unlocked
2198 ** (note: a provider should allow auto-checkin only for resources which
2199 ** were automatically checked out)
2200 **
2201 ** In all cases, DAV_AUTO_VERSION_NEVER results in no auto-versioning behavior.
2202 */
2203 typedef enum {
2208 
2209 /*
2210 ** This structure is used to record what auto-versioning operations
2211 ** were done to make a resource writable, so that they can be undone
2212 ** at the end of a request.
2213 */
2214 typedef struct {
2215  int resource_versioned; /* 1 => resource was auto-version-controlled */
2216  int resource_checkedout; /* 1 => resource was auto-checked-out */
2217  int parent_checkedout; /* 1 => parent was auto-checked-out */
2218  dav_resource *parent_resource; /* parent resource, if it was needed */
2220 
2221 /* Ensure that a resource is writable. If there is no versioning
2222  * provider, then this is essentially a no-op. Versioning repositories
2223  * require explicit resource creation and checkout before they can
2224  * be written to. If a new resource is to be created, or an existing
2225  * resource deleted, the parent collection must be checked out as well.
2226  *
2227  * Set the parent_only flag to only make the parent collection writable.
2228  * Otherwise, both parent and child are made writable as needed. If the
2229  * child does not exist, then a new versioned resource is created and
2230  * checked out.
2231  *
2232  * If auto-versioning is not enabled for a versioned resource, then an error is
2233  * returned, since the resource cannot be modified.
2234  *
2235  * The dav_auto_version_info structure is filled in with enough information
2236  * to restore both parent and child resources to the state they were in
2237  * before the auto-versioning operations occurred.
2238  */
2239 DAV_DECLARE(dav_error *) dav_auto_checkout(
2240  request_rec *r,
2242  int parent_only,
2244 
2245 /* Revert the writability of resources back to what they were
2246  * before they were modified. If undo == 0, then the resource
2247  * modifications are maintained (i.e. they are checked in).
2248  * If undo != 0, then resource modifications are discarded
2249  * (i.e. they are unchecked out).
2250  *
2251  * Set the unlock flag to indicate that the resource is about
2252  * to be unlocked; it will be checked in if the resource
2253  * auto-versioning property indicates it should be. In this case,
2254  * av_info is ignored, so it can be NULL.
2255  *
2256  * The resource argument may be NULL if only the parent resource
2257  * was checked out (i.e. the parent_only was != 0 in the
2258  * dav_auto_checkout call).
2259  */
2260 DAV_DECLARE(dav_error *) dav_auto_checkin(
2261  request_rec *r,
2263  int undo,
2264  int unlock,
2266 
2267 /*
2268 ** This structure is used to describe available reports
2269 **
2270 ** "nmspace" should be valid XML and URL-quoted. mod_dav will place
2271 ** double-quotes around it and use it in an xmlns declaration.
2272 */
2273 typedef struct {
2274  const char *nmspace; /* namespace of the XML report element */
2275  const char *name; /* element name for the XML report */
2277 
2278 
2279 /* Versioning provider hooks */
2280 struct dav_hooks_vsn
2281 {
2282  /*
2283  ** MANDATORY HOOKS
2284  ** The following hooks are mandatory for all versioning providers;
2285  ** they define the functionality needed to implement "core" versioning.
2286  */
2287 
2288  /* Return supported versioning options.
2289  * Each dav_text item in the list will be returned as a separate
2290  * DAV header. Providers are advised to limit the length of an
2291  * individual text item to 63 characters, to conform to the limit
2292  * used by MS Web Folders.
2293  */
2295 
2296  /* Get the value of a specific option for an OPTIONS request.
2297  * The option being requested is given by the parsed XML
2298  * element object "elem". The value of the option should be
2299  * appended to the "option" text object.
2300  */
2301  dav_error * (*get_option)(const dav_resource *resource,
2302  const apr_xml_elem *elem,
2303  apr_text_header *option);
2305  /* Determine whether a non-versioned (or non-existent) resource
2306  * is versionable. Returns != 0 if resource can be versioned.
2307  */
2308  int (*versionable)(const dav_resource *resource);
2309 
2310  /* Determine whether auto-versioning is enabled for a resource
2311  * (which may not exist, or may not be versioned). If the resource
2312  * is a checked-out resource, the provider must only enable
2313  * auto-checkin if the resource was automatically checked out.
2314  *
2315  * The value returned depends on both the state of the resource
2316  * and the value of its DAV:auto-version property. See the description
2317  * of the dav_auto_version enumeration above for the details.
2318  */
2320 
2321  /* Put a resource under version control. If the resource already
2322  * exists unversioned, then it becomes the initial version of the
2323  * new version history, and it is replaced by a version selector
2324  * which targets the new version.
2325  *
2326  * If the resource does not exist, then a new version-controlled
2327  * resource is created which either targets an existing version (if the
2328  * "target" argument is not NULL), or the initial, empty version
2329  * in a new history resource (if the "target" argument is NULL).
2330  *
2331  * If successful, the resource object state is updated appropriately
2332  * (that is, changed to refer to the new version-controlled resource).
2333  */
2334  dav_error * (*vsn_control)(dav_resource *resource,
2335  const char *target);
2336 
2337  /* Checkout a resource. If successful, the resource
2338  * object state is updated appropriately.
2339  *
2340  * The auto_checkout flag will be set if this checkout is being
2341  * done automatically, as part of some method which modifies
2342  * the resource. The provider must remember that the resource
2343  * was automatically checked out, so it can determine whether it
2344  * can be automatically checked in. (Auto-checkin should only be
2345  * enabled for resources which were automatically checked out.)
2346  *
2347  * If the working resource has a different URL from the
2348  * target resource, a dav_resource descriptor is returned
2349  * for the new working resource. Otherwise, the original
2350  * resource descriptor will refer to the working resource.
2351  * The working_resource argument can be NULL if the caller
2352  * is not interested in the working resource.
2353  *
2354  * If the client has specified DAV:unreserved or DAV:fork-ok in the
2355  * checkout request, then the corresponding flags are set. If
2356  * DAV:activity-set has been specified, then create_activity is set
2357  * if DAV:new was specified; otherwise, the DAV:href elements' CDATA
2358  * (the actual href text) is passed in the "activities" array (each
2359  * element of the array is a const char *). activities will be NULL
2360  * no DAV:activity-set was provided or when create_activity is set.
2361  */
2362  dav_error * (*checkout)(dav_resource *resource,
2363  int auto_checkout,
2364  int is_unreserved, int is_fork_ok,
2365  int create_activity,
2366  apr_array_header_t *activities,
2367  dav_resource **working_resource);
2369  /* Uncheckout a checked-out resource. If successful, the resource
2370  * object state is updated appropriately.
2371  */
2372  dav_error * (*uncheckout)(dav_resource *resource);
2373 
2374  /* Checkin a checked-out resource. If successful, the resource
2375  * object state is updated appropriately, and the
2376  * version_resource descriptor will refer to the new version.
2377  * The version_resource argument can be NULL if the caller
2378  * is not interested in the new version resource.
2379  *
2380  * If the client has specified DAV:keep-checked-out in the checkin
2381  * request, then the keep_checked_out flag is set. The provider
2382  * should create a new version, but keep the resource in the
2383  * checked-out state.
2384  */
2385  dav_error * (*checkin)(dav_resource *resource,
2386  int keep_checked_out,
2387  dav_resource **version_resource);
2388 
2389  /*
2390  ** Return the set of reports available at this resource.
2391  **
2392  ** An array of report elements should be returned, with an end-marker
2393  ** element containing namespace==NULL. The value of the
2394  ** DAV:supported-report-set property will be constructed and
2395  ** returned.
2396  */
2397  dav_error * (*avail_reports)(const dav_resource *resource,
2398  const dav_report_elem **reports);
2399 
2400  /*
2401  ** Determine whether a Label header can be used
2402  ** with a particular report. The dav_xml_doc structure
2403  ** contains the parsed report request body.
2404  ** Returns 0 if the Label header is not allowed.
2405  */
2407 
2408  /*
2409  ** Generate a report on a resource. Since a provider is free
2410  ** to define its own reports, and the value of request headers
2411  ** may affect the interpretation of a report, the request record
2412  ** must be passed to this routine.
2413  **
2414  ** The dav_xml_doc structure contains the parsed report request
2415  ** body. The report response should be generated into the specified
2416  ** output filter.
2417  **
2418  ** If an error occurs, and a response has not yet been generated,
2419  ** then an error can be returned from this function. mod_dav will
2420  ** construct an appropriate error response. Once some output has
2421  ** been placed into the filter, however, the provider should not
2422  ** return an error -- there is no way that mod_dav can deliver it
2423  ** properly.
2424  **
2425  ** ### maybe we need a way to signal an error anyways, and then
2426  ** ### apache can abort the connection?
2427  **
2428  ** API ISSUE: don't use the passed-in 'output' filter.
2429  **
2430  ** Instead, generate the response into the output filter stack for the
2431  ** request (r->output_filters). An implementation can use the request_rec
2432  ** that was passed to get_resource() for this purpose. Using 'output'
2433  ** filter for the response can cause unbounded memory usage.
2434  **
2435  ** See https://mail-archives.apache.org/mod_mbox/httpd-dev/201608.mbox/%3C20160822151917.GA22369%40redhat.com%3E
2436  */
2437  dav_error * (*deliver_report)(request_rec *r,
2438  const dav_resource *resource,
2439  const apr_xml_doc *doc,
2440  ap_filter_t *output);
2441 
2442  /*
2443  ** OPTIONAL HOOKS
2444  ** The following hooks are optional; if not defined, then the
2445  ** corresponding protocol methods will be unsupported.
2446  */
2447 
2448  /*
2449  ** Set the state of a checked-in version-controlled resource.
2450  **
2451  ** If the request specified a version, the version resource
2452  ** represents that version. If the request specified a label,
2453  ** then "version" is NULL, and "label" is the label.
2454  **
2455  ** The depth argument is ignored for a file, and can be 0, 1, or
2456  ** DAV_INFINITY for a collection. The depth argument only applies
2457  ** with a label, not a version.
2458  **
2459  ** If an error occurs in a child resource, then the return value is
2460  ** non-NULL, and *response is set to a multistatus response.
2461  **
2462  ** This hook is optional; if not defined, then the UPDATE method
2463  ** will not be supported.
2464  */
2465  dav_error * (*update)(const dav_resource *resource,
2466  const dav_resource *version,
2467  const char *label,
2468  int depth,
2470 
2471  /*
2472  ** Add a label to a version. The resource is either a specific
2473  ** version, or a version selector, in which case the label should
2474  ** be added to the current target of the version selector. The
2475  ** version selector cannot be checked out.
2476  **
2477  ** If replace != 0, any existing label by the same name is
2478  ** effectively deleted first. Otherwise, it is an error to
2479  ** attempt to add a label which already exists on some version
2480  ** of the same history resource.
2481  **
2482  ** This hook is optional; if not defined, then the LABEL method
2483  ** will not be supported. If it is defined, then the remove_label
2484  ** hook must be defined also.
2485  */
2486  dav_error * (*add_label)(const dav_resource *resource,
2487  const char *label,
2488  int replace);
2489 
2490  /*
2491  ** Remove a label from a version. The resource is either a specific
2492  ** version, or a version selector, in which case the label should
2493  ** be added to the current target of the version selector. The
2494  ** version selector cannot be checked out.
2495  **
2496  ** It is an error if no such label exists on the specified version.
2497  **
2498  ** This hook is optional, but if defined, the add_label hook
2499  ** must be defined also.
2500  */
2501  dav_error * (*remove_label)(const dav_resource *resource,
2502  const char *label);
2503 
2504  /*
2505  ** Determine whether a null resource can be created as a workspace.
2506  ** The provider may restrict workspaces to certain locations.
2507  ** Returns 0 if the resource cannot be a workspace.
2508  **
2509  ** This hook is optional; if the provider does not support workspaces,
2510  ** it should be set to NULL.
2511  */
2513 
2514  /*
2515  ** Create a workspace resource. The resource must not already
2516  ** exist. Any <DAV:mkworkspace> element is passed to the provider
2517  ** in the "doc" structure; it may be empty.
2518  **
2519  ** If workspace creation is successful, the state of the resource
2520  ** object is updated appropriately.
2521  **
2522  ** This hook is optional; if the provider does not support workspaces,
2523  ** it should be set to NULL.
2524  */
2525  dav_error * (*make_workspace)(dav_resource *resource,
2526  apr_xml_doc *doc);
2527 
2528  /*
2529  ** Determine whether a null resource can be created as an activity.
2530  ** The provider may restrict activities to certain locations.
2531  ** Returns 0 if the resource cannot be an activity.
2532  **
2533  ** This hook is optional; if the provider does not support activities,
2534  ** it should be set to NULL.
2535  */
2537 
2538  /*
2539  ** Create an activity resource. The resource must not already
2540  ** exist.
2541  **
2542  ** If activity creation is successful, the state of the resource
2543  ** object is updated appropriately.
2544  **
2545  ** This hook is optional; if the provider does not support activities,
2546  ** it should be set to NULL.
2547  */
2548  dav_error * (*make_activity)(dav_resource *resource);
2549 
2550  /*
2551  ** Merge a resource (tree) into target resource (tree).
2552  **
2553  ** ### more doc...
2554  **
2555  ** This hook is optional; if the provider does not support merging,
2556  ** then this should be set to NULL.
2557  **
2558  ** API ISSUE: don't use the passed-in 'output' filter.
2559  **
2560  ** Instead, generate the response into the output filter stack for the
2561  ** request (r->output_filters). An implementation can use the request_rec
2562  ** that was passed to get_resource() for this purpose. Using 'output'
2563  ** filter for the response can cause unbounded memory usage.
2564  **
2565  ** See https://mail-archives.apache.org/mod_mbox/httpd-dev/201608.mbox/%3C20160822151917.GA22369%40redhat.com%3E
2566  */
2567  dav_error * (*merge)(dav_resource *target, dav_resource *source,
2568  int no_auto_merge, int no_checkout,
2569  apr_xml_elem *prop_elem,
2570  ap_filter_t *output);
2571 
2572  /*
2573  ** If a provider needs a context to associate with this hooks structure,
2574  ** then this field may be used. In most cases, it will just be NULL.
2575  */
2576  void *ctx;
2577 };
2578 
2579 
2580 /* --------------------------------------------------------------------
2581 **
2582 ** BINDING FUNCTIONS
2583 */
2584 
2585 /* binding provider hooks */
2586 struct dav_hooks_binding {
2588  /* Determine whether a resource can be the target of a binding.
2589  * Returns 0 if the resource cannot be a binding target.
2590  */
2591  int (*is_bindable)(const dav_resource *resource);
2592 
2593  /* Create a binding to a resource.
2594  * The resource argument is the target of the binding;
2595  * the binding argument must be a resource which does not already
2596  * exist.
2597  */
2598  dav_error * (*bind_resource)(const dav_resource *resource,
2599  dav_resource *binding);
2600 
2601  /*
2602  ** If a provider needs a context to associate with this hooks structure,
2603  ** then this field may be used. In most cases, it will just be NULL.
2604  */
2605  void *ctx;
2606 
2607 };
2608 
2609 
2610 /* --------------------------------------------------------------------
2611 **
2612 ** SEARCH(DASL) FUNCTIONS
2613 */
2614 
2615 /* search provider hooks */
2616 struct dav_hooks_search {
2617  /* Set header for a OPTION method
2618  * An error may be returned.
2619  * To set a hadder, this function might call
2620  * apr_table_setn(r->headers_out, "DASL", dasl_optin1);
2621  *
2622  * Examples:
2623  * DASL: <DAV:basicsearch>
2624  * DASL: <http://foo.bar.com/syntax1>
2625  * DASL: <http://akuma.com/syntax2>
2626  */
2627  dav_error * (*set_option_head)(request_rec *r);
2628 
2629  /* Search resources
2630  * An error may be returned. *response will contain multistatus
2631  * responses (if any) suitable for the body of the error. It is also
2632  * possible to return NULL, yet still have multistatus responses.
2633  * In this case, typically the caller should return a 207 (Multistatus)
2634  * and the responses (in the body) as the HTTP response.
2635  */
2636  dav_error * (*search_resource)(request_rec *r,
2638 
2639  /*
2640  ** If a provider needs a context to associate with this hooks structure,
2641  ** then this field may be used. In most cases, it will just be NULL.
2642  */
2643  void *ctx;
2644 
2645 };
2646 
2647 
2648 /* --------------------------------------------------------------------
2649 **
2650 ** MISCELLANEOUS STUFF
2651 */
2652 
2653 typedef struct {
2654  int propid; /* live property ID */
2655  const dav_hooks_liveprop *provider; /* the provider defining this prop */
2657 
2658 
2659 /* MS-WDV combined operation handler */
2660 DAV_DECLARE(int) dav_mswdv_preprocessing(request_rec *r);
2661 DAV_DECLARE(dav_error *) dav_mswdv_postprocessing(request_rec *r);
2662 DAV_DECLARE(apr_status_t) dav_mswdv_output(ap_filter_t *f,
2669 
2670 /* --------------------------------------------------------------------
2671 **
2672 ** DAV ACL HOOKS
2673 */
2674 
2675 struct dav_acl_provider
2677  dav_error * (*acl_check_method)(request_rec *r,
2678  const dav_resource *resource);
2680  dav_error * (*acl_check_read)(request_rec *r,
2681  const dav_resource *resource);
2682 
2683  dav_error * (*acl_check_prop)(request_rec *r,
2685  const dav_prop_name *name,
2689  const dav_resource *resource,
2690  int new_resource_created);
2691  void *ctx;
2692 };
2694 DAV_DECLARE(void) dav_acl_provider_register(apr_pool_t *p,
2695  const dav_acl_provider *acl);
2696 
2697 DAV_DECLARE(const dav_acl_provider *) dav_get_acl_providers(void);
2698 
2699 
2700 /* --------------------------------------------------------------------
2701 **
2702 ** DAV OPTIONS
2703 */
2704 #define DAV_OPTIONS_EXTENSION_GROUP "dav_options"
2705 
2706 typedef struct dav_options_provider
2707 {
2708  dav_error* (*dav_header)(request_rec *r,
2709  const dav_resource *resource,
2711 
2712  dav_error* (*dav_method)(request_rec *r,
2716  void *ctx;
2718 
2719 extern DAV_DECLARE(const dav_options_provider *) dav_get_options_providers(const char *name);
2720 
2721 extern DAV_DECLARE(void) dav_options_provider_register(apr_pool_t *p,
2722  const char *name,
2724 
2725 /* --------------------------------------------------------------------
2726 **
2727 ** DAV RESOURCE TYPE HOOKS
2728 */
2729 
2730 typedef struct dav_resource_type_provider
2733  const char **name,
2734  const char **uri);
2736 
2737 #define DAV_RESOURCE_TYPE_GROUP "dav_resource_type"
2738 
2739 DAV_DECLARE(void) dav_resource_type_provider_register(apr_pool_t *p,
2740  const char *name,
2742 
2743 DAV_DECLARE(const dav_resource_type_provider *) dav_get_resource_type_providers(const char *name);
2744 
2745 #ifdef __cplusplus
2746 }
2747 #endif
2748 
2749 #endif /* _MOD_DAV_H_ */
APR-UTIL DBM library.
APR Hash Tables.
Apache hook functions.
APR Table library.
apr_read_type_e
Definition: apr_buckets.h:62
#define APR_DECLARE_EXTERNAL_HOOK(ns, link, ret, name, args)
Definition: apr_hooks.h:118
const char * ns_uri
Definition: mod_dav.h:1089
apr_text_header * phdr
Definition: mod_dav.h:649
apr_bucket_brigade ap_input_mode_t apr_read_type_e apr_off_t readbytes
Definition: mod_dav.h:2664
int int use_checked_in
Definition: mod_dav.h:437
int ro
Definition: mod_dav.h:1428
struct dav_lockdb_private dav_lockdb_private
Definition: mod_dav.h:1332
dav_lockdb const dav_resource int int depth
Definition: mod_dav.h:1447
int int apr_status_t const char * desc
Definition: mod_dav.h:143
dav_resource int dav_locktoken dav_response int flags
Definition: mod_dav.h:1458
struct dav_error dav_error
dav_buffer apr_size_t size
Definition: mod_dav.h:461
const dav_resource dav_prop_insert what
Definition: mod_dav.h:1095
request_rec * r
Definition: mod_dav.h:518
const char const dav_provider * hooks
Definition: mod_dav.h:806
struct dav_walker_ctx dav_walker_ctx
struct dav_locktoken_list dav_locktoken_list
dav_lock_rectype
Definition: mod_dav.h:1363
struct dav_propdb dav_propdb
Definition: mod_dav.h:1693
dav_lock * locks
Definition: mod_dav.h:1423
dav_buffer apr_size_t extra_needed
Definition: mod_dav.h:469
dav_auto_version
Definition: mod_dav.h:2199
request_rec int must_be_absolute
Definition: mod_dav.h:519
dav_buffer const char * str
Definition: mod_dav.h:465
dav_lockdb const dav_resource int apr_array_header_t * ns_xlate
Definition: mod_dav.h:1704
struct dav_resource dav_resource
struct dav_resource_private dav_resource_private
Definition: mod_dav.h:320
namespace const char * tagname
Definition: mod_dav.h:153
dav_lock_scope
Definition: mod_dav.h:1352
struct dav_if_header dav_if_header
dav_prop_insert
Definition: mod_dav.h:522
const dav_liveprop_group const dav_liveprop_spec ** info
Definition: mod_dav.h:1055
apr_array_header_t * prop_ctx
Definition: mod_dav.h:578
int int error_id
Definition: mod_dav.h:142
dav_error dav_response * response
Definition: mod_dav.h:204
int const char * attrname
Definition: mod_dav.h:597
request_rec int apr_array_header_t * namespaces
Definition: mod_dav.h:566
int status
Definition: mod_dav.h:141
struct dav_deadprop_rollback dav_deadprop_rollback
Definition: mod_dav.h:1207
#define DAV_DECLARE_NONSTD(type)
Definition: mod_dav.h:86
struct dav_options_provider dav_options_provider
struct dav_stream dav_stream
Definition: mod_dav.h:1908
struct dav_db dav_db
Definition: mod_dav.h:1205
dav_resource int parent_only
Definition: mod_dav.h:2238
struct dav_prop_ctx dav_prop_ctx
int dav_lockdb ** lockdb
Definition: mod_dav.h:1429
const dav_resource * resource
Definition: mod_dav.h:1094
request_rec * out_req
Definition: mod_dav.h:2175
int int dav_resource ** res_p
Definition: mod_dav.h:437
int dav_response * first
Definition: mod_dav.h:574
int ns
Definition: mod_dav.h:587
dav_lock_type
Definition: mod_dav.h:1358
const char const char * propname
Definition: mod_dav.h:1730
int dav_get_props_result * propstats
Definition: mod_dav.h:1889
struct dav_resource_type_provider dav_resource_type_provider
struct dav_locktoken dav_locktoken
Definition: mod_dav.h:434
dav_lockdb const dav_resource int apr_array_header_t dav_propdb ** propdb
Definition: mod_dav.h:1705
dav_lockdb const dav_resource int resource_state
Definition: mod_dav.h:1446
dav_resource int dav_auto_version_info * av_info
Definition: mod_dav.h:2239
dav_buffer const void apr_size_t amt
Definition: mod_dav.h:481
const dav_resource const dav_locktoken * locktoken
Definition: mod_dav.h:1438
apr_bucket_brigade * bb
Definition: mod_dav.h:555
dav_stream_mode
Definition: mod_dav.h:1910
dav_if_state_type
Definition: mod_dav.h:847
int label_allowed
Definition: mod_dav.h:436
const char * prefix
Definition: mod_dav.h:631
const dav_resource dav_lockdb const apr_xml_doc dav_lock ** lock_request
Definition: mod_dav.h:1435
const dav_resource dav_lockdb const apr_xml_doc * doc
Definition: mod_dav.h:1434
const char * s
Definition: mod_dav.h:1327
dav_error * src
Definition: mod_dav.h:186
#define DAV_DECLARE(type)
Definition: mod_dav.h:85
const char const char apr_text_header * body
Definition: mod_dav.h:1731
struct dav_lock dav_lock
dav_buffer const void * mem
Definition: mod_dav.h:481
int def_depth
Definition: mod_dav.h:582
int int const char dav_error * prev
Definition: mod_dav.h:171
apr_bucket_brigade ap_input_mode_t mode
Definition: mod_dav.h:2662
struct dav_namespace_map dav_namespace_map
Definition: mod_dav.h:1206
dav_buffer const void apr_size_t apr_size_t pad
Definition: mod_dav.h:482
int int apr_status_t aprerr
Definition: mod_dav.h:142
const dav_resource dav_lockdb dav_lock * request
Definition: mod_dav.h:1441
dav_resource_type
Definition: mod_dav.h:296
const char const dav_liveprop_group * group
Definition: mod_dav.h:1049
apr_pool_t int strip_white
Definition: mod_dav.h:605
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:557
dav_resource int undo
Definition: mod_dav.h:2259
dav_buffer * pbuf
Definition: mod_dav.h:460
const char const char * uri
Definition: mod_dav.h:631
dav_error * err
Definition: mod_dav.h:203
dav_locktoken_list ** ltl
Definition: mod_dav.h:884
struct dav_lock_private dav_lock_private
Definition: mod_dav.h:1337
const dav_acl_provider * acl
Definition: mod_dav.h:2691
const char const dav_options_provider * provider
Definition: mod_dav.h:2719
struct dav_if_state_list dav_if_state_list
struct dav_liveprop_rollback dav_liveprop_rollback
Definition: mod_dav.h:893
dav_hooks_propdb dav_hooks_db
Definition: mod_dav.h:276
const char * name
Definition: mod_dav.h:805
apr_bucket_brigade ap_input_mode_t apr_read_type_e block
Definition: mod_dav.h:2663
dav_resource int int unlock
Definition: mod_dav.h:2260
@ DAV_LOCKREC_DIRECT
Definition: mod_dav.h:1364
@ DAV_LOCKREC_INDIRECT_PARTIAL
Definition: mod_dav.h:1366
@ DAV_LOCKREC_INDIRECT
Definition: mod_dav.h:1365
@ DAV_AUTO_VERSION_NEVER
Definition: mod_dav.h:2200
@ DAV_AUTO_VERSION_LOCKED
Definition: mod_dav.h:2202
@ DAV_AUTO_VERSION_ALWAYS
Definition: mod_dav.h:2201
@ DAV_LOCKSCOPE_UNKNOWN
Definition: mod_dav.h:1353
@ DAV_LOCKSCOPE_SHARED
Definition: mod_dav.h:1355
@ DAV_LOCKSCOPE_EXCLUSIVE
Definition: mod_dav.h:1354
@ DAV_PROP_INSERT_NAME
Definition: mod_dav.h:531
@ DAV_PROP_INSERT_VALUE
Definition: mod_dav.h:533
@ DAV_PROP_INSERT_NOTDEF
Definition: mod_dav.h:523
@ DAV_PROP_INSERT_NOTSUPP
Definition: mod_dav.h:528
@ DAV_PROP_INSERT_SUPPORTED
Definition: mod_dav.h:535
@ DAV_LOCKTYPE_UNKNOWN
Definition: mod_dav.h:1359
@ DAV_LOCKTYPE_WRITE
Definition: mod_dav.h:1360
@ DAV_PROPID_BEGIN
Definition: mod_dav.h:1120
@ DAV_PROPID_getcontentlength
Definition: mod_dav.h:1126
@ DAV_PROPID_version_history
Definition: mod_dav.h:1170
@ DAV_PROPID_activity_checkout_set
Definition: mod_dav.h:1136
@ DAV_PROPID_getetag
Definition: mod_dav.h:1128
@ DAV_PROPID_baseline_collection
Definition: mod_dav.h:1141
@ DAV_PROPID_auto_version
Definition: mod_dav.h:1140
@ DAV_PROPID_checkout_fork
Definition: mod_dav.h:1147
@ DAV_PROPID_supported_live_property_set
Definition: mod_dav.h:1164
@ DAV_PROPID_workspace
Definition: mod_dav.h:1172
@ DAV_PROPID_version_controlled_binding_set
Definition: mod_dav.h:1168
@ DAV_PROPID_checkin_fork
Definition: mod_dav.h:1146
@ DAV_PROPID_activity_version_set
Definition: mod_dav.h:1138
@ DAV_PROPID_creationdate
Definition: mod_dav.h:1123
@ DAV_PROPID_auto_merge_set
Definition: mod_dav.h:1139
@ DAV_PROPID_label_name_set
Definition: mod_dav.h:1155
@ DAV_PROPID_workspace_checkout_set
Definition: mod_dav.h:1173
@ DAV_PROPID_END
Definition: mod_dav.h:1179
@ DAV_PROPID_resourcetype
Definition: mod_dav.h:1131
@ DAV_PROPID_variant_set
Definition: mod_dav.h:1167
@ DAV_PROPID_source
Definition: mod_dav.h:1132
@ DAV_PROPID_root_version
Definition: mod_dav.h:1159
@ DAV_PROPID_checked_out
Definition: mod_dav.h:1145
@ DAV_PROPID_default_variant
Definition: mod_dav.h:1153
@ DAV_PROPID_getcontenttype
Definition: mod_dav.h:1127
@ DAV_PROPID_version_controlled_configuration
Definition: mod_dav.h:1169
@ DAV_PROPID_merge_set
Definition: mod_dav.h:1156
@ DAV_PROPID_version_name
Definition: mod_dav.h:1171
@ DAV_PROPID_supported_method_set
Definition: mod_dav.h:1163
@ DAV_PROPID_successor_set
Definition: mod_dav.h:1162
@ DAV_PROPID_eclipsed_set
Definition: mod_dav.h:1154
@ DAV_PROPID_getlastmodified
Definition: mod_dav.h:1129
@ DAV_PROPID_activity_set
Definition: mod_dav.h:1137
@ DAV_PROPID_checked_in
Definition: mod_dav.h:1144
@ DAV_PROPID_baseline_controlled_collection
Definition: mod_dav.h:1142
@ DAV_PROPID_displayname
Definition: mod_dav.h:1124
@ DAV_PROPID_comment
Definition: mod_dav.h:1149
@ DAV_PROPID_getcontentlanguage
Definition: mod_dav.h:1125
@ DAV_PROPID_unreserved
Definition: mod_dav.h:1166
@ DAV_PROPID_checkout_set
Definition: mod_dav.h:1148
@ DAV_PROPID_quota_used_bytes
Definition: mod_dav.h:1177
@ DAV_PROPID_lockdiscovery
Definition: mod_dav.h:1130
@ DAV_PROPID_supported_report_set
Definition: mod_dav.h:1165
@ DAV_PROPID_precursor_set
Definition: mod_dav.h:1157
@ DAV_PROPID_current_activity_set
Definition: mod_dav.h:1151
@ DAV_PROPID_subbaseline_set
Definition: mod_dav.h:1161
@ DAV_PROPID_subactivity_set
Definition: mod_dav.h:1160
@ DAV_PROPID_quota_available_bytes
Definition: mod_dav.h:1176
@ DAV_PROPID_current_workspace_set
Definition: mod_dav.h:1152
@ DAV_PROPID_creator_displayname
Definition: mod_dav.h:1150
@ DAV_PROPID_baseline_controlled_collection_set
Definition: mod_dav.h:1143
@ DAV_PROPID_supportedlock
Definition: mod_dav.h:1133
@ DAV_PROPID_predecessor_set
Definition: mod_dav.h:1158
@ DAV_MODE_WRITE_SEEKABLE
Definition: mod_dav.h:1912
@ DAV_MODE_WRITE_TRUNC
Definition: mod_dav.h:1911
@ dav_if_unknown
Definition: mod_dav.h:850
@ dav_if_opaquelock
Definition: mod_dav.h:849
@ dav_if_etag
Definition: mod_dav.h:848
@ DAV_CALLTYPE_LOCKNULL
Definition: mod_dav.h:1808
@ DAV_CALLTYPE_COLLECTION
Definition: mod_dav.h:1807
@ DAV_CALLTYPE_MEMBER
Definition: mod_dav.h:1806
@ DAV_RESOURCE_TYPE_PRIVATE
Definition: mod_dav.h:313
@ DAV_RESOURCE_TYPE_VERSION
Definition: mod_dav.h:303
@ DAV_RESOURCE_TYPE_WORKSPACE
Definition: mod_dav.h:309
@ DAV_RESOURCE_TYPE_REGULAR
Definition: mod_dav.h:299
@ DAV_RESOURCE_TYPE_WORKING
Definition: mod_dav.h:307
@ DAV_RESOURCE_TYPE_ACTIVITY
Definition: mod_dav.h:311
@ DAV_RESOURCE_TYPE_HISTORY
Definition: mod_dav.h:305
@ DAV_RESOURCE_TYPE_UNKNOWN
Definition: mod_dav.h:297
int
Definition: mod_proxy.h:674
int apr_status_t
Definition: apr_errno.h:44
struct apr_hash_t apr_hash_t
Definition: apr_hash.h:52
off_t apr_off_t
Definition: apr.h:396
size_t apr_size_t
Definition: apr.h:394
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
HTTP Daemon routines.
The representation of a filter chain.
Definition: util_filter.h:278
Definition: apr_tables.h:62
Definition: apr_buckets.h:263
Definition: apr_xml.h:64
Definition: apr_xml.h:53
Definition: apr_xml.h:148
Definition: apr_xml.h:200
Definition: apr_xml.h:162
Definition: mod_dav.h:2672
void * ctx
Definition: mod_dav.h:2687
void(* acl_post_processing)(request_rec *r, const dav_resource *resource, int new_resource_created)
Definition: mod_dav.h:2684
Definition: mod_dav.h:2210
Definition: mod_dav.h:451
apr_size_t alloc_len
Definition: mod_dav.h:452
apr_size_t cur_len
Definition: mod_dav.h:453
char * buf
Definition: mod_dav.h:454
Definition: mod_dav.h:2649
Definition: mod_dav.h:121
int status
Definition: mod_dav.h:122
const char * childtags
Definition: mod_dav.h:133
struct dav_error * prev
Definition: mod_dav.h:131
const char * desc
Definition: mod_dav.h:124
int error_id
Definition: mod_dav.h:123
apr_status_t aprerr
Definition: mod_dav.h:126
const char * tagname
Definition: mod_dav.h:128
Definition: mod_dav.h:492
apr_text * xmlns
Definition: mod_dav.h:494
apr_text * propstats
Definition: mod_dav.h:493
Definition: mod_dav.h:2582
void * ctx
Definition: mod_dav.h:2601
int(* is_bindable)(const dav_resource *resource)
Definition: mod_dav.h:2587
Definition: mod_dav.h:896
int(* is_writable)(const dav_resource *resource, int propid)
Definition: mod_dav.h:940
void * ctx
Definition: mod_dav.h:1011
const char *const * namespace_uris
Definition: mod_dav.h:950
void(* patch_commit)(const dav_resource *resource, int operation, void *context, dav_liveprop_rollback *rollback_ctx)
Definition: mod_dav.h:996
dav_prop_insert(* insert_prop)(const dav_resource *resource, int propid, dav_prop_insert what, apr_text_header *phdr)
Definition: mod_dav.h:928
Definition: mod_dav.h:1481
int(* compare_locktoken)(const dav_locktoken *lt1, const dav_locktoken *lt2)
Definition: mod_dav.h:1512
void(* close_lockdb)(dav_lockdb *lockdb)
Definition: mod_dav.h:1542
void * ctx
Definition: mod_dav.h:1678
Definition: mod_dav.h:1216
void(* close)(dav_db *db)
Definition: mod_dav.h:1219
int(* exists)(dav_db *db, const dav_prop_name *name)
Definition: mod_dav.h:1286
void * ctx
Definition: mod_dav.h:1314
Definition: mod_dav.h:1923
int(* is_same_resource)(const dav_resource *res1, const dav_resource *res2)
Definition: mod_dav.h:1979
void * ctx
Definition: mod_dav.h:2153
int(* is_parent_resource)(const dav_resource *res1, const dav_resource *res2)
Definition: mod_dav.h:1989
int handle_get
Definition: mod_dav.h:1930
Definition: mod_dav.h:2612
void * ctx
Definition: mod_dav.h:2639
Definition: mod_dav.h:2277
int(* versionable)(const dav_resource *resource)
Definition: mod_dav.h:2304
int(* can_be_activity)(const dav_resource *resource)
Definition: mod_dav.h:2532
int(* can_be_workspace)(const dav_resource *resource)
Definition: mod_dav.h:2508
dav_auto_version(* auto_versionable)(const dav_resource *resource)
Definition: mod_dav.h:2315
int(* report_label_header_allowed)(const apr_xml_doc *doc)
Definition: mod_dav.h:2402
void(* get_vsn_options)(apr_pool_t *p, apr_text_header *phdr)
Definition: mod_dav.h:2290
void * ctx
Definition: mod_dav.h:2572
Definition: mod_dav.h:868
apr_size_t uri_len
Definition: mod_dav.h:870
struct dav_if_state_list * state
Definition: mod_dav.h:871
const char * uri
Definition: mod_dav.h:869
struct dav_if_header * next
Definition: mod_dav.h:872
int dummy_header
Definition: mod_dav.h:874
Definition: mod_dav.h:854
dav_locktoken * locktoken
Definition: mod_dav.h:862
const char * etag
Definition: mod_dav.h:861
dav_if_state_type type
Definition: mod_dav.h:855
int condition
Definition: mod_dav.h:857
struct dav_if_state_list * next
Definition: mod_dav.h:864
Definition: mod_dav.h:1071
const apr_xml_elem * elem
Definition: mod_dav.h:1073
const apr_xml_doc * doc
Definition: mod_dav.h:1072
Definition: mod_dav.h:1040
const dav_hooks_liveprop * hooks
Definition: mod_dav.h:1043
const char *const * namespace_uris
Definition: mod_dav.h:1042
const dav_liveprop_spec * specs
Definition: mod_dav.h:1041
Definition: mod_dav.h:1024
int propid
Definition: mod_dav.h:1028
int is_writable
Definition: mod_dav.h:1030
int ns
Definition: mod_dav.h:1025
const char * name
Definition: mod_dav.h:1026
Definition: mod_dav.h:1400
time_t timeout
Definition: mod_dav.h:1409
const char * auth_user
Definition: mod_dav.h:1414
int is_locknull
Definition: mod_dav.h:1402
dav_lock_type type
Definition: mod_dav.h:1407
const dav_locktoken * locktoken
Definition: mod_dav.h:1411
int depth
Definition: mod_dav.h:1408
struct dav_lock * next
Definition: mod_dav.h:1418
dav_lock_scope scope
Definition: mod_dav.h:1406
const char * owner
Definition: mod_dav.h:1413
dav_lock_private * info
Definition: mod_dav.h:1416
dav_lock_rectype rectype
Definition: mod_dav.h:1401
Definition: mod_dav.h:1344
Definition: mod_dav.h:878
struct dav_locktoken_list * next
Definition: mod_dav.h:880
dav_locktoken * locktoken
Definition: mod_dav.h:879
Definition: mod_dav.h:512
request_rec * rnew
Definition: mod_dav.h:513
dav_error err
Definition: mod_dav.h:514
Definition: mod_dav.h:2703
void * ctx
Definition: mod_dav.h:2712
Definition: mod_dav.h:1770
struct dav_rollback_item * rollback
Definition: mod_dav.h:1783
dav_propdb * propdb
Definition: mod_dav.h:1771
request_rec * r
Definition: mod_dav.h:1788
dav_error * err
Definition: mod_dav.h:1785
apr_xml_elem * prop
Definition: mod_dav.h:1773
int operation
Definition: mod_dav.h:1775
void * liveprop_ctx
Definition: mod_dav.h:1782
int is_liveprop
Definition: mod_dav.h:1781
Definition: mod_dav.h:1209
Definition: mod_dav.h:679
const dav_hooks_vsn * vsn
Definition: mod_dav.h:683
const dav_hooks_propdb * propdb
Definition: mod_dav.h:681
const dav_hooks_locks * locks
Definition: mod_dav.h:682
void * ctx
Definition: mod_dav.h:687
const dav_hooks_repository * repos
Definition: mod_dav.h:680
const dav_hooks_search * search
Definition: mod_dav.h:685
const dav_hooks_binding * binding
Definition: mod_dav.h:684
Definition: mod_dav.h:2269
Definition: mod_dav.h:2727
int(* get_resource_type)(const dav_resource *resource, const char **name, const char **uri)
Definition: mod_dav.h:2728
Definition: mod_dav.h:389
int working
Definition: mod_dav.h:406
dav_resource_private * info
Definition: mod_dav.h:414
const char * uri
Definition: mod_dav.h:410
const dav_hooks_repository * hooks
Definition: mod_dav.h:416
const dav_acl_provider * acls
Definition: mod_dav.h:423
apr_pool_t * pool
Definition: mod_dav.h:421
void * ctx
Definition: mod_dav.h:425
int collection
Definition: mod_dav.h:394
int baselined
Definition: mod_dav.h:402
int exists
Definition: mod_dav.h:392
int versioned
Definition: mod_dav.h:398
dav_resource_type type
Definition: mod_dav.h:390
Definition: mod_dav.h:499
int status
Definition: mod_dav.h:506
dav_get_props_result propresult
Definition: mod_dav.h:504
const char * desc
Definition: mod_dav.h:501
struct dav_response * next
Definition: mod_dav.h:508
const char * href
Definition: mod_dav.h:500
Definition: mod_dav.h:1828
Definition: mod_dav.h:1812
Definition: mod_dav.h:1852
dav_walk_params w
Definition: mod_dav.h:1854
int flags
Definition: mod_dav.h:1881
const dav_locktoken * locktoken
Definition: mod_dav.h:1877
dav_buffer work_buf
Definition: mod_dav.h:1883
int propfind_type
Definition: mod_dav.h:1869
apr_pool_t * scratchpool
Definition: mod_dav.h:1863
const dav_if_header * if_header
Definition: mod_dav.h:1876
apr_bucket_brigade * bb
Definition: mod_dav.h:1860
apr_text * propstat_404
Definition: mod_dav.h:1874
apr_xml_doc * doc
Definition: mod_dav.h:1868
const dav_lock * lock
Definition: mod_dav.h:1878
int skip_root
Definition: mod_dav.h:1879
request_rec * r
Definition: mod_dav.h:1865
Definition: mod_dav.h:618
apr_pool_t * pool
Definition: mod_dav.h:619
apr_hash_t * uri_prefix
Definition: mod_dav.h:620
int count
Definition: mod_dav.h:622
apr_hash_t * prefix_uri
Definition: mod_dav.h:621
A structure that represents the current request.
Definition: httpd.h:856
apr_pool_t * p
Apache filter library.
ap_input_mode_t
input filtering modes
Definition: util_filter.h:41
Apache XML library.