--- parser3/src/targets/cgi/parser3.C 2001/03/24 14:56:09 1.45 +++ parser3/src/targets/cgi/parser3.C 2001/04/03 07:20:54 1.55 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: parser3.C,v 1.45 2001/03/24 14:56:09 paf Exp $ + $Id: parser3.C,v 1.55 2001/04/03 07:20:54 paf Exp $ */ #include "pa_config_includes.h" @@ -38,7 +38,7 @@ static LONG WINAPI TopLevelExceptionFilt char buf[MAX_STRING]; if(ExceptionInfo && ExceptionInfo->ExceptionRecord) { struct _EXCEPTION_RECORD *er=ExceptionInfo->ExceptionRecord; - snprintf(buf, MAX_STRING, "Exception %#X at %p", + snprintf(buf, MAX_STRING, "Exception 0x%X at %p", er->ExceptionCode, er->ExceptionAddress); } else @@ -52,8 +52,7 @@ static LONG WINAPI TopLevelExceptionFilt } #endif -//@{ -/// SAPI funcs decl +// SAPI const char *SAPI::get_env(Pool& pool, const char *name) { return getenv(name); } @@ -76,7 +75,7 @@ void SAPI::add_header_attribute(Pool& po printf("%s: %s\n", key, value); } -/// @todo intelligent cache-control +/// @todo parser4: intelligent cache-control void SAPI::send_header(Pool& pool) { if(cgi) { puts("expires: Fri, 23 Mar 2001 09:32:23 GMT"); @@ -86,11 +85,11 @@ void SAPI::send_header(Pool& pool) { } } -void SAPI::send_body(Pool& pool, const char *buf, size_t size) { +void SAPI::send_body(Pool& pool, const void *buf, size_t size) { stdout_write(buf, size); } -/// appends to parser3.log located beside my binary +// appends to parser3.log located beside my binary void SAPI::log(Pool& pool, const char *fmt, ...) { bool opened; FILE *f=0; @@ -122,12 +121,11 @@ void SAPI::log(Pool& pool, const char *f if(opened) fclose(f); } -//@} /** main workhorse - @todo + @todo parser4: IIS: remove trailing default-document[index.html] from $request.uri. to do that we need to consult metabase, wich is tested but seems slow. @@ -182,9 +180,9 @@ int main(int argc, char *argv[]) { // Request info Request::Info request_info; if(cgi) { - if(const char *env_document_root=getenv("DOCUMENT_ROOT")) + if(const char *env_document_root=SAPI::get_env(pool, "DOCUMENT_ROOT")) request_info.document_root=env_document_root; - else if(const char *path_info=getenv("PATH_INFO")) { + else if(const char *path_info=SAPI::get_env(pool, "PATH_INFO")) { // IIS size_t len=strlen(filespec_to_process)-strlen(path_info); char *buf=(char *)pool.malloc(len+1); @@ -203,12 +201,12 @@ int main(int argc, char *argv[]) { } request_info.path_translated=filespec_to_process; request_info.method=request_method; - const char *query_string=getenv("QUERY_STRING"); + const char *query_string=SAPI::get_env(pool, "QUERY_STRING"); request_info.query_string=query_string; if(cgi) - if(const char *env_request_uri=getenv("REQUEST_URI")) + if(const char *env_request_uri=SAPI::get_env(pool, "REQUEST_URI")) request_info.uri=env_request_uri; - else if(const char *path_info=getenv("PATH_INFO")) + else if(const char *path_info=SAPI::get_env(pool, "PATH_INFO")) if(query_string) { char *reconstructed_uri=(char *)malloc( strlen(path_info)+1/*'?'*/+ @@ -226,15 +224,16 @@ int main(int argc, char *argv[]) { else request_info.uri=0; - request_info.content_type=getenv("CONTENT_TYPE"); - const char *content_length=getenv("CONTENT_LENGTH"); + request_info.content_type=SAPI::get_env(pool, "CONTENT_TYPE"); + const char *content_length=SAPI::get_env(pool, "CONTENT_LENGTH"); request_info.content_length=(content_length?atoi(content_length):0); - request_info.cookie=getenv("HTTP_COOKIE"); + request_info.cookie=SAPI::get_env(pool, "HTTP_COOKIE"); + request_info.user_agent=SAPI::get_env(pool, "HTTP_USER_AGENT"); // prepare to process request Request request(pool, request_info, - cgi ? String::UL_HTML_TYPO : String::UL_NO + 1||cgi ? String::UL_HTML_TYPO : String::UL_CLEAN ); // some root-controlled location @@ -244,7 +243,7 @@ int main(int argc, char *argv[]) { GetWindowsDirectory(root_auto_path, MAX_STRING); #else // ~nobody todo: figure out a better place - char *root_auto_path=getenv("HOME"); + char *root_auto_path=SAPI::get_env(pool, "HOME"); #endif // beside by binary