Apache HTTPD
std_liveprop.c
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
17#include "httpd.h"
18#include "util_xml.h"
19#include "apr_strings.h"
20#include "ap_provider.h"
21
22#include "mod_dav.h"
23
24/* forward-declare */
26
27/*
28** The namespace URIs that we use. There will only ever be "DAV:".
29*/
30static const char * const dav_core_namespace_uris[] =
31{
32 "DAV:",
33 NULL /* sentinel */
34};
35
36/*
37** Define each of the core properties that this provider will handle.
38** Note that all of them are in the DAV: namespace, which has a
39** provider-local index of 0.
40*/
42{
43 { 0, "comment", DAV_PROPID_comment, 1 },
44 { 0, "creator-displayname", DAV_PROPID_creator_displayname, 1 },
45 { 0, "displayname", DAV_PROPID_displayname, 1 },
46 { 0, "resourcetype", DAV_PROPID_resourcetype, 0 },
47 { 0, "source", DAV_PROPID_source, 1 },
48
49 { 0 } /* sentinel */
50};
51
58
60 int propid, dav_prop_insert what,
62{
63 const char *value = NULL;
64 const char *s;
65 apr_pool_t *p = resource->pool;
67 long global_ns;
68
69 switch (propid)
70 {
72 { /* additional type info provided by external modules ? */
73 int i;
74
79
80 for (i = 0; i < extensions->nelts; i++, entry++) {
83 const char *name = NULL, *uri = NULL;
84
85 if (!res_hooks || !res_hooks->get_resource_type)
86 continue;
87
88 if (!res_hooks->get_resource_type(resource, &name, &uri) &&
89 name) {
90
91 if (!uri || !strcasecmp(uri, "DAV:"))
92 value = apr_pstrcat(p, value ? value : "",
93 "<D:", name, "/>", NULL);
94 else
95 value = apr_pstrcat(p, value ? value : "",
96 "<x:", name,
97 " xmlns:x=\"", uri,
98 "\"/>", NULL);
99 }
100 }
101 }
102 switch (resource->type) {
104 if (resource->baselined) {
105 value = apr_pstrcat(p, value ? value : "", "<D:baseline/>", NULL);
106 break;
107 }
108 /* fall through */
111 if (resource->collection) {
112 value = apr_pstrcat(p, value ? value : "", "<D:collection/>", NULL);
113 }
114 else {
115 /* ### should we denote lock-null resources? */
116 if (value == NULL) {
117 value = ""; /* becomes: <D:resourcetype/> */
118 }
119 }
120 break;
122 value = apr_pstrcat(p, value ? value : "", "<D:version-history/>", NULL);
123 break;
125 value = apr_pstrcat(p, value ? value : "", "<D:collection/>", NULL);
126 break;
128 value = apr_pstrcat(p, value ? value : "", "<D:activity/>", NULL);
129 break;
130
131 default:
132 /* ### bad juju */
134 }
135 break;
136
141 default:
142 /*
143 ** This property is known, but not defined as a liveprop. However,
144 ** it may be a dead property.
145 */
147 }
148
149 /* assert: value != NULL */
150
151 /* get the information and global NS index for the property */
153
154 /* assert: info != NULL && info->name != NULL */
155
157 s = apr_pstrcat(p,
158 "<D:supported-live-property D:name=\"", info->name,
159 "\" D:namespace=\"", dav_core_namespace_uris[info->ns],
160 "\"/>" DEBUG_CR, NULL);
161 }
162 else if (what == DAV_PROP_INSERT_VALUE && *value != '\0') {
163 s = apr_psprintf(p, "<lp%ld:%s>%s</lp%ld:%s>" DEBUG_CR,
164 global_ns, info->name, value, global_ns, info->name);
165 }
166 else {
167 s = apr_psprintf(p, "<lp%ld:%s/>" DEBUG_CR, global_ns, info->name);
168 }
170
171 /* we inserted what was asked for */
172 return what;
173}
174
175static int dav_core_is_writable(const dav_resource *resource, int propid)
176{
177 const dav_liveprop_spec *info;
178
180 return info->is_writable;
181}
182
184 const apr_xml_elem *elem,
185 int operation, void **context,
186 int *defer_to_dead)
187{
188 /* all of our writable props go in the dead prop database */
189 *defer_to_dead = 1;
190
191 return NULL;
192}
193
199 NULL, /* patch_exec */
200 NULL, /* patch_commit */
201 NULL, /* patch_rollback */
202};
203
211
221
223{
224 /* register the namespace URIs */
226}
Apache Provider API.
APR Strings library.
request_rec * r
apr_md5_ctx_t * context
Definition util_md5.h:58
apr_array_header_t * ap_list_provider_names(apr_pool_t *pool, const char *provider_group, const char *provider_version)
Definition provider.c:127
void ** resource
const char * uri
Definition apr_uri.h:159
void dav_core_insert_all_liveprops(request_rec *r, const dav_resource *resource, dav_prop_insert what, apr_text_header *phdr)
#define DAV_RESOURCE_TYPE_GROUP
Definition mod_dav.h:2653
long dav_get_liveprop_info(int propid, const dav_liveprop_group *group, const dav_liveprop_spec **info)
Definition liveprop.c:111
void dav_core_register_uris(apr_pool_t *p)
dav_prop_insert
Definition mod_dav.h:516
void dav_register_liveprop_group(apr_pool_t *p, const dav_liveprop_group *group)
Definition liveprop.c:131
#define DEBUG_CR
Definition mod_dav.h:65
#define DAV_DECLARE_NONSTD(type)
Definition mod_dav.h:86
int dav_do_find_liveprop(const char *ns_uri, const char *name, const dav_liveprop_group *group, const dav_hooks_liveprop **hooks)
Definition liveprop.c:83
const dav_resource_type_provider * dav_get_resource_type_providers(const char *name)
Definition providers.c:55
int dav_core_find_liveprop(const dav_resource *resource, const char *ns_uri, const char *name, const dav_hooks_liveprop **hooks)
@ DAV_PROPID_resourcetype
Definition mod_dav.h:1125
@ DAV_PROPID_source
Definition mod_dav.h:1126
@ DAV_PROPID_displayname
Definition mod_dav.h:1118
@ DAV_PROPID_comment
Definition mod_dav.h:1143
@ DAV_PROPID_creator_displayname
Definition mod_dav.h:1144
@ DAV_PROP_INSERT_VALUE
Definition mod_dav.h:527
@ DAV_PROP_INSERT_NOTDEF
Definition mod_dav.h:517
@ DAV_PROP_INSERT_SUPPORTED
Definition mod_dav.h:529
@ 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
apr_size_t size
const char * value
Definition apr_env.h:51
int strcasecmp(const char *a, const char *b)
const char * s
Definition apr_strings.h:95
HTTP Daemon routines.
apr_pool_t * p
Definition md_event.c:32
DAV extension module for Apache 2.0.*.
static const char *const hooks[]
return NULL
Definition mod_so.c:359
int i
Definition mod_so.c:347
char * name
static int dav_core_is_writable(const dav_resource *resource, int propid)
static dav_error * dav_core_patch_validate(const dav_resource *resource, const apr_xml_elem *elem, int operation, void **context, int *defer_to_dead)
static const dav_liveprop_spec dav_core_props[]
static const dav_hooks_liveprop dav_core_hooks_liveprop
static const char *const dav_core_namespace_uris[]
static const dav_liveprop_group dav_core_liveprop_group
static dav_prop_insert dav_core_insert_prop(const dav_resource *resource, int propid, dav_prop_insert what, apr_text_header *phdr)
const char * provider_name
Definition ap_provider.h:36
A structure that represents the current request.
Definition httpd.h:845
Apache XML library.
INT info