httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@locus.apache.org
Subject cvs commit: apache-2.0/src/modules/dav/main mod_dav.c mod_dav.h util_lock.c
Date Fri, 07 Jul 2000 10:38:24 GMT
gstein      00/07/07 03:38:24

  Modified:    src/modules/dav/fs mod_dav_fs.c repos.c repos.h
               src/modules/dav/main mod_dav.c mod_dav.h util_lock.c
  Log:
  do the "get resource" via a hook rather than through the repository hook
      structure. once the resource is retrieved, then we have the relevant
      repository hooks and can dispatch through those.
  some additional tweaks to use lockdb->hooks rather than fetching them
  
  Revision  Changes    Path
  1.2       +1 -1      apache-2.0/src/modules/dav/fs/mod_dav_fs.c
  
  Index: mod_dav_fs.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/dav/fs/mod_dav_fs.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- mod_dav_fs.c	2000/07/07 07:58:11	1.1
  +++ mod_dav_fs.c	2000/07/07 10:38:22	1.2
  @@ -121,7 +121,7 @@
   
   static void register_hooks(void)
   {
  -    /* nothing yet */
  +    ap_hook_get_resource(dav_fs_hook_get_resource, NULL, NULL, AP_HOOK_MIDDLE);
   }
   
   module MODULE_VAR_EXPORT dav_fs_module =
  
  
  
  1.10      +13 -7     apache-2.0/src/modules/dav/fs/repos.c
  
  Index: repos.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/dav/fs/repos.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- repos.c	2000/07/07 02:22:17	1.9
  +++ repos.c	2000/07/07 10:38:22	1.10
  @@ -2020,13 +2020,6 @@
   */
   static const dav_dyn_provider dav_dyn_providers_fs[] =
   {
  -    /* repository provider */
  -    {
  -	DAV_FS_PROVIDER_ID,
  -        DAV_DYN_TYPE_REPOSITORY,
  -        &dav_hooks_repository_fs,
  -        NULL
  -    },
       /* liveprop provider */
       {
   	DAV_FS_PROVIDER_ID,
  @@ -2067,3 +2060,16 @@
   
       dav_dyn_providers_fs
   };
  +
  +int dav_fs_hook_get_resource(request_rec *r, const char *root_dir,
  +                             const char *workspace)
  +{
  +    dav_resource *resource = dav_fs_get_resource(r, root_dir, workspace);
  +
  +    if (resource == NULL)
  +        return DECLINED;
  +
  +    (void) ap_set_userdata(resource, DAV_KEY_RESOURCE, ap_null_cleanup,
  +                           r->pool);
  +    return OK;
  +}
  
  
  
  1.6       +2 -0      apache-2.0/src/modules/dav/fs/repos.h
  
  Index: repos.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/dav/fs/repos.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- repos.h	2000/07/07 07:58:11	1.5
  +++ repos.h	2000/07/07 10:38:22	1.6
  @@ -95,5 +95,7 @@
   /* where is the lock database located? */
   const char *dav_get_lockdb_path(const request_rec *r);
   
  +int dav_fs_hook_get_resource(request_rec *r, const char *root_dir,
  +                             const char *workspace);
   
   #endif /* _DAV_FS_REPOS_H_ */
  
  
  
  1.9       +32 -39    apache-2.0/src/modules/dav/main/mod_dav.c
  
  Index: mod_dav.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/dav/main/mod_dav.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- mod_dav.c	2000/07/07 07:58:13	1.8
  +++ mod_dav.c	2000/07/07 10:38:23	1.9
  @@ -115,7 +115,6 @@
       dav_dyn_hooks propdb;
       dav_dyn_hooks locks;
       dav_dyn_hooks *liveprop;
  -    dav_dyn_hooks repository;
       dav_dyn_hooks vsn;
   } dav_dir_conf;
   
  @@ -178,11 +177,6 @@
   	    conf->vsn = hooks;
   	    break;
   
  -	case DAV_DYN_TYPE_REPOSITORY:
  -	    conf->repository = hooks;
  -	    conf->handle_get = DAV_AS_HOOKS_REPOSITORY(&hooks)->handle_get;
  -	    break;
  -
   	case DAV_DYN_TYPE_LIVEPROP:
   	{
   	    dav_dyn_hooks *ddh = ap_palloc(p, sizeof(*ddh));
  @@ -299,14 +293,6 @@
       else
           newconf->vsn = parent->vsn;
   
  -    if (child->repository.hooks != NULL)
  -        newconf->repository = child->repository;
  -    else
  -        newconf->repository = parent->repository;
  -    newconf->handle_get =
  -	newconf->repository.hooks != NULL
  -	&& DAV_AS_HOOKS_REPOSITORY(&newconf->repository)->handle_get;
  -
       if (child->liveprop != NULL)
           newconf->liveprop = child->liveprop;
       else
  @@ -374,10 +360,6 @@
           hooks = &conf->vsn;
           break;
   
  -    case DAV_DYN_TYPE_REPOSITORY:
  -        hooks = &conf->repository;
  -        break;
  -
       case DAV_DYN_TYPE_LIVEPROP:
           hooks = conf->liveprop;
           break;
  @@ -745,31 +727,29 @@
   /* resolve a request URI to a resource descriptor */
   static int dav_get_resource(request_rec *r, dav_resource **res_p)
   {
  -    dav_dir_conf *conf;
  -    const dav_hooks_repository *repos_hooks;
  -
  -    /* Call repository hook to resolve resource */
  -    conf = (dav_dir_conf *) ap_get_module_config(r->per_dir_config,
  -						 &dav_module);
  +    void *data;
   
  -    repos_hooks = DAV_AS_HOOKS_REPOSITORY(&conf->repository);
  -    if (repos_hooks == NULL || repos_hooks->get_resource == NULL) {
  -	/* ### this should happen at startup rather than per-request */
  -	ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, r,
  -                      "No %s has been configured.",
  -                      repos_hooks == NULL
  -                      ? "repository module"
  -                      : "GET handler");
  -        return HTTP_INTERNAL_SERVER_ERROR;
  -    }
  +    /* go look for the resource if it isn't already present */
  +    (void) ap_get_userdata(&data, DAV_KEY_RESOURCE, r->pool);
  +    if (data == NULL) {
  +        dav_dir_conf *conf;
  +        int rv;
  +
  +        conf = ap_get_module_config(r->per_dir_config, &dav_module);
  +
  +        /* have somebody store it into the request's user data... */
  +        rv = ap_run_get_resource(r, conf->dir, dav_get_target_selector(r));
  +        if (rv == DECLINED) {
  +            /* Apache will supply a default error for this. */
  +            return HTTP_NOT_FOUND;
  +        }
  +        else if (rv != OK)
  +            return rv;
   
  -    *res_p = (*repos_hooks->get_resource)(r, conf->dir,
  -                                          dav_get_target_selector(r));
  -    if (*res_p == NULL) {
  -	/* Apache will supply a default error for this. */
  -        return HTTP_NOT_FOUND;
  +        (void) ap_get_userdata(&data, DAV_KEY_RESOURCE, r->pool);
       }
   
  +    *res_p = data;
       return OK;
   }
   
  @@ -3281,3 +3261,16 @@
       dav_handlers,		/* handlers */
       register_hooks,             /* register hooks */
   };
  +
  +AP_HOOK_STRUCT(
  +    AP_HOOK_LINK(get_resource)
  +    AP_HOOK_LINK(set_lock_hooks)
  +    AP_HOOK_LINK(set_propdb_hooks)
  +    AP_HOOK_LINK(set_vsn_hooks)
  +    AP_HOOK_LINK(find_liveprop)
  +    AP_HOOK_LINK(insert_all_liveprops)
  +    )
  +AP_IMPLEMENT_HOOK_RUN_FIRST(int, get_resource,
  +                            (request_rec *r, const char *root_dir,
  +                             const char *workspace),
  +                            (r, root_dir, workspace), DECLINED);
  
  
  
  1.9       +31 -5     apache-2.0/src/modules/dav/main/mod_dav.h
  
  Index: mod_dav.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/dav/main/mod_dav.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- mod_dav.h	2000/07/07 07:58:14	1.8
  +++ mod_dav.h	2000/07/07 10:38:23	1.9
  @@ -65,6 +65,8 @@
   
   #include "httpd.h"
   #include "util_xml.h"
  +#include "ap_hooks.h"
  +#include "apr_hash.h"
   
   #include <limits.h>     /* for INT_MAX */
   
  @@ -375,6 +377,32 @@
   
   /* --------------------------------------------------------------------
   **
  +** DAV PLUGINS
  +*/
  +
  +/* ### docco ... */
  +
  +AP_DECLARE_HOOK(int, get_resource, (request_rec *r, const char *root_dir,
  +                                    const char *workspace))
  +AP_DECLARE_HOOK(int, set_lock_hooks, (request_rec *r))
  +AP_DECLARE_HOOK(int, set_propdb_hooks, (request_rec *r))
  +AP_DECLARE_HOOK(int, set_vsn_hooks, (request_rec *r))
  +AP_DECLARE_HOOK(int, find_liveprop, (const char *ns_uri, const char *name,
  +                                     struct dav_hooks_liveprop **hooks))
  +AP_DECLARE_HOOK(void, insert_all_liveprops, (const dav_resource *resource,
  +                                             int insvalue, ap_hash_t *ns_map,
  +                                             ap_text_header *phdr))
  +
  +#define DAV_KEY_RESOURCE        "dav-resource"
  +#define DAV_KEY_LOCK_HOOKS      "dav-lock-hooks"
  +#define DAV_KEY_PROPDB_HOOKS    "dav-propdb-hooks"
  +#define DAV_KEY_VSN_HOOKS       "dav-vsn-hooks"
  +
  +
  +/* --------------------------------------------------------------------
  +**
  +** ====> DEPRECATED <====
  +**
   ** DYNAMIC EXTENSIONS
   */
   
  @@ -428,7 +456,6 @@
       DAV_DYN_TYPE_QUERY_GRAMMAR,	/* DASL search grammar (N per dir) */
       DAV_DYN_TYPE_ACL,		/* ACL handling (1 per dir) */
       DAV_DYN_TYPE_VSN,		/* versioning (1 per dir) */
  -    DAV_DYN_TYPE_REPOSITORY,	/* resource repository (1 per dir) */
       DAV_DYN_TYPE_LIVEPROP,	/* live property handler (N per dir) */
   
       DAV_DYN_TYPE_MAX
  @@ -533,7 +560,6 @@
   #define DAV_AS_HOOKS_QUERY_GRAMMAR(ph)	((void *)((ph)->hooks))
   #define DAV_AS_HOOKS_ACL(ph)		((void *)((ph)->hooks))
   #define DAV_AS_HOOKS_VSN(ph)		((const dav_hooks_vsn *)((ph)->hooks))
  -#define DAV_AS_HOOKS_REPOSITORY(ph)	((const dav_hooks_repository *)((ph)->hooks))
   #define DAV_AS_HOOKS_LIVEPROP(ph)	((const dav_hooks_liveprop *)((ph)->hooks))
   
   /* get provider hooks, given a request record */
  @@ -544,7 +570,6 @@
   #define DAV_GET_HOOKS_QUERY_GRAMMAR(r)  DAV_AS_HOOKS_QUERY_GRAMMAR(dav_get_provider_hooks(r,
DAV_DYN_TYPE_QUERY_GRAMMAR))
   #define DAV_GET_HOOKS_ACL(r)            DAV_AS_HOOKS_ACL(dav_get_provider_hooks(r, DAV_DYN_TYPE_ACL))
   #define DAV_GET_HOOKS_VSN(r)            DAV_AS_HOOKS_VSN(dav_get_provider_hooks(r, DAV_DYN_TYPE_VSN))
  -#define DAV_GET_HOOKS_REPOSITORY(r)     DAV_AS_HOOKS_REPOSITORY(dav_get_provider_hooks(r,
DAV_DYN_TYPE_REPOSITORY))
   #define DAV_GET_HOOKS_LIVEPROP(r)       DAV_AS_HOOKS_LIVEPROP(dav_get_provider_hooks(r,
DAV_DYN_TYPE_LIVEPROP))
   
   
  @@ -837,12 +862,12 @@
   time_t dav_get_timeout(request_rec *r);
   
   /*
  -** Opaque, repository-specific information for a lock database.
  +** Opaque, provider-specific information for a lock database.
   */
   typedef struct dav_lockdb_private dav_lockdb_private;
   
   /*
  -** Opaque, repository-specific information for a lock record.
  +** Opaque, provider-specific information for a lock record.
   */
   typedef struct dav_lock_private dav_lock_private;
   
  @@ -1355,6 +1380,7 @@
       DAV_MODE_WRITE_TRUNC,	/* truncate and open for writing */
       DAV_MODE_WRITE_SEEKABLE	/* open for writing; random access */
   } dav_stream_mode;
  +
   
   /* --------------------------------------------------------------------
   **
  
  
  
  1.5       +5 -5      apache-2.0/src/modules/dav/main/util_lock.c
  
  Index: util_lock.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/dav/main/util_lock.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- util_lock.c	2000/07/03 22:51:03	1.4
  +++ util_lock.c	2000/07/07 10:38:23	1.5
  @@ -197,19 +197,19 @@
   				    const ap_xml_doc *doc,
   				    dav_lock **lock_request)
   {
  -    const dav_hooks_locks *hooks = DAV_GET_HOOKS_LOCKS(r);
       ap_pool_t *p = r->pool;
       dav_error *err;
       ap_xml_elem *child;
       dav_lock *lock;
  -	
  +
       if (!dav_validate_root(doc, "lockinfo")) {
   	return dav_new_error(p, HTTP_BAD_REQUEST, 0,
   			     "The request body contains an unexpected "
   			     "XML root element.");
       }
   
  -    if ((err = (*hooks->create_lock)(lockdb, resource, &lock)) != NULL) {
  +    if ((err = (*lockdb->hooks->create_lock)(lockdb, resource,
  +                                             &lock)) != NULL) {
   	return dav_push_error(p, err->status, 0,
   			      "Could not parse the lockinfo due to an "
   			      "internal problem creating a lock structure.",
  @@ -319,7 +319,6 @@
   			 dav_lockdb *lockdb, dav_lock *lock,
   			 dav_response **response)
   {
  -    const dav_hooks_locks *hooks = DAV_GET_HOOKS_LOCKS(r);
       dav_error *err;
       int depth = lock->depth;
   
  @@ -345,7 +344,8 @@
       **
       ** Note: this also handles locknull resources
       */
  -    if ((err = (*hooks->append_locks)(lockdb, resource, 0, lock)) != NULL) {
  +    if ((err = (*lockdb->hooks->append_locks)(lockdb, resource, 0,
  +                                              lock)) != NULL) {
   	/* ### maybe add a higher-level description */
   	return err;
       }
  
  
  

Mime
View raw message