--- parser3/src/targets/isapi/parser3isapi.C 2002/06/24 11:59:33 1.76 +++ parser3/src/targets/isapi/parser3isapi.C 2003/01/31 16:05:59 1.82.2.2 @@ -1,12 +1,12 @@ /** @file Parser: IIS extension. - Copyright (c) 2000,2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2000,2001-2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - - $Id: parser3isapi.C,v 1.76 2002/06/24 11:59:33 paf Exp $ */ +static const char* IDENT_PARSER3ISAPI_C="$Date: 2003/01/31 16:05:59 $"; + #ifndef _MSC_VER # error compile ISAPI module with MSVC [no urge for now to make it autoconf-ed (PAF)] #endif @@ -30,27 +30,7 @@ // consts -extern const char *main_RCSIds[]; -#ifdef USE_SMTP -extern const char *smtp_RCSIds[]; -#endif -extern const char *gd_RCSIds[]; -extern const char *classes_RCSIds[]; -extern const char *types_RCSIds[]; -extern const char *parser3isapi_RCSIds[]; -const char **RCSIds[]={ - main_RCSIds, -#ifdef USE_SMTP - smtp_RCSIds, -#endif - gd_RCSIds, - classes_RCSIds, - types_RCSIds, - parser3isapi_RCSIds, - 0 -}; - -const char *IIS51vars[]={ +const char* IIS51vars[]={ "APPL_MD_PATH", "APPL_PHYSICAL_PATH", "AUTH_PASSWORD", "AUTH_TYPE", "AUTH_USER", "CERT_COOKIE", "CERT_FLAGS", "CERT_ISSUER", "CERT_KEYSIZE", "CERT_SECRETKEYSIZE", @@ -87,13 +67,13 @@ struct SAPI_func_context { #endif // goes to 'cs-uri-query' log file field. webmaster: switch it ON[default OFF]. -void SAPI::log(Pool& pool, const char *fmt, ...) { +void SAPI::log(Pool& pool, const char* fmt, ...) { SAPI_func_context& ctx=*static_cast(pool.get_context()); va_list args; va_start(args,fmt); char buf[MAX_STRING]; - const char *prefix="PARSER_ERROR:"; + const char* prefix="PARSER_ERROR:"; strcpy(buf, prefix); char *start=buf+strlen(prefix); DWORD size=vsnprintf(start, MAX_STRING-strlen(prefix), fmt, args); @@ -104,17 +84,18 @@ void SAPI::log(Pool& pool, const char *f } /// @todo event log -void SAPI::die(const char *fmt, ...) { +void SAPI::die(const char* fmt, ...) { if(FILE *log=fopen("c:\\die.log", "at")) { va_list args; va_start(args,fmt); vfprintf(log, fmt, args); fclose(log); } - exit(1); + // exit & try to produce core dump + abort(); } -const char *SAPI::get_env(Pool& pool, const char *name) { +const char* SAPI::get_env(Pool& pool, const char* name) { SAPI_func_context& ctx=*static_cast(pool.get_context()); char *variable_buf=(char *)pool.malloc(MAX_STRING); @@ -141,7 +122,7 @@ const char *SAPI::get_env(Pool& pool, co return 0; } -static int grep_char(const char *s, char c) { +static int grep_char(const char* s, char c) { int result=0; if(s) { while(s=strchr(s, c)) { @@ -151,24 +132,24 @@ static int grep_char(const char *s, char } return result; } -static const char *mk_env_pair(Pool& pool, const char *key, const char *value) { +static const char* mk_env_pair(Pool& pool, const char* key, const char* value) { char *result=(char *)pool.malloc(strlen(key)+1/*=*/+strlen(value)+1/*0*/); strcpy(result, key); strcat(result, "="); strcat(result, value); return result; } -const char *const *SAPI::environment(Pool& pool) { +const char* const *SAPI::environment(Pool& pool) { // we know this buf is writable char *all_http_vars=const_cast(SAPI::get_env(pool, "ALL_HTTP")); const int http_var_count=grep_char(all_http_vars, '\n')+1/*\n for theoretical(never saw) this \0*/; - const char **result= - (const char **)pool.malloc(sizeof(char *)*(IIS51var_count+http_var_count+1/*0*/)); - const char **cur=result; + const char* *result= + (const char* *)pool.malloc(sizeof(char *)*(IIS51var_count+http_var_count+1/*0*/)); + const char* *cur=result; // IIS5.1 vars for(int i=0; i(pool.get_context()); if(strcasecmp(key, "location")==0) ctx.http_response_code=302; if(strcasecmp(key, "status")==0) - ctx.http_response_code=atoi(value); + ctx.http_response_code=atoi(dont_store_value); else { - ctx.header->APPEND_CONST(key); +todo: copy dont_store_ to nonvilotile + ctx.header->APPEND_CONST(dont_store_key); ctx.header->APPEND_CONST(": "); - ctx.header->APPEND_CONST(value); + ctx.header->APPEND_CONST(dont_store_value); ctx.header->APPEND_CONST("\r\n"); } } @@ -308,7 +291,7 @@ static bool parser_init() { // successful finish return true; } catch(const Exception& e) { // global problem - const char *body=e.comment(); + const char* body=e.comment(); // unsuccessful finish return false; @@ -348,7 +331,7 @@ void real_parser_handler(Pool& pool, LPE back_slashes_to_slashes(filespec_to_process); #endif - if(const char *path_info=SAPI::get_env(pool, "PATH_INFO")) { + 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); @@ -402,10 +385,11 @@ void real_parser_handler(Pool& pool, LPE snprintf(config_filespec, MAX_STRING, "%s/%s", beside_binary_path, AUTO_FILE_NAME); + bool fail_on_config_read_problem=entry_exists(config_filespec); // process the request request.core( - config_filespec, false /*fail_on_read_problem*/, // /path/to/first/auto.p + config_filespec, fail_on_config_read_problem, // /path/to/first/auto.p header_only); } @@ -442,7 +426,7 @@ inline DWORD RealHttpExtensionProc(LPEXT SAPI_func_context ctx={ lpECB, 0, // filling later: so that if there would be error pool would have ctx - 200 // default http_response_code + 200 // default http_response_code [lpECB->dwHttpStatusCode seems to be always 0, even on 404 redirect to /404.html] }; pool.set_context(&ctx);// no allocations before this line! @@ -454,7 +438,7 @@ inline DWORD RealHttpExtensionProc(LPEXT // don't allocate anything on pool here: // possible pool' exception not catch-ed now // and there could be out-of-memory exception - const char *body=e.comment(); + const char* body=e.comment(); // log it SAPI::log(pool, "exception in request exception handler: %s", body); @@ -489,7 +473,7 @@ inline DWORD RealHttpExtensionProc(LPEXT // unsuccessful finish } /* - const char *body="test"; + const char* body="test"; // int content_length=strlen(body);