/*
** 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.
*/
#define APR_WANT_STRFUNC
#include "apr_want.h"
#include "apreq_module.h"
#include "apreq_error.h"
#include "apr_strings.h"
#include "apr_lib.h"
#include "apr_env.h"
#include "apreq_util.h"
/* Parroting APLOG_* ... */
/** Interactive patch:
* TODO Don't use 65K buffer
* TODO Handle empty/non-existant parameters
* TODO Allow body elements to be files
* values (and don't start at 0 in count)
* TODO What happens if user does apreq_param, but needs POST value - we'll
* never catch it now, as args param will match...
*/
struct cgi_handle {
const char *temp_dir;
int interactive_mode;
const char *promptstr;
};
static const char *nullstr = 0;
typedef struct {
const char *t_name;
int t_val;
} TRANS;
{"emerg", CGILOG_EMERG},
{"alert", CGILOG_ALERT},
{"crit", CGILOG_CRIT},
{"error", CGILOG_ERR},
{"warn", CGILOG_WARNING},
{"notice", CGILOG_NOTICE},
{"info", CGILOG_INFO},
{"debug", CGILOG_DEBUG},
{NULL, -1},
};
{
while (--p >= 0) {
switch ((char)(str[p])) {
case '\015':
break;
default:return str;
}
}
return str;
}
/** TODO: Support wide-characters */
/* prompt takes a apreq_handle and 2 strings - name and type - and prompts a
name must be defined. type can be null.
we take the promptstring defined in the handle and interpolate variables as
follows:
$n - name of the variable we're asking for (param 2 to prompt())
$t - type of the variable we're asking for - like cookie, get, post, etc
(param 3 to prompt())
parentheses - if a variable is surrounded by parentheses, and interpolates
as null, then nothing else in the parentheses will be displayed
Useful if you want a string to only show up if a given variable
is available
These are planned for forward-compatibility, but the underlying features
need some love... I left these in here just as feature reminders, rather
than completely removing them from the code - at least they provide sanity
testing of the default prompt & parentheses - issac
$l - label for the param - the end-user-developer can provide a textual
description of the param (name) being requested (currently unused in
lib)
$d - default value for the param (currently unused in lib)
*/
const char *type) {
const char *cprompt;
/* Array of current arg for given p-level */
int plevel;
while (*(++cprompt) != 0) {
switch (*cprompt) {
case '$': /* interpolate argument; curarg[plevel] => 1 */
cprompt++;
switch (*cprompt) {
case 't':
} else {
}
break;
case 'n':
/* Name can't be null :-) [If it can, we should
* immediately return NULL] */
break;
case 'l':
} else {
}
break;
case 'd':
/* TODO: Once null defaults are available,
* remove if and use nullstr if defval == NULL */
} else {
}
break;
default:
/* Handle this? */
break;
}
break;
case '(':
if (plevel <= MAX_PROMPT_NESTING_LEVELS) {
plevel++;
}
/* else? */
break;
case ')':
if (plevel > 0) {
*start = 0; /* Null terminate current string */
/* Move pointer to end of string */
plevel--;
/* If old curarg was set, concat buffer with level down */
}
break;
}
case '\\': /* Check next character for escape sequence
* (just ignore it for now) */
(void)*cprompt++;
/* Fallthrough */
default:
}
}
*start = 0; /* Null terminate the string */
/* if (strcmp(buf[0], nullstr)) */
/* return NULL; */
}
return NULL;
}
const char *name)
{
for (k = key; *k; ++k) {
if (*k == '-')
*k = '_';
else
*k = apr_toupper(*k);
}
{
}
return value;
}
const char *fmt, ...)
{
const char *remote_addr;
#ifndef WIN32
#endif
remote_addr = ra;
else
remote_addr = "address unavailable";
#ifndef WIN32
apr_file_open_stderr(&err, p);
#else
#endif
}
}
{
return value;
}
{
char *dummy;
"Invalid Content-Length header (%s)", cl_header);
return;
}
"Content-Length header (%s) exceeds configured "
return;
}
}
ba,
pf,
NULL);
}
else {
return;
}
}
else {
return;
}
}
else {
}
}
{
apr_bucket *e;
apr_status_t s;
return req->body_status;
case APR_SUCCESS:
break;
}
req->body_status =
break;
case APR_INCOMPLETE:
if (s != APR_SUCCESS) {
req->body_status = s;
break;
}
"Bytes read (%" APR_UINT64_T_FMT
break;
}
req->body_status =
break;
default:
req->body_status = s;
}
return req->body_status;
}
const apr_table_t **t)
{
apreq_cookie_t *p;
int i = 1;
while (1) {
i++);
break;
}
val = "";
}
} /** Fallthrough */
req->jar_status =
}
else
}
return req->jar_status;
}
const apr_table_t **t)
{
apreq_param_t *p;
int i = 1;
while (1) {
apr_file_printf(req->sout, "[CGI] Please enter a name for parameter %d (or just hit ENTER to end): ",
i++);
break;
}
val = "";
}
} /** Fallthrough */
req->args_status =
}
else
}
return req->args_status;
}
const char *name)
{
const apr_table_t *t;
else
if (!req->interactive_mode) {
return NULL;
} else {
apreq_cookie_t *p;
return NULL;
}
}
return apreq_value_to_cookie(val);
}
const char *name)
{
const apr_table_t *t;
else
if (!req->interactive_mode) {
return NULL;
} else {
apreq_param_t *p;
return NULL;
}
}
return apreq_value_to_param(val);
}
const apr_table_t **t)
{
apreq_param_t *p;
int i = 1;
while (1) {
apr_file_printf(req->sout, "[CGI] Please enter a name for parameter %d (or just hit ENTER to end): ",
i++);
break;
}
val = "";
}
} /** Fallthrough */
switch (req->body_status) {
case APR_EINIT:
break;
case APR_INCOMPLETE:
== APR_INCOMPLETE)
; /*loop*/
}
return req->body_status;
}
const char *name)
{
apreq_hook_t *h;
if (req->interactive_mode) {
return NULL;
} else {
apreq_param_t *p;
return NULL;
return apreq_value_to_param(val);
}
}
switch (req->body_status) {
case APR_SUCCESS:
return apreq_value_to_param(val);
return NULL;
case APR_EINIT:
return NULL;
case APR_INCOMPLETE:
return apreq_value_to_param(val);
/* Not seen yet, so we need to scan for
param while prefetching the body */
h = req->find_param;
do {
return NULL;
default:
return NULL;
return apreq_value_to_param(val);
return NULL;
}
/* not reached */
return NULL;
}
const apreq_parser_t **parser)
{
return APR_SUCCESS;
}
{
if (s != APR_SUCCESS)
return s;
}
}
}
return APR_SUCCESS;
}
else
return APREQ_ERROR_MISMATCH;
}
{
}
h = h->next;
}
else {
}
return APR_SUCCESS;
}
{
? &req->brigade_limit
return APR_SUCCESS;
}
return APREQ_ERROR_MISMATCH;
}
{
? req->brigade_limit
return APR_SUCCESS;
}
{
return APR_SUCCESS;
}
return APREQ_ERROR_MISMATCH;
}
{
return APR_SUCCESS;
}
const char *path)
{
return APR_SUCCESS;
}
return APREQ_ERROR_MISMATCH;
}
const char **path)
{
return APR_SUCCESS;
}
#ifdef APR_POOL_DEBUG
{
return APR_SUCCESS;
}
#endif
/** Determine if we're interactive mode or not. Order is
QUERY_STRING ? NO : Interactive
I think we should just rely on GATEWAY_INTERFACE to set
non-interactive mode, and be interactive if it's not there
Behaviour change should really be:
Always check query_string before prompting user,
Definately more work needed here...
*/
{
if (rv != APR_SUCCESS)
if (rv == APR_ENOENT)
return 1;
/** handle else? (!SUCCESS && !ENOENT) */
return 0;
}
{
void *data;
return data;
/* check pool's userdata first. */
req->args_status =
req->jar_status =
if (is_interactive_mode(pool)) {
}
#ifdef APR_POOL_DEBUG
#endif
}