Diff for /parser3/src/include/pa_request.h between versions 1.47 and 1.65

version 1.47, 2001/03/13 13:53:36 version 1.65, 2001/03/21 14:06:43
Line 1 Line 1
 /*  /** @file
         Parser          Parser: request class decl.
   
         Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
   
         Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)          Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
   
         $Id$          $Id$
Line 10 Line 12
 #define PA_REQUEST_H  #define PA_REQUEST_H
   
 #include "pa_pool.h"  #include "pa_pool.h"
 #include "pa_exception.h"  
 #include "pa_hash.h"  #include "pa_hash.h"
 #include "pa_wcontext.h"  #include "pa_wcontext.h"
 #include "pa_value.h"  #include "pa_value.h"
Line 18 Line 19
 #include "pa_vclass.h"  #include "pa_vclass.h"
 #include "pa_vobject.h"  #include "pa_vobject.h"
 #include "pa_venv.h"  #include "pa_venv.h"
   #include "pa_vform.h"
 #define UNNAMED_NAME "unnamed"  #include "pa_vrequest.h"
   #include "pa_vresponse.h"
 #define MAIN_METHOD_NAME "main"  #include "pa_vcookie.h"
 #define AUTO_METHOD_NAME "auto"  
 #define MAIN_CLASS_NAME "MAIN"  
   
 #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  \  #       define COMPILE_PARAMS  \
Line 48 Line 43
   
 class Temp_lang;  class Temp_lang;
   
   /// Main workhorse.
 class Request : public Pooled {  class Request : public Pooled {
         friend Temp_lang;          friend Temp_lang;
 public:  public:
   
           /// some information from web server
           class Info {
           public:
                   const char *document_root;
                   const char *path_translated;
                   const char *method;
                   const char *query_string;
                   const char *uri;
                   const char *content_type;
                   size_t content_length;
                   const char *cookie;
           };
                   
         Request(Pool& apool);          Request(Pool& apool,
                   Info& ainfo,
                   String::Untaint_lang adefault_lang ///< all tainted data default untainting lang
           );
         ~Request() {}          ~Request() {}
   
         // global classes          /// global classes
         Hash& classes() { return fclasses; }          Hash& classes() { return fclasses; }
         Array& classes_array() { return fclasses_array; }  
   
         // core request processing          /**
         void core();                  core request processing
   
                   BEWARE: may throw exception to you: catch it!
           */
           void core(
                   const char *sys_auto_path1,
                   const char *sys_auto_path2,
                   bool header_only);
   
           /// executes ops
         void execute(const Array& ops);          void execute(const Array& ops);
   
           /// compiles the file, maybe forcing it's class @a name and @a base_class.
         VStateless_class *use_file(          VStateless_class *use_file(
                 const char *file, bool fail_on_read_problem=true,                  const char *file, bool fail_on_read_problem=true,
                 const String *name=0,                   const String *name=0, 
                 VStateless_class *base_class=0); // core.C                  VStateless_class *base_class=0); // core.C
           /// compiles a @a source buffer
         VStateless_class *use_buf(          VStateless_class *use_buf(
                 const char *source, const char *file,                  const char *source, const char *file,
                 VStateless_class *aclass=0, const String *name=0,                   VStateless_class *aclass=0, const String *name=0, 
                 VStateless_class *base_class=0); // core.C                  VStateless_class *base_class=0); // core.C
           /// processes any code-junction there may be inside of @a value
         Value& process(          Value& process(
                 Value& value,                   Value& value, 
                 const String *name=0,                  const String *name=0,
                 bool intercept_string=true); // execute.C                  bool intercept_string=true); // execute.C
   
         void write(const String& astring) {          /// appending, sure of clean string inside
                 wcontext->write(astring, String::Untaint_lang::NO);  // write(const) = clean          void write_no_lang(const String& astring) {
                   wcontext->write(astring, String::UL_NO);
         }          }
           /// appending string, passing language built into string being written
           void write_pass_lang(const String& astring) {
                   wcontext->write(astring, String::UL_PASS_APPENDED); 
           }
           /// appending possible string, assigning untaint language
         void write_assign_lang(Value& avalue) {          void write_assign_lang(Value& avalue) {
                 // appending possible string, assigning untaint language  
                 wcontext->write(avalue, flang);                   wcontext->write(avalue, flang); 
         }          }
           /// appending possible string, passing language built into string being written
         void write_pass_lang(Value& avalue) {          void write_pass_lang(Value& avalue) {
                 // appending possible string, passing language built into string being written                  wcontext->write(avalue, String::UL_PASS_APPENDED); 
                 wcontext->write(avalue, String::Untaint_lang::PASS_APPENDED);           }
           /// appending sure value, that would be converted to clean string
           void write_no_lang(Value& avalue) {
                   wcontext->write(avalue, String::UL_NO);
           }
           /// appending sure value, not VString
           void write_expr_result(Value& avalue) {
                   wcontext->write(avalue); 
         }          }
   
         void fail_if_junction_(bool is, Value& value, const String& method_name, char *msg);          /// handy is-value-a-junction ensurer
           void fail_if_junction_(bool is, Value& value, 
                   const String& method_name, const char *msg);
   
           /// returns relative to @a path  path to @a file 
         char *relative(const char *path, const char *file);          char *relative(const char *path, const char *file);
   
           /// returns an absolute @a path to relative @a name
         char *absolute(const char *name);          char *absolute(const char *name);
   
 public:  public:
                   
         // default base          /// info from web server
         VClass root_class;          Info& info;
         // $ENV:fields here  
         VEnv env_class;          /// default base
           VClass ROOT;
           /// $env:fields here
           VEnv env;
           /// $form:elements here
           VForm form;
           /// $request:elements here
           VRequest request;
           /// $response:
           VResponse response;
           /// $cookie:
           VCookie cookie;
   
         // contexts          /// contexts
         Value *self, *root, *rcontext;          Value *self, *root, *rcontext;
           /// contexts
         WContext *wcontext;          WContext *wcontext;
   
 private: // core data  private: // core data
   
         // classes          // classes
         Hash fclasses;          Hash fclasses;
         Array fclasses_array;  
   
         // execution stack          // execution stack
         Stack stack;          Stack stack;
Line 121  private: // compile.C Line 171  private: // compile.C
   
 private: // execute.C  private: // execute.C
   
         char *execute_method(Value& aself, const Method& method, bool return_cstr);          const String *execute_method(Value& aself, const Method& method, 
         char *execute_method(Value& aself, const String& method_name, bool return_cstr);                  bool return_cstr=true);
           const String *execute_method(Value& aself, const String& method_name, 
                   bool return_cstr=true);
   
         Value *get_element();          Value *get_element();
   
Line 130  private: // lang&raw Line 182  private: // lang&raw
                   
         String::Untaint_lang flang;          String::Untaint_lang flang;
   
   private: // defaults
   
           const String::Untaint_lang fdefault_lang;
           Value *fdefault_content_type;
   
 private: // lang manipulation  private: // lang manipulation
   
         String::Untaint_lang set_lang(String::Untaint_lang alang) {          String::Untaint_lang set_lang(String::Untaint_lang alang) {
Line 141  private: // lang manipulation Line 198  private: // lang manipulation
                 flang=alang;                  flang=alang;
         }          }
   
 private: // web  private:
   
         const char *document_root;  
         const char *page_filespec;  
   
           void output_result(const String& body_string, bool header_only);
 };  };
   
   ///     Auto-object used for temporary changing Request::flang.
 class Temp_lang {  class Temp_lang {
         Request& frequest;          Request& frequest;
         String::Untaint_lang saved_lang;          String::Untaint_lang saved_lang;

Removed from v.1.47  
changed lines
  Added in v.1.65


E-mail: