|
|
| version 1.152.2.2, 2003/01/23 17:05:34 | version 1.152.2.13, 2003/02/04 12:08:57 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: globals. | Parser: globals. |
| Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| */ | */ |
| Line 19 extern "C" { | Line 19 extern "C" { |
| #include "pa_globals.h" | #include "pa_globals.h" |
| #include "pa_string.h" | #include "pa_string.h" |
| #include "pa_hash.h" | |
| #include "pa_sql_driver_manager.h" | |
| #include "pa_dictionary.h" | |
| #include "pa_stylesheet_manager.h" | |
| #include "pa_sapi.h" | #include "pa_sapi.h" |
| #include "pa_cache_managers.h" | |
| #include "pa_charsets.h" | |
| #include "pa_charset.h" | |
| #include "pa_threads.h" | #include "pa_threads.h" |
| #define AUTO_FILE_NAME "auto.p" | #ifdef XML |
| #include "pa_stylesheet_manager.h" | |
| #endif | |
| #define CONTENT_TYPE_NAME "content-type" | |
| #define CHARSET_NAME "charset" | |
| #define BODY_NAME "body" | |
| #define DOWNLOAD_NAME "download" | |
| #define VALUE_NAME "value" | |
| #define EXPIRES_NAME "expires" | |
| #define PATH_NAME "path" | |
| #define NAME_NAME "name" | |
| #define NONAME_DAT "noname.dat" | |
| #define SIZE_NAME "size" | |
| #define TEXT_NAME "text" | |
| #define CONF_METHOD_NAME "conf" | |
| #define AUTO_METHOD_NAME "auto" | |
| #define MAIN_CLASS_NAME "MAIN" | |
| #define DEFAULTS_NAME "DEFAULTS" | #define DEFAULTS_NAME "DEFAULTS" |
| #define CHARSETS_NAME "CHARSETS" | |
| #define MIME_TYPES_NAME "MIME-TYPES" | |
| #define ORIGINS_MODE_NAME "ORIGINS" | |
| #define RESULT_VAR_NAME "result" | |
| #define MATCH_VAR_NAME "match" | #define MATCH_VAR_NAME "match" |
| #define EXCEPTION_VAR_NAME "exception" | #define EXCEPTION_VAR_NAME "exception" |
| Line 66 extern "C" { | Line 43 extern "C" { |
| #define DATE_CALENDAR_WEEKNO_NAME "week" | #define DATE_CALENDAR_WEEKNO_NAME "week" |
| #define DATE_CALENDAR_WEEKYEAR_NAME "year" | #define DATE_CALENDAR_WEEKYEAR_NAME "year" |
| #define CONTENT_DISPOSITION_NAME "content-disposition" | |
| #define CONTENT_DISPOSITION_VALUE "attachment" | |
| #define CONTENT_DISPOSITION_FILENAME_NAME "filename" | |
| #define SWITCH_DATA_NAME "SWITCH-DATA" | #define SWITCH_DATA_NAME "SWITCH-DATA" |
| #define CACHE_DATA_NAME "CACHE-DATA" | #define CACHE_DATA_NAME "CACHE-DATA" |
| #define CLASS_PATH_NAME "CLASS_PATH" | |
| #define SQL_LIMIT_NAME "limit" | #define SQL_LIMIT_NAME "limit" |
| #define SQL_OFFSET_NAME "offset" | #define SQL_OFFSET_NAME "offset" |
| #define SQL_DEFAULT_NAME "default" | #define SQL_DEFAULT_NAME "default" |
| #define SQL_DISTINCT_NAME "distinct" | #define SQL_DISTINCT_NAME "distinct" |
| #define CHARSET_UTF8_NAME "UTF-8" | |
| #define HASH_DEFAULT_ELEMENT_NAME "_default" | #define HASH_DEFAULT_ELEMENT_NAME "_default" |
| #define HTTP_METHOD_NAME "method" | |
| #define HTTP_TIMEOUT_NAME "timeout" | |
| #define HTTP_HEADERS_NAME "headers" | |
| #define HTTP_ANY_STATUS_NAME "any-status" | |
| #define FILE_STATUS_NAME "status" | |
| String content_type_name(CONTENT_TYPE_NAME); | |
| String charset_name(CHARSET_NAME); | |
| String body_name(BODY_NAME); | |
| String download_name(DOWNLOAD_NAME); | |
| String value_name(VALUE_NAME); | |
| String expires_name(EXPIRES_NAME); | |
| String path_name(PATH_NAME); | |
| String name_name(NAME_NAME); | |
| String size_name(SIZE_NAME); | |
| String text_name(TEXT_NAME); | |
| String content_disposition_name(CONTENT_DISPOSITION_NAME); | |
| String content_disposition_value(CONTENT_DISPOSITION_VALUE); | |
| String content_disposition_filename_name(CONTENT_DISPOSITION_FILENAME_NAME); | |
| String conf_method_name(CONF_METHOD_NAME); | |
| String auto_method_name(AUTO_METHOD_NAME); | |
| String main_class_name(MAIN_CLASS_NAME); | |
| String result_var_name(RESULT_VAR_NAME); | |
| String match_var_name(MATCH_VAR_NAME); | |
| String exception_var_name(EXCEPTION_VAR_NAME); | |
| String exception_type_part_name(EXCEPTION_TYPE_PART_NAME); | |
| String exception_source_part_name(EXCEPTION_SOURCE_PART_NAME); | |
| String exception_comment_part_name(EXCEPTION_COMMENT_PART_NAME); | |
| String exception_handled_part_name(EXCEPTION_HANDLED_PART_NAME); | |
| String charsets_name(CHARSETS_NAME); | |
| String mime_types_name(MIME_TYPES_NAME); | |
| String vfile_mime_type_name(VFILE_MIME_TYPE_NAME); | |
| String origins_mode_name(ORIGINS_MODE_NAME); | |
| String class_path_name(CLASS_PATH_NAME); | StringPtr match_var_name(new String(MATCH_VAR_NAME)); |
| StringPtr exception_var_name(new String(EXCEPTION_VAR_NAME)); | |
| StringPtr exception_type_part_name(new String(EXCEPTION_TYPE_PART_NAME)); | |
| StringPtr exception_source_part_name(new String(EXCEPTION_SOURCE_PART_NAME)); | |
| StringPtr exception_comment_part_name(new String(EXCEPTION_COMMENT_PART_NAME)); | |
| StringPtr exception_handled_part_name(new String(EXCEPTION_HANDLED_PART_NAME)); | |
| //^switch ^case | //^switch ^case |
| String switch_data_name(SWITCH_DATA_NAME); | StringPtr switch_data_name(new String(SWITCH_DATA_NAME)); |
| //^cache | //^cache |
| String cache_data_name(CACHE_DATA_NAME); | StringPtr cache_data_name(new String(CACHE_DATA_NAME)); |
| // sql | // sql |
| String sql_limit_name(SQL_LIMIT_NAME); | StringPtr sql_limit_name(new String(SQL_LIMIT_NAME)); |
| String sql_offset_name(SQL_OFFSET_NAME); | StringPtr sql_offset_name(new String(SQL_OFFSET_NAME)); |
| String sql_default_name(SQL_DEFAULT_NAME); | StringPtr sql_default_name(new String(SQL_DEFAULT_NAME)); |
| String sql_distinct_name(SQL_DISTINCT_NAME); | StringPtr sql_distinct_name(new String(SQL_DISTINCT_NAME)); |
| // charsets | |
| String charset_UTF8_name(CHARSET_UTF8_NAME); | |
| // hash | // hash |
| String hash_default_element_name(HASH_DEFAULT_ELEMENT_NAME); | StringPtr hash_default_element_name(new String(HASH_DEFAULT_ELEMENT_NAME)); |
| // http | |
| String http_method_name(HTTP_METHOD_NAME); | |
| String http_timeout_name(HTTP_TIMEOUT_NAME); | |
| String http_headers_name(HTTP_HEADERS_NAME); | |
| String http_any_status_name(HTTP_ANY_STATUS_NAME); | |
| String file_status_name(FILE_STATUS_NAME); | |
| Table date_calendar_table_template; | |
| Charset utf8_charset; | |
| short hex_value[0x100]; | short hex_value[0x100]; |
| Line 208 XML_Generic_error_info *xml_generic_erro | Line 131 XML_Generic_error_info *xml_generic_erro |
| } | } |
| static void | static void |
| xmlParserGenericErrorFunc(void *ctx, const char *msg, ...) { | xmlParserGenericErrorFunc(void *ctx, const char* msg, ...) { |
| pa_thread_t thread_id=pa_get_thread_id(); | pa_thread_t thread_id=pa_get_thread_id(); |
| // infinitely looking for free slot to fill it | // infinitely looking for free slot to fill it |
| Line 248 bool xmlHaveGenericErrors() { | Line 171 bool xmlHaveGenericErrors() { |
| return xml_generic_error_info(thread_id)!=0; | return xml_generic_error_info(thread_id)!=0; |
| } | } |
| const char *xmlGenericErrors() { | const char* xmlGenericErrors() { |
| pa_thread_t thread_id=pa_get_thread_id(); | pa_thread_t thread_id=pa_get_thread_id(); |
| SYNCHRONIZED; // find+free blocked | SYNCHRONIZED; // find+free blocked |
| Line 257 const char *xmlGenericErrors() { | Line 180 const char *xmlGenericErrors() { |
| if(!p) // no errors for our thread_id registered | if(!p) // no errors for our thread_id registered |
| return 0; | return 0; |
| const char *result=p->message; | const char* result=p->message; |
| // free slot up | // free slot up |
| memset(p, 0, sizeof(*p)); | memset(p, 0, sizeof(*p)); |
| Line 275 const char *xmlGenericErrors() { | Line 198 const char *xmlGenericErrors() { |
| * Returns 1 if matches, 0 otherwise | * Returns 1 if matches, 0 otherwise |
| */ | */ |
| static int | static int |
| xmlFileMatchLocalhost(const char *filename) { | xmlFileMatchLocalhost(const char* filename) { |
| if (!strncmp(filename, "http://localhost", 16)) | if (!strncmp(filename, "http://localhost", 16)) |
| return(1); | return(1); |
| return(0); | return(0); |
| Line 294 xmlFileMatchLocalhost(const char *filena | Line 217 xmlFileMatchLocalhost(const char *filena |
| * Returns an I/O context or NULL in case of error | * Returns an I/O context or NULL in case of error |
| */ | */ |
| static void * | static void * |
| xmlFileOpenLocalhost (const char *filename) { | xmlFileOpenLocalhost (const char* filename) { |
| FILE *fd; | FILE *fd; |
| const char* documentRoot; | const char* documentRoot; |
| char path[1000]; | char path[1000]; |
| Line 345 void pa_globals_destroy(void *) { | Line 268 void pa_globals_destroy(void *) { |
| GdomeException exc; | GdomeException exc; |
| gdome_di_unref (domimpl, &exc); | gdome_di_unref (domimpl, &exc); |
| #endif | #endif |
| if(cache_managers) | |
| cache_managers->~Cache_managers(); | |
| charsets->~Charsets(); | |
| } catch(const Exception& e) { | } catch(const Exception& e) { |
| SAPI::die("pa_globals_destroy failed: %s", e.comment()); | SAPI::die("pa_globals_destroy failed: %s", e.comment()); |
| } | } |
| Line 362 void pa_globals_init() { | Line 280 void pa_globals_init() { |
| // hex value | // hex value |
| setup_hex_value(); | setup_hex_value(); |
| // date_calendar_table_template | |
| { | |
| Array *columns=NEW Array(pool); | |
| for(int i=0; i<=6; i++) { | |
| char *column=(char *)pool.malloc(MAX_NUMBER); | |
| snprintf(column, MAX_NUMBER, "%d", i); | |
| *columns+=NEW String(pool, column); // .i column name | |
| } | |
| *columns+=NEW String(pool, DATE_CALENDAR_WEEKNO_NAME); | |
| *columns+=NEW String(pool, DATE_CALENDAR_WEEKYEAR_NAME); | |
| date_calendar_table_template=NEW Table(pool, 0, columns); | |
| } | |
| // charsets | |
| charsets=NEW Charsets(pool); | |
| charsets->put(*charset_UTF8_name, | |
| utf8_charset=NEW Charset(pool, *charset_UTF8_name, 0/*no file=system*/)); | |
| // Status registration, must be initialized before all registrants | |
| cache_managers=NEW Cache_managers(pool); | |
| // SQL driver manager | |
| cache_managers->put(*NEW String(pool, "sql"), | |
| SQL_driver_manager=NEW SQL_Driver_manager(pool)); | |
| #ifdef XML | #ifdef XML |
| // initializing xml libs | // initializing xml libs |