};
/* forward declaration for internal treewalkers */
-static dav_error * dav_fs_walk(dav_walker_ctx *wctx, int depth);
+static dav_error * dav_fs_walk(const dav_walk_params *params, int depth,
+ dav_response **response);
static dav_error * dav_fs_internal_walk(const dav_walk_params *params,
int depth, int is_move,
const dav_resource *root_dst,
* including the state dirs
*/
if (resource->collection) {
- dav_walker_ctx ctx = { { 0 } };
+ dav_walk_params params = { 0 };
dav_error *err = NULL;
+ dav_response *multi_status;
- ctx.w.walk_type = (DAV_WALKTYPE_NORMAL
- | DAV_WALKTYPE_HIDDEN
- | DAV_WALKTYPE_POSTFIX);
- ctx.w.func = dav_fs_delete_walker;
- ctx.w.walk_ctx = &ctx;
- ctx.w.pool = info->pool;
- ctx.w.root = resource;
+ params.walk_type = (DAV_WALKTYPE_NORMAL
+ | DAV_WALKTYPE_HIDDEN
+ | DAV_WALKTYPE_POSTFIX);
+ params.func = dav_fs_delete_walker;
+ params.pool = info->pool;
+ params.root = resource;
- if ((err = dav_fs_walk(&ctx, DAV_INFINITY)) != NULL) {
+ if ((err = dav_fs_walk(¶ms, DAV_INFINITY,
+ &multi_status)) != NULL) {
/* on a "real" error, then just punt. nothing else to do. */
return err;
}
- if ((*response = ctx.response) != NULL) {
+ if ((*response = multi_status) != NULL) {
/* some multistatus responses exist. wrap them in a 207 */
return dav_new_error(info->pool, HTTP_MULTI_STATUS, 0,
"Error(s) occurred on some resources during "
return err;
}
-static dav_error * dav_fs_walk(dav_walker_ctx *wctx, int depth)
+static dav_error * dav_fs_walk(const dav_walk_params *params, int depth,
+ dav_response **response)
{
- dav_response *response;
- dav_error *err;
-
/* always return the error, and any/all multistatus responses */
- err = dav_fs_internal_walk(&wctx->w, depth, 0, NULL, &response);
- wctx->response = response;
- return err;
+ return dav_fs_internal_walk(params, depth, 0, NULL, response);
}
/* dav_fs_etag: Stolen from ap_make_etag. Creates a strong etag
ap_xml_doc *doc;
const ap_xml_elem *child;
dav_walker_ctx ctx = { { 0 } };
+ dav_response *multi_status;
/* Ask repository module to resolve the resource */
result = dav_get_resource(r, 1 /*target_allowed*/, NULL, &resource);
ctx.w.walk_type |= DAV_WALKTYPE_LOCKNULL;
}
- err = (*resource->hooks->walk)(&ctx, depth);
+ err = (*resource->hooks->walk)(&ctx.w, depth, &multi_status);
if (ctx.w.lockdb != NULL) {
(*ctx.w.lockdb->hooks->close_lockdb)(ctx.w.lockdb);
* scope for the badprops. */
/* NOTE: propstat_404 != NULL implies doc != NULL */
if (ctx.propstat_404 != NULL) {
- dav_send_multistatus(r, HTTP_MULTI_STATUS, ctx.response,
+ dav_send_multistatus(r, HTTP_MULTI_STATUS, multi_status,
doc->namespaces);
}
else {
- dav_send_multistatus(r, HTTP_MULTI_STATUS, ctx.response, NULL);
+ dav_send_multistatus(r, HTTP_MULTI_STATUS, multi_status, NULL);
}
/* the response has been sent. */
/* input: */
dav_walk_params w;
- /* output: */
- dav_response *response;
-
/* ### client data... phasing out this big glom */
/* Walk a resource hierarchy.
*
- * Iterates over the resource hierarchy specified by wctx->resource.
- * Parameter for control of the walk and the callback are specified
- * by wctx.
+ * Iterates over the resource hierarchy specified by params->root.
+ * Control of the walk and the callback are specified by 'params'.
*
- * An HTTP_* status code is returned if an error occurs during the
- * walk or the callback indicates an error. OK is returned on success.
+ * An error may be returned. *response will contain multistatus
+ * responses (if any) suitable for the body of the error. It is also
+ * possible to return NULL, yet still have multistatus responses.
+ * In this case, typically the caller should return a 207 (Multistatus)
+ * and the responses (in the body) as the HTTP response.
*/
- dav_error * (*walk)(dav_walker_ctx *wctx, int depth);
+ dav_error * (*walk)(const dav_walk_params *params, int depth,
+ dav_response **response);
/* Get the entity tag for a resource */
const char * (*getetag)(const dav_resource *resource);
/* (1) Validate the specified resource, at the specified depth */
if (resource->exists && depth > 0) {
dav_walker_ctx ctx = { { 0 } };
+ dav_response *multi_status;
ctx.w.walk_type = DAV_WALKTYPE_NORMAL;
ctx.w.func = dav_validate_walker;
ctx.w.walk_type |= DAV_WALKTYPE_LOCKNULL;
}
- err = (*repos_hooks->walk)(&ctx, DAV_INFINITY);
+ err = (*repos_hooks->walk)(&ctx.w, DAV_INFINITY, &multi_status);
if (err == NULL) {
- *response = ctx.response;
+ *response = multi_status;;
}
/* else: implies a 5xx status code occurred. */
}
if (depth > 0) {
/* Walk existing collection and set indirect locks */
dav_walker_ctx ctx = { { 0 } };
+ dav_response *multi_status;
ctx.w.walk_type = DAV_WALKTYPE_NORMAL | DAV_WALKTYPE_AUTH;
ctx.w.func = dav_lock_walker;
ctx.r = r;
ctx.lock = lock;
- err = (*resource->hooks->walk)(&ctx, DAV_INFINITY);
+ err = (*resource->hooks->walk)(&ctx.w, DAV_INFINITY, &multi_status);
if (err != NULL) {
/* implies a 5xx status code occurred. screw the multistatus */
return err;
}
- if (ctx.response != NULL) {
+ if (multi_status != NULL) {
/* manufacture a 207 error for the multistatus response */
- *response = ctx.response;
+ *response = multi_status;
return dav_new_error(r->pool, HTTP_MULTI_STATUS, 0,
"Error(s) occurred on resources during the "
"addition of a depth lock.");
if (lock_resource->collection) {
dav_walker_ctx ctx = { { 0 } };
+ dav_response *multi_status;
ctx.w.walk_type = DAV_WALKTYPE_NORMAL | DAV_WALKTYPE_LOCKNULL;
ctx.w.func = dav_unlock_walker;
ctx.r = r;
ctx.locktoken = locktoken;
- err = (*repos_hooks->walk)(&ctx, DAV_INFINITY);
+ err = (*repos_hooks->walk)(&ctx.w, DAV_INFINITY, &multi_status);
/* ### fix this! */
+ /* ### do something with multi_status */
result = err == NULL ? OK : err->status;
}
else
dav_lock *prev;
dav_walker_ctx ctx = { { 0 } };
const dav_hooks_repository *repos_hooks = resource->hooks;
+ dav_response *multi_status;
if (use_parent) {
which_resource = (*repos_hooks->get_parent_resource)(resource);
ctx.lock = locks;
ctx.skip_root = !use_parent;
- return (*repos_hooks->walk)(&ctx, DAV_INFINITY);
+ /* ### do something with multi_status */
+ return (*repos_hooks->walk)(&ctx.w, DAV_INFINITY, &multi_status);
}
/* ---------------------------------------------------------------