]> granicus.if.org Git - apache/commitdiff
final round of walker cleanup: fix the provider API to match what is Right.
authorGreg Stein <gstein@apache.org>
Thu, 9 Nov 2000 13:08:06 +0000 (13:08 +0000)
committerGreg Stein <gstein@apache.org>
Thu, 9 Nov 2000 13:08:06 +0000 (13:08 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86887 13f79535-47bb-0310-9956-ffa450edef68

modules/dav/fs/repos.c
modules/dav/main/mod_dav.c
modules/dav/main/mod_dav.h
modules/dav/main/util.c
modules/dav/main/util_lock.c

index 546883f362b5589e07d537e60b507d2258e84583..c6d198fb4e978d0f551014bb65121ac6736ad788 100644 (file)
@@ -208,7 +208,8 @@ struct dav_stream {
 };
 
 /* 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,
@@ -1251,23 +1252,24 @@ static dav_error * dav_fs_remove_resource(dav_resource *resource,
      * 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(&params, 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 "
@@ -1648,15 +1650,11 @@ static dav_error * dav_fs_internal_walk(const dav_walk_params *params,
     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
index 703036d5d9b644bcaa768971ec51e79d1687a893..a61a7f85b5b68368d71941aa5d785bb55aa6f85f 100644 (file)
@@ -1531,6 +1531,7 @@ static int dav_method_propfind(request_rec *r)
     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);
@@ -1622,7 +1623,7 @@ static int dav_method_propfind(request_rec *r)
        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);
@@ -1641,11 +1642,11 @@ static int dav_method_propfind(request_rec *r)
      * 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. */
index 73571536db79f5e7fd7cf3a71da7bd6f75809045..ae0968c1249cdf68dbea3ec8b19af81a00363787 100644 (file)
@@ -1267,9 +1267,6 @@ typedef struct dav_walker_ctx
     /* input: */
     dav_walk_params w;
 
-    /* output: */
-    dav_response *response;
-
 
     /* ### client data... phasing out this big glom */
 
@@ -1529,14 +1526,17 @@ struct dav_hooks_repository
 
     /* 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);
index 00c0a0e63e68dc5865c82e8259c4d46970f9b4ad..5af802f7273556ba1d0e736e038ff5c7cfa5564d 100644 (file)
@@ -1314,6 +1314,7 @@ dav_error * dav_validate_request(request_rec *r, 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;
@@ -1330,9 +1331,9 @@ dav_error * dav_validate_request(request_rec *r, dav_resource *resource,
            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. */
     }
index edbd69d538b38bc1ed0a6bd17b7951fc944eeb8d..4c23d5e595049b5b0b1c5a85571c46a87f4a07ac 100644 (file)
@@ -356,6 +356,7 @@ dav_error * dav_add_lock(request_rec *r, const dav_resource *resource,
     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;
@@ -367,15 +368,15 @@ dav_error * dav_add_lock(request_rec *r, const dav_resource *resource,
        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.");
@@ -556,6 +557,7 @@ int dav_unlock(request_rec *r, const dav_resource *resource,
 
     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;
@@ -567,9 +569,10 @@ int dav_unlock(request_rec *r, const dav_resource *resource,
        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
@@ -614,6 +617,7 @@ static dav_error * dav_inherit_locks(request_rec *r, dav_lockdb *lockdb,
     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);
@@ -677,7 +681,8 @@ static dav_error * dav_inherit_locks(request_rec *r, dav_lockdb *lockdb,
     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);
 }
 
 /* ---------------------------------------------------------------