--- parser3/src/classes/file.C 2003/11/20 16:34:23 1.115 +++ parser3/src/classes/file.C 2004/03/02 14:56:42 1.121 @@ -1,11 +1,11 @@ /** @file Parser: @b file parser class. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2004 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_FILE_C="$Date: 2003/11/20 16:34:23 $"; +static const char * const IDENT_FILE_C="$Date: 2004/03/02 14:56:42 $"; #include "pa_config_includes.h" @@ -24,6 +24,7 @@ static const char * const IDENT_FILE_C=" #include "pa_vtable.h" #include "pa_charset.h" #include "pa_charsets.h" +#include "pa_sql_connection.h" // defines @@ -294,7 +295,7 @@ static void _exec_cgi(Request& r, Method if(params.count()>1) { Value& venv=params.as_no_junction(1, "env must not be code"); if(HashStringValue* user_env=venv.get_hash()) { - Append_env_pair_info info={&env}; + Append_env_pair_info info={&env, 0, 0}; user_env->for_each(append_env_pair, &info); // $.stdin if(info.vstdin) { @@ -398,7 +399,7 @@ static void _exec_cgi(Request& r, Method ArrayString rows; size_t pos_after=0; header->split(rows, pos_after, eol_marker); - Pass_cgi_header_attribute_info info={0}; + Pass_cgi_header_attribute_info info={0, 0, 0}; info.charset=&r.charsets.source(); info.fields=&self.fields(); rows.for_each(pass_cgi_header_attribute, &info); @@ -501,10 +502,11 @@ static void lock_execute_body(int , void info.r->write_assign_lang(info.r->process(*info.body_code)); }; static void _lock(Request& r, MethodParams& params) { - Lock_execute_body_info info={0}; - info.r=&r; const String& file_spec=r.absolute(params.as_string(0, "file name must be string")); - info.body_code=¶ms.as_junction(1, "body must be code"); + Lock_execute_body_info info={ + &r, + ¶ms.as_junction(1, "body must be code") + }; file_write_action_under_lock(file_spec, "lock", lock_execute_body, &info); } @@ -513,7 +515,7 @@ static int lastposafter(const String& s, size_t size=0; // just to calm down compiler if(beforelast) size=s.length(); - int at; + size_t at; while((at=s.pos(String::Body(substr, substr_size), after))!=STRING_NOT_FOUND) { size_t newafter=at+substr_size/*skip substr*/; if(beforelast && newafter==size) @@ -614,6 +616,12 @@ static void _fullpath(Request& r, Method r.write_assign_lang(*result); } +static void _sql_string(Request& r, MethodParams&) { + VFile& self=GET_SELF(r, VFile); + + const char *quoted=r.connection()->quote(self.value_ptr(), self.value_size()); + r.write_assign_lang(*new String(quoted)); +} // constructor @@ -666,4 +674,7 @@ MFile::MFile(): Methoded("file") { add_native_method("justext", Method::CT_STATIC, _justext, 1, 1); // /some/page.html: ^file:fullpath[a.gif] => /some/a.gif add_native_method("fullpath", Method::CT_STATIC, _fullpath, 1, 1); + + // ^file.sql-string[] + add_native_method("sql-string", Method::CT_DYNAMIC, _sql_string, 0, 0); }