|
|
| version 1.152.2.15, 2003/02/14 16:52:21 | version 1.152.2.19.2.1, 2003/03/18 15:14:19 |
|---|---|
| Line 22 extern "C" { | Line 22 extern "C" { |
| #include "pa_sapi.h" | #include "pa_sapi.h" |
| #include "pa_threads.h" | #include "pa_threads.h" |
| #ifdef XML | |
| #include "pa_stylesheet_manager.h" | |
| #endif | |
| short hex_value[0x100]; | short hex_value[0x100]; |
| #ifdef XML | #ifdef XML |
| Line 62 static void setup_hex_value() { | Line 58 static void setup_hex_value() { |
| const int MAX_CONCURRENT_XML_GENERIC_ERROR_THREADS=10; | const int MAX_CONCURRENT_XML_GENERIC_ERROR_THREADS=10; |
| struct XML_Generic_error_info { | class XML_Generic_error_info { |
| public: | |
| pa_thread_t thread_id; | pa_thread_t thread_id; |
| char *message; | char buf[MAX_STRING]; |
| size_t used; | |
| public: | |
| XML_Generic_error_info() { | |
| reset(); | |
| } | |
| void reset() { | |
| thread_id=0; | |
| buf[used=0]=0; | |
| } | |
| const char* get_and_reset() { | |
| const char* result(new char[used+1]); | |
| memcpy(result.get(), buf, used+1); | |
| reset(); | |
| return result; | |
| } | |
| } xml_generic_error_infos[MAX_CONCURRENT_XML_GENERIC_ERROR_THREADS]; | } xml_generic_error_infos[MAX_CONCURRENT_XML_GENERIC_ERROR_THREADS]; |
| XML_Generic_error_info *xml_generic_error_info(pa_thread_t thread_id) { | XML_Generic_error_info *xml_generic_error_info(pa_thread_t thread_id) { |
| Line 93 xmlParserGenericErrorFunc(void *ctx, con | Line 105 xmlParserGenericErrorFunc(void *ctx, con |
| } | } |
| p->thread_id=thread_id; | p->thread_id=thread_id; |
| size_t offset=p->message?strlen(p->message):0; | |
| p->message=(char *)realloc(p->message, offset+MAX_STRING); | |
| if(!p->message) | |
| SAPI::die( | |
| "out of memory in 'xmlParserGenericErrorFunc', failed to reallocate to %u bytes", | |
| offset+MAX_STRING); | |
| va_list args; | va_list args; |
| va_start(args, msg); | va_start(args, msg); |
| vsnprintf(p->message+offset, MAX_STRING, msg, args); | p->used+=vsnprintf(p->buf+p->used, sizeof(p->buf)-p->used, msg, args); |
| va_end(args); | va_end(args); |
| break; | break; |
| Line 124 const char* xmlGenericErrors() { | Line 130 const char* xmlGenericErrors() { |
| XML_Generic_error_info *p=xml_generic_error_info(thread_id); | XML_Generic_error_info *p=xml_generic_error_info(thread_id); |
| if(!p) // no errors for our thread_id registered | if(!p) // no errors for our thread_id registered |
| return 0; | return CharPtr(0); |
| const char* result=p->message; | |
| // free slot up | return p->get_and_reset(); |
| memset(p, 0, sizeof(*p)); | |
| // it is up to caller to free it | |
| return result; | |
| } | } |
| /** | /** |
| Line 215 void pa_globals_destroy(void *) { | Line 215 void pa_globals_destroy(void *) { |
| gdome_di_unref (domimpl, &exc); | gdome_di_unref (domimpl, &exc); |
| #endif | #endif |
| } catch(const Exception& e) { | } catch(const Exception& e) { |
| SAPI::die("pa_globals_destroy failed: %s", e.comment()); | SAPI::abort("pa_globals_destroy failed: %s", e.comment()); |
| } | } |
| } | } |
| Line 270 void pa_globals_init() { | Line 270 void pa_globals_init() { |
| //regretfully this not only replaces entities on parse, but also on generate xmlSubstituteEntitiesDefault(1); | //regretfully this not only replaces entities on parse, but also on generate xmlSubstituteEntitiesDefault(1); |
| // never switched this on xmlIndentTreeOutput=1; | // never switched this on xmlIndentTreeOutput=1; |
| memset(xml_generic_error_infos, 0, sizeof(xml_generic_error_infos)); | |
| xmlSetGenericErrorFunc(0, xmlParserGenericErrorFunc); | xmlSetGenericErrorFunc(0, xmlParserGenericErrorFunc); |
| xsltSetGenericErrorFunc(0, xmlParserGenericErrorFunc); | xsltSetGenericErrorFunc(0, xmlParserGenericErrorFunc); |
| // FILE *f=fopen("y:\\xslt.log", "wt"); | // FILE *f=fopen("y:\\xslt.log", "wt"); |
| Line 280 void pa_globals_init() { | Line 279 void pa_globals_init() { |
| xmlRegisterInputCallbacks( | xmlRegisterInputCallbacks( |
| xmlFileMatchLocalhost, xmlFileOpenLocalhost, | xmlFileMatchLocalhost, xmlFileOpenLocalhost, |
| pa_xmlFileRead, pa_xmlFileClose); | pa_xmlFileRead, pa_xmlFileClose); |
| // XSLT stylesheet manager | |
| cache_managers->put(*NEW String(pool, "stylesheet"), | |
| stylesheet_manager=NEW Stylesheet_manager(pool)); | |
| #endif | #endif |
| } | } |