Diff for /parser3/src/classes/file.C between versions 1.78 and 1.82

version 1.78, 2002/04/15 13:17:03 version 1.82, 2002/06/11 12:20:41
Line 26 Line 26
   
 // defines  // defines
   
 #define FILE_CLASS_NAME "file"  
   
 #define TEXT_MODE_NAME "text"  #define TEXT_MODE_NAME "text"
   
 // class  // class
Line 179  static void _exec_cgi(Request& r, const Line 177  static void _exec_cgi(Request& r, const
                         name##value.APPEND_CONST(value_cstr); \                          name##value.APPEND_CONST(value_cstr); \
                         env.put(name##key, &name##value); \                          env.put(name##key, &name##value); \
                 }                  }
           // passing SAPI::environment
           /*
         #define EPASS(name) \          #define EPASS(name) \
                 String name##key(pool, #name); \                  String name##key(pool, #name); \
                 String name##value(pool); \                  String name##value(pool); \
Line 187  static void _exec_cgi(Request& r, const Line 187  static void _exec_cgi(Request& r, const
                         env.put(name##key, &name##value); \                          env.put(name##key, &name##value); \
                 }                  }
   
           EPASS(SERVER_PROTOCOL);
           EPASS(SERVER_NAME);
           EPASS(SERVER_PORT);
           EPASS(REMOTE_ADDR);
           EPASS(REMOTE_HOST);
           EPASS(REMOTE_USER);
           EPASS(HTTP_REFERER);
           EPASS(HTTP_USER_AGENT);
           EPASS(HTTP_COOKIE);
           */
           if(const char *const *pairs=SAPI::environment(pool)) {
                   while(const char *pair=*pairs++)
                           if(const char *eq_at=strchr(pair, '=')) {
                                   String& key=*new(pool) String(pool, pair, eq_at-pair);
                                   String& value=*new(pool) String(pool, eq_at+1);
                                   env.put(key, &value);
                           }
           }
   
         // const          // const
         ECSTR(GATEWAY_INTERFACE, "CGI/1.1");          ECSTR(GATEWAY_INTERFACE, "CGI/1.1");
         // from Request.info          // from Request.info
Line 200  static void _exec_cgi(Request& r, const Line 219  static void _exec_cgi(Request& r, const
         snprintf(content_length_cstr, MAX_NUMBER, "%u", r.info.content_length);          snprintf(content_length_cstr, MAX_NUMBER, "%u", r.info.content_length);
         String content_length(pool, content_length_cstr);          String content_length(pool, content_length_cstr);
         ECSTR(CONTENT_LENGTH, content_length_cstr);          ECSTR(CONTENT_LENGTH, content_length_cstr);
         ECSTR(HTTP_COOKIE, r.info.cookie);          // SCRIPT_*
         ECSTR(HTTP_USER_AGENT, r.info.user_agent);  
         // passing some SAPI:get_env-s  
         EPASS(SERVER_PROTOCOL);  
         EPASS(SERVER_NAME);  
         EPASS(SERVER_PORT);  
         EPASS(HTTP_REFERER);  
         EPASS(REMOTE_ADDR);  
         EPASS(REMOTE_HOST);  
         EPASS(REMOTE_USER);  
         // SCRIPT_NAME  
         env.put(*new(pool) String(pool, "SCRIPT_NAME"), &script_name);          env.put(*new(pool) String(pool, "SCRIPT_NAME"), &script_name);
 #ifdef WIN32          //env.put(*new(pool) String(pool, "SCRIPT_FILENAME"), ??&script_name);
         // WIN32 shell  
         EPASS(COMSPEC);  
 #endif  
   
         if(params->size()>1) {          if(params->size()>1) {
                 Value& venv=params->as_no_junction(1, "env must not be code");                  Value& venv=params->as_no_junction(1, "env must not be code");
Line 254  static void _exec_cgi(Request& r, const Line 260  static void _exec_cgi(Request& r, const
                         delim_size=0; // calm down, compiler                          delim_size=0; // calm down, compiler
                         throw Exception(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 301  static void _list(Request& r, const Stri Line 307  static void _list(Request& r, const Stri
   
         const String *regexp;          const String *regexp;
         pcre *regexp_code;          pcre *regexp_code;
         int ovecsize;          const int ovecsize=(1/*match*/)*3;
         int *ovector;          int ovector[ovecsize];
         if(params->size()>1) {          if(params->size()>1) {
                 regexp=&params->as_no_junction(1, "regexp must not be code").as_string();                  regexp=&params->as_no_junction(1, "regexp must not be code").as_string();
   
Line 317  static void _list(Request& r, const Stri Line 323  static void _list(Request& r, const Stri
                         throw Exception(0,                           throw Exception(0, 
                                 &regexp->mid(erroffset, regexp->size()),                                   &regexp->mid(erroffset, regexp->size()), 
                                 "regular expression syntax error - %s", errptr);                                  "regular expression syntax error - %s", errptr);
   
                 ovector=(int *)pool.malloc(sizeof(int)*(ovecsize=(1/*match*/)*3));  
         } else           } else 
                 regexp_code=0;                  regexp_code=0;
   
Line 367  static void _list(Request& r, const Stri Line 371  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 396  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);
   

Removed from v.1.78  
changed lines
  Added in v.1.82


E-mail: