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 providers.c config.m4 mod_dav.c mod_dav.h
Date Sat, 09 Sep 2000 23:23:42 GMT
gstein      00/09/09 16:23:42

  Modified:    src/modules/dav/fs mod_dav_fs.c repos.c repos.h
               src/modules/dav/main config.m4 mod_dav.c mod_dav.h
  Added:       src/modules/dav/main providers.c
  Log:
  The "get resource" functionality is no longer a hook. Instead, providers
  register themselves by name with mod_dav. The user configures a particular
  provider for a location/directory. mod_dav looks up that provider and uses
  it explicitly. (the prior behavior simply asked "anybody" to satisfy the
  get_resource, but it did not mesh well with user-specified providers)
  
  *) add providers.c to deal with provider registration
  *) rejigger mod_dav.c to toss the hook and use the provider
  *) clean out dav/fs/ of the old scheme and have it register itself
  
  Revision  Changes    Path
  1.7       +1 -2      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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- mod_dav_fs.c	2000/08/02 05:26:56	1.6
  +++ mod_dav_fs.c	2000/09/09 23:23:40	1.7
  @@ -121,7 +121,6 @@
   
   static void register_hooks(void)
   {
  -    ap_hook_get_resource(dav_fs_hook_get_resource, NULL, NULL, AP_HOOK_MIDDLE);
       ap_hook_get_lock_hooks(dav_fs_get_lock_hooks, NULL, NULL, AP_HOOK_MIDDLE);
       ap_hook_get_propdb_hooks(dav_fs_get_propdb_hooks, NULL, NULL,
                                AP_HOOK_MIDDLE);
  @@ -131,7 +130,7 @@
       ap_hook_insert_all_liveprops(dav_fs_insert_all_liveprops, NULL, NULL,
                                    AP_HOOK_MIDDLE);
   
  -    dav_fs_register_uris(NULL /* ### pconf */);
  +    dav_fs_register(NULL /* ### pconf */);
   }
   
   module MODULE_VAR_EXPORT dav_fs_module =
  
  
  
  1.20      +5 -14     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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- repos.c	2000/08/09 12:58:21	1.19
  +++ repos.c	2000/09/09 23:23:40	1.20
  @@ -1996,19 +1996,6 @@
   };
   
   
  -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) apr_set_userdata(resource, DAV_KEY_RESOURCE, apr_null_cleanup,
  -                           r->pool);
  -    return OK;
  -}
  -
   const dav_hooks_locks *dav_fs_get_lock_hooks(request_rec *r)
   {
       return &dav_hooks_locks_fs;
  @@ -2045,11 +2032,15 @@
       dav_fs_insert_all(resource, insvalue, phdr);
   }
   
  -void dav_fs_register_uris(apr_pool_t *p)
  +void dav_fs_register(apr_pool_t *p)
   {
  +    /* register the namespace URIs */
       const char * const * uris = dav_fs_namespace_uris;
   
       for ( ; *uris != NULL; ++uris) {
           dav_register_liveprop_namespace(p, *uris);
       }
  +
  +    /* register the repository provider */
  +    dav_register_repository(p, "filesystem", &dav_hooks_repository_fs);
   }
  
  
  
  1.11      +1 -3      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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- repos.h	2000/08/02 05:26:57	1.10
  +++ repos.h	2000/09/09 23:23:40	1.11
  @@ -95,8 +95,6 @@
   /* 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);
   const dav_hooks_locks *dav_fs_get_lock_hooks(request_rec *r);
   const dav_hooks_propdb *dav_fs_get_propdb_hooks(request_rec *r);
   
  @@ -106,6 +104,6 @@
   void dav_fs_insert_all_liveprops(request_rec *r, const dav_resource *resource,
                                    int insvalue, ap_text_header *phdr);
   
  -void dav_fs_register_uris(apr_pool_t *p);
  +void dav_fs_register(apr_pool_t *p);
   
   #endif /* _DAV_FS_REPOS_H_ */
  
  
  
  1.10      +1 -1      apache-2.0/src/modules/dav/main/config.m4
  
  Index: config.m4
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/dav/main/config.m4,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- config.m4	2000/07/12 10:58:19	1.9
  +++ config.m4	2000/09/09 23:23:41	1.10
  @@ -2,7 +2,7 @@
   
   APACHE_MODPATH_INIT(dav/main)
   
  -dav_objects="mod_dav.lo props.lo util.lo util_lock.lo opaquelock.lo liveprop.lo"
  +dav_objects="mod_dav.lo props.lo util.lo util_lock.lo opaquelock.lo liveprop.lo providers.lo"
   
   APACHE_MODULE(dav, WebDAV protocol handling, $dav_objects, , no)
   
  
  
  
  1.20      +17 -21    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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- mod_dav.c	2000/09/09 22:55:09	1.19
  +++ mod_dav.c	2000/09/09 23:23:41	1.20
  @@ -623,28 +623,29 @@
                               dav_resource **res_p)
   {
       void *data;
  +    dav_dir_conf *conf;
  +    const dav_hooks_repository *repos_hooks;
   
       /* go look for the resource if it isn't already present */
       (void) apr_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, target);
  -        if (rv == DECLINED) {
  -            /* Apache will supply a default error for this. */
  -            return HTTP_NOT_FOUND;
  -        }
  -        else if (rv != OK)
  -            return rv;
  +    if (data != NULL) {
  +        *res_p = data;
  +        return OK;
  +    }
  +
  +    conf = ap_get_module_config(r->per_dir_config, &dav_module);
   
  -        (void) apr_get_userdata(&data, DAV_KEY_RESOURCE, r->pool);
  +    /* assert: provider != NULL */
  +    repos_hooks = dav_lookup_repository(conf->provider);
  +
  +    *res_p = (*repos_hooks->get_resource)(r, conf->dir, target);
  +    if (*res_p == NULL) {
  +        /* Apache will supply a default error for this. */
  +        return HTTP_NOT_FOUND;
       }
   
  -    *res_p = data;
  +    (void) apr_set_userdata(*res_p, DAV_KEY_RESOURCE, apr_null_cleanup,
  +                            r->pool);
       return OK;
   }
   
  @@ -3289,7 +3290,6 @@
   };
   
   AP_HOOK_STRUCT(
  -    AP_HOOK_LINK(get_resource)
       AP_HOOK_LINK(get_lock_hooks)
       AP_HOOK_LINK(get_propdb_hooks)
       AP_HOOK_LINK(get_vsn_hooks)
  @@ -3297,10 +3297,6 @@
       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);
   AP_IMPLEMENT_HOOK_RUN_FIRST(const dav_hooks_locks *, get_lock_hooks,
                               (request_rec *r), (r), NULL);
   AP_IMPLEMENT_HOOK_RUN_FIRST(const dav_hooks_db *, get_propdb_hooks,
  
  
  
  1.16      +4 -4      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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- mod_dav.h	2000/09/09 09:25:22	1.15
  +++ mod_dav.h	2000/09/09 23:23:42	1.16
  @@ -385,10 +385,6 @@
   
   /* ### docco ... */
   
  -/* ### add a repository friendly-name to the get_resource */
  -AP_DECLARE_HOOK(int, get_resource, (request_rec *r, const char *root_dir,
  -                                    const char *workspace))
  -
   AP_DECLARE_HOOK(const dav_hooks_locks *, get_lock_hooks, (request_rec *r))
   AP_DECLARE_HOOK(const dav_hooks_propdb *, get_propdb_hooks, (request_rec *r))
   AP_DECLARE_HOOK(const dav_hooks_vsn *, get_vsn_hooks, (request_rec *r))
  @@ -410,6 +406,10 @@
   const dav_hooks_locks *dav_get_lock_hooks(request_rec *r);
   const dav_hooks_propdb *dav_get_propdb_hooks(request_rec *r);
   const dav_hooks_vsn *dav_get_vsn_hooks(request_rec *r);
  +
  +void dav_register_repository(apr_pool_t *p, const char *name,
  +                             const dav_hooks_repository *hooks);
  +const dav_hooks_repository * dav_lookup_repository(const char *name);
   
   void dav_register_liveprop_namespace(apr_pool_t *pool, const char *uri);
   int dav_get_liveprop_ns_index(const char *uri);
  
  
  
  1.1                  apache-2.0/src/modules/dav/main/providers.c
  
  Index: providers.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "apr_pools.h"
  #include "apr_hash.h"
  
  #include "ap_hooks.h"   /* ### for ap_global_hook_pool */
  
  #include "mod_dav.h"
  
  
  static apr_hash_t *dav_repos_providers = NULL;
  
  
  static apr_status_t dav_cleanup_providers(void *ctx)
  {
      dav_repos_providers = NULL;
      return APR_SUCCESS;
  }
  
  void dav_register_repository(apr_pool_t *p, const char *name,
                               const dav_hooks_repository *hooks)
  {
      /* ### ignore the pool; it is NULL right now */
      p = ap_global_hook_pool;
  
      if (dav_repos_providers == NULL) {
          dav_repos_providers = apr_make_hash(p);
          apr_register_cleanup(p, NULL, dav_cleanup_providers, apr_null_cleanup);
      }
  
      /* just set it. no biggy if it was there before. */
      apr_hash_set(dav_repos_providers, name, 0, hooks);
  }
  
  const dav_hooks_repository * dav_lookup_repository(const char *name)
  {
      return apr_hash_get(dav_repos_providers, name, 0);
  }
  
  
  

Mime
View raw message