You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by gs...@locus.apache.org on 2000/07/10 05:18:14 UTC

cvs commit: apache-2.0/src/modules/dav/main liveprop.c config.m4 dav_dyn.c mod_dav.h props.c

gstein      00/07/09 20:18:14

  Modified:    src/modules/dav/fs mod_dav_fs.c repos.c repos.h
               src/modules/dav/main config.m4 dav_dyn.c mod_dav.h props.c
  Added:       src/modules/dav/main liveprop.c
  Log:
  new liveprop namespace registration and lookup. modules register each
      namespace they will use, which then receives a process-wide index.
  get rid of old dav_liveprop_uris global (and minor cleaning in dav_dyn);
      encapsulate liveprop handling in liveprop.c.
  do not build/use an ns_map; use dav_get_liveprop_ns_index().
  
  Revision  Changes    Path
  1.4       +4 -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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- mod_dav_fs.c	2000/07/08 13:22:07	1.3
  +++ mod_dav_fs.c	2000/07/10 03:18:13	1.4
  @@ -123,7 +123,10 @@
   {
       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);
  +    ap_hook_get_propdb_hooks(dav_fs_get_propdb_hooks, NULL, NULL,
  +                             AP_HOOK_MIDDLE);
  +
  +    dav_fs_register_uris(NULL /* ### pconf */);
   }
   
   module MODULE_VAR_EXPORT dav_fs_module =
  
  
  
  1.12      +11 -1     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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- repos.c	2000/07/08 13:22:07	1.11
  +++ repos.c	2000/07/10 03:18:13	1.12
  @@ -1785,7 +1785,8 @@
       /* assert: scan->name != NULL */
   
       /* map our NS index into a global NS index */
  -    ns = ns_map[scan->ns];
  +    /* ns = ns_map[scan->ns]; */
  +    ns = dav_get_liveprop_ns_index(dav_fs_namespace_uris[scan->ns]);
   
       /* DBG3("FS: inserting lp%d:%s  (local %d)", ns, scan->name, scan->ns); */
   
  @@ -2069,4 +2070,13 @@
   const dav_hooks_propdb *dav_fs_get_propdb_hooks(request_rec *r)
   {
       return &dav_hooks_db_dbm;
  +}
  +
  +void dav_fs_register_uris(ap_pool_t *p)
  +{
  +    const char * const * uris = dav_fs_namespace_uris;
  +
  +    for ( ; *uris != NULL; ++uris) {
  +        dav_register_liveprop_namespace(p, *uris);
  +    }
   }
  
  
  
  1.8       +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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- repos.h	2000/07/08 13:22:11	1.7
  +++ repos.h	2000/07/10 03:18:13	1.8
  @@ -100,4 +100,6 @@
   const dav_hooks_locks *dav_fs_get_lock_hooks(request_rec *r);
   const dav_hooks_propdb *dav_fs_get_propdb_hooks(request_rec *r);
   
  +void dav_fs_register_uris(ap_pool_t *p);
  +
   #endif /* _DAV_FS_REPOS_H_ */
  
  
  
  1.5       +1 -0      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- config.m4	2000/07/07 10:35:23	1.4
  +++ config.m4	2000/07/10 03:18:13	1.5
  @@ -4,6 +4,7 @@
   
   APACHE_MODULE(dav, WebDAV protocol handling,
   	mod_dav.lo props.lo util.lo util_lock.lo opaquelock.lo dav_dyn.lo
  +	liveprop.lo
   	, , no)
   
   if test "$enable_dav" = "yes"; then
  
  
  
  1.5       +2 -29     apache-2.0/src/modules/dav/main/dav_dyn.c
  
  Index: dav_dyn.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/dav/main/dav_dyn.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- dav_dyn.c	2000/07/03 22:50:58	1.4
  +++ dav_dyn.c	2000/07/10 03:18:13	1.5
  @@ -134,10 +134,7 @@
   static int dav_loaded_count = 0;
   static dav_dyn_runtime *dav_loaded_modules = NULL;
   
  -/* record the namespaces found in all liveprop providers in all modules */
  -ap_array_header_t *dav_liveprop_uris = NULL;
   
  -
   /* builtin, default module for filesystem-based access */
   extern const dav_dyn_module dav_dyn_module_default;
   
  @@ -156,43 +153,19 @@
   
       return &dav_dyn_module_default;
   }
  -
  -static ap_status_t dav_cleanup_liveprops(void *ptr)
  -{
  -    /* DBG1("dav_cleanup_liveprops (0x%08ld)", (unsigned long)dav_liveprop_uris); */
  -
  -    dav_liveprop_uris = NULL;
  -    return APR_SUCCESS;
  -}
   
  +/* ### this is probably obsolete... wait for next round */
   /* return a mapping from namespace_uris to dav_liveprop_uris */
   int * dav_collect_liveprop_uris(ap_pool_t *p, const dav_hooks_liveprop *hooks)
   {
       int count = 0;
       const char * const * p_uri;
       int *ns_map;
  -    int *cur_map;
   
       for (p_uri = hooks->namespace_uris; *p_uri != NULL; ++p_uri)
   	++count;
       ns_map = ap_palloc(p, count * sizeof(*ns_map));
   
  -    /* clean up this stuff if the pool goes away */
  -    ap_register_cleanup(p, NULL, dav_cleanup_liveprops, dav_cleanup_liveprops);
  -
  -    if (dav_liveprop_uris == NULL) {
  -	dav_liveprop_uris = ap_make_array(p, 5, sizeof(const char *));
  -	(void) ap_xml_insert_uri(dav_liveprop_uris, "DAV:");
  -    }
  -
  -    for (cur_map = ns_map, p_uri = hooks->namespace_uris; *p_uri != NULL; ) {
  -	*cur_map++ = ap_xml_insert_uri(dav_liveprop_uris, *p_uri++);
  -
  -	/* DBG2("collect_liveprop: local %d  =>  global %d",
  -	     p_uri - hooks->namespace_uris - 1, *(cur_map - 1));
  -	*/
  -    }
  -
       return ns_map;
   }
   
  @@ -282,7 +255,7 @@
       ** create_dir_config is called before init_handler, so we need to
       ** process the builtin modules right now.
       */
  -    if (dav_loaded_modules == NULL || dav_liveprop_uris == NULL) {
  +    if (dav_loaded_modules == NULL) {
           /* DBG0("reloading during scan"); */
   	dav_process_builtin_modules(p);
       }
  
  
  
  1.11      +6 -2      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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- mod_dav.h	2000/07/08 13:22:14	1.10
  +++ mod_dav.h	2000/07/10 03:18:13	1.11
  @@ -395,7 +395,7 @@
                                        const dav_hooks_liveprop **hooks))
   AP_DECLARE_HOOK(void, insert_all_liveprops, (request_rec *r,
                                                const dav_resource *resource,
  -                                             int insvalue, ap_hash_t *ns_map,
  +                                             int insvalue,
                                                ap_text_header *phdr))
   
   #define DAV_KEY_RESOURCE        "dav-resource"
  @@ -407,7 +407,12 @@
   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_liveprop_namespace(ap_pool_t *pool, const char *uri);
  +int dav_get_liveprop_ns_index(const char *uri);
  +int dav_get_liveprop_ns_count(void);
  +void dav_add_all_liveprop_xmlns(ap_pool_t *p, ap_text_header *phdr);
   
  +
   /* --------------------------------------------------------------------
   **
   ** ====> DEPRECATED <====
  @@ -556,7 +561,6 @@
   void dav_process_module(ap_pool_t *p, const dav_dyn_module *mod);
   
   int * dav_collect_liveprop_uris(ap_pool_t *p, const dav_hooks_liveprop *hooks);
  -extern ap_array_header_t *dav_liveprop_uris;
   
   void *dav_prepare_scan(ap_pool_t *p, const dav_dyn_module *mod);
   int dav_scan_providers(void *ctx,
  
  
  
  1.8       +12 -13    apache-2.0/src/modules/dav/main/props.c
  
  Index: props.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/dav/main/props.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- props.c	2000/07/08 13:22:14	1.7
  +++ props.c	2000/07/10 03:18:14	1.8
  @@ -1031,8 +1031,6 @@
       int found_contenttype = 0;
       int found_contentlang = 0;
       int unused_inserted;
  -    int i;
  -    const char * const * scan_uri;
       const dav_dyn_hooks *ddh;
   
       /* generate all the namespaces that are in the propdb */
  @@ -1124,10 +1122,7 @@
       }
   
       /* add namespaces for all the liveprop providers */
  -    for (i = 0, scan_uri = (const char * const *)dav_liveprop_uris->elts;
  -	 i < dav_liveprop_uris->nelts;
  -	 ++i, ++scan_uri)
  -	dav_insert_xmlns(propdb->p, "lp", i, *scan_uri, &hdr_ns);
  +    dav_add_all_liveprop_xmlns(propdb->p, &hdr_ns);
       
       /* ask the liveprop providers to insert their properties */
       for (ddh = propdb->liveprop; ddh != NULL; ddh = ddh->next) {
  @@ -1209,7 +1204,7 @@
       marks_input = ap_pcalloc(propdb->p, propdb->ns_xlate->nelts);
   
       /* same for the liveprops */
  -    marks_liveprop = ap_pcalloc(propdb->p, dav_liveprop_uris->nelts);
  +    marks_liveprop = ap_pcalloc(propdb->p, dav_get_liveprop_ns_count());
   
       for (elem = elem->first_child; elem; elem = elem->next) {
   	dav_datum key;
  @@ -1259,15 +1254,19 @@
   		*/
   		if (priv->provider != NULL) {
   		    const char * const * scan_ns_uri;
  -		    const int * scan_ns;
   
  -		    for (scan_ns_uri = priv->provider->namespace_uris,
  -			     scan_ns = priv->ns_map;
  +		    for (scan_ns_uri = priv->provider->namespace_uris;
   			 *scan_ns_uri != NULL;
  -			 ++scan_ns_uri, ++scan_ns) {
  +			 ++scan_ns_uri) {
  +                        int ns;
   
  -			dav_add_marked_xmlns(propdb, marks_liveprop, *scan_ns,
  -					     dav_liveprop_uris, "lp", &hdr_ns);
  +                        ns = dav_get_liveprop_ns_index(*scan_ns_uri);
  +                        if (marks_liveprop[ns])
  +                            continue;
  +                        marks_liveprop[ns] = 1;
  +
  +                        dav_insert_xmlns(propdb->p, "lp", ns, *scan_ns_uri,
  +                                         &hdr_ns);
   		    }
   		}
   
  
  
  
  1.1                  apache-2.0/src/modules/dav/main/liveprop.c
  
  Index: liveprop.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 "apr_errno.h"
  
  #include "ap_hooks.h"   /* ### for ap_global_hook_pool */
  #include "util_xml.h"   /* for ap_text_header */
  
  #include "mod_dav.h"
  
  
  static ap_hash_t *dav_liveprop_uris = NULL;
  static int dav_liveprop_count = 0;
  
  
  static ap_status_t dav_cleanup_liveprops(void *ctx)
  {
      dav_liveprop_uris = NULL;
      dav_liveprop_count = 0;
      return APR_SUCCESS;
  }
  
  void dav_register_liveprop_namespace(ap_pool_t *p, const char *uri)
  {
      int value;
  
      /* ### ignore the pool; it is NULL right now */
      p = ap_global_hook_pool;
  
      if (dav_liveprop_uris == NULL) {
          dav_liveprop_uris = ap_make_hash(p);
          ap_register_cleanup(p, NULL, dav_cleanup_liveprops, ap_null_cleanup);
      }
  
      value = (int)ap_hash_get(dav_liveprop_uris, uri, 0);
      if (value != 0) {
          /* already registered */
          return;
      }
  
      /* start at 1, and count up */
      ap_hash_set(dav_liveprop_uris, uri, 0, (void *)++dav_liveprop_count);
  }
  
  int dav_get_liveprop_ns_index(const char *uri)
  {
      return (int)ap_hash_get(dav_liveprop_uris, uri, 0);
  }
  
  int dav_get_liveprop_ns_count(void)
  {
      return dav_liveprop_count;
  }
  
  void dav_add_all_liveprop_xmlns(ap_pool_t *p, ap_text_header *phdr)
  {
      ap_hash_index_t *idx = ap_hash_first(dav_liveprop_uris);
  
      for ( ; idx != NULL; idx = ap_hash_next(idx) ) {
          const void *key;
          void *val;
          const char *s;
  
          ap_hash_this(idx, &key, NULL, &val);
  
          s = ap_psprintf(p, " xmlns:lp%d=\"%s\"", (int)val, key);
          ap_text_append(p, phdr, s);
      }
  }