|
|
| version 1.71, 2002/02/08 07:27:40 | version 1.80, 2002/04/18 10:50:59 |
|---|---|
| Line 2 | Line 2 |
| Parser: @b file parser class. | Parser: @b file parser class. |
| Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| $Id$ | $Id$ |
| */ | */ |
| Line 26 | Line 26 |
| // defines | // defines |
| #define FILE_CLASS_NAME "file" | |
| #define TEXT_MODE_NAME "text" | #define TEXT_MODE_NAME "text" |
| // class | // class |
| Line 85 static void _find(Request& r, const Stri | Line 83 static void _find(Request& r, const Stri |
| // passed file name simply exists in current dir | // passed file name simply exists in current dir |
| if(file_readable(r.absolute(lfile_name))) { | if(file_readable(r.absolute(lfile_name))) { |
| r.write_no_lang(*new(pool) VString(lfile_name)); | r.write_no_lang(lfile_name); |
| return; | return; |
| } | } |
| // scan .. dirs for result | // scan .. dirs for result |
| for(int i=0; i<FIND_MONKEY_MAX_HOPS; i++) { | for(int i=0; i<FIND_MONKEY_MAX_HOPS; i++) { |
| String test_name(pool); | String local_test_name(pool); |
| for(int j=0; j<i; j++) | for(int j=0; j<i; j++) |
| test_name.APPEND_CONST("../"); | local_test_name.APPEND_CONST("../"); |
| test_name.append(lfile_name, String::UL_CLEAN); | local_test_name.append(lfile_name, String::UL_CLEAN); |
| if(file_readable(r.absolute(test_name))) { | if(file_readable(r.absolute(local_test_name))) { |
| r.write_no_lang(*new(pool) VString(*new(pool) String(test_name))); | r.write_no_lang(*new(pool) String(local_test_name)); |
| return; | return; |
| } | } |
| } | } |
| Line 236 static void _exec_cgi(Request& r, const | Line 234 static void _exec_cgi(Request& r, const |
| //out.APPEND_CONST("content-type:text/plain\nheader:test-header\n\ntest-body"); | //out.APPEND_CONST("content-type:text/plain\nheader:test-header\n\ntest-body"); |
| //out<<in; | //out<<in; |
| String& err=*new(pool) String(pool); | String& err=*new(pool) String(pool); |
| int status=pa_exec(script_name, &env, argv, in, out, err); | int status=pa_exec(false/*forced_allow*/, script_name, &env, argv, in, out, err); |
| VFile& self=*static_cast<VFile *>(r.self); | VFile& self=*static_cast<VFile *>(r.self); |
| Line 252 static void _exec_cgi(Request& r, const | Line 250 static void _exec_cgi(Request& r, const |
| } | } |
| if(pos<0) { | if(pos<0) { |
| delim_size=0; // calm down, compiler | delim_size=0; // calm down, compiler |
| throw Exception(0, 0, | throw Exception(0, |
| &method_name, | &method_name, |
| "output does not contain CGI header; exit code=%d; outsize=%u; out: \"%s\"; errsize=%u; err: \"%s\"", | "output does not contain CGI header; exit status=%d; stdoutsize=%u; stdout: \"%s\"; stderrsize=%u; stderr: \"%s\"", |
| status, | status, |
| (uint)out.size(), out.cstr(), | (uint)out.size(), out.cstr(), |
| (uint)err.size(), err.cstr()); | (uint)err.size(), err.cstr()); |
| Line 314 static void _list(Request& r, const Stri | Line 312 static void _list(Request& r, const Stri |
| pool.get_client_charset().pcre_tables); | pool.get_client_charset().pcre_tables); |
| if(!regexp_code) | if(!regexp_code) |
| throw Exception(0, 0, | throw Exception(0, |
| ®exp->mid(erroffset, regexp->size()), | ®exp->mid(erroffset, regexp->size()), |
| "regular expression syntax error - %s", errptr); | "regular expression syntax error - %s", errptr); |
| Line 342 static void _list(Request& r, const Stri | Line 340 static void _list(Request& r, const Stri |
| suits=false; | suits=false; |
| else if(exec_result<0) { | else if(exec_result<0) { |
| (*pcre_free)(regexp_code); | (*pcre_free)(regexp_code); |
| throw Exception(0, 0, | throw Exception(0, |
| regexp, | regexp, |
| "regular expression execute (%d)", | "regular expression execute (%d)", |
| exec_result); | exec_result); |
| Line 367 static void _list(Request& r, const Stri | Line 365 static void _list(Request& r, const Stri |
| // write out result | // write out result |
| VTable& result=*new(pool) VTable(pool, &table); | VTable& result=*new(pool) VTable(pool, &table); |
| result.set_name(method_name); | |
| r.write_no_lang(result); | r.write_no_lang(result); |
| } | } |
| Line 393 static void _lock(Request& r, const Stri | Line 390 static void _lock(Request& r, const Stri |
| // constructor | // constructor |
| MFile::MFile(Pool& apool) : Methoded(apool) { | MFile::MFile(Pool& apool) : Methoded(apool, "file") { |
| set_name(*NEW String(pool(), FILE_CLASS_NAME)); | |
| // ^save[mode;file-name] | // ^save[mode;file-name] |
| add_native_method("save", Method::CT_DYNAMIC, _save, 2, 2); | add_native_method("save", Method::CT_DYNAMIC, _save, 2, 2); |