1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-07 04:02:58 +03:00

Stylistic changes - remove tabs, clean up long lines, etc.

(No functional changes.)
(Functional optimizations/cleanups coming later...)


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95369 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Justin Erenkrantz
2002-05-29 22:27:37 +00:00
parent d7b9f6f3c7
commit f728b15f24

View File

@@ -156,7 +156,8 @@ static void *create_cgi_config(apr_pool_t *p, server_rec *s)
static void *merge_cgi_config(apr_pool_t *p, void *basev, void *overridesv)
{
cgi_server_conf *base = (cgi_server_conf *) basev, *overrides = (cgi_server_conf *) overridesv;
cgi_server_conf *base = (cgi_server_conf *) basev,
*overrides = (cgi_server_conf *) overridesv;
return overrides->logname ? overrides : base;
}
@@ -224,11 +225,11 @@ static int log_scripterror(request_rec *r, cgi_server_conf * conf, int ret,
/* XXX Very expensive mainline case! Open, then getfileinfo! */
if (!conf->logname ||
((apr_stat(&finfo, conf->logname,
APR_FINFO_SIZE, r->pool) == APR_SUCCESS)
&& (finfo.size > conf->logbytes)) ||
APR_FINFO_SIZE, r->pool) == APR_SUCCESS) &&
(finfo.size > conf->logbytes)) ||
(apr_file_open(&f, conf->logname,
APR_APPEND|APR_WRITE|APR_CREATE, APR_OS_DEFAULT, r->pool)
!= APR_SUCCESS)) {
APR_APPEND|APR_WRITE|APR_CREATE, APR_OS_DEFAULT,
r->pool) != APR_SUCCESS)) {
return ret;
}
@@ -283,10 +284,11 @@ static int log_script(request_rec *r, cgi_server_conf * conf, int ret,
/* XXX Very expensive mainline case! Open, then getfileinfo! */
if (!conf->logname ||
((apr_stat(&finfo, conf->logname,
APR_FINFO_SIZE, r->pool) == APR_SUCCESS)
&& (finfo.size > conf->logbytes)) ||
APR_FINFO_SIZE, r->pool) == APR_SUCCESS) &&
(finfo.size > conf->logbytes)) ||
(apr_file_open(&f, conf->logname,
APR_APPEND|APR_WRITE|APR_CREATE, APR_OS_DEFAULT, r->pool) != APR_SUCCESS)) {
APR_APPEND|APR_WRITE|APR_CREATE, APR_OS_DEFAULT,
r->pool) != APR_SUCCESS)) {
/* Soak up script output */
discard_script_output(bb);
log_script_err(r, script_err);
@@ -306,8 +308,8 @@ static int log_script(request_rec *r, cgi_server_conf * conf, int ret,
continue;
apr_file_printf(f, "%s: %s\n", hdrs[i].key, hdrs[i].val);
}
if ((r->method_number == M_POST || r->method_number == M_PUT)
&& *dbuf) {
if ((r->method_number == M_POST || r->method_number == M_PUT) &&
*dbuf) {
apr_file_printf(f, "\n%s\n", dbuf);
}
@@ -345,8 +347,9 @@ static int log_script(request_rec *r, cgi_server_conf * conf, int ret,
apr_file_puts("%stderr\n", f);
apr_file_puts(argsbuffer, f);
while (apr_file_gets(argsbuffer, HUGE_STRING_LEN,
script_err) == APR_SUCCESS)
script_err) == APR_SUCCESS) {
apr_file_puts(argsbuffer, f);
}
apr_file_puts("\n", f);
}
@@ -368,12 +371,15 @@ static void add_ssi_vars(request_rec *r, ap_filter_t *next)
if (r->path_info && r->path_info[0] != '\0') {
request_rec *pa_req;
apr_table_setn(e, "PATH_INFO", ap_escape_shell_cmd(r->pool, r->path_info));
apr_table_setn(e, "PATH_INFO", ap_escape_shell_cmd(r->pool,
r->path_info));
pa_req = ap_sub_req_lookup_uri(ap_escape_uri(r->pool, r->path_info), r, next);
pa_req = ap_sub_req_lookup_uri(ap_escape_uri(r->pool, r->path_info),
r, next);
if (pa_req->filename) {
apr_table_setn(e, "PATH_TRANSLATED",
apr_pstrcat(r->pool, pa_req->filename, pa_req->path_info, NULL));
apr_pstrcat(r->pool, pa_req->filename,
pa_req->path_info, NULL));
}
ap_destroy_sub_req(pa_req);
}
@@ -383,7 +389,8 @@ static void add_ssi_vars(request_rec *r, ap_filter_t *next)
apr_table_setn(e, "QUERY_STRING", r->args);
ap_unescape_url(arg_copy);
apr_table_setn(e, "QUERY_STRING_UNESCAPED", ap_escape_shell_cmd(r->pool, arg_copy));
apr_table_setn(e, "QUERY_STRING_UNESCAPED",
ap_escape_shell_cmd(r->pool, arg_copy));
}
}
@@ -449,17 +456,22 @@ static apr_status_t run_cgi_child(apr_file_t **script_out,
e_info->out_pipe,
e_info->err_pipe)) != APR_SUCCESS) ||
((rc = apr_procattr_dir_set(procattr,
ap_make_dirstr_parent(r->pool, r->filename))) != APR_SUCCESS) ||
ap_make_dirstr_parent(r->pool,
r->filename))) != APR_SUCCESS) ||
#ifdef RLIMIT_CPU
((rc = apr_procattr_limit_set(procattr, APR_LIMIT_CPU, conf->limit_cpu)) != APR_SUCCESS) ||
((rc = apr_procattr_limit_set(procattr, APR_LIMIT_CPU,
conf->limit_cpu)) != APR_SUCCESS) ||
#endif
#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
((rc = apr_procattr_limit_set(procattr, APR_LIMIT_MEM, conf->limit_mem)) != APR_SUCCESS) ||
((rc = apr_procattr_limit_set(procattr, APR_LIMIT_MEM,
conf->limit_mem)) != APR_SUCCESS) ||
#endif
#ifdef RLIMIT_NPROC
((rc = apr_procattr_limit_set(procattr, APR_LIMIT_NPROC, conf->limit_nproc)) != APR_SUCCESS) ||
((rc = apr_procattr_limit_set(procattr, APR_LIMIT_NPROC,
conf->limit_nproc)) != APR_SUCCESS) ||
#endif
((rc = apr_procattr_cmdtype_set(procattr, e_info->cmd_type)) != APR_SUCCESS)) {
((rc = apr_procattr_cmdtype_set(procattr,
e_info->cmd_type)) != APR_SUCCESS)) {
/* Something bad happened, tell the world. */
ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r,
"couldn't set child process attributes: %s", r->filename);
@@ -467,18 +479,21 @@ static apr_status_t run_cgi_child(apr_file_t **script_out,
else {
procnew = apr_pcalloc(p, sizeof(*procnew));
if (e_info->prog_type == RUN_AS_SSI) {
SPLIT_AND_PASS_PRETAG_BUCKETS(*(e_info->bb), e_info->ctx, e_info->next, rc);
SPLIT_AND_PASS_PRETAG_BUCKETS(*(e_info->bb), e_info->ctx,
e_info->next, rc);
if (rc != APR_SUCCESS) {
return rc;
}
}
rc = ap_os_create_privileged_process(r, procnew, command, argv, env, procattr, p);
rc = ap_os_create_privileged_process(r, procnew, command, argv, env,
procattr, p);
if (rc != APR_SUCCESS) {
/* Bad things happened. Everyone should have cleaned up. */
ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r,
"couldn't create child process: %d: %s", rc, r->filename);
"couldn't create child process: %d: %s", rc,
r->filename);
}
else {
apr_pool_note_subprocess(p, procnew, APR_KILL_AFTER_TIMEOUT);
@@ -486,18 +501,23 @@ static apr_status_t run_cgi_child(apr_file_t **script_out,
*script_in = procnew->out;
if (!*script_in)
return APR_EBADF;
apr_file_pipe_timeout_set(*script_in, (int)(r->server->timeout * APR_USEC_PER_SEC));
apr_file_pipe_timeout_set(*script_in, (int)(r->server->timeout *
APR_USEC_PER_SEC));
if (e_info->prog_type == RUN_AS_CGI) {
*script_out = procnew->in;
if (!*script_out)
return APR_EBADF;
apr_file_pipe_timeout_set(*script_out, (int)(r->server->timeout * APR_USEC_PER_SEC));
apr_file_pipe_timeout_set(*script_out,
(int)(r->server->timeout *
APR_USEC_PER_SEC));
*script_err = procnew->err;
if (!*script_err)
return APR_EBADF;
apr_file_pipe_timeout_set(*script_err, (int)(r->server->timeout * APR_USEC_PER_SEC));
apr_file_pipe_timeout_set(*script_err,
(int)(r->server->timeout *
APR_USEC_PER_SEC));
}
}
}
@@ -707,11 +727,12 @@ static int cgi_handler(request_rec *r)
rv = apr_file_write(script_out, argsbuffer + bytes_written,
&bytes_to_write);
bytes_written += bytes_to_write;
} while (rv == APR_SUCCESS
&& bytes_written < (apr_size_t)len_read);
} while (rv == APR_SUCCESS &&
bytes_written < (apr_size_t)len_read);
if (rv != APR_SUCCESS || bytes_written < (apr_size_t)len_read) {
/* silly script stopped reading, soak up remaining message */
while (ap_get_client_block(r, argsbuffer, HUGE_STRING_LEN) > 0) {
while (ap_get_client_block(r, argsbuffer,
HUGE_STRING_LEN) > 0) {
/* dump it */
}
break;
@@ -905,8 +926,8 @@ static int include_cmd(include_ctx_t *ctx, apr_bucket_brigade **bb,
e_info.ctx = ctx;
e_info.next = f->next;
if ((rv = cgi_build_command(&command, &argv, r, r->pool, 0, &e_info.cmd_type))
!= APR_SUCCESS) {
if ((rv = cgi_build_command(&command, &argv, r, r->pool, 0,
&e_info.cmd_type)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"don't know how to spawn cmd child process: %s",
r->filename);
@@ -915,7 +936,8 @@ static int include_cmd(include_ctx_t *ctx, apr_bucket_brigade **bb,
/* run the script in its own process */
if ((rv = run_cgi_child(&script_out, &script_in, &script_err,
command, argv, r, r->pool, &e_info)) != APR_SUCCESS) {
command, argv, r, r->pool,
&e_info)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"couldn't spawn child process: %s", r->filename);
return HTTP_INTERNAL_SERVER_ERROR;
@@ -934,8 +956,9 @@ static int include_cmd(include_ctx_t *ctx, apr_bucket_brigade **bb,
return 0;
}
static int handle_exec(include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec *r,
ap_filter_t *f, apr_bucket *head_ptr, apr_bucket **inserted_head)
static int handle_exec(include_ctx_t *ctx, apr_bucket_brigade **bb,
request_rec *r, ap_filter_t *f, apr_bucket *head_ptr,
apr_bucket **inserted_head)
{
char *tag = NULL;
char *tag_val = NULL;
@@ -955,40 +978,49 @@ static int handle_exec(include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec
cgi_pfn_gtv(ctx, &tag, &tag_val, 1);
if (tag_val == NULL) {
if (tag == NULL) {
return (0);
return 0;
}
else {
return 1;
}
}
if (!strcmp(tag, "cmd")) {
cgi_pfn_ps(r, ctx, tag_val, parsed_string, sizeof(parsed_string), 1);
cgi_pfn_ps(r, ctx, tag_val, parsed_string,
sizeof(parsed_string), 1);
if (include_cmd(ctx, bb, parsed_string, r, f) == -1) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"execution failure for parameter \"%s\" "
"to tag exec in file %s", tag, r->filename);
CREATE_ERROR_BUCKET(ctx, tmp_buck, head_ptr, *inserted_head);
CREATE_ERROR_BUCKET(ctx, tmp_buck, head_ptr,
*inserted_head);
}
}
else if (!strcmp(tag, "cgi")) {
apr_status_t retval = APR_SUCCESS;
cgi_pfn_ps(r, ctx, tag_val, parsed_string, sizeof(parsed_string), 0);
cgi_pfn_ps(r, ctx, tag_val, parsed_string,
sizeof(parsed_string), 0);
SPLIT_AND_PASS_PRETAG_BUCKETS(*bb, ctx, f->next, retval);
if (retval != APR_SUCCESS) {
return retval;
}
if (include_cgi(parsed_string, r, f->next, head_ptr, inserted_head) == -1) {
if (include_cgi(parsed_string, r, f->next, head_ptr,
inserted_head) == -1) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"invalid CGI ref \"%s\" in %s", tag_val, file);
CREATE_ERROR_BUCKET(ctx, tmp_buck, head_ptr, *inserted_head);
"invalid CGI ref \"%s\" in %s",
tag_val, file);
CREATE_ERROR_BUCKET(ctx, tmp_buck, head_ptr,
*inserted_head);
}
}
else {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"unknown parameter \"%s\" to tag exec in %s", tag, file);
CREATE_ERROR_BUCKET(ctx, tmp_buck, head_ptr, *inserted_head);
"unknown parameter \"%s\" to tag exec in %s",
tag, file);
CREATE_ERROR_BUCKET(ctx, tmp_buck, head_ptr,
*inserted_head);
}
}
}