httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: httpd-2.0/modules/mappers mod_rewrite.c mod_rewrite.h
Date Fri, 23 Aug 2002 12:49:09 GMT
trawick     2002/08/23 05:49:08

  Modified:    .        CHANGES
               modules/mappers mod_rewrite.c mod_rewrite.h
  Log:
  add the ability to specify the dbm type (e.g., gdbm, ndbm) for
  dbm rewrite maps
  
  use dbm:filename for the default type
  
  use dbm=TYPE:filename for a non-default type
  
  Revision  Changes    Path
  1.895     +2 -1      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.894
  retrieving revision 1.895
  diff -u -r1.894 -r1.895
  --- CHANGES	21 Aug 2002 19:47:14 -0000	1.894
  +++ CHANGES	23 Aug 2002 12:49:07 -0000	1.895
  @@ -1,7 +1,8 @@
   Changes with Apache 2.0.41
   
     *) Change mod_rewrite to use apr-util's dbm support for dbm rewrite
  -     maps.  PR 10644  [Jeff Trawick]
  +     maps.  The dbm type (e.g., ndbm, gdbm) can be specified on the
  +     RewriteMap directive.  PR 10644  [Jeff Trawick]
   
     *) Fixed mod_rewrite's RewriteMap prg: support so that request/response
        pairs will no longer get out of sync with each other.  PR 9534
  
  
  
  1.127     +39 -12    httpd-2.0/modules/mappers/mod_rewrite.c
  
  Index: mod_rewrite.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.c,v
  retrieving revision 1.126
  retrieving revision 1.127
  diff -u -r1.126 -r1.127
  --- mod_rewrite.c	21 Aug 2002 19:47:15 -0000	1.126
  +++ mod_rewrite.c	23 Aug 2002 12:49:08 -0000	1.127
  @@ -120,8 +120,6 @@
   #include "unixd.h"
   #endif
   
  -#define DBM_MAP_TYPE "SDBM"
  -
   /*
   ** +-------------------------------------------------------+
   ** |                                                       |
  @@ -428,13 +426,41 @@
           newmap->datafile  = a2+4;
           newmap->checkfile = a2+4;
       }
  -    else if (strncmp(a2, "dbm:", 4) == 0) {
  +    else if (strncmp(a2, "dbm", 3) == 0) {
           const char *ignored_fname;
  +        int bad = 0;
  +        apr_status_t rv;
   
  -        newmap->type      = MAPTYPE_DBM;
  -        newmap->datafile  = a2+4;
  -        apr_dbm_get_usednames_ex(cmd->pool, DBM_MAP_TYPE, newmap->datafile, 
  -                                 &newmap->checkfile, &ignored_fname);
  +        if (a2[3] == ':') {
  +            newmap->dbmtype    = "default";
  +            newmap->datafile   = a2+4;
  +        }
  +        else if (a2[3] == '=') {
  +            const char *colon = ap_strchr_c(a2 + 4, ':');
  +            
  +            if (colon) {
  +                newmap->dbmtype = apr_pstrndup(cmd->pool, a2 + 4, colon - (a2 + 3)
- 1);
  +                newmap->datafile = colon + 1;
  +            }
  +            else {
  +                ++bad;
  +            }
  +        }
  +        else {
  +            ++bad;
  +        }
  +
  +        if (bad) {
  +            return apr_pstrcat(cmd->pool, "RewriteMap: bad map:",
  +                               a2, NULL);
  +        }
  +    
  +        rv = apr_dbm_get_usednames_ex(cmd->pool, newmap->dbmtype, newmap->datafile,
  +                                      &newmap->checkfile, &ignored_fname);
  +        if (rv != APR_SUCCESS) {
  +            return apr_pstrcat(cmd->pool, "RewriteMap: dbm type ", newmap->dbmtype,
  +                               " is invalid", NULL);
  +        }
       }
       else if (strncmp(a2, "prg:", 4) == 0) {
           newmap->type      = MAPTYPE_PRG;
  @@ -466,8 +492,8 @@
           && (apr_stat(&st, newmap->checkfile, APR_FINFO_MIN, 
                        cmd->pool) != APR_SUCCESS)) {
           return apr_pstrcat(cmd->pool,
  -                          "RewriteMap: map file not found:",
  -                          newmap->checkfile, NULL);
  +                          "RewriteMap: file for map ", newmap->name,
  +                           " not found:", newmap->checkfile, NULL);
       }
   
       return NULL;
  @@ -2787,7 +2813,7 @@
                       rewritelog(r, 6,
                                  "cache lookup FAILED, forcing new map lookup");
                       if ((value =
  -                         lookup_map_dbmfile(r, s->datafile, key)) != NULL) {
  +                         lookup_map_dbmfile(r, s->datafile, s->dbmtype, key)) !=
NULL) {
                           rewritelog(r, 5, "map lookup OK: map=%s[dbm] key=%s "
                                      "-> val=%s", s->name, key, value);
                           set_cache_string(cachep, s->name, CACHEMODE_TS,
  @@ -2925,7 +2951,8 @@
       return value;
   }
   
  -static char *lookup_map_dbmfile(request_rec *r, const char *file, char *key)
  +static char *lookup_map_dbmfile(request_rec *r, const char *file, 
  +                                const char *dbmtype, char *key)
   {
       apr_dbm_t *dbmfp = NULL;
       apr_datum_t dbmkey;
  @@ -2936,7 +2963,7 @@
   
       dbmkey.dptr  = key;
       dbmkey.dsize = strlen(key);
  -    if ((rv = apr_dbm_open_ex(&dbmfp, DBM_MAP_TYPE, file, APR_DBM_READONLY, 
  +    if ((rv = apr_dbm_open_ex(&dbmfp, dbmtype, file, APR_DBM_READONLY, 
                                 0 /* irrelevant when reading */, r->pool)) == APR_SUCCESS)
{
           rv = apr_dbm_fetch(dbmfp, dbmkey, &dbmval);
           if (rv == APR_SUCCESS) {
  
  
  
  1.39      +3 -1      httpd-2.0/modules/mappers/mod_rewrite.h
  
  Index: mod_rewrite.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.h,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- mod_rewrite.h	22 Aug 2002 11:23:26 -0000	1.38
  +++ mod_rewrite.h	23 Aug 2002 12:49:08 -0000	1.39
  @@ -226,6 +226,7 @@
   typedef struct {
       const char *name;              /* the name of the map */
       const char *datafile;          /* filename for map data files */
  +    const char *dbmtype;           /* dbm type for dbm map data files */
       const char *checkfile;         /* filename to check for map existence */
       int   type;                    /* the type of the map */
       apr_file_t *fpin;               /* in  file pointer for program maps */
  @@ -408,7 +409,8 @@
       /* rewrite map support functions */
   static char *lookup_map(request_rec *r, char *name, char *key);
   static char *lookup_map_txtfile(request_rec *r, const char *file, char *key);
  -static char *lookup_map_dbmfile(request_rec *r, const char *file, char *key);
  +static char *lookup_map_dbmfile(request_rec *r, const char *file, 
  +                                const char *dbmtype, char *key);
   static char *lookup_map_program(request_rec *r, apr_file_t *fpin,
                                   apr_file_t *fpout, char *key);
   
  
  
  

Mime
View raw message