--- parser3/src/classes/file.C 2001/04/25 10:25:31 1.31 +++ parser3/src/classes/file.C 2001/06/28 07:44:17 1.38 @@ -5,11 +5,12 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: file.C,v 1.31 2001/04/25 10:25:31 paf Exp $ + $Id: file.C,v 1.38 2001/06/28 07:44:17 parser Exp $ */ +static const char *RCSId="$Id: file.C,v 1.38 2001/06/28 07:44:17 parser Exp $"; +#include "classes.h" #include "pa_request.h" -#include "_file.h" #include "pa_vfile.h" #include "pa_table.h" #include "pa_vint.h" @@ -17,11 +18,28 @@ // consts -const int FIND_MONKEY_MAX_HOPS=10; +// defines + +#define FILE_CLASS_NAME "file" + +// class + +class MFile : public Methoded { +public: // VStateless_class + + Value *create_new_value(Pool& pool) { return new(pool) VFile(pool); } -// global var +public: // Methoded + bool used_directly() { return true; } + +public: + MFile(Pool& pool); + +}; + +// consts -VStateless_class *file_class; +const int FIND_MONKEY_MAX_HOPS=10; // methods @@ -111,12 +129,7 @@ static void pass_cgi_header_attribute(Ar hash.put(string.mid(0, colon_pos), new(string.pool()) VString(string.mid(colon_pos+1, string.size()))); } -/** - ^exec[file-name] - ^exec[file-name;env hash] - ^exec[file-name;env hash;cmd;line;arg;s] - @todo fix `` in perl - they produced flipping consoles and no output to perl -*/ +/// @todo fix `` in perl - they produced flipping consoles and no output to perl static void _cgi(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); @@ -237,28 +250,41 @@ static void _cgi(Request& r, const Strin } } -// initialize +// constructor + +MFile::MFile(Pool& apool) : Methoded(apool) { + set_name(*NEW String(pool(), FILE_CLASS_NAME)); + -void initialize_file_class(Pool& pool, VStateless_class& vclass) { // ^save[file-name] - vclass.add_native_method("save", Method::CT_DYNAMIC, _save, 1, 1); + add_native_method("save", Method::CT_DYNAMIC, _save, 1, 1); // ^delete[file-name] - vclass.add_native_method("delete", Method::CT_STATIC, _delete, 1, 1); + add_native_method("delete", Method::CT_STATIC, _delete, 1, 1); // ^find[file-name] // ^find[file-name]{when-not-found} - vclass.add_native_method("find", Method::CT_STATIC, _find, 1, 2); + add_native_method("find", Method::CT_STATIC, _find, 1, 2); // ^load[disk-name] // ^load[disk-name;user-name] - vclass.add_native_method("load", Method::CT_DYNAMIC, _load, 1, 2); + add_native_method("load", Method::CT_DYNAMIC, _load, 1, 2); // ^stat[disk-name] - vclass.add_native_method("stat", Method::CT_DYNAMIC, _stat, 1, 1); + add_native_method("stat", Method::CT_DYNAMIC, _stat, 1, 1); + + // ^cgi[file-name] + // ^cgi[file-name;env hash] + // ^cgi[file-name;env hash;1cmd;2line;3ar;4g;5s] + add_native_method("cgi", Method::CT_DYNAMIC, _cgi, 1, 2+5); +} + +// global variable + +Methoded *file_class; + +// creator - // ^exec[file-name] - // ^exec[file-name;env hash] - // ^exec[file-name;env hash;1cmd;2line;3ar;4g;5s] - vclass.add_native_method("cgi", Method::CT_DYNAMIC, _cgi, 1, 2+5); +Methoded *MFile_create(Pool& pool) { + return file_class=new(pool) MFile(pool); }