httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Holsman <i...@apache.org>
Subject Re: [PATCH] PR 10644 - mod_rewrite using apr-util dbm support
Date Wed, 21 Aug 2002 16:21:57 GMT
Jeff Trawick wrote:
> questions for *dbm gurus...  is a switch from 1.3's ndbm usage to
> apr-util's built-in sdbm going to hurt anybody (file compatibility)?
> 
It will.
but the easiest way to handle this is to support ndbm in apr-util.
I've got a patch from someone to do this.. I've just been lazy
I'll go and implement that now.
(so you'll have the best of both worlds)
> is it going to be necessary to let the admin choose the file format
> from among the formats supported by apr-util?
> 
> how would one easily create rewrite mappings for use with apr-util's
> sdbm support?
> 
> Index: modules/mappers/config9.m4
> ===================================================================
> RCS file: /home/cvs/httpd-2.0/modules/mappers/config9.m4,v
> retrieving revision 1.11
> diff -u -r1.11 config9.m4
> --- modules/mappers/config9.m4	20 May 2002 21:00:27 -0000	1.11
> +++ modules/mappers/config9.m4	21 Aug 2002 16:10:02 -0000
> @@ -13,9 +13,7 @@
>  APACHE_MODULE(userdir, mapping of user requests, , , yes)
>  APACHE_MODULE(alias, translation of requests, , , yes)
>  
> -APACHE_MODULE(rewrite, regex URL translation, , , most, [
> -  APR_ADDTO(CFLAGS,-DNO_DBM_REWRITEMAP)
> -])
> +APACHE_MODULE(rewrite, regex URL translation, , , most)
>  
>  dnl mod_so should only be built as a static module
>  if test "$enable_so" = "yes"; then
> Index: modules/mappers/mod_rewrite.c
> ===================================================================
> RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.c,v
> retrieving revision 1.124
> diff -u -r1.124 mod_rewrite.c
> --- modules/mappers/mod_rewrite.c	10 Jul 2002 06:01:10 -0000	1.124
> +++ modules/mappers/mod_rewrite.c	21 Aug 2002 16:10:07 -0000
> @@ -161,23 +161,6 @@
>  **         or not!
>  */
>  
> -    /* The section for the Configure script:
> -    * XXX: this needs updating for apache-2.0 configuration method
> -     * MODULE-DEFINITION-START
> -     * Name: rewrite_module
> -     * ConfigStart
> -    . ./build/find-dbm-lib
> -    if [ "x$found_dbm" = "x1" ]; then
> -        echo "      enabling DBM support for mod_rewrite"
> -    else
> -        echo "      disabling DBM support for mod_rewrite"
> -        echo "      (perhaps you need to add -ldbm, -lndbm or -lgdbm to EXTRA_LIBS)"
> -        CFLAGS="$CFLAGS -DNO_DBM_REWRITEMAP"
> -    fi
> -     * ConfigEnd
> -     * MODULE-DEFINITION-END
> -     */
> -
>      /* the module (predeclaration) */
>  module AP_MODULE_DECLARE_DATA rewrite_module;
>  
> @@ -444,14 +427,12 @@
>          newmap->checkfile = a2+4;
>      }
>      else if (strncmp(a2, "dbm:", 4) == 0) {
> -#ifndef NO_DBM_REWRITEMAP
> +        const char *ignored_fname;
> +
>          newmap->type      = MAPTYPE_DBM;
>          newmap->datafile  = a2+4;
> -        newmap->checkfile = apr_pstrcat(cmd->pool, a2+4, NDBM_FILE_SUFFIX, NULL);
> -#else
> -        return apr_pstrdup(cmd->pool, "RewriteMap: cannot use NDBM mapfile, "
> -                          "because no NDBM support is compiled in");
> -#endif
> +        apr_dbm_get_usednames_ex(cmd->pool, "SDBM", newmap->datafile, 
> +                                 &newmap->checkfile, &ignored_fname);
>      }
>      else if (strncmp(a2, "prg:", 4) == 0) {
>          newmap->type      = MAPTYPE_PRG;
> @@ -2789,7 +2770,6 @@
>                  }
>              }
>              else if (s->type == MAPTYPE_DBM) {
> -#ifndef NO_DBM_REWRITEMAP
>                  if ((rv = apr_stat(&st, s->checkfile,
>                                     APR_FINFO_MIN, r->pool)) != APR_SUCCESS) {
>                      ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
> @@ -2825,9 +2805,6 @@
>                                 "-> val=%s", s->name, key, value);
>                      return value[0] != '\0' ? value : NULL;
>                  }
> -#else
> -                return NULL;
> -#endif
>              }
>              else if (s->type == MAPTYPE_PRG) {
>                  if ((value =
> @@ -2946,31 +2923,33 @@
>      return value;
>  }
>  
> -#ifndef NO_DBM_REWRITEMAP
>  static char *lookup_map_dbmfile(request_rec *r, const char *file, char *key)
>  {
> -    DBM *dbmfp = NULL;
> -    datum dbmkey;
> -    datum dbmval;
> +    apr_dbm_t *dbmfp = NULL;
> +    apr_datum_t dbmkey;
> +    apr_datum_t dbmval;
>      char *value = NULL;
>      char buf[MAX_STRING_LEN];
> +    apr_status_t rv;
>  
>      dbmkey.dptr  = key;
>      dbmkey.dsize = strlen(key);
> -    if ((dbmfp = dbm_open(file, O_RDONLY, 0666)) != NULL) {
> -        dbmval = dbm_fetch(dbmfp, dbmkey);
> -        if (dbmval.dptr != NULL) {
> +    /* always use SDBM for now; always available since apr-util includes it
> +     */
> +    if ((rv = apr_dbm_open_ex(&dbmfp, "SDBM", file, APR_DBM_READONLY, 
> +                              0 /* irrelevant when reading */, r->pool)) == APR_SUCCESS)
{
> +        rv = apr_dbm_fetch(dbmfp, dbmkey, &dbmval);
> +        if (rv == APR_SUCCESS) {
>              memcpy(buf, dbmval.dptr, 
>                     dbmval.dsize < sizeof(buf)-1 ? 
>                     dbmval.dsize : sizeof(buf)-1  );
>              buf[dbmval.dsize] = '\0';
>              value = apr_pstrdup(r->pool, buf);
>          }
> -        dbm_close(dbmfp);
> +        apr_dbm_close(dbmfp);
>      }
>      return value;
>  }
> -#endif
>  
>  static char *lookup_map_program(request_rec *r, apr_file_t *fpin,
>                                  apr_file_t *fpout, char *key)
> Index: modules/mappers/mod_rewrite.h
> ===================================================================
> RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.h,v
> retrieving revision 1.35
> diff -u -r1.35 mod_rewrite.h
> --- modules/mappers/mod_rewrite.h	22 Jun 2002 03:36:57 -0000	1.35
> +++ modules/mappers/mod_rewrite.h	21 Aug 2002 16:10:07 -0000
> @@ -116,6 +116,7 @@
>  #include "apr_thread_mutex.h"
>  #endif
>  #include "apr_optional.h"
> +#include "apr_dbm.h"
>  #include "ap_config.h"
>  
>      /* Include from the Apache server ... */
> @@ -134,28 +135,6 @@
>  #define VARY_KEY "rewrite-Vary"
>  #define VARY_KEY_THIS "rewrite-Vary-this"
>  
> -    /* The NDBM support:
> -     * We support only NDBM files.
> -     * But we have to stat the file for the mtime,
> -     * so we also need to know the file extension
> -     */
> -#ifndef NO_DBM_REWRITEMAP
> -#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) \
> -    && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
> -#include <db1/ndbm.h>
> -#else
> -#include <ndbm.h>
> -#endif
> -#if defined(DBM_SUFFIX)
> -#define NDBM_FILE_SUFFIX DBM_SUFFIX
> -#elif defined(__FreeBSD__) || (defined(DB_LOCK) && defined(DB_SHMEM))
> -#define NDBM_FILE_SUFFIX ".db"
> -#else
> -#define NDBM_FILE_SUFFIX ".pag"
> -#endif
> -#endif
> -
> -
>  /*
>  **
>  **  Some defines
> @@ -164,10 +143,6 @@
>  
>  #define ENVVAR_SCRIPT_URL "SCRIPT_URL"
>  #define ENVVAR_SCRIPT_URI "SCRIPT_URI"
> -
> -#ifndef SUPPORT_DBM_REWRITEMAP
> -#define SUPPORT_DBM_REWRITEMAP 0
> -#endif
>  
>  #define REWRITE_FORCED_MIMETYPE_NOTEVAR "rewrite-forced-mimetype"
>  
> 



Mime
View raw message