--- parser3/src/main/pa_xml_io.C 2003/11/27 15:10:01 1.2 +++ parser3/src/main/pa_xml_io.C 2003/11/28 09:36:04 1.6 @@ -9,7 +9,7 @@ #ifdef XML -static const char * const IDENT="$Date: 2003/11/27 15:10:01 $"; +static const char * const IDENT="$Date: 2003/11/28 09:36:04 $"; #include "libxslt/extensions.h" @@ -45,7 +45,6 @@ xmlFileMatchLocalhost(const char* filena */ static void * xmlFileOpenLocalhost (const char* filename) { - //_asm int 3; FILE *fd; const char* document_root=pa_thread_request().request_info.document_root; if(!document_root) @@ -105,6 +104,7 @@ struct MemoryStream { size_t to_read=min(a_size, left); memcpy(a_buffer, m_buf, to_read); + m_position+=to_read; return to_read; } @@ -113,34 +113,40 @@ struct MemoryStream { static int xmlFileMatchMethod(const char* filename) { - if (!strncmp(filename, "parser://", 7 /*strlen("parser://"), and check xmlFileOpenMethod*/)) + if (!strncmp(filename, "parser://", 9 /*strlen("parser://"), and check xmlFileOpenMethod*/)) return(1); return(0); } -/// parser://method/param/here -> ^/abc | ./abc +/// parser://method/param/here -> ^MAIN:method[/params/here] static void * xmlFileOpenMethod (const char* afilename) { - //_asm int 3; Request& r=pa_thread_request(); - char* s=pa_strdup(afilename+7 /*strlen("parser://")*/); + char* s=pa_strdup(afilename+9 /*strlen("parser://")*/); const char* method_cstr=lsplit(&s, '/'); const String* method=new String(method_cstr); + String::Body param_body("/"); + if(s) + param_body.append_know_length(s, strlen(s)); + + VString* vparam=new VString(*new String(param_body, String::L_TAINTED)); { Temp_lang temp_lang(r, String::L_XML); // default language: XML - // @todo: s=params - if(const String* body_string=r.execute_virtual_method(r.main_class, *method)) { + Request::Execute_nonvirtual_method_result body= + r.execute_nonvirtual_method(r.main_class, *method, vparam, true); + if(body.string) { MemoryStream *stream=new(UseGC) MemoryStream; - stream->m_buf=body_string->cstr(String::L_UNSPECIFIED); + stream->m_buf=body.string->cstr(String::L_UNSPECIFIED); stream->m_size=strlen(stream->m_buf); return (void*)stream; } } throw Exception(0, - method, - "not found (referred from parser://name/)"); + new String(afilename), + "'%s' method not found in %s class", + method_cstr, MAIN_CLASS_NAME); } static int @@ -171,7 +177,7 @@ void pa_xml_io_init() { xmlFileMatchLocalhost, xmlFileOpenLocalhost, pa_xmlFileRead, pa_xmlFileClose); - // parser://method/param/here -> ^/abc | ./abc + // parser://method/param/here -> ^MAIN:method[/params/here] xmlRegisterInputCallbacks( xmlFileMatchMethod, xmlFileOpenMethod, pa_xmlFileReadMethod, pa_xmlFileCloseMethod);