--- parser3/src/main/pa_request.C 2001/04/03 07:20:53 1.92 +++ parser3/src/main/pa_request.C 2001/04/05 20:01:22 1.99 @@ -5,11 +5,13 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_request.C,v 1.92 2001/04/03 07:20:53 paf Exp $ + $Id: pa_request.C,v 1.99 2001/04/05 20:01:22 paf Exp $ */ #include "pa_config_includes.h" +#include + #include "pa_sapi.h" #include "pa_common.h" #include "pa_request.h" @@ -51,7 +53,8 @@ Request::Request(Pool& apool, info(ainfo), used_files(apool), default_content_type(0), - mime_types(0) + mime_types(0), + connection(0), protocol2library(0) { // root superclass, // parent of all classes, @@ -99,7 +102,7 @@ static void add_header_attribute(const H all located classes become children of one another, composing class we name 'MAIN' - @test post-process + @todo figure out 'setlocale' thread safety */ void Request::core(const char *root_auto_path, bool root_auto_fail, const char *site_auto_path, bool site_auto_fail, @@ -196,11 +199,34 @@ void Request::core(const char *root_auto if(Table *table=element->get_table()) pool().set_tag(table); + // $MAIN:SQL.drivers + if(Value *sql=main_class->get_element(*main_sql_name)) + if(Value *element=sql->get_element(*main_sql_drivers_name)) + protocol2library=element->get_table(); + // $MAIN:MIME-TYPES if(Value *element=main_class->get_element(*mime_types_name)) if(Table *table=element->get_table()) mime_types=table; + // $MAIN:LOCALE.ctype[Russian_Russia.1251] +/* +#define LC_ALL 0 +#define LC_COLLATE 1 +#define LC_CTYPE 2 +#define LC_MONETARY 3 +#define LC_NUMERIC 4 +#define LC_TIME 5 +*/ + if(Value *locale=main_class->get_element(*locale_name)) + if(Value *element=locale->get_element(*locale_ctype_name)) { + const String& name=element->as_string(); + if(!setlocale(LC_CTYPE, name.cstr())) + THROW(0, 0, + &name, + "locale is invalid"); + } + // execute @main[] const String *body_string=execute_method(*main_class, *main_method_name); if(!body_string) @@ -217,7 +243,7 @@ void Request::core(const char *root_auto if(const Method *method=junction->method) { // preparing to pass parameters to // @post-process[data] - VMethodFrame frame(pool(), *junction); + VMethodFrame frame(pool(), *junction, false); frame.set_self(*main_class); frame.store_param(method->name, @@ -252,17 +278,17 @@ void Request::core(const char *root_auto problem_source->origin().file?problem_source->origin().file:"global", problem_source->origin().line, #endif - problem_source->cstr(), + problem_source->cstr(String::UL_AS_IS), e.comment(), - e.type()?e.type()->cstr():"-", - e.code()?e.code()->cstr():"-" + e.type()?e.type()->cstr(String::UL_AS_IS):"-", + e.code()?e.code()->cstr(String::UL_AS_IS):"-" ); else SAPI::log(pool(), "%s [%s %s]", e.comment(), - e.type()?e.type()->cstr():"-", - e.code()?e.code()->cstr():"-" + e.type()?e.type()->cstr(String::UL_AS_IS):"-", + e.code()?e.code()->cstr(String::UL_AS_IS):"-" ); // reset language to default @@ -282,7 +308,7 @@ void Request::core(const char *root_auto if(const Method *method=junction->method) { // preparing to pass parameters to // @exception[origin;source;comment;type;code] - VMethodFrame frame(pool(), *junction); + VMethodFrame frame(pool(), *junction, false); frame.set_self(*main_class); const String *problem_source=e.problem_source(); @@ -362,18 +388,18 @@ void Request::core(const char *root_auto origin.file, 1+origin.line); #endif printed+=snprintf(buf+printed, MAX_STRING-printed, "'%s' ", - problem_source->cstr()); + problem_source->cstr(String::UL_AS_IS)); } printed+=snprintf(buf+printed, MAX_STRING-printed, "%s", e.comment()); const String *type=e.type(); if(type) { printed+=snprintf(buf+printed, MAX_STRING-printed, " type: %s", - type->cstr()); + type->cstr(String::UL_AS_IS)); const String *code=e.code(); if(code) printed+=snprintf(buf+printed, MAX_STRING-printed, ", code: %s", - code->cstr()); + code->cstr(String::UL_AS_IS)); } // future $response:content-type @@ -403,7 +429,6 @@ void Request::core(const char *root_auto THROW(rethrow_me.type(), rethrow_me.code(), rethrow_me.problem_source(), rethrow_me.comment()); - } VStateless_class *Request::use_file(const String& file_spec, bool fail_on_read_problem,