Профессиональное программирование на PHP

Страница 563 из 591


SAPI-интерфейсы 583

}

retval = php_fopen_primary_script(&file_handle TSRMLS_CC); if (retval == FAILURE && file_handle.handle.fp == NULL) {

SG(sapi_headers).http_response_code = 404;

PUTS("He задан входной файл.\п");

php_reguest_shutdovm ((void *) 0);

php_module_shutdovm(TSRMLS_C);

return FAILURE;

}

php_execute_script(&file_handle TSRMLS_CC); if (SG(request_info).path_translated) { char *path_translated;

path_translated = strdup(SG(reguest_info).path_translated); efree(SG(request_info) .path_translated) ; SG(request_info) .path_translated = path_translated;

php_reguest_shutdovm ((void *) 0); if (exit_status ==0) {

exit_status = EG(exit status);

}

if (SG(request_info).path_translated) { free(SG(request_info).path_translated); SG(request_info) .path translated = NULL;

}

} zend_catch {

exit_status = 255; } zend_end_try() ; php_module_shutdown(TSRMLS_C); sapi_shutdovm (); return exit_status;

}

Ниже приведена вспомогательная функция init_request_inf о (), которая устанавливает из среды глобальные переменные SAPI для сценария и параметры строки запроса согласно спецификации CGI.

static void init_request_infо(TSRMLS D) {

char *env_script_filename = sapi_cgibin_getenv("SCRIPT_FILENAME",0 TSRMLS_CC);

char *env_path_translated = sapi_cgibin_getenv("PATH_TRANSLATED",0 TSRMLS_CC);

char *script_path_translated = env_script_filename;

/* инициализация стандартных параметров */

SG(request_infо).path_translated = NULL;

SG(request_info).request_method = NULL;

SG(request_info).query_string = NULL;

SG(request_info).request_uri = NULL;

SG(request_info).content_type = NULL;

SG(request_info).content_length = 0;

SG(sapi_headers).http_response_code = 200;

/* установленное значение script_path_translated указывает на то, что сценарий работает в cgi-среде, поскольку иначе оно установлено в null. В последнем случае имя




  Hostland.Ru

 «Бесплатный хостинг Hostland.Su» © 2006