summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorJeff Trawick <trawick@apache.org>2002-08-23 14:49:08 +0200
committerJeff Trawick <trawick@apache.org>2002-08-23 14:49:08 +0200
commita424be649ce4e86bd0ab4332f343d2dd39b192a1 (patch)
treec07de189a123dbb0630ca74b7e994d1ca6e268bb /modules
parentMaxSpareServers and MinSpareServers are native to prefork, not mpm_common. (diff)
downloadapache2-a424be649ce4e86bd0ab4332f343d2dd39b192a1.tar.xz
apache2-a424be649ce4e86bd0ab4332f343d2dd39b192a1.zip
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 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96493 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules')
-rw-r--r--modules/mappers/mod_rewrite.c51
-rw-r--r--modules/mappers/mod_rewrite.h4
2 files changed, 42 insertions, 13 deletions
diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c
index 9363e5651c..e246df85bc 100644
--- a/modules/mappers/mod_rewrite.c
+++ b/modules/mappers/mod_rewrite.c
@@ -120,8 +120,6 @@
#include "unixd.h"
#endif
-#define DBM_MAP_TYPE "SDBM"
-
/*
** +-------------------------------------------------------+
** | |
@@ -428,13 +426,41 @@ static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, const char *a1,
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 @@ static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, const char *a1,
&& (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 @@ static char *lookup_map(request_rec *r, char *name, char *key)
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 @@ static char *lookup_map_txtfile(request_rec *r, const char *file, char *key)
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 @@ static char *lookup_map_dbmfile(request_rec *r, const char *file, char *key)
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) {
diff --git a/modules/mappers/mod_rewrite.h b/modules/mappers/mod_rewrite.h
index 0f173beea3..7ca91f3661 100644
--- a/modules/mappers/mod_rewrite.h
+++ b/modules/mappers/mod_rewrite.h
@@ -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 @@ static char *expand_tildepaths(request_rec *r, char *uri);
/* 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);