|
|
| version 1.19, 2005/08/09 08:14:53 | version 1.27, 2010/11/24 00:44:09 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: plugins to xml library, controlling i/o; implementation | Parser: plugins to xml library, controlling i/o; implementation |
| Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2009 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 17 static const char * const IDENT="$Date$" | Line 17 static const char * const IDENT="$Date$" |
| #include "pa_globals.h" | #include "pa_globals.h" |
| #include "pa_request.h" | #include "pa_request.h" |
| static Hash<pa_thread_t, HashStringBool*> xml_dependencies; | THREAD_LOCAL HashStringBool* xml_dependencies = NULL; |
| static void add_dependency(const String::Body url) { | static void add_dependency(const String::Body url) { |
| pa_thread_t thread_id=pa_get_thread_id(); | if(xml_dependencies) // do we need to monitor now? |
| HashStringBool* urls; | xml_dependencies->put(url, true); |
| { | |
| SYNCHRONIZED; | |
| // try to get existing for this thread_id | |
| urls=xml_dependencies.get(thread_id); | |
| } | |
| if(urls) // do we need to monitor now? | |
| urls->put(url, true); | |
| } | } |
| void pa_xmlStartMonitoringDependencies() { | void pa_xmlStartMonitoringDependencies() { |
| pa_thread_t thread_id=pa_get_thread_id(); | xml_dependencies=new HashStringBool; |
| HashStringBool* urls=new HashStringBool; | |
| { | |
| SYNCHRONIZED; // find+fill blocked | |
| xml_dependencies.put(thread_id, urls); | |
| } | |
| } | } |
| void pa_xmlStopMonitoringDependencies() { | void pa_xmlStopMonitoringDependencies() { |
| pa_thread_t thread_id=pa_get_thread_id(); | xml_dependencies=NULL; |
| { | |
| SYNCHRONIZED; // find+fill blocked | |
| xml_dependencies.put(thread_id, 0); | |
| } | |
| } | } |
| HashStringBool* pa_xmlGetDependencies() { | HashStringBool* pa_xmlGetDependencies() { |
| pa_thread_t thread_id=pa_get_thread_id(); | HashStringBool* result=xml_dependencies; |
| { | xml_dependencies=NULL; |
| SYNCHRONIZED; // find+remove blocked | return result; |
| HashStringBool* result=xml_dependencies.get(thread_id); | |
| xml_dependencies.remove(thread_id); | |
| return result; | |
| } | |
| } | } |
| #ifndef DOXYGEN | #ifndef DOXYGEN |
| Line 105 xmlFileOpen_ReadIntoStream (const char* | Line 80 xmlFileOpen_ReadIntoStream (const char* |
| strcat(adjust_buf, &do_not_store_filename[16]); | strcat(adjust_buf, &do_not_store_filename[16]); |
| do_not_store_filename=adjust_buf; | do_not_store_filename=adjust_buf; |
| } else | } else |
| if(strstr(do_not_store_filename, "file://")) | if(!strstr(do_not_store_filename, "http://")) |
| do_not_store_filename+=7/*strlen("file://")*/; | if(strstr(do_not_store_filename, "file://")){ |
| else if(*do_not_store_filename && do_not_store_filename[1]!=':' && strstr(do_not_store_filename, "://")) { | do_not_store_filename+=7/*strlen("file://")*/; |
| pa_xmlStopMonitoringDependencies(); | #ifdef WIN32 |
| return 0; // plug out [do not handle other prefixes] | if( |
| } | do_not_store_filename[0]=='/' |
| && do_not_store_filename[1] | |
| && do_not_store_filename[2]==':' | |
| && do_not_store_filename[3]=='/' | |
| ){ | |
| // skip leading slash for absolute path file:///C:/path/to/file | |
| do_not_store_filename++; | |
| } | |
| #endif | |
| } else if(*do_not_store_filename && do_not_store_filename[1]!=':' && strstr(do_not_store_filename, "://")) { | |
| pa_xmlStopMonitoringDependencies(); | |
| return 0; // plug out [do not handle other prefixes] | |
| } | |
| const char* can_store_filename=pa_strdup(do_not_store_filename); | const char* can_store_filename=pa_strdup(do_not_store_filename); |
| add_dependency(can_store_filename); | add_dependency(can_store_filename); |
| const char *buf; | const char *buf; |
| try { | try { |
| buf=file_read_text(r.charsets, *new String(can_store_filename)); | buf=file_load_text(r, *new String(can_store_filename), |
| true/*fail_on_read_problem*/, | |
| 0/*params*/, | |
| false/*don't transcode result because it must be fit with @encoding value!*/); | |
| } catch(const Exception& e) { | } catch(const Exception& e) { |
| if(strcmp(e.type(), "file.missing")==0) | if(strcmp(e.type(), "file.missing")==0) |
| return 0; // let the library try that and report an error properly | return 0; // let the library try that and report an error properly |
| Line 197 xmlFileOpenMethod (const char* afilename | Line 187 xmlFileOpenMethod (const char* afilename |
| Request::Execute_nonvirtual_method_result body= | Request::Execute_nonvirtual_method_result body= |
| r.execute_nonvirtual_method(r.main_class, *method, vparam, true); | r.execute_nonvirtual_method(r.main_class, *method, vparam, true); |
| if(body.string) { | if(body.string) { |
| buf=body.string->cstr(String::L_UNSPECIFIED); | buf=body.string->untaint_cstr(r.flang); |
| } else | } else |
| throw Exception(0, | throw Exception(0, |
| new String(afilename), | new String(afilename), |