|
|
| version 1.16, 2001/03/19 17:42:16 | version 1.39, 2001/04/03 07:20:53 |
|---|---|
| Line 9 | Line 9 |
| */ | */ |
| #include "pa_globals.h" | #include "pa_globals.h" |
| #include "pa_string.h" | |
| #include "pa_hash.h" | |
| #include "pa_table.h" | |
| #include "_string.h" | #include "_string.h" |
| #include "_double.h" | #include "_double.h" |
| #include "_int.h" | #include "_int.h" |
| #include "_table.h" | #include "_table.h" |
| #include "_form.h" | #include "_form.h" |
| #include "_env.h" | |
| #include "_request.h" | |
| #include "_response.h" | #include "_response.h" |
| #include "_cookie.h" | #include "_file.h" |
| #include "_random.h" | |
| Service_funcs service_funcs; | |
| String *html_typo_name; | |
| String *content_type_name; | String *content_type_name; |
| String *body_name; | String *body_name; |
| String *value_name; | String *value_name; |
| String *expires_name; | String *expires_name; |
| String *path_name; | String *path_name; |
| String *name_name; | |
| String *size_name; | |
| String *text_name; | |
| String *exception_method_name; | String *exception_method_name; |
| String *post_process_method_name; | |
| String *content_disposition_name; | |
| String *content_disposition_filename_name; | |
| String *unnamed_name; | String *unnamed_name; |
| String *empty_string; | String *empty_string; |
| Line 39 String *root_class_name; | Line 47 String *root_class_name; |
| String *main_class_name; | String *main_class_name; |
| String *env_class_name; | String *env_class_name; |
| String *table_class_name; | String *table_class_name; |
| String *file_class_name; | |
| String *form_class_name; | String *form_class_name; |
| String *request_class_name; | String *request_class_name; |
| String *response_class_name; | String *response_class_name; |
| String *cookie_class_name; | String *cookie_class_name; |
| String *random_class_name; | |
| String *result_var_name; | String *result_var_name; |
| Line 50 String *limits_name; | Line 60 String *limits_name; |
| String *post_max_size_name; | String *post_max_size_name; |
| String *defaults_name; | String *defaults_name; |
| String *mime_types_name; | |
| String *vfile_mime_type_name; | |
| Hash *untaint_lang_name2enum; | Hash *untaint_lang_name2enum; |
| Table *default_typo_table; | |
| short hex_value[0x100]; | short hex_value[0x100]; |
| static void setup_hex_value() { | static void setup_hex_value() { |
| Line 84 static void setup_hex_value() { | Line 98 static void setup_hex_value() { |
| hex_value['f'] = 15; | hex_value['f'] = 15; |
| } | } |
| void globals_init(Pool& pool) { | void pa_globals_init(Pool& pool) { |
| #undef NEW | |
| #define NEW new(pool) | |
| // hex value | // hex value |
| setup_hex_value(); | setup_hex_value(); |
| // names | // names |
| content_type_name=new(pool) String(pool, CONTENT_TYPE_NAME); | html_typo_name=NEW String(pool, HTML_TYPO_NAME); |
| body_name=new(pool) String(pool, BODY_NAME); | content_type_name=NEW String(pool, CONTENT_TYPE_NAME); |
| value_name=new(pool) String(pool, VALUE_NAME); | body_name=NEW String(pool, BODY_NAME); |
| expires_name=new(pool) String(pool, EXPIRES_NAME); | value_name=NEW String(pool, VALUE_NAME); |
| path_name=new(pool) String(pool, PATH_NAME); | expires_name=NEW String(pool, EXPIRES_NAME); |
| path_name=NEW String(pool, PATH_NAME); | |
| exception_method_name=new(pool) String(pool, EXCEPTION_METHOD_NAME); | name_name=NEW String(pool, NAME_NAME); |
| size_name=NEW String(pool, SIZE_NAME); | |
| unnamed_name=new(pool) String(pool, UNNAMED_NAME); | text_name=NEW String(pool, TEXT_NAME); |
| empty_string=new(pool) String(pool); | |
| exception_method_name=NEW String(pool, EXCEPTION_METHOD_NAME); | |
| auto_method_name=new(pool) String(pool, AUTO_METHOD_NAME); | post_process_method_name=NEW String(pool, POST_PROCESS_METHOD_NAME); |
| main_method_name=new(pool) String(pool, MAIN_METHOD_NAME); | |
| content_disposition_name=NEW String(pool, CONTENT_DISPOSITION_NAME); | |
| root_class_name=new(pool) String(pool, ROOT_CLASS_NAME); | content_disposition_filename_name=NEW String(pool, CONTENT_DISPOSITION_FILENAME_NAME); |
| main_class_name=new(pool) String(pool, MAIN_CLASS_NAME); | |
| table_class_name=new(pool) String(pool, TABLE_CLASS_NAME); | unnamed_name=NEW String(pool, UNNAMED_NAME); |
| env_class_name=new(pool) String(pool, ENV_CLASS_NAME); | empty_string=NEW String(pool); |
| form_class_name=new(pool) String(pool, FORM_CLASS_NAME); | |
| request_class_name=new(pool) String(pool, REQUEST_CLASS_NAME); | auto_method_name=NEW String(pool, AUTO_METHOD_NAME); |
| response_class_name=new(pool) String(pool, RESPONSE_CLASS_NAME); | main_method_name=NEW String(pool, MAIN_METHOD_NAME); |
| cookie_class_name=new(pool) String(pool, COOKIE_CLASS_NAME); | |
| root_class_name=NEW String(pool, ROOT_CLASS_NAME); | |
| result_var_name=new(pool) String(pool, RESULT_VAR_NAME); | main_class_name=NEW String(pool, MAIN_CLASS_NAME); |
| table_class_name=NEW String(pool, TABLE_CLASS_NAME); | |
| file_class_name=NEW String(pool, FILE_CLASS_NAME); | |
| limits_name=new(pool) String(pool, LIMITS_NAME); | env_class_name=NEW String(pool, ENV_CLASS_NAME); |
| post_max_size_name=new(pool) String(pool, POST_MAX_SIZE_NAME); | form_class_name=NEW String(pool, FORM_CLASS_NAME); |
| request_class_name=NEW String(pool, REQUEST_CLASS_NAME); | |
| defaults_name=new(pool) String(pool, DEFAULTS_NAME); | response_class_name=NEW String(pool, RESPONSE_CLASS_NAME); |
| cookie_class_name=NEW String(pool, COOKIE_CLASS_NAME); | |
| random_class_name=NEW String(pool, RANDOM_CLASS_NAME); | |
| result_var_name=NEW String(pool, RESULT_VAR_NAME); | |
| limits_name=NEW String(pool, LIMITS_NAME); | |
| post_max_size_name=NEW String(pool, POST_MAX_SIZE_NAME); | |
| defaults_name=NEW String(pool, DEFAULTS_NAME); | |
| mime_types_name=NEW String(pool, MIME_TYPES_NAME); | |
| vfile_mime_type_name=NEW String(pool, VFILE_MIME_TYPE_NAME); | |
| // hashes | // hashes |
| untaint_lang_name2enum=new(pool) Hash(pool); | untaint_lang_name2enum=NEW Hash(pool); |
| String as_is(pool, "as-is"); | String as_is(pool, "as-is"); |
| untaint_lang_name2enum->put(as_is, (int)String::Untaint_lang::AS_IS); | untaint_lang_name2enum->put(as_is, (int)String::UL_AS_IS); |
| String file_name(pool, "file-name"); | |
| untaint_lang_name2enum->put(file_name, (int)String::UL_FILE_NAME); | |
| String header(pool, "header"); | String header(pool, "header"); |
| untaint_lang_name2enum->put(header, (int)String::Untaint_lang::HEADER); | untaint_lang_name2enum->put(header, (int)String::UL_HEADER); |
| String uri(pool, "uri"); | String uri(pool, "uri"); |
| untaint_lang_name2enum->put(uri, (int)String::Untaint_lang::URI); | untaint_lang_name2enum->put(uri, (int)String::UL_URI); |
| String table(pool, "table"); | String table(pool, "table"); |
| untaint_lang_name2enum->put(table, (int)String::Untaint_lang::TABLE); | untaint_lang_name2enum->put(table, (int)String::UL_TABLE); |
| String sql(pool, "sql"); | String sql(pool, "sql"); |
| untaint_lang_name2enum->put(sql, (int)String::Untaint_lang::SQL); | untaint_lang_name2enum->put(sql, (int)String::UL_SQL); |
| String js(pool, "js"); | String js(pool, "js"); |
| untaint_lang_name2enum->put(js, (int)String::Untaint_lang::JS); | untaint_lang_name2enum->put(js, (int)String::UL_JS); |
| String html(pool, "html"); | String html(pool, "html"); |
| untaint_lang_name2enum->put(html, (int)String::Untaint_lang::HTML); | untaint_lang_name2enum->put(html, (int)String::UL_HTML); |
| String html_typo(pool, "html-typo"); | String html_typo(pool, "html-typo"); |
| untaint_lang_name2enum->put(html_typo, (int)String::Untaint_lang::HTML_TYPO); | untaint_lang_name2enum->put(html_typo, (int)String::UL_HTML_TYPO); |
| // tables | |
| default_typo_table=NEW Table(pool, 0, 0); | |
| { | |
| // < -> < | |
| { | |
| Array *row=NEW Array(pool); | |
| *row+=NEW String(pool, "<"); | |
| *row+=NEW String(pool, "<"); | |
| *default_typo_table+=row; | |
| } | |
| // > -> > | |
| { | |
| Array *row=NEW Array(pool); | |
| *row+=NEW String(pool, ">"); | |
| *row+=NEW String(pool, ">"); | |
| *default_typo_table+=row; | |
| } | |
| // " -> " | |
| { | |
| Array *row=NEW Array(pool); | |
| *row+=NEW String(pool, "\""); | |
| *row+=NEW String(pool, """); | |
| *default_typo_table+=row; | |
| } | |
| // & -> & | |
| { | |
| Array *row=NEW Array(pool); | |
| *row+=NEW String(pool, "&"); | |
| *row+=NEW String(pool, "&"); | |
| *default_typo_table+=row; | |
| } | |
| // \n\n -> <p> | |
| { | |
| Array *row=NEW Array(pool); | |
| *row+=NEW String(pool, "\\n\\n"); | |
| *row+=NEW String(pool, "<p>"); | |
| *default_typo_table+=row; | |
| } | |
| // \n -> <br> | |
| { | |
| Array *row=NEW Array(pool); | |
| *row+=NEW String(pool, "\\n"); | |
| *row+=NEW String(pool, "<br>"); | |
| *default_typo_table+=row; | |
| } | |
| } | |
| // stateless classes | |
| initialize_string_class(pool, *(string_class=NEW VStateless_class(pool))); | |
| initialize_double_class(pool, *(double_class=NEW VStateless_class(pool))); | |
| initialize_int_class(pool, *(int_class=NEW VStateless_class(pool))); | |
| initialize_table_class(pool, *(table_class=NEW VStateless_class(pool))); | |
| initialize_file_class(pool, *(file_class=NEW VStateless_class(pool))); | |
| initialize_response_class(pool, *(response_class=NEW VStateless_class(pool))); | |
| initialize_random_class(pool, *(random_class=NEW VStateless_class(pool))); | |
| // read-only stateless classes | // stateless base classes |
| initialize_string_class(pool, *(string_class=new(pool) VStateless_class(pool))); string_class->freeze(); | initialize_form_base_class(pool, *(form_base_class=NEW VStateless_class(pool))); form_base_class->set_name(*form_class_name); |
| initialize_double_class(pool, *(double_class=new(pool) VStateless_class(pool))); double_class->freeze(); | |
| initialize_int_class(pool, *(int_class=new(pool) VStateless_class(pool))); int_class->freeze(); | |
| initialize_table_class(pool, *(table_class=new(pool) VStateless_class(pool))); table_class->freeze(); | |
| // read-only stateless base classes | |
| initialize_env_base_class(pool, *(env_base_class=new(pool) VStateless_class(pool))); env_base_class->set_name(*env_class_name); env_base_class->freeze(); | |
| initialize_form_base_class(pool, *(form_base_class=new(pool) VStateless_class(pool))); form_base_class->set_name(*form_class_name); form_base_class->freeze(); | |
| initialize_request_base_class(pool, *(request_base_class=new(pool) VStateless_class(pool))); request_base_class->set_name(*request_class_name); request_base_class->freeze(); | |
| initialize_response_base_class(pool, *(response_base_class=new(pool) VStateless_class(pool))); response_base_class->set_name(*response_class_name); response_base_class->freeze(); | |
| initialize_cookie_base_class(pool, *(cookie_base_class=new(pool) VStateless_class(pool))); cookie_base_class->set_name(*cookie_class_name); cookie_base_class->freeze(); | |
| } | } |