MCPcopy Create free account
hub / github.com/apache/httpd / vhost_alias_interpolate

Function vhost_alias_interpolate

modules/mappers/mod_vhost_alias.c:253–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253static void vhost_alias_interpolate(request_rec *r, const char *name,
254 const char *map, const char *uri)
255{
256 /* 0..9 9..0 */
257 enum { MAXDOTS = 19 };
258 const char *dots[MAXDOTS+1];
259 int ndots;
260
261 char buf[HUGE_STRING_LEN];
262 char *dest;
263 const char *docroot;
264
265 int N, M, Np, Mp, Nd, Md;
266 const char *start, *end;
267
268 const char *p;
269
270 ndots = 0;
271 dots[ndots++] = name-1; /* slightly naughty */
272 for (p = name; *p; ++p) {
273 if (*p == '.' && ndots < MAXDOTS) {
274 dots[ndots++] = p;
275 }
276 }
277 dots[ndots] = p;
278
279 r->filename = NULL;
280
281 dest = buf;
282 while (*map) {
283 if (*map != '%') {
284 /* normal characters */
285 vhost_alias_checkspace(r, buf, &dest, 1);
286 *dest++ = *map++;
287 continue;
288 }
289 /* we are in a format specifier */
290 ++map;
291 /* %% -> % */
292 if (*map == '%') {
293 ++map;
294 vhost_alias_checkspace(r, buf, &dest, 1);
295 *dest++ = '%';
296 continue;
297 }
298 /* port number */
299 if (*map == 'p') {
300 ++map;
301 /* no. of decimal digits in a short plus one */
302 vhost_alias_checkspace(r, buf, &dest, 7);
303 dest += apr_snprintf(dest, 7, "%d", ap_get_server_port(r));
304 continue;
305 }
306 /* deal with %-N+.-M+ -- syntax is already checked */
307 M = 0; /* value */
308 Np = Mp = 0; /* is there a plus? */
309 Nd = Md = 0; /* is there a dash? */
310 if (*map == '-') ++map, Nd = 1;

Callers 1

mva_translateFunction · 0.85

Calls 4

vhost_alias_checkspaceFunction · 0.85
ap_get_server_portFunction · 0.85
ap_set_context_infoFunction · 0.85
ap_set_document_rootFunction · 0.85

Tested by

no test coverage detected