1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "apr_strings.h"
21 #define APR_WANT_STRFUNC
28 #include "ap_config.h"
30 #include "http_config.h"
31 #include "http_main.h"
33 #include "http_core.h"
34 #include "http_protocol.h"
35 #include "http_request.h" /* for sub_req_lookup_uri() */
36 #include "util_script.h"
37 #include "apr_date.h" /* For apr_date_parse_http() */
38 #include "util_ebcdic.h"
46 * Various utility functions which are common to a whole lot of
47 * script-type extensions mechanisms, and might as well be gathered
48 * in one place (if only to avoid creating inter-module dependancies
49 * where there don't have to be).
52 /* we know core's module_index is 0 */
53 #undef APLOG_MODULE_INDEX
54 #define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX
56 static char *http2env(request_rec *r, const char *w)
58 char *res = (char *)apr_palloc(r->pool, sizeof("HTTP_") + strlen(w));
68 while ((c = *w++) != 0) {
70 *cp++ = apr_toupper(c);
77 ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r,
78 "Not exporting header with invalid name as envvar: %s",
79 ap_escape_logitem(r->pool, w));
88 static void add_unless_null(apr_table_t *table, const char *name, const char *val)
91 apr_table_addn(table, name, val);
95 static void env2env(apr_table_t *table, const char *name)
97 add_unless_null(table, name, getenv(name));
100 AP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t)
102 const apr_array_header_t *env_arr = apr_table_elts(t);
103 const apr_table_entry_t *elts = (const apr_table_entry_t *) env_arr->elts;
104 char **env = (char **) apr_palloc(p, (env_arr->nelts + 2) * sizeof(char *));
110 if (!apr_table_get(t, "TZ")) {
113 env[j++] = apr_pstrcat(p, "TZ=", tz, NULL);
116 for (i = 0; i < env_arr->nelts; ++i) {
120 env[j] = apr_pstrcat(p, elts[i].key, "=", elts[i].val, NULL);
122 if (apr_isdigit(*whack)) {
125 while (*whack != '=') {
127 if (!apr_isalnum(*whack) && *whack != '(' && *whack != ')') {
129 if (!apr_isalnum(*whack)) {
142 AP_DECLARE(void) ap_add_common_vars(request_rec *r)
145 server_rec *s = r->server;
146 conn_rec *c = r->connection;
147 core_dir_config *conf =
148 (core_dir_config *)ap_get_core_module_config(r->per_dir_config);
149 const char *env_temp;
150 const apr_array_header_t *hdrs_arr = apr_table_elts(r->headers_in);
151 const apr_table_entry_t *hdrs = (const apr_table_entry_t *) hdrs_arr->elts;
156 /* use a temporary apr_table_t which we'll overlap onto
157 * r->subprocess_env later
158 * (exception: if r->subprocess_env is empty at the start,
159 * write directly into it)
161 if (apr_is_empty_table(r->subprocess_env)) {
162 e = r->subprocess_env;
165 e = apr_table_make(r->pool, 25 + hdrs_arr->nelts);
168 /* First, add environment vars from headers... this is as per
169 * CGI specs, though other sorts of scripting interfaces see
173 for (i = 0; i < hdrs_arr->nelts; ++i) {
178 /* A few headers are special cased --- Authorization to prevent
179 * rogue scripts from capturing passwords; content-type and -length
180 * for no particular reason.
183 if (!strcasecmp(hdrs[i].key, "Content-type")) {
184 apr_table_addn(e, "CONTENT_TYPE", hdrs[i].val);
186 else if (!strcasecmp(hdrs[i].key, "Content-length")) {
187 apr_table_addn(e, "CONTENT_LENGTH", hdrs[i].val);
189 /* HTTP_PROXY collides with a popular envvar used to configure
190 * proxies, don't let clients set/override it. But, if you must...
192 #ifndef SECURITY_HOLE_PASS_PROXY
193 else if (!ap_cstr_casecmp(hdrs[i].key, "Proxy")) {
198 * You really don't want to disable this check, since it leaves you
199 * wide open to CGIs stealing passwords and people viewing them
200 * in the environment with "ps -e". But, if you must...
202 #ifndef SECURITY_HOLE_PASS_AUTHORIZATION
203 else if (!strcasecmp(hdrs[i].key, "Authorization")
204 || !strcasecmp(hdrs[i].key, "Proxy-Authorization")) {
205 if (conf->cgi_pass_auth == AP_CGI_PASS_AUTH_ON) {
206 add_unless_null(e, http2env(r, hdrs[i].key), hdrs[i].val);
211 add_unless_null(e, http2env(r, hdrs[i].key), hdrs[i].val);
214 env_temp = apr_table_get(r->subprocess_env, "PATH");
215 if (env_temp == NULL) {
216 env_temp = getenv("PATH");
218 if (env_temp == NULL) {
219 env_temp = DEFAULT_PATH;
221 apr_table_addn(e, "PATH", apr_pstrdup(r->pool, env_temp));
224 env2env(e, "SystemRoot");
225 env2env(e, "COMSPEC");
226 env2env(e, "PATHEXT");
227 env2env(e, "WINDIR");
229 env2env(e, "COMSPEC");
232 env2env(e, "PERLLIB_PREFIX");
234 env2env(e, "LIBRARY_PATH");
235 #elif defined(DARWIN)
236 env2env(e, "DYLD_LIBRARY_PATH");
238 env2env(e, "LIBPATH");
239 #elif defined(__HPUX__)
240 /* HPUX PARISC 2.0W knows both, otherwise redundancy is harmless */
241 env2env(e, "SHLIB_PATH");
242 env2env(e, "LD_LIBRARY_PATH");
243 #else /* Some Unix */
244 env2env(e, "LD_LIBRARY_PATH");
247 apr_table_addn(e, "SERVER_SIGNATURE", ap_psignature("", r));
248 apr_table_addn(e, "SERVER_SOFTWARE", ap_get_server_banner());
249 apr_table_addn(e, "SERVER_NAME",
250 ap_escape_html(r->pool, ap_get_server_name_for_url(r)));
251 apr_table_addn(e, "SERVER_ADDR", r->connection->local_ip); /* Apache */
252 apr_table_addn(e, "SERVER_PORT",
253 apr_psprintf(r->pool, "%u", ap_get_server_port(r)));
254 add_unless_null(e, "REMOTE_HOST",
255 ap_get_useragent_host(r, REMOTE_HOST, NULL));
256 apr_table_addn(e, "REMOTE_ADDR", r->useragent_ip);
257 apr_table_addn(e, "DOCUMENT_ROOT", ap_document_root(r)); /* Apache */
258 apr_table_setn(e, "REQUEST_SCHEME", ap_http_scheme(r));
259 apr_table_addn(e, "CONTEXT_PREFIX", ap_context_prefix(r));
260 apr_table_addn(e, "CONTEXT_DOCUMENT_ROOT", ap_context_document_root(r));
261 apr_table_addn(e, "SERVER_ADMIN", s->server_admin); /* Apache */
262 if (apr_table_get(r->notes, "proxy-noquery") && (q = ap_strchr(r->filename, '?'))) {
264 apr_table_addn(e, "SCRIPT_FILENAME", apr_pstrdup(r->pool, r->filename));
268 apr_table_addn(e, "SCRIPT_FILENAME", r->filename); /* Apache */
271 rport = c->client_addr->port;
272 apr_table_addn(e, "REMOTE_PORT", apr_itoa(r->pool, rport));
275 apr_table_addn(e, "REMOTE_USER", r->user);
278 request_rec *back = r->prev;
282 apr_table_addn(e, "REDIRECT_REMOTE_USER", back->user);
288 add_unless_null(e, "AUTH_TYPE", r->ap_auth_type);
289 env_temp = ap_get_remote_logname(r);
291 apr_table_addn(e, "REMOTE_IDENT", apr_pstrdup(r->pool, env_temp));
294 /* Apache custom error responses. If we have redirected set two new vars */
297 if (conf->qualify_redirect_url != AP_CORE_CONFIG_ON) {
298 add_unless_null(e, "REDIRECT_URL", r->prev->uri);
301 /* PR#57785: reconstruct full URL here */
302 apr_uri_t *uri = &r->prev->parsed_uri;
304 uri->scheme = (char*)ap_http_scheme(r->prev);
307 uri->port = ap_get_server_port(r->prev);
308 uri->port_str = apr_psprintf(r->pool, "%u", uri->port);
310 if (!uri->hostname) {
311 uri->hostname = (char*)ap_get_server_name_for_url(r->prev);
313 add_unless_null(e, "REDIRECT_URL",
314 apr_uri_unparse(r->pool, uri, 0));
316 add_unless_null(e, "REDIRECT_QUERY_STRING", r->prev->args);
319 if (e != r->subprocess_env) {
320 apr_table_overlap(r->subprocess_env, e, APR_OVERLAP_TABLES_SET);
324 /* This "cute" little function comes about because the path info on
325 * filenames and URLs aren't always the same. So we take the two,
326 * and find as much of the two that match as possible.
329 AP_DECLARE(int) ap_find_path_info(const char *uri, const char *path_info)
331 int lu = strlen(uri);
332 int lp = strlen(path_info);
334 while (lu-- && lp-- && uri[lu] == path_info[lp]) {
335 if (path_info[lp] == '/') {
336 while (lu && uri[lu-1] == '/') lu--;
344 while (uri[lu] != '\0' && uri[lu] != '/') {
350 /* Obtain the Request-URI from the original request-line, returning
351 * a new string from the request pool containing the URI or "".
353 static char *original_uri(request_rec *r)
357 if (r->the_request == NULL) {
358 return (char *) apr_pcalloc(r->pool, 1);
361 first = r->the_request; /* use the request-line */
363 while (*first && !apr_isspace(*first)) {
364 ++first; /* skip over the method */
366 while (apr_isspace(*first)) {
367 ++first; /* and the space(s) */
371 while (*last && !apr_isspace(*last)) {
372 ++last; /* end at next whitespace */
375 return apr_pstrmemdup(r->pool, first, last - first);
378 AP_DECLARE(void) ap_add_cgi_vars(request_rec *r)
380 apr_table_t *e = r->subprocess_env;
381 core_dir_config *conf =
382 (core_dir_config *)ap_get_core_module_config(r->per_dir_config);
383 int request_uri_from_original = 1;
384 const char *request_uri_rule;
386 apr_table_setn(e, "GATEWAY_INTERFACE", "CGI/1.1");
387 apr_table_setn(e, "SERVER_PROTOCOL", r->protocol);
388 apr_table_setn(e, "REQUEST_METHOD", r->method);
389 apr_table_setn(e, "QUERY_STRING", r->args ? r->args : "");
391 if (conf->cgi_var_rules) {
392 request_uri_rule = apr_hash_get(conf->cgi_var_rules, "REQUEST_URI",
393 APR_HASH_KEY_STRING);
394 if (request_uri_rule && !strcmp(request_uri_rule, "current-uri")) {
395 request_uri_from_original = 0;
398 apr_table_setn(e, "REQUEST_URI",
399 request_uri_from_original ? original_uri(r) : r->uri);
401 /* Note that the code below special-cases scripts run from includes,
402 * because it "knows" that the sub_request has been hacked to have the
403 * args and path_info of the original request, and not any that may have
404 * come with the script URI in the include command. Ugh.
407 if (!strcmp(r->protocol, "INCLUDED")) {
408 apr_table_setn(e, "SCRIPT_NAME", r->uri);
409 if (r->path_info && *r->path_info) {
410 apr_table_setn(e, "PATH_INFO", r->path_info);
413 else if (!r->path_info || !*r->path_info) {
414 apr_table_setn(e, "SCRIPT_NAME", r->uri);
417 int path_info_start = ap_find_path_info(r->uri, r->path_info);
419 apr_table_setn(e, "SCRIPT_NAME",
420 apr_pstrndup(r->pool, r->uri, path_info_start));
422 apr_table_setn(e, "PATH_INFO", r->path_info);
425 if (r->path_info && r->path_info[0]) {
427 * To get PATH_TRANSLATED, treat PATH_INFO as a URI path.
428 * Need to re-escape it for this, since the entire URI was
429 * un-escaped before we determined where the PATH_INFO began.
433 pa_req = ap_sub_req_lookup_uri(ap_escape_uri(r->pool, r->path_info), r,
436 if (pa_req->filename) {
437 char *pt = apr_pstrcat(r->pool, pa_req->filename, pa_req->path_info,
440 /* We need to make this a real Windows path name */
441 apr_filepath_merge(&pt, "", pt, APR_FILEPATH_NATIVE, r->pool);
443 apr_table_setn(e, "PATH_TRANSLATED", pt);
445 ap_destroy_sub_req(pa_req);
450 static int set_cookie_doo_doo(void *v, const char *key, const char *val)
452 apr_table_addn(v, key, val);
456 #define HTTP_UNSET (-HTTP_OK)
457 #define SCRIPT_LOG_MARK __FILE__,__LINE__,module_index
459 AP_DECLARE(int) ap_scan_script_header_err_core_ex(request_rec *r, char *buffer,
460 int (*getsfunc) (char *, int, void *),
464 char x[MAX_STRING_LEN];
467 int cgi_status = HTTP_UNSET;
469 apr_table_t *cookie_table;
470 int trace_log = APLOG_R_MODULE_IS_LEVEL(r, module_index, APLOG_TRACE1);
471 int first_header = 1;
476 w = buffer ? buffer : x;
478 /* temporary place to hold headers to merge in later */
479 merge = apr_table_make(r->pool, 10);
481 /* The HTTP specification says that it is legal to merge duplicate
482 * headers into one. Some browsers that support Cookies don't like
483 * merged headers and prefer that each Set-Cookie header is sent
484 * separately. Lets humour those browsers by not merging.
485 * Oh what a pain it is.
487 cookie_table = apr_table_make(r->pool, 2);
488 apr_table_do(set_cookie_doo_doo, cookie_table, r->err_headers_out, "Set-Cookie", NULL);
492 int rv = (*getsfunc) (w, MAX_STRING_LEN - 1, getsfunc_data);
494 const char *msg = "Premature end of script headers";
496 msg = "End of script output before headers";
497 /* Intentional no APLOGNO */
498 ap_log_rerror(SCRIPT_LOG_MARK, APLOG_ERR|APLOG_TOCLIENT, 0, r,
500 apr_filepath_name_get(r->filename));
501 return HTTP_INTERNAL_SERVER_ERROR;
504 /* Intentional no APLOGNO */
505 ap_log_rerror(SCRIPT_LOG_MARK, APLOG_ERR|APLOG_TOCLIENT, 0, r,
506 "Script timed out before returning headers: %s",
507 apr_filepath_name_get(r->filename));
508 return HTTP_GATEWAY_TIME_OUT;
511 /* Delete terminal (CR?)LF */
514 /* Indeed, the host's '\n':
515 '\012' for UNIX; '\015' for MacOS; '\025' for OS/390
516 -- whatever the script generates.
518 if (p > 0 && w[p - 1] == '\n') {
519 if (p > 1 && w[p - 2] == CR) {
528 * If we've finished reading the headers, check to make sure any
529 * HTTP/1.1 conditions are met. If so, we're done; normal processing
530 * will handle the script's output. If not, just return the error.
531 * The appropriate thing to do would be to send the script process a
532 * SIGPIPE to let it know we're ignoring it, close the channel to the
533 * script process, and *then* return the failed-to-meet-condition
534 * error. Otherwise we'd be waiting for the script to finish
535 * blithering before telling the client the output was no good.
536 * However, we don't have the information to do that, so we have to
537 * leave it to an upper layer.
540 int cond_status = OK;
542 /* PR#38070: This fails because it gets confused when a
543 * CGI Status header overrides ap_meets_conditions.
545 * We can fix that by dropping ap_meets_conditions when
546 * Status has been set. Since this is the only place
547 * cgi_status gets used, let's test it explicitly.
549 * The alternative would be to ignore CGI Status when
550 * ap_meets_conditions returns anything interesting.
551 * That would be safer wrt HTTP, but would break CGI.
553 if ((cgi_status == HTTP_UNSET) && (r->method_number == M_GET)) {
554 cond_status = ap_meets_conditions(r);
556 apr_table_overlap(r->err_headers_out, merge,
557 APR_OVERLAP_TABLES_MERGE);
558 if (!apr_is_empty_table(cookie_table)) {
559 /* the cookies have already been copied to the cookie_table */
560 apr_table_unset(r->err_headers_out, "Set-Cookie");
561 r->err_headers_out = apr_table_overlay(r->pool,
562 r->err_headers_out, cookie_table);
569 ap_log_rerror(SCRIPT_LOG_MARK, APLOG_TRACE4, 0, r,
570 "Headers from script '%s':",
571 apr_filepath_name_get(r->filename));
572 ap_log_rerror(SCRIPT_LOG_MARK, APLOG_TRACE4, 0, r, " %s", w);
575 /* if we see a bogus header don't ignore it. Shout and scream */
577 #if APR_CHARSET_EBCDIC
578 /* Chances are that we received an ASCII header text instead of
579 * the expected EBCDIC header lines. Try to auto-detect:
581 if (!(l = strchr(w, ':'))) {
582 int maybeASCII = 0, maybeEBCDIC = 0;
583 unsigned char *cp, native;
584 apr_size_t inbytes_left, outbytes_left;
586 for (cp = w; *cp != '\0'; ++cp) {
587 native = apr_xlate_conv_byte(ap_hdrs_from_ascii, *cp);
588 if (apr_isprint(*cp) && !apr_isprint(native))
590 if (!apr_isprint(*cp) && apr_isprint(native))
593 if (maybeASCII > maybeEBCDIC) {
594 ap_log_error(SCRIPT_LOG_MARK, APLOG_ERR, 0, r->server,
595 APLOGNO(02660) "CGI Interface Error: "
596 "Script headers apparently ASCII: (CGI = %s)",
598 inbytes_left = outbytes_left = cp - w;
599 apr_xlate_conv_buffer(ap_hdrs_from_ascii,
600 w, &inbytes_left, w, &outbytes_left);
603 #endif /*APR_CHARSET_EBCDIC*/
604 if (!(l = strchr(w, ':'))) {
606 /* Soak up all the script output - may save an outright kill */
607 while ((*getsfunc)(w, MAX_STRING_LEN - 1, getsfunc_data) > 0) {
612 /* Intentional no APLOGNO */
613 ap_log_rerror(SCRIPT_LOG_MARK, APLOG_ERR|APLOG_TOCLIENT, 0, r,
614 "malformed header from script '%s': Bad header: %.30s",
615 apr_filepath_name_get(r->filename), w);
616 return HTTP_INTERNAL_SERVER_ERROR;
620 while (apr_isspace(*l)) {
624 if (!strcasecmp(w, "Content-type")) {
627 /* Nuke trailing whitespace */
629 char *endp = l + strlen(l) - 1;
630 while (endp > l && apr_isspace(*endp)) {
634 tmp = apr_pstrdup(r->pool, l);
635 ap_content_type_tolower(tmp);
636 ap_set_content_type(r, tmp);
639 * If the script returned a specific status, that's what
640 * we'll use - otherwise we assume 200 OK.
642 else if (!strcasecmp(w, "Status")) {
643 r->status = cgi_status = atoi(l);
644 if (!ap_is_HTTP_VALID_RESPONSE(cgi_status))
645 /* Intentional no APLOGNO */
646 ap_log_rerror(SCRIPT_LOG_MARK, APLOG_ERR|APLOG_TOCLIENT, 0, r,
647 "Invalid status line from script '%s': %.30s",
648 apr_filepath_name_get(r->filename), l);
651 ap_log_rerror(SCRIPT_LOG_MARK, APLOG_TRACE1, 0, r,
652 "Status line from script '%s': %.30s",
653 apr_filepath_name_get(r->filename), l);
654 r->status_line = apr_pstrdup(r->pool, l);
656 else if (!strcasecmp(w, "Location")) {
657 apr_table_set(r->headers_out, w, l);
659 else if (!strcasecmp(w, "Content-Length")) {
660 apr_table_set(r->headers_out, w, l);
662 else if (!strcasecmp(w, "Content-Range")) {
663 apr_table_set(r->headers_out, w, l);
665 else if (!strcasecmp(w, "Transfer-Encoding")) {
666 apr_table_set(r->headers_out, w, l);
668 else if (!strcasecmp(w, "ETag")) {
669 apr_table_set(r->headers_out, w, l);
672 * If the script gave us a Last-Modified header, we can't just
673 * pass it on blindly because of restrictions on future values.
675 else if (!strcasecmp(w, "Last-Modified")) {
676 ap_update_mtime(r, apr_date_parse_http(l));
677 ap_set_last_modified(r);
679 else if (!strcasecmp(w, "Set-Cookie")) {
680 apr_table_add(cookie_table, w, l);
683 apr_table_add(merge, w, l);
687 /* never reached - we leave this function within the while loop above */
691 AP_DECLARE(int) ap_scan_script_header_err_core(request_rec *r, char *buffer,
692 int (*getsfunc) (char *, int, void *),
695 return ap_scan_script_header_err_core_ex(r, buffer, getsfunc,
700 static int getsfunc_FILE(char *buf, int len, void *f)
702 return apr_file_gets(buf, len, (apr_file_t *) f) == APR_SUCCESS;
705 AP_DECLARE(int) ap_scan_script_header_err(request_rec *r, apr_file_t *f,
708 return ap_scan_script_header_err_core_ex(r, buffer, getsfunc_FILE, f,
712 AP_DECLARE(int) ap_scan_script_header_err_ex(request_rec *r, apr_file_t *f,
713 char *buffer, int module_index)
715 return ap_scan_script_header_err_core_ex(r, buffer, getsfunc_FILE, f,
720 static int getsfunc_BRIGADE(char *buf, int len, void *arg)
722 apr_bucket_brigade *bb = (apr_bucket_brigade *)arg;
723 const char *dst_end = buf + len - 1; /* leave room for terminating null */
725 apr_bucket *e = APR_BRIGADE_FIRST(bb);
729 while ((dst < dst_end) && !done && e != APR_BRIGADE_SENTINEL(bb)
730 && !APR_BUCKET_IS_EOS(e)) {
731 const char *bucket_data;
732 apr_size_t bucket_data_len;
737 rv = apr_bucket_read(e, &bucket_data, &bucket_data_len,
739 if (rv != APR_SUCCESS || (bucket_data_len == 0)) {
741 return APR_STATUS_IS_TIMEUP(rv) ? -1 : 0;
744 src_end = bucket_data + bucket_data_len;
745 while ((src < src_end) && (dst < dst_end) && !done) {
749 else if (*src != '\r') {
756 apr_bucket_split(e, src - bucket_data);
758 next = APR_BUCKET_NEXT(e);
759 apr_bucket_delete(e);
766 AP_DECLARE(int) ap_scan_script_header_err_brigade(request_rec *r,
767 apr_bucket_brigade *bb,
770 return ap_scan_script_header_err_core_ex(r, buffer, getsfunc_BRIGADE, bb,
774 AP_DECLARE(int) ap_scan_script_header_err_brigade_ex(request_rec *r,
775 apr_bucket_brigade *bb,
779 return ap_scan_script_header_err_core_ex(r, buffer, getsfunc_BRIGADE, bb,
790 static int getsfunc_STRING(char *w, int len, void *pvastrs)
792 struct vastrs *strs = (struct vastrs*) pvastrs;
796 if (!strs->curpos || !*strs->curpos) {
800 p = ap_strchr_c(strs->curpos, '\n');
804 p = ap_strchr_c(strs->curpos, '\0');
805 t = p - strs->curpos;
808 strncpy (w, strs->curpos, t);
810 if (!strs->curpos[t]) {
812 strs->curpos = va_arg(strs->args, const char *);
819 /* ap_scan_script_header_err_strs() accepts additional const char* args...
820 * each is treated as one or more header lines, and the first non-header
821 * character is returned to **arg, **data. (The first optional arg is
824 AP_DECLARE_NONSTD(int) ap_scan_script_header_err_strs_ex(request_rec *r,
833 va_start(strs.args, termarg);
835 strs.curpos = va_arg(strs.args, char*);
836 res = ap_scan_script_header_err_core_ex(r, buffer, getsfunc_STRING,
837 (void *) &strs, module_index);
839 *termch = strs.curpos;
846 AP_DECLARE_NONSTD(int) ap_scan_script_header_err_strs(request_rec *r,
854 va_start(strs.args, termarg);
856 strs.curpos = va_arg(strs.args, char*);
857 res = ap_scan_script_header_err_core_ex(r, buffer, getsfunc_STRING,
858 (void *) &strs, APLOG_MODULE_INDEX);
860 *termch = strs.curpos;
868 argstr_to_table(char *str, apr_table_t *parms)
878 key = apr_strtok(str, "&", &strtok_state);
880 value = strchr(key, '=');
882 *value = '\0'; /* Split the string in two */
883 value++; /* Skip passed the = */
888 ap_unescape_url(key);
889 ap_unescape_url(value);
890 apr_table_set(parms, key, value);
891 key = apr_strtok(NULL, "&", &strtok_state);
895 AP_DECLARE(void) ap_args_to_table(request_rec *r, apr_table_t **table)
897 apr_table_t *t = apr_table_make(r->pool, 10);
898 argstr_to_table(apr_pstrdup(r->pool, r->args), t);