summaryrefslogtreecommitdiffstats
path: root/modules/mappers
diff options
context:
space:
mode:
authorJeff Trawick <trawick@apache.org>2002-08-21 21:47:15 +0200
committerJeff Trawick <trawick@apache.org>2002-08-21 21:47:15 +0200
commitc14aa6528b4ba6cb1e1c151ed336b140325ced58 (patch)
tree069f06c592302369773e2b667e9b88c65c7f20c2 /modules/mappers
parent Small fixes for SSLC (diff)
downloadapache2-c14aa6528b4ba6cb1e1c151ed336b140325ced58.tar.xz
apache2-c14aa6528b4ba6cb1e1c151ed336b140325ced58.zip
Change mod_rewrite to use apr-util's dbm support for dbm rewrite
maps. For now, the SDBM dbm flavor is always used. It won't be compatible with dbm rewrite maps built for Apache 1.3 until apr-util supports ndbm and mod_rewrite is changed to prefer ndbm over the built-in sdbm. PR: 10644 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96478 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/mappers')
-rw-r--r--modules/mappers/config9.m44
-rw-r--r--modules/mappers/mod_rewrite.c51
-rw-r--r--modules/mappers/mod_rewrite.h27
3 files changed, 17 insertions, 65 deletions
diff --git a/modules/mappers/config9.m4 b/modules/mappers/config9.m4
index a2863c020b..60b9138ffc 100644
--- a/modules/mappers/config9.m4
+++ b/modules/mappers/config9.m4
@@ -13,9 +13,7 @@ APACHE_MODULE(speling, correct common URL misspellings, , , most)
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
diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c
index 513aa50828..9363e5651c 100644
--- a/modules/mappers/mod_rewrite.c
+++ b/modules/mappers/mod_rewrite.c
@@ -120,6 +120,8 @@
#include "unixd.h"
#endif
+#define DBM_MAP_TYPE "SDBM"
+
/*
** +-------------------------------------------------------+
** | |
@@ -161,23 +163,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 +429,12 @@ static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, const char *a1,
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, DBM_MAP_TYPE, newmap->datafile,
+ &newmap->checkfile, &ignored_fname);
}
else if (strncmp(a2, "prg:", 4) == 0) {
newmap->type = MAPTYPE_PRG;
@@ -2789,7 +2772,6 @@ static char *lookup_map(request_rec *r, char *name, char *key)
}
}
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 +2807,6 @@ static char *lookup_map(request_rec *r, char *name, char *key)
"-> 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 +2925,31 @@ static char *lookup_map_txtfile(request_rec *r, const char *file, char *key)
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) {
+ if ((rv = apr_dbm_open_ex(&dbmfp, DBM_MAP_TYPE, 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)
diff --git a/modules/mappers/mod_rewrite.h b/modules/mappers/mod_rewrite.h
index 7ffd8b7034..69a53dfa7a 100644
--- a/modules/mappers/mod_rewrite.h
+++ b/modules/mappers/mod_rewrite.h
@@ -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
@@ -165,10 +144,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"
#define CONDFLAG_NONE 1<<0