--- parser3/src/classes/file.C 2001/08/23 12:10:30 1.49 +++ parser3/src/classes/file.C 2001/10/19 12:43:29 1.59 @@ -2,12 +2,10 @@ Parser: @b file parser class. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) - $Id: file.C,v 1.49 2001/08/23 12:10:30 parser Exp $ + $Id: file.C,v 1.59 2001/10/19 12:43:29 parser Exp $ */ -static const char *RCSId="$Id: file.C,v 1.49 2001/08/23 12:10:30 parser Exp $"; #include "pa_config_includes.h" @@ -74,7 +72,7 @@ static void _move(Request& r, const Stri Value& vfrom_file_name=params->as_no_junction(0, "from file name must not be code"); Value& vto_file_name=params->as_no_junction(1, "to file name must not be code"); - // unlink + // move file_move(pool, r.absolute(vfrom_file_name.as_string()), r.absolute(vto_file_name.as_string())); @@ -122,11 +120,11 @@ static void _load(Request& r, const Stri file_read(pool, r.absolute(lfile_name), data, size, vmode_name.as_string()==TEXT_MODE_NAME); - char *user_file_name=params->size()>2?params->get(2).as_string().cstr() - :lfile_name.cstr(String::UL_FILE_NAME); + char *user_file_name=params->size()>2?params->as_string(2, "filename must be string").cstr() + :lfile_name.cstr(String::UL_FILE_SPEC); static_cast(r.self)->set(true/*tainted*/, data, size, - user_file_name, &r.mime_type_of(user_file_name)); + user_file_name, new(pool) VString(r.mime_type_of(user_file_name))); } static void _stat(Request& r, const String& method_name, MethodParams *params) { @@ -225,10 +223,11 @@ static void _exec_cgi(Request& r, const if(params->size()>2) { argv=new(pool) Array(pool, params->size()-2); for(int i=2; isize(); i++) - *argv+=¶ms->get(i).as_string(); + *argv+=¶ms->as_string(i, "parameter must be string"); } - const String in(pool, r.post_data, r.post_size); + String in(pool); + in.APPEND(r.post_data, r.post_size, String::UL_CLEAN, "passing post data", 0); String out(pool); //out.APPEND_CONST("content-type:text/plain\nheader:test-header\n\ntest-body"); //out<mid(erroffset, regexp->size()), "regular expression syntax error - %s", errptr); - ovector=(int *)malloc(sizeof(int)*(ovecsize=(1/*match*/)*3)); + ovector=(int *)pool.malloc(sizeof(int)*(ovecsize=(1/*match*/)*3)); } else regexp_code=0; const char* absolute_path_cstr=r.absolute(relative_path.as_string()) - .cstr(String::UL_FILE_NAME); + .cstr(String::UL_FILE_SPEC); Array& columns=*new(pool) Array(pool); columns+=new(pool) String(pool, "name"); @@ -339,7 +338,7 @@ static void _list(Request& r, const Stri suits=false; else if(exec_result<0) { (*pcre_free)(regexp_code); - PTHROW(0, 0, + throw Exception(0, 0, regexp, "regular expression execute (%d)", exec_result); @@ -347,10 +346,10 @@ static void _list(Request& r, const Stri } if(suits) { - char *file_name_cstr=(char *)r.malloc(file_name_size); + char *file_name_cstr=(char *)pool.malloc(file_name_size); memcpy(file_name_cstr, ffblk.ff_name, file_name_size); String &file_name=*new(pool) String(pool); - file_name.APPEND(file_name_cstr, file_name_size, String::UL_FILE_NAME, + file_name.APPEND(file_name_cstr, file_name_size, String::UL_FILE_SPEC, method_name.origin().file, method_name.origin().line); Array& row=*new(pool) Array(pool);