|
|
| version 1.12, 2001/02/24 15:26:02 | version 1.43, 2001/03/12 17:16:49 |
|---|---|
| Line 1 | Line 1 |
| /* | /* |
| $Id$ | Parser |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | |
| Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) | |
| $Id$ | |
| */ | */ |
| #ifndef PA_REQUEST_H | #ifndef PA_REQUEST_H |
| Line 14 | Line 18 |
| #include "pa_vclass.h" | #include "pa_vclass.h" |
| #define MAIN_METHOD_NAME "main" | #define MAIN_METHOD_NAME "main" |
| #define SELF_NAME "self" | #define AUTO_METHOD_NAME "auto" |
| #define USES_NAME "USES" | #define MAIN_CLASS_NAME "MAIN" |
| #define NAME_RUN "RUN" | |
| #define ROOT_CLASS_NAME "ROOT" | |
| #define ENV_CLASS_NAME "ENV" | |
| #define TABLE_CLASS_NAME "table" | |
| #ifndef NO_STRING_ORIGIN | #ifndef NO_STRING_ORIGIN |
| # define COMPILE_PARAMS char *source, char *file | # define COMPILE_PARAMS \ |
| # define COMPILE(source, file) real_compile(source, file) | const char *source, \ |
| VClass *aclass, const String *name, \ | |
| VClass *base_class, \ | |
| const char *file | |
| # define COMPILE(source, aclass, name, base_class, file) \ | |
| real_compile(source, aclass, name, base_class, file) | |
| #else | #else |
| # define COMPILE_PARAMS char *source | # define COMPILE_PARAMS \ |
| # define COMPILE(source, file) real_compile(source) | const char *source, \ |
| VClass *aclass, const String *name, \ | |
| VClass *base_class | |
| # define COMPILE(source, aclass, name, base_class, file) \ | |
| real_compile(source, aclass, name, base_class) | |
| #endif | #endif |
| class Local_request_exception; | class Temp_lang; |
| class Request : public Pooled { | class Request : public Pooled { |
| friend Temp_lang; | |
| public: | public: |
| Request(Pool& apool) : Pooled(apool), | Request(Pool& apool); |
| stack(apool), | |
| fclasses(apool), | |
| fclasses_array(apool) | |
| { | |
| } | |
| ~Request() {} | ~Request() {} |
| // global classes | // global classes |
| Line 46 public: | Line 58 public: |
| // core request processing | // core request processing |
| void core(); | void core(); |
| void execute(const Array& ops); | |
| VClass *use_file( | |
| const char *file, bool fail_on_read_problem=true, | |
| VClass *aclass=0, const String *name=0, | |
| VClass *base_class=0); // core.C | |
| VClass *use_buf( | |
| const char *source, const char *file, | |
| VClass *aclass=0, const String *name=0, | |
| VClass *base_class=0); // core.C | |
| Value& process( | |
| Value& value, | |
| const String *name=0, | |
| bool intercept_string=true); // execute.C | |
| void write(const String& astring) { | |
| wcontext->write(astring, String::Untaint_lang::NO); // write(const) = clean | |
| } | |
| void write_assign_lang(Value& avalue) { | |
| // appending possible string, assigning untaint language | |
| wcontext->write(avalue, flang); | |
| } | |
| void write_pass_lang(Value& avalue) { | |
| // appending possible string, passing language built into string being written | |
| wcontext->write(avalue, String::Untaint_lang::PASS_APPENDED); | |
| } | |
| void fail_if_junction_(bool is, Value& value, const String& method_name, char *msg); | |
| char *relative(const char *path, const char *file); | |
| char *absolute(const char *name); | |
| public: | |
| // default base | |
| VClass root_class; | |
| // $ENV:fields here | |
| VClass env_class; | |
| // contexts | |
| Value *self, *root, *rcontext; | |
| WContext *wcontext; | |
| private: // core data | private: // core data |
| // classes | // classes |
| Hash fclasses; | Hash fclasses; |
| Array fclasses_array; | Array fclasses_array; |
| // contexts | |
| Value *self, *root, *rcontext; | |
| WContext *wcontext; | |
| // execution stack | // execution stack |
| Stack stack; | Stack stack; |
| public: // core.C | |
| void use(char *file, String *name); | |
| private: // core.C | private: // core.C |
| char *execute_MAIN(); | char *execute_MAIN(); |
| Line 73 private: // compile.C | Line 121 private: // compile.C |
| private: // execute.C | private: // execute.C |
| void execute(const Array& ops); | char *execute_static_method(VClass& vclass, String& method_name, bool return_cstr); |
| Value *get_element(); | Value *get_element(); |
| private: // lang&raw | |
| String::Untaint_lang flang; | |
| private: // lang manipulation | |
| String::Untaint_lang set_lang(String::Untaint_lang alang) { | |
| String::Untaint_lang result=flang; | |
| flang=alang; | |
| return result; | |
| } | |
| void restore_lang(String::Untaint_lang alang) { | |
| flang=alang; | |
| } | |
| private: // web | |
| const char *document_root; | |
| const char *page_filespec; | |
| }; | }; |
| // core func | class Temp_lang { |
| void core(); | Request& frequest; |
| String::Untaint_lang saved_lang; | |
| public: | |
| Temp_lang(Request& arequest, String::Untaint_lang alang) : | |
| frequest(arequest), | |
| saved_lang(arequest.set_lang(alang)) { | |
| } | |
| ~Temp_lang() { | |
| frequest.restore_lang(saved_lang); | |
| } | |
| }; | |
| #endif | #endif |