DWORD WINAPI HttpFilterProc(PHTTP_FILTER_CONTEXT pfc, DWORD notificationType, LPVOID pvNotification) { char url[URL_SIZE]; char host[1024]; char port_buf[80]; int port = 0; unsigned long size; char query = 0; unsigned int query_index = 0; HTTP_FILTER_PREPROC_HEADERS *headers=NULL;; HTTP_FILTER_AUTH_COMPLETE_INFO *AuthComp=NULL;; if (g_is_iis5 < 0) { char version[1024]; size = sizeof(version); g_is_iis5 = 0; if (pfc->GetServerVariable(pfc, "SERVER_SOFTWARE", version, &size)) { LOG(("IIS version %s\n", version)); g_is_iis5 = atof(version + strlen("Microsoft-IIS/")) >= 5.0; } else { LOG(("Can't Get SERVER_SOFTWARE %d\n",GetLastError())); } } switch (notificationType) { case SF_NOTIFY_PREPROC_HEADERS: LOG(("HttpFilterProc: SF_NOTIFY_PREPROC_HEADERS\n")); if (g_is_iis5) break; headers = (HTTP_FILTER_PREPROC_HEADERS *) pvNotification; size = sizeof(host); host[0] = 0; pfc->GetServerVariable(pfc, "SERVER_NAME", host, &size); size = sizeof(port_buf); if (pfc->GetServerVariable(pfc, "SERVER_PORT", port_buf, &size) && size > 0) { port = atoi(port_buf); } size = sizeof(url); if (headers->GetHeader(pfc, "URL", url, &size) && size > 0) { url[size] = 0; for (query_index = 0; query_index < size; query_index++) { if (url[query_index] == '?') { query = url[query_index]; url[query_index] = 0; break; } } DWORD request_time = GetTickCount() / 1000; if (cse_match_request(g_config, host, port, url, 1, request_time) || g_config->enable_caucho_status && ! strcmp(url, "/caucho-status")) { char newurl[SCRIPT_URL_SIZE]; if (! pfc->pFilterContext) { pfc->pFilterContext = pfc->AllocMem(pfc, SCRIPT_URL_SIZE, 0); if (! pfc->pFilterContext) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); return SF_STATUS_REQ_ERROR; } ((char *) pfc->pFilterContext)[0] = 0; } url[query_index] = query; strcpy(newurl, ISAPI_SCRIPT); strcat(newurl, url); headers->SetHeader(pfc, "URL", newurl); strcpy((char *) pfc->pFilterContext, url); ((char *) pfc->pFilterContext)[query_index] = 0; } } break; case SF_NOTIFY_AUTH_COMPLETE: LOG(("HttpFilterProc: SF_NOTIFY_AUTH_COMPLETE\n")); AuthComp = (HTTP_FILTER_AUTH_COMPLETE_INFO *) pvNotification; size = sizeof(host); host[0] = 0; pfc->GetServerVariable(pfc, "SERVER_NAME", host, &size); size = sizeof(port_buf); if (pfc->GetServerVariable(pfc, "SERVER_PORT", port_buf, &size) && size > 0) { port = atoi(port_buf); } size = sizeof(url); if (AuthComp->GetHeader(pfc, "URL", url, &size) && size > 0) { url[size] = 0; for (query_index = 0; query_index < size; query_index++) { if (url[query_index] == '?') { query = url[query_index]; url[query_index] = 0; break; } } DWORD request_time = GetTickCount() / 1000; if (cse_match_request(g_config, host, port, url, 1, request_time) || g_config->enable_caucho_status && ! strcmp(url, "/caucho-status")) { char newurl[SCRIPT_URL_SIZE]; if (! pfc->pFilterContext) { pfc->pFilterContext = pfc->AllocMem(pfc, SCRIPT_URL_SIZE, 0); if (! pfc->pFilterContext) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); return SF_STATUS_REQ_ERROR; } ((char *) pfc->pFilterContext)[0] = 0; } url[query_index] = query; strcpy(newurl, ISAPI_SCRIPT); strcat(newurl, url); AuthComp->SetHeader(pfc, "URL", newurl); strcpy((char *) pfc->pFilterContext, url); ((char *) pfc->pFilterContext)[query_index] = 0; } } break; case SF_NOTIFY_LOG: LOG(("NOTIFY-LOG %p\n", pfc->pFilterContext)); if (pfc->pFilterContext && ((char *) pfc->pFilterContext)[0]) { char *pch = (char *) pfc->pFilterContext; LOG(("NOTIFY_LOG %s\n", pch ? pch : "null")); HTTP_FILTER_LOG *pLog = (HTTP_FILTER_LOG *) pvNotification; pLog->pszTarget = pch; } break; default: LOG(("Log %d\n", notificationType)); break; } return SF_STATUS_REQ_NEXT_NOTIFICATION; }