|
|
| version 1.54, 2001/04/11 13:03:44 | version 1.80, 2001/10/01 08:53:58 |
|---|---|
| Line 2 | Line 2 |
| Parser: globals. | Parser: globals. |
| 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$ |
| */ | */ |
| #include "pcre.h" | |
| #include "pa_globals.h" | #include "pa_globals.h" |
| #include "pa_string.h" | #include "pa_string.h" |
| #include "pa_hash.h" | #include "pa_hash.h" |
| #include "pa_table.h" | |
| #include "_string.h" | |
| #include "_double.h" | |
| #include "_int.h" | |
| #include "_table.h" | |
| #include "_form.h" | |
| #include "_response.h" | |
| #include "_file.h" | |
| #include "_random.h" | |
| #include "pa_sql_driver_manager.h" | #include "pa_sql_driver_manager.h" |
| #include "_mail.h" | #include "pa_dictionary.h" |
| #include "_image.h" | #include "pa_xslt_stylesheet_manager.h" |
| #include "pa_charset_manager.h" | |
| #ifdef XML | |
| #include <util/PlatformUtils.hpp> | |
| #include <XalanTransformer/XalanTransformer.hpp> | |
| #endif | |
| String *html_typo_name; | String *user_html_name; |
| String *content_type_name; | String *content_type_name; |
| String *charset_name; | |
| String *body_name; | String *body_name; |
| String *value_name; | String *value_name; |
| String *expires_name; | String *expires_name; |
| Line 48 String *empty_string; | Line 43 String *empty_string; |
| String *auto_method_name; | String *auto_method_name; |
| String *main_method_name; | String *main_method_name; |
| String *op_class_name; | |
| String *main_class_name; | String *main_class_name; |
| String *string_class_name; | |
| String *double_class_name; | |
| String *int_class_name; | |
| String *env_class_name; | |
| String *table_class_name; | |
| String *file_class_name; | |
| String *form_class_name; | |
| String *request_class_name; | |
| String *response_class_name; | |
| String *cookie_class_name; | |
| String *random_class_name; | |
| String *mail_class_name; | |
| String *image_class_name; | |
| String *result_var_name; | String *result_var_name; |
| String *match_var_name; | |
| String *string_pre_match_name; | String *string_pre_match_name; |
| String *string_match_name; | String *string_match_name; |
| String *string_post_match_name; | String *string_post_match_name; |
| String *limits_name; | |
| String *post_max_size_name; | |
| String *defaults_name; | String *defaults_name; |
| String *locale_name; | String *charsets_name; |
| String *locale_ctype_name; | |
| String *mime_types_name; | String *mime_types_name; |
| String *vfile_mime_type_name; | String *vfile_mime_type_name; |
| String *mail_name; | String *origins_mode_name; |
| String *main_sql_name; | String *class_path_name; |
| String *main_sql_drivers_name; | |
| Hash *untaint_lang_name2enum; | String *switch_data_name; |
| String *case_default_value; | |
| String *sql_limit_name; | |
| String *sql_offset_name; | |
| String *sql_default_name; | |
| Table *default_typo_table; | String *hash_default_element_name; |
| const unsigned char *pcre_tables; | Hash *untaint_lang_name2enum; |
| Dictionary *default_typo_dict; | |
| short hex_value[0x100]; | short hex_value[0x100]; |
| static void setup_hex_value() { | static void setup_hex_value() { |
| int i; | memset(hex_value, 0, sizeof(hex_value)); |
| for (i=0; (i < 0x100); i++) { | |
| hex_value[i] = 0; | |
| } | |
| hex_value['0'] = 0; | hex_value['0'] = 0; |
| hex_value['1'] = 1; | hex_value['1'] = 1; |
| hex_value['2'] = 2; | hex_value['2'] = 2; |
| Line 127 void pa_globals_init(Pool& pool) { | Line 108 void pa_globals_init(Pool& pool) { |
| setup_hex_value(); | setup_hex_value(); |
| // names | // names |
| html_typo_name=NEW String(pool, HTML_TYPO_NAME); | user_html_name=NEW String(pool, USER_HTML_NAME); |
| content_type_name=NEW String(pool, CONTENT_TYPE_NAME); | content_type_name=NEW String(pool, CONTENT_TYPE_NAME); |
| charset_name=NEW String(pool, CHARSET_NAME); | |
| body_name=NEW String(pool, BODY_NAME); | body_name=NEW String(pool, BODY_NAME); |
| value_name=NEW String(pool, VALUE_NAME); | value_name=NEW String(pool, VALUE_NAME); |
| expires_name=NEW String(pool, EXPIRES_NAME); | expires_name=NEW String(pool, EXPIRES_NAME); |
| Line 149 void pa_globals_init(Pool& pool) { | Line 131 void pa_globals_init(Pool& pool) { |
| auto_method_name=NEW String(pool, AUTO_METHOD_NAME); | auto_method_name=NEW String(pool, AUTO_METHOD_NAME); |
| main_method_name=NEW String(pool, MAIN_METHOD_NAME); | main_method_name=NEW String(pool, MAIN_METHOD_NAME); |
| op_class_name=NEW String(pool, OP_CLASS_NAME); | |
| main_class_name=NEW String(pool, MAIN_CLASS_NAME); | main_class_name=NEW String(pool, MAIN_CLASS_NAME); |
| string_class_name=NEW String(pool, STRING_CLASS_NAME); | |
| double_class_name=NEW String(pool, DOUBLE_CLASS_NAME); | |
| int_class_name=NEW String(pool, INT_CLASS_NAME); | |
| table_class_name=NEW String(pool, TABLE_CLASS_NAME); | |
| file_class_name=NEW String(pool, FILE_CLASS_NAME); | |
| env_class_name=NEW String(pool, ENV_CLASS_NAME); | |
| form_class_name=NEW String(pool, FORM_CLASS_NAME); | |
| request_class_name=NEW String(pool, REQUEST_CLASS_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); | |
| mail_class_name=NEW String(pool, MAIL_CLASS_NAME); | |
| image_class_name=NEW String(pool, IMAGE_CLASS_NAME); | |
| result_var_name=NEW String(pool, RESULT_VAR_NAME); | result_var_name=NEW String(pool, RESULT_VAR_NAME); |
| match_var_name=NEW String(pool, MATCH_VAR_NAME); | |
| string_pre_match_name=NEW String(pool, STRING_PRE_MATCH_NAME); | string_pre_match_name=NEW String(pool, STRING_PRE_MATCH_NAME); |
| string_match_name=NEW String(pool, STRING_MATCH_NAME); | string_match_name=NEW String(pool, STRING_MATCH_NAME); |
| string_post_match_name=NEW String(pool, STRING_POST_MATCH_NAME); | string_post_match_name=NEW String(pool, STRING_POST_MATCH_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); | defaults_name=NEW String(pool, DEFAULTS_NAME); |
| locale_name=NEW String(pool, LOCALE_NAME); | charsets_name=NEW String(pool, CHARSETS_NAME); |
| locale_ctype_name=NEW String(pool, LOCALE_CTYPE_NAME); | |
| mime_types_name=NEW String(pool, MIME_TYPES_NAME); | mime_types_name=NEW String(pool, MIME_TYPES_NAME); |
| vfile_mime_type_name=NEW String(pool, VFILE_MIME_TYPE_NAME); | vfile_mime_type_name=NEW String(pool, VFILE_MIME_TYPE_NAME); |
| mail_name=NEW String(pool, MAIL_NAME); | origins_mode_name=NEW String(pool, ORIGINS_MODE_NAME); |
| class_path_name=NEW String(pool, CLASS_PATH_NAME); | |
| //^switch ^case | |
| switch_data_name=NEW String(pool, SWITCH_DATA_NAME); | |
| case_default_value=NEW String(pool, CASE_DEFAULT_VALUE); | |
| // sql | |
| sql_limit_name=NEW String(pool, SQL_LIMIT_NAME); | |
| sql_offset_name=NEW String(pool, SQL_OFFSET_NAME); | |
| sql_default_name=NEW String(pool, SQL_DEFAULT_NAME); | |
| // hash | |
| hash_default_element_name=NEW String(pool, HASH_DEFAULT_ELEMENT_NAME); | |
| main_sql_name=NEW String(pool, MAIN_SQL_NAME); | |
| main_sql_drivers_name=NEW String(pool, MAIN_SQL_DRIVERS_NAME); | |
| // hashes | // hashes |
| untaint_lang_name2enum=NEW 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 http_header(pool, "http-header"); | ULN(file_name, "file-spec", FILE_SPEC); |
| untaint_lang_name2enum->put(http_header, (int)String::UL_HTTP_HEADER); | ULN(http_header, "http-header", HTTP_HEADER); |
| String mail_header(pool, "mail-header"); | ULN(mail_header, "mail-header", MAIL_HEADER); |
| untaint_lang_name2enum->put(mail_header, (int)String::UL_MAIL_HEADER); | ULN(uri, "uri", URI); |
| String uri(pool, "uri"); | ULN(table, "table", TABLE); |
| untaint_lang_name2enum->put(uri, (int)String::UL_URI); | ULN(sql, "sql", SQL); |
| String table(pool, "table"); | ULN(js, "js", JS); |
| untaint_lang_name2enum->put(table, (int)String::UL_TABLE); | ULN(xml, "xml", XML); |
| String sql(pool, "sql"); | ULN(html, "html", HTML); |
| untaint_lang_name2enum->put(sql, (int)String::UL_SQL); | ULN(user_html, "user-html", USER_HTML); |
| String js(pool, "js"); | |
| untaint_lang_name2enum->put(js, (int)String::UL_JS); | |
| String html(pool, "html"); | |
| untaint_lang_name2enum->put(html, (int)String::UL_HTML); | |
| String html_typo(pool, "html-typo"); | |
| untaint_lang_name2enum->put(html_typo, (int)String::UL_HTML_TYPO); | |
| // tables | // tables |
| default_typo_table=NEW Table(pool, 0, 0); | Table *default_typo_table=NEW Table(pool, 0, 0); |
| { | #define DT_ROW(from, to) { \ |
| // < -> < | Array *row=NEW Array(pool); \ |
| { | *row+=NEW String(pool, from); \ |
| Array *row=NEW Array(pool); | *row+=NEW String(pool, to); \ |
| *row+=NEW String(pool, "<"); | *default_typo_table+=row; \ |
| *row+=NEW String(pool, "<"); | } |
| *default_typo_table+=row; | DT_ROW("<", "<"); |
| } | DT_ROW(">", ">"); |
| // > -> > | DT_ROW("\"", """); |
| { | DT_ROW("&", "&"); |
| Array *row=NEW Array(pool); | DT_ROW("\\n\\n", "<p>"); |
| *row+=NEW String(pool, ">"); | DT_ROW("\\n", "<br>"); |
| *row+=NEW String(pool, ">"); | default_typo_dict=NEW Dictionary(*default_typo_table); |
| *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; | |
| } | |
| } | |
| // pcre tables | // SQL driver manager |
| pcre_tables=pcre_maketables(); | SQL_driver_manager=NEW SQL_Driver_manager(pool); |
| // stateless classes | #ifdef XML |
| initialize_string_class(pool, *(string_class=NEW VStateless_class(pool))); string_class->set_name(*string_class_name); | // Xerces & Xalan |
| initialize_double_class(pool, *(double_class=NEW VStateless_class(pool))); double_class->set_name(*double_class_name); | |
| initialize_int_class(pool, *(int_class=NEW VStateless_class(pool))); int_class->set_name(*int_class_name); | |
| initialize_table_class(pool, *(table_class=NEW VStateless_class(pool))); table_class->set_name(*table_class_name); | |
| initialize_file_class(pool, *(file_class=NEW VStateless_class(pool))); file_class->set_name(*file_class_name); | |
| initialize_response_class(pool, *(response_class=NEW VStateless_class(pool))); response_class->set_name(*response_class_name); | |
| initialize_random_class(pool, *(random_class=NEW VStateless_class(pool))); random_class->set_name(*random_class_name); | |
| initialize_mail_class(pool, *(mail_class=NEW VStateless_class(pool))); mail_class->set_name(*mail_class_name); | |
| initialize_image_class(pool, *(image_class=NEW VStateless_class(pool))); image_class->set_name(*image_class_name); | |
| // stateless base classes | // Use the static initializers to initialize the Xalan-C++ and Xerces-C++ platforms. |
| initialize_form_base_class(pool, *(form_base_class=NEW VStateless_class(pool))); form_base_class->set_name(*form_class_name); | // You must initialize Xerces-C++ once per process |
| XMLPlatformUtils::Initialize(); | |
| XalanTransformer::initialize(); | |
| // XSLT stylesheet driver manager | |
| XSLT_stylesheet_manager=NEW XSLT_Stylesheet_manager(pool); | |
| #endif | |
| // SQL_Driver_manager | // Charset manager |
| SQL_driver_manager=NEW SQL_Driver_manager(pool); | charset_manager=NEW Charset_manager(pool); |
| } | } |
| #if defined(XML) && defined(_MSC_VER) | |
| # define XERCES_BUILD_WIN32_BUILD "/parser3project/win32xml/xml-xerces/c/Build/Win32/VC6" | |
| # define XALAN_BUILD_WIN32_BUILD "/parser3project/win32xml/xml-xalan/c/Build/Win32/VC6" | |
| # ifdef _DEBUG | |
| # pragma comment(lib, XERCES_BUILD_WIN32_BUILD "/Debug/xerces-c_1D.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Debug/XSLTD.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Debug/XPathD.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Debug/XalanTransformerD.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Debug/XalanDOMD.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Debug/DOMSupportD.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Debug/PlatformSupportD.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Debug/XMLSupportD.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Debug/XercesParserLiaisonD.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Debug/XalanSourceTreeD.lib") | |
| # else | |
| # pragma comment(lib, XERCES_BUILD_WIN32_BUILD "/Release/xerces-c_1.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Release/XalanSourceTree.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Release/PlatformSupport.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Release/XalanDOM.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Release/DOMSupport.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Release/XalanTransformer.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Release/XercesParserLiaison.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Release/XMLSupport.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Release/XPath.lib") | |
| # pragma comment(lib, XALAN_BUILD_WIN32_BUILD "/Release/XSLT.lib") | |
| # endif | |
| #endif |