mod_vhost_alias.c revision 4fca72b7b53b5419325e06837c98266148111b52
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* mod_vhost_alias.c: support for dynamically configured mass virtual hosting
*
* Copyright (c) 1998-1999 Demon Internet Ltd.
*
* This software was submitted by Demon Internet to the Apache Software Foundation
* in May 1999. Future revisions and derivatives of this source code
* must acknowledge Demon Internet as the original contributor of
* this module. All other licensing and usage conditions are those
* of the Apache Software Foundation.
*
* Originally written by Tony Finch <fanf@demon.net> <dot@dotat.at>.
*
* Implementation ideas were taken from mod_alias.c. The overall
* concept is derived from the OVERRIDE_DOC_ROOT/OVERRIDE_CGIDIR
* patch to Apache 1.3b3 and a similar feature in Demon's thttpd,
* both written by James Grinter <jrg@blodwen.demon.co.uk>.
*/
#include "apr.h"
#include "apr_strings.h"
#include "apr_hooks.h"
#include "apr_lib.h"
#define APR_WANT_STRFUNC
#include "apr_want.h"
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_request.h" /* for ap_hook_translate_name */
/*
* basic configuration things
* we abbreviate "mod_vhost_alias" to "mva" for shorter names
*/
typedef enum {
} mva_mode_e;
/*
* Per-server module config record.
*/
typedef struct mva_sconf_t {
const char *doc_root;
const char *cgi_root;
} mva_sconf_t;
{
return conf;
}
{
}
else {
}
}
else {
}
return conf;
}
/*
* These are just here to tell us what vhost_alias_set should do.
* We don't put anything into them; we just use the cell addresses.
*/
static int vhost_alias_set_doc_root_ip,
{
const char **pmap;
const char *p;
/* there ought to be a better way of doing this */
}
}
}
}
else {
return "INTERNAL ERROR: unknown command info";
}
return "format string must be an absolute path, or 'none'";
}
return NULL;
}
/* sanity check */
p = map;
while (*p != '\0') {
if (*p++ != '%') {
continue;
}
/* we just found a '%' */
if (*p == 'p' || *p == '%') {
++p;
continue;
}
/* optional dash */
if (*p == '-') {
++p;
}
/* digit N */
if (apr_isdigit(*p)) {
++p;
}
else {
return "syntax error in format string";
}
/* optional plus */
if (*p == '+') {
++p;
}
/* do we end here? */
if (*p != '.') {
continue;
}
++p;
/* optional dash */
if (*p == '-') {
++p;
}
/* digit M */
if (apr_isdigit(*p)) {
++p;
}
else {
return "syntax error in format string";
}
/* optional plus */
if (*p == '+') {
++p;
}
}
return NULL;
}
static const command_rec mva_commands[] =
{
"how to create a ScriptAlias based on the host"),
"how to create the DocumentRoot based on the host"),
"how to create a ScriptAlias based on the host"),
"how to create the DocumentRoot based on the host"),
{ NULL }
};
/*
* This really wants to be a nested function
* but C is too feeble to support them.
*/
{
/* XXX: what if size > HUGE_STRING_LEN? */
**pdest = '\0';
if (r->filename) {
}
else {
}
}
}
{
/* 0..9 9..0 */
enum { MAXDOTS = 19 };
int ndots;
char buf[HUGE_STRING_LEN];
const char *p;
ndots = 0;
for (p = name; *p; ++p){
}
}
last = '\0';
while (*map) {
if (*map != '%') {
/* normal characters */
continue;
}
/* we are in a format specifier */
++map;
/* can't be a slash */
last = '\0';
/* %% -> % */
if (*map == '%') {
++map;
*dest++ = '%';
continue;
}
/* port number */
if (*map == 'p') {
++map;
/* no. of decimal digits in a short plus one */
continue;
}
/* deal with %-N+.-M+ -- syntax is already checked */
M = 0; /* value */
N = *map++ - '0';
if (*map == '.') {
++map;
if (*map == '-') {
}
M = *map++ - '0';
if (*map == '+') {
}
}
/* note that N and M are one-based indices, not zero-based */
if (N != 0) {
if (N > ndots) {
start = "_";
}
else if (!Nd) {
if (!Np) {
}
}
else {
if (!Np) {
}
}
}
if (M != 0) {
start = "_";
}
else if (!Md) {
if (!Mp) {
}
}
else {
if (!Mp) {
}
}
}
*dest++ = apr_tolower(*p);
}
}
*dest = '\0';
/* no double slashes */
if (last == '/') {
++uri;
}
if (r->filename) {
}
else {
}
}
static int mva_translate(request_rec *r)
{
const char *cgi;
}
}
if (cgi) {
}
else if (r->uri[0] == '/') {
}
else {
return DECLINED;
}
if (mode == VHOST_ALIAS_NAME) {
name = ap_get_server_name(r);
}
else if (mode == VHOST_ALIAS_IP) {
}
else {
return DECLINED;
}
/* ### There is an optimization available here to determine the
* absolute portion of the path from the server config phase,
* through the first % segment, and note that portion of the path
* canonical_path buffer.
*/
r->canonical_filename = "";
if (cgi) {
/* see is_scriptaliased() in mod_cgi */
r->handler = "cgi-script";
}
return OK;
}
static void register_hooks(apr_pool_t *p)
{
}
{
NULL, /* dir config creater */
NULL, /* dir merger --- default is to override */
mva_create_server_config, /* server config */
mva_merge_server_config, /* merge server configs */
mva_commands, /* command apr_table_t */
register_hooks /* register hooks */
};