|
|
| version 1.25, 2001/03/21 14:06:46 | version 1.62, 2001/06/28 07:44:17 |
|---|---|
| Line 4 | Line 4 |
| 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$ | |
| */ | */ |
| static const char *RCSId="$Id$"; | |
| #include "pa_globals.h" | #include "pa_globals.h" |
| #include "_string.h" | #include "pa_string.h" |
| #include "_double.h" | #include "pa_hash.h" |
| #include "_int.h" | #include "pa_sql_driver_manager.h" |
| #include "_table.h" | |
| #include "_form.h" | |
| #include "_response.h" | |
| #include "_file.h" | |
| Service_funcs service_funcs; | |
| String *user_html_name; | |
| String *content_type_name; | String *content_type_name; |
| String *body_name; | String *body_name; |
| String *value_name; | String *value_name; |
| Line 29 String *size_name; | Line 23 String *size_name; |
| String *text_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 36 String *empty_string; | Line 34 String *empty_string; |
| String *auto_method_name; | String *auto_method_name; |
| String *main_method_name; | String *main_method_name; |
| String *root_class_name; | |
| String *main_class_name; | String *main_class_name; |
| String *env_class_name; | |
| String *table_class_name; | |
| String *form_class_name; | |
| String *request_class_name; | |
| String *response_class_name; | |
| String *cookie_class_name; | |
| String *result_var_name; | String *result_var_name; |
| String *string_pre_match_name; | |
| String *limits_name; | String *string_match_name; |
| String *post_max_size_name; | String *string_post_match_name; |
| String *defaults_name; | String *defaults_name; |
| String *ctype_name; | |
| String *ctype_white_space_name; | |
| String *ctype_digit_name; | |
| String *ctype_hex_digit_name; | |
| String *ctype_letter_name; | |
| String *ctype_word_name; | |
| String *ctype_lowercase_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 85 static void setup_hex_value() { | Line 87 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); | user_html_name=NEW String(pool, USER_HTML_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); |
| name_name=new(pool) String(pool, NAME_NAME); | path_name=NEW String(pool, PATH_NAME); |
| size_name=new(pool) String(pool, SIZE_NAME); | name_name=NEW String(pool, NAME_NAME); |
| text_name=new(pool) String(pool, TEXT_NAME); | size_name=NEW String(pool, SIZE_NAME); |
| text_name=NEW String(pool, TEXT_NAME); | |
| exception_method_name=new(pool) String(pool, EXCEPTION_METHOD_NAME); | |
| exception_method_name=NEW String(pool, EXCEPTION_METHOD_NAME); | |
| unnamed_name=new(pool) String(pool, UNNAMED_NAME); | post_process_method_name=NEW String(pool, POST_PROCESS_METHOD_NAME); |
| empty_string=new(pool) String(pool); | |
| content_disposition_name=NEW String(pool, CONTENT_DISPOSITION_NAME); | |
| auto_method_name=new(pool) String(pool, AUTO_METHOD_NAME); | content_disposition_filename_name=NEW String(pool, CONTENT_DISPOSITION_FILENAME_NAME); |
| main_method_name=new(pool) String(pool, MAIN_METHOD_NAME); | |
| unnamed_name=NEW String(pool, UNNAMED_NAME); | |
| root_class_name=new(pool) String(pool, ROOT_CLASS_NAME); | empty_string=NEW String(pool); |
| main_class_name=new(pool) String(pool, MAIN_CLASS_NAME); | |
| table_class_name=new(pool) String(pool, TABLE_CLASS_NAME); | auto_method_name=NEW String(pool, AUTO_METHOD_NAME); |
| env_class_name=new(pool) String(pool, ENV_CLASS_NAME); | main_method_name=NEW String(pool, MAIN_METHOD_NAME); |
| form_class_name=new(pool) String(pool, FORM_CLASS_NAME); | |
| request_class_name=new(pool) String(pool, REQUEST_CLASS_NAME); | main_class_name=NEW String(pool, MAIN_CLASS_NAME); |
| response_class_name=new(pool) String(pool, RESPONSE_CLASS_NAME); | |
| cookie_class_name=new(pool) String(pool, COOKIE_CLASS_NAME); | result_var_name=NEW String(pool, RESULT_VAR_NAME); |
| string_pre_match_name=NEW String(pool, STRING_PRE_MATCH_NAME); | |
| result_var_name=new(pool) String(pool, RESULT_VAR_NAME); | string_match_name=NEW String(pool, STRING_MATCH_NAME); |
| string_post_match_name=NEW String(pool, STRING_POST_MATCH_NAME); | |
| limits_name=new(pool) String(pool, LIMITS_NAME); | |
| post_max_size_name=new(pool) String(pool, POST_MAX_SIZE_NAME); | defaults_name=NEW String(pool, DEFAULTS_NAME); |
| ctype_name=NEW String(pool, CTYPE_NAME); | |
| defaults_name=new(pool) String(pool, DEFAULTS_NAME); | ctype_white_space_name=NEW String(pool, CTYPE_WHITE_SPACE_NAME); |
| ctype_digit_name=NEW String(pool, CTYPE_DIGIT_NAME); | |
| ctype_hex_digit_name=NEW String(pool, CTYPE_HEX_DIGIT_NAME); | |
| ctype_letter_name=NEW String(pool, CTYPE_LETTER_NAME); | |
| ctype_word_name=NEW String(pool, CTYPE_WORD_NAME); | |
| ctype_lowercase_name=NEW String(pool, CTYPE_LOWERCASE_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"); | #define ULN(var, cstr, LANG) \ |
| untaint_lang_name2enum->put(as_is, (int)String::UL_AS_IS); | String var(pool, cstr); \ |
| String file_name(pool, "file-name"); | untaint_lang_name2enum->put(var, (int)String::UL_##LANG); |
| untaint_lang_name2enum->put(file_name, (int)String::UL_FILE_NAME); | ULN(as_is, "as-is", AS_IS); |
| String header(pool, "header"); | ULN(file_name, "file-name", FILE_NAME); |
| untaint_lang_name2enum->put(header, (int)String::UL_HEADER); | ULN(http_header, "http-header", HTTP_HEADER); |
| String uri(pool, "uri"); | ULN(mail_header, "mail-header", MAIL_HEADER); |
| untaint_lang_name2enum->put(uri, (int)String::UL_URI); | ULN(uri, "uri", URI); |
| String table(pool, "table"); | ULN(table, "table", TABLE); |
| untaint_lang_name2enum->put(table, (int)String::UL_TABLE); | ULN(sql, "sql", SQL); |
| String sql(pool, "sql"); | ULN(js, "js", JS); |
| untaint_lang_name2enum->put(sql, (int)String::UL_SQL); | ULN(html, "html", HTML); |
| String js(pool, "js"); | ULN(user_html, "user-html", USER_HTML); |
| untaint_lang_name2enum->put(js, (int)String::UL_JS); | |
| String html(pool, "html"); | // tables |
| untaint_lang_name2enum->put(html, (int)String::UL_HTML); | default_typo_table=NEW Table(pool, 0, 0); |
| String html_typo(pool, "html-typo"); | #define DT_ROW(from, to) { \ |
| untaint_lang_name2enum->put(html_typo, (int)String::UL_HTML_TYPO); | Array *row=NEW Array(pool); \ |
| *row+=NEW String(pool, from); \ | |
| // read-only stateless classes | *row+=NEW String(pool, to); \ |
| initialize_string_class(pool, *(string_class=new(pool) VStateless_class(pool))); string_class->freeze(); | *default_typo_table+=row; \ |
| 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(); | DT_ROW("<", "<"); |
| initialize_table_class(pool, *(table_class=new(pool) VStateless_class(pool))); table_class->freeze(); | DT_ROW(">", ">"); |
| initialize_file_class(pool, *(file_class=new(pool) VStateless_class(pool))); file_class->freeze(); | DT_ROW("\"", """); |
| initialize_response_class(pool, *(response_class=new(pool) VStateless_class(pool))); response_class->freeze(); | DT_ROW("&", "&"); |
| DT_ROW("\\n\\n", "<p>"); | |
| DT_ROW("\\n", "<br>"); | |
| // read-only stateless base classes | // SQL_Driver_manager |
| 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(); | SQL_driver_manager=NEW SQL_Driver_manager(pool); |
| } | } |