--- httpd-2.0/modules/mappers/mod_vhost_alias.c 2004-05-30 00:18:19.000000000 +0200 +++ httpd-2.0/modules/mappers/mod_vhost_alias.c 2004-05-30 00:24:36.000000000 +0200 @@ -64,6 +64,8 @@ typedef struct mva_sconf_t { const char *doc_root; const char *cgi_root; + const char *unset_part; + int unset_part_len; mva_mode_e doc_root_mode; mva_mode_e cgi_root_mode; } mva_sconf_t; @@ -75,6 +77,8 @@ conf = (mva_sconf_t *) apr_pcalloc(p, sizeof(mva_sconf_t)); conf->doc_root = NULL; conf->cgi_root = NULL; + conf->unset_part = "_"; + conf->unset_part_len = 1; conf->doc_root_mode = VHOST_ALIAS_UNSET; conf->cgi_root_mode = VHOST_ALIAS_UNSET; return conf; @@ -103,6 +107,14 @@ conf->cgi_root_mode = child->cgi_root_mode; conf->cgi_root = child->cgi_root; } + if (strcmp(child->unset_part, "_") != 0) { + conf->unset_part = child->unset_part; + conf->unset_part_len = child->unset_part_len; + } + else { + conf->unset_part = parent->unset_part; + conf->unset_part_len = parent->unset_part_len; + } return conf; } @@ -211,6 +223,17 @@ return NULL; } +static const char *vhost_alias_set_part(cmd_parms *cmd, void *dummy, + const char *unset_part) +{ + mva_sconf_t *conf; + conf = (mva_sconf_t *) ap_get_module_config(cmd->server->module_config, + &vhost_alias_module); + conf->unset_part = unset_part; + conf->unset_part_len = strlen(unset_part); + return NULL; +} + static const command_rec mva_commands[] = { AP_INIT_TAKE1("VirtualScriptAlias", vhost_alias_set, @@ -225,6 +248,9 @@ AP_INIT_TAKE1("VirtualDocumentRootIP", vhost_alias_set, &vhost_alias_set_doc_root_ip, RSRC_CONF, "how to create the DocumentRoot based on the host"), + AP_INIT_TAKE1("VirtualUnsetPart", vhost_alias_set_part, + NULL, RSRC_CONF, + "how to set the replacement for empty parts"), { NULL } }; @@ -249,8 +275,9 @@ } } -static void vhost_alias_interpolate(request_rec *r, const char *name, - const char *map, const char *uri) +static void vhost_alias_interpolate(request_rec *r, mva_sconf_t *conf, + const char *name, const char *map, + const char *uri) { /* 0..9 9..0 */ enum { MAXDOTS = 19 }; @@ -326,8 +353,8 @@ end = dots[ndots]; /* ptr to the character after the last one */ if (N != 0) { if (N > ndots) { - start = "_"; - end = start+1; + start = conf->unset_part; + end = start+conf->unset_part_len; } else if (!Nd) { start = dots[N-1]+1; @@ -344,8 +371,8 @@ } if (M != 0) { if (M > end - start) { - start = "_"; - end = start+1; + start = conf->unset_part; + end = start+conf->unset_part_len; } else if (!Md) { start = start+M-1; @@ -425,7 +452,7 @@ * canonical_path buffer. */ r->canonical_filename = ""; - vhost_alias_interpolate(r, name, map, uri); + vhost_alias_interpolate(r, conf, name, map, uri); if (cgi) { /* see is_scriptaliased() in mod_cgi */