--- parser3/src/targets/apache13/modules/extra/Attic/mod_parser3.C 2001/04/03 07:32:47 1.21 +++ parser3/src/targets/apache13/modules/extra/Attic/mod_parser3.C 2001/04/09 15:48:59 1.26 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: mod_parser3.C,v 1.21 2001/04/03 07:32:47 paf Exp $ + $Id: mod_parser3.C,v 1.26 2001/04/09 15:48:59 paf Exp $ */ #include "httpd.h" @@ -21,6 +21,9 @@ #include "pa_globals.h" #include "pa_request.h" #include "pa_version.h" +#include "pa_socks.h" + +/// @todo init_socks struct Parser_module_config { const char* parser_root_auto_path; /// filespec of admin's auto.p file @@ -79,12 +82,23 @@ static const char *cmd_parser_auto_path( //@{ /// SAPI func decl +void SAPI::log(Pool& pool, const char *fmt, ...) { + request_rec *r=static_cast(pool.context()); + + va_list args; + va_start(args,fmt); + char buf[MAX_STRING]; + vsnprintf(buf, MAX_STRING, fmt, args); + ap_log_rerror(0, 0, APLOG_ERR | APLOG_NOERRNO, r, "%s", buf); + va_end(args); +} + const char *SAPI::get_env(Pool& pool, const char *name) { request_rec *r=static_cast(pool.context()); return (const char *)ap_table_get(r->subprocess_env, name); } -uint SAPI::read_post(Pool& pool, char *buf, uint max_bytes) { +size_t SAPI::read_post(Pool& pool, char *buf, size_t max_bytes) { request_rec *r=static_cast(pool.context()); /* ap_log_error(APLOG_MARK, APLOG_DEBUG, r->server, @@ -141,16 +155,29 @@ void SAPI::send_body(Pool& pool, const v ap_kill_timeout(r); } -void SAPI::log(Pool& pool, const char *fmt, ...) { - request_rec *r=static_cast(pool.context()); - - va_list args; - va_start(args,fmt); - char buf[MAX_STRING]; - vsnprintf(buf, MAX_STRING, fmt, args); - ap_log_rerror(0, 0, APLOG_ERR | APLOG_NOERRNO, r, "%s", buf); - va_end(args); +int SAPI::execute(Pool& pool, + const String& file_spec, + const Hash *env, + const Array *argv, + const String& in, String& out, String& err) { + request_rec *r=static_cast(pool.context()); + + /* + * we spawn out of r->main if it's there so that we can avoid + * waiting for free_proc_chain to cleanup in the middle of an + * SSI request -djg + */ + if(!ap_bspawn_child(r->main ? r->main->pool : r->pool, cgi_child, + (void *) &cld, kill_after_timeout, + &script_out, &script_in, &script_err)) + PTHROW(0, 0, + &file_spec, + "could not spawn child process"); + + + return pa_exec(file_spec, env, argv, in, out, err); } + //@} /** @@ -218,7 +245,7 @@ static int parser_handler(request_rec *r // prepare header SAPI::add_header_attribute(pool, "content-type", "text/plain"); char content_length_cstr[MAX_NUMBER]; - snprintf(content_length_cstr, MAX_NUMBER, "%lu", content_length); + snprintf(content_length_cstr, MAX_NUMBER, "%u", content_length); SAPI::add_header_attribute(pool, "content-length", content_length_cstr); // send header