--- parser3/src/classes/file.C 2003/09/25 09:15:02 1.112 +++ 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* IDENT_FILE_C="$Date: 2003/09/25 09:15:02 $"; +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* IDENT_FILE_C="$Date: #include "pa_vtable.h" #include "pa_charset.h" #include "pa_charsets.h" +#include "pa_sql_connection.h" // defines @@ -36,7 +37,7 @@ static const char* IDENT_FILE_C="$Date: class MFile: public Methoded { public: // VStateless_class - Value* create_new_value() { return new VFile(); } + Value* create_new_value(Pool&) { return new VFile(); } public: // Methoded bool used_directly() { return true; } @@ -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) { @@ -348,7 +349,6 @@ static void _exec_cgi(Request& r, Method VFile& self=GET_SELF(r, VFile); const String* body=real_out; // ^file:exec - Value* content_type=0; const char* eol_marker=0; size_t eol_marker_size; const String* header=0; if(cgi) { // ^file:cgi @@ -399,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); @@ -444,8 +444,10 @@ static void _list(Request& r, MethodPara throw Exception(0, ®exp->mid(erroffset, regexp->length()), "regular expression syntax error - %s", errptr); - } else + } else { + regexp=0; // not used, just to calm down compiler regexp_code=0; + } const char* absolute_path_cstr=r.absolute(relative_path.as_string()).cstr(String::L_FILE_SPEC); @@ -500,19 +502,20 @@ 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); } static int lastposafter(const String& s, size_t after, const char* substr, size_t substr_size, bool beforelast=false) { - size_t size; + 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) @@ -613,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 @@ -665,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); }