--- parser3/src/main/pa_request.C 2001/04/05 20:01:22 1.99 +++ parser3/src/main/pa_request.C 2001/04/07 13:56:46 1.103 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_request.C,v 1.99 2001/04/05 20:01:22 paf Exp $ + $Id: pa_request.C,v 1.103 2001/04/07 13:56:46 paf Exp $ */ #include "pa_config_includes.h" @@ -17,7 +17,7 @@ #include "pa_request.h" #include "pa_wwrapper.h" #include "pa_vclass.h" -#include "_root.h" +#include "_op.h" #include "_table.h" #include "_file.h" #include "pa_globals.h" @@ -27,6 +27,7 @@ #include "pa_vtable.h" #include "_random.h" #include "pa_vfile.h" +#include "_mail.h" /// $limits.post_max_size default 10M const size_t MAX_POST_SIZE_DEFAULT=10*0x400*400; @@ -42,7 +43,7 @@ Request::Request(Pool& apool, Info& ainfo, String::Untaint_lang adefault_lang) : Pooled(apool), stack(apool), - ROOT(apool), + OP(apool), env(apool), form(apool), request(apool, *this), @@ -54,13 +55,14 @@ Request::Request(Pool& apool, used_files(apool), default_content_type(0), mime_types(0), - connection(0), protocol2library(0) + connection(0), protocol2library(0), + mail(0) { // root superclass, // parent of all classes, // operators holder - initialize_root_class(pool(), ROOT); - classes().put(*root_class_name, &ROOT); + initialize_op_class(pool(), OP); + classes().put(*op_class_name, &OP); // table class classes().put(*table_class_name, table_class); // file class @@ -77,21 +79,8 @@ Request::Request(Pool& apool, classes().put(*response_class_name, &response); // cookie class classes().put(*cookie_class_name, &cookie); -} - -static void add_header_attribute(const Hash::Key& aattribute, Hash::Val *ameaning, - void *info) { - String *attribute_to_exclude=static_cast(info); - if(aattribute==*attribute_to_exclude) - return; - - Value& lmeaning=*static_cast(ameaning); - Pool& pool=lmeaning.pool(); - - String attribute(pool); - SAPI::add_header_attribute(pool, - attribute.append(aattribute, String::UL_HEADER, true).cstr(), - attributed_meaning_to_string(lmeaning).cstr()); + // mail class + classes().put(*mail_class_name, mail_class); } /** @@ -102,7 +91,7 @@ static void add_header_attribute(const H all located classes become children of one another, composing class we name 'MAIN' - @todo figure out 'setlocale' thread safety + @test get read of setlocale */ void Request::core(const char *root_auto_path, bool root_auto_fail, const char *site_auto_path, bool site_auto_fail, @@ -227,6 +216,14 @@ void Request::core(const char *root_auto "locale is invalid"); } + // $MAIN:MAIL[$SMTP[mail.design.ru]] + if(Value *mail_element=main_class->get_element(*mail_name)) + if(!(mail=mail_element->get_hash())) + THROW(0, 0, + 0, + "$MAIN:MAIL is not hash"); + + // execute @main[] const String *body_string=execute_method(*main_class, *main_method_name); if(!body_string) @@ -492,6 +489,20 @@ const String& Request::absolute(const St return relative(info.path_translated, relative_name); } +static void add_header_attribute(const Hash::Key& aattribute, Hash::Val *ameaning, + void *info) { + String *attribute_to_exclude=static_cast(info); + if(aattribute==*attribute_to_exclude) + return; + + Value& lmeaning=*static_cast(ameaning); + Pool& pool=lmeaning.pool(); + + String attribute(pool); + SAPI::add_header_attribute(pool, + attribute.append(aattribute, String::UL_HTTP_HEADER, true).cstr(), + attributed_meaning_to_string(lmeaning, String::UL_HTTP_HEADER).cstr()); +} void Request::output_result(const VFile& body_file, bool header_only) { // header: cookies cookie.output_result();