/* Licensed to the Apache Software Foundation (ASF) under one or more *contributorlicenseagreements.SeetheNOTICEfiledistributedwith *thisworkforadditionalinformationregardingcopyrightownership. *TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0 *(the"License");youmaynotusethisfileexceptincompliancewith *theLicense.YoumayobtainacopyoftheLicenseat * *http://www.apache.org/licenses/LICENSE-2.0 * *Unlessrequiredbyapplicablelaworagreedtoinwriting,software *distributedundertheLicenseisdistributedonan"ASIS"BASIS, *WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied. *SeetheLicenseforthespecificlanguagegoverningpermissionsand *limitationsundertheLicense.
*/
if (!ap_os_is_path_absolute(cmd->pool, map)) { if (ap_cstr_casecmp(map, "none")) { return"format string must be an absolute path, or 'none'";
}
*pmap = NULL;
*pmode = VHOST_ALIAS_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;
}
}
*pmap = map;
*pmode = mode; return NULL;
}
staticconst command_rec mva_commands[] =
{
AP_INIT_TAKE1("VirtualScriptAlias", vhost_alias_set,
&vhost_alias_set_cgi_root_name, RSRC_CONF, "how to create a ScriptAlias based on the host"),
AP_INIT_TAKE1("VirtualDocumentRoot", vhost_alias_set,
&vhost_alias_set_doc_root_name, RSRC_CONF, "how to create the DocumentRoot based on the host"),
AP_INIT_TAKE1("VirtualScriptAliasIP", vhost_alias_set,
&vhost_alias_set_cgi_root_ip, RSRC_CONF, "how to create a ScriptAlias based on the host"),
AP_INIT_TAKE1("VirtualDocumentRootIP", vhost_alias_set,
&vhost_alias_set_doc_root_ip, RSRC_CONF, "how to create the DocumentRoot based on the host"),
{ NULL }
};
dest = buf; while (*map) { if (*map != '%') { /* normal characters */
vhost_alias_checkspace(r, buf, &dest, 1);
*dest++ = *map++; continue;
} /* we are in a format specifier */
++map; /* %% -> % */ if (*map == '%') {
++map;
vhost_alias_checkspace(r, buf, &dest, 1);
*dest++ = '%'; continue;
} /* port number */ if (*map == 'p') {
++map; /* no. of decimal digits in a short plus one */
vhost_alias_checkspace(r, buf, &dest, 7);
dest += apr_snprintf(dest, 7, "%d", ap_get_server_port(r)); continue;
} /* deal with %-N+.-M+ -- syntax is already checked */
M = 0; /* value */
Np = Mp = 0; /* is there a plus? */
Nd = Md = 0; /* is there a dash? */ if (*map == '-') ++map, Nd = 1;
N = *map++ - '0'; if (*map == '+') ++map, Np = 1; if (*map == '.') {
++map; if (*map == '-') {
++map, Md = 1;
}
M = *map++ - '0'; if (*map == '+') {
++map, Mp = 1;
}
} /* note that N and M are one-based indices, not zero-based */
start = dots[0]+1; /* ptr to the first character */
end = dots[ndots]; /* ptr to the character after the last one */ if (N != 0) { if (N > ndots) {
start = "_";
end = start+1;
} elseif (!Nd) {
start = dots[N-1]+1; if (!Np) {
end = dots[N];
}
} else { if (!Np) {
start = dots[ndots-N]+1;
}
end = dots[ndots-N+1];
}
} if (M != 0) { if (M > end - start) {
start = "_";
end = start+1;
} elseif (!Md) {
start = start+M-1; if (!Mp) {
end = start+1;
}
} else { if (!Mp) {
start = end-M;
}
end = end-M+1;
}
}
vhost_alias_checkspace(r, buf, &dest, end - start); for (p = start; p < end; ++p) {
*dest++ = apr_tolower(*p);
}
} /* no double slashes */ if (dest - buf > 0 && dest[-1] == '/') {
--dest;
}
*dest = '\0';
if (mode == VHOST_ALIAS_NAME) {
name = ap_get_server_name(r);
} elseif (mode == VHOST_ALIAS_IP) {
name = r->connection->local_ip;
} else { return DECLINED;
}
/* ### There is an optimization available here to determine the *absoluteportionofthepathfromtheserverconfigphase, *throughthefirst%segment,andnotethatportionofthepath *canonical_pathbuffer.
*/
r->canonical_filename = "";
vhost_alias_interpolate(r, name, map, uri);
if (cgi) { /* see is_scriptaliased() in mod_cgi */
r->handler = "cgi-script";
apr_table_setn(r->notes, "alias-forced-type", r->handler);
ap_set_context_info(r, "/cgi-bin", NULL);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.