cvs: php4 /ext/standard basic_functions.c /main main.c /sapi/apache mod_php4.c sapi_apache.c /sapi/cgi cgi_main.c /sapi/isapi php4isapi.c
/sapi/pi3web pi3web_sapi.c /sapi/servlet servlet.c

From: Date: Sat, 21 Jul 2001 14:27:57 +0000
Subject: cvs: php4 /ext/standard basic_functions.c /main main.c /sapi/apache mod_php4.c sapi_apache.c /sapi/cgi cgi_main.c /sapi/isapi php4isapi.c
/sapi/pi3web pi3web_sapi.c /sapi/servlet servlet.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-6304@lists.php.net to get a copy of this message
zeev Sat Jul 21 10:27:57 2001 EDT Modified files: /php4/ext/standard basic_functions.c /php4/main main.c /php4/sapi/apache mod_php4.c sapi_apache.c /php4/sapi/cgi cgi_main.c /php4/sapi/isapi php4isapi.c /php4/sapi/pi3web pi3web_sapi.c /php4/sapi/servlet servlet.c Log: Improved bailout mechanism, supports nested bailouts a-la try..catch Note: You may *not* return directly from a catch block

Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.358 php4/ext/standard/basic_functions.c:1.359 --- php4/ext/standard/basic_functions.c:1.358 Mon Jul 9 13:36:03 2001 +++ php4/ext/standard/basic_functions.c Sat Jul 21 10:27:54 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.358 2001/07/09 17:36:03 rasmus Exp $ */ +/* $Id: basic_functions.c,v 1.359 2001/07/21 14:27:54 zeev Exp $ */ #include "php.h" #include "php_main.h" @@ -1889,21 +1889,12 @@ BLS_FETCH(); ELS_FETCH(); - if (BG(user_shutdown_function_names)) { - jmp_buf orig_bailout; - - memcpy(&orig_bailout, &EG(bailout), sizeof(jmp_buf)); - if (setjmp(EG(bailout))!=0) { - /* one of the shutdown functions bailed out */ - memcpy(&EG(bailout), &orig_bailout, sizeof(jmp_buf)); - return; - } - zend_hash_apply(BG(user_shutdown_function_names), - (apply_func_t)user_shutdown_function_call); + if (BG(user_shutdown_function_names)) zend_try { + zend_hash_apply(BG(user_shutdown_function_names), (apply_func_t)user_shutdown_function_call); memcpy(&EG(bailout), &orig_bailout, sizeof(jmp_buf)); zend_hash_destroy(BG(user_shutdown_function_names)); efree(BG(user_shutdown_function_names)); - } + } zend_end_try(); } /* {{{ proto void register_shutdown_function(string function_name) Index: php4/main/main.c diff -u php4/main/main.c:1.381 php4/main/main.c:1.382 --- php4/main/main.c:1.381 Fri Jul 20 09:59:00 2001 +++ php4/main/main.c Sat Jul 21 10:27:54 2001 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.381 2001/07/20 13:59:00 zeev Exp $ */ +/* $Id: main.c,v 1.382 2001/07/21 14:27:54 zeev Exp $ */ /* {{{ includes */ @@ -620,54 +620,56 @@ */ int php_request_startup(CLS_D ELS_DC PLS_DC SLS_DC) { + int retval = SUCCESS; + #if PHP_SIGCHILD signal(SIGCHLD,sigchld_handler); #endif - if (setjmp(EG(bailout))!=0) { - return FAILURE; - } + zend_try { + PG(during_request_startup) = 1; + + php_output_activate(); - PG(during_request_startup) = 1; - - php_output_activate(); + /* initialize global variables */ + PG(modules_activated) = 0; + PG(header_is_being_sent) = 0; + PG(connection_status) = PHP_CONNECTION_NORMAL; + + zend_activate(CLS_C ELS_CC); + sapi_activate(SLS_C); - /* initialize global variables */ - PG(modules_activated) = 0; - PG(header_is_being_sent) = 0; - PG(connection_status) = PHP_CONNECTION_NORMAL; - - zend_activate(CLS_C ELS_CC); - sapi_activate(SLS_C); + zend_set_timeout(EG(timeout_seconds)); - zend_set_timeout(EG(timeout_seconds)); + if (PG(expose_php)) { + sapi_add_header(SAPI_PHP_VERSION_HEADER, sizeof(SAPI_PHP_VERSION_HEADER)-1, 1); + } - if (PG(expose_php)) { - sapi_add_header(SAPI_PHP_VERSION_HEADER, sizeof(SAPI_PHP_VERSION_HEADER)-1, 1); - } + if (PG(output_handler) && PG(output_handler)[0]) { + zval *output_handler; - if (PG(output_handler) && PG(output_handler)[0]) { - zval *output_handler; + ALLOC_INIT_ZVAL(output_handler); + Z_STRLEN_P(output_handler) = strlen(PG(output_handler)); /* this can be optimized */ + Z_STRVAL_P(output_handler) = estrndup(PG(output_handler), Z_STRLEN_P(output_handler)); + Z_TYPE_P(output_handler) = IS_STRING; + php_start_ob_buffer(output_handler, 0); + } else if (PG(output_buffering)) { + php_start_ob_buffer(NULL, 0); + } else if (PG(implicit_flush)) { + php_start_implicit_flush(); + } - ALLOC_INIT_ZVAL(output_handler); - Z_STRLEN_P(output_handler) = strlen(PG(output_handler)); /* this can be optimized */ - Z_STRVAL_P(output_handler) = estrndup(PG(output_handler), Z_STRLEN_P(output_handler)); - Z_TYPE_P(output_handler) = IS_STRING; - php_start_ob_buffer(output_handler, 0); - } else if (PG(output_buffering)) { - php_start_ob_buffer(NULL, 0); - } else if (PG(implicit_flush)) { - php_start_implicit_flush(); - } - - /* We turn this off in php_execute_script() */ - /* PG(during_request_startup) = 0; */ - - php_hash_environment(ELS_C SLS_CC PLS_CC); - zend_activate_modules(); - PG(modules_activated)=1; + /* We turn this off in php_execute_script() */ + /* PG(during_request_startup) = 0; */ - return SUCCESS; + php_hash_environment(ELS_C SLS_CC PLS_CC); + zend_activate_modules(); + PG(modules_activated)=1; + } zend_catch { + retval = FAILURE; + } zend_end_try(); + + return retval; } /* }}} */ @@ -692,17 +694,17 @@ php_output_set_status(0); - if (setjmp(EG(bailout))==0) { + zend_try { php_end_ob_buffers((zend_bool)(SG(request_info).headers_only?0:1)); - } + } zend_end_try(); - if (setjmp(EG(bailout))==0) { + zend_try { sapi_send_headers(); - } + } zend_end_try(); - if (PG(modules_activated) && setjmp(EG(bailout))==0) { + if (PG(modules_activated)) zend_try { php_call_shutdown_functions(); - } + } zend_end_try(); if (PG(modules_activated)) { zend_deactivate_modules(); @@ -710,17 +712,17 @@ zend_deactivate(CLS_C ELS_CC); - if (setjmp(EG(bailout))==0) { + zend_try { sapi_deactivate(SLS_C); - } + } zend_end_try(); - if (setjmp(EG(bailout))==0) { + zend_try { shutdown_memory_manager(CG(unclean_shutdown), 0); - } + } zend_end_try(); - if (setjmp(EG(bailout))==0) { + zend_try { zend_unset_timeout(); - } + } zend_end_try(); } /* }}} */ @@ -866,6 +868,7 @@ core_globals_id = ts_allocate_id(sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, NULL); core_globals = ts_resource(core_globals_id); #endif + EG(bailout_set) = 0; EG(error_reporting) = E_ALL & ~E_NOTICE; PG(header_is_being_sent) = 0; @@ -1239,55 +1242,51 @@ SLS_FETCH(); EG(exit_status) = 0; - if (php_handle_special_queries(SLS_C PLS_CC)) + if (php_handle_special_queries(SLS_C PLS_CC)) { return 0; + } #define OLD_CWD_SIZE 4096 old_cwd = do_alloca(OLD_CWD_SIZE); old_cwd[0] = '\0'; - if (setjmp(EG(bailout))!=0) { - if (old_cwd[0] != '\0') - VCWD_CHDIR(old_cwd); - free_alloca(old_cwd); - return EG(exit_status); - } - + zend_try { #ifdef PHP_WIN32 - UpdateIniFromRegistry(primary_file->filename); + UpdateIniFromRegistry(primary_file->filename); #endif - PG(during_request_startup) = 0; + PG(during_request_startup) = 0; - if (primary_file->type == ZEND_HANDLE_FILENAME - && primary_file->filename) { - VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1); - VCWD_CHDIR_FILE(primary_file->filename); - } + if (primary_file->type == ZEND_HANDLE_FILENAME + && primary_file->filename) { + VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1); + VCWD_CHDIR_FILE(primary_file->filename); + } - if (PG(auto_prepend_file) && PG(auto_prepend_file)[0]) { - prepend_file.filename = PG(auto_prepend_file); - prepend_file.opened_path = NULL; - prepend_file.free_filename = 0; - prepend_file.type = ZEND_HANDLE_FILENAME; - prepend_file_p = &prepend_file; - } else { - prepend_file_p = NULL; - } - if (PG(auto_append_file) && PG(auto_append_file)[0]) { - append_file.filename = PG(auto_append_file); - append_file.opened_path = NULL; - append_file.free_filename = 0; - append_file.type = ZEND_HANDLE_FILENAME; - append_file_p = &append_file; - } else { - append_file_p = NULL; - } - zend_execute_scripts(ZEND_REQUIRE CLS_CC ELS_CC, 3, prepend_file_p, primary_file, append_file_p); + if (PG(auto_prepend_file) && PG(auto_prepend_file)[0]) { + prepend_file.filename = PG(auto_prepend_file); + prepend_file.opened_path = NULL; + prepend_file.free_filename = 0; + prepend_file.type = ZEND_HANDLE_FILENAME; + prepend_file_p = &prepend_file; + } else { + prepend_file_p = NULL; + } + if (PG(auto_append_file) && PG(auto_append_file)[0]) { + append_file.filename = PG(auto_append_file); + append_file.opened_path = NULL; + append_file.free_filename = 0; + append_file.type = ZEND_HANDLE_FILENAME; + append_file_p = &append_file; + } else { + append_file_p = NULL; + } + zend_execute_scripts(ZEND_REQUIRE CLS_CC ELS_CC, 3, prepend_file_p, primary_file, append_file_p); + } zend_end_try(); - if (old_cwd[0] != '\0') + if (old_cwd[0] != '\0') { VCWD_CHDIR(old_cwd); + } free_alloca(old_cwd); - return EG(exit_status); } /* }}} */ @@ -1345,20 +1344,20 @@ zend_op_array *op_array; SLS_FETCH(); - if (setjmp(EG(bailout))!=0) { - return FAILURE; - } - - op_array = zend_compile_file(file, ZEND_INCLUDE CLS_CC); - zend_destroy_file_handle(file CLS_CC); + zend_try { + op_array = zend_compile_file(file, ZEND_INCLUDE CLS_CC); + zend_destroy_file_handle(file CLS_CC); + + if (op_array) { + destroy_op_array(op_array); + efree(op_array); + return SUCCESS; + } else { + return FAILURE; + } + } zend_end_try(); - if (op_array) { - destroy_op_array(op_array); - efree(op_array); - return SUCCESS; - } else { - return FAILURE; - } + return FAILURE; } /* }}} */ Index: php4/sapi/apache/mod_php4.c diff -u php4/sapi/apache/mod_php4.c:1.105 php4/sapi/apache/mod_php4.c:1.106 --- php4/sapi/apache/mod_php4.c:1.105 Wed Jun 6 09:05:53 2001 +++ php4/sapi/apache/mod_php4.c Sat Jul 21 10:27:55 2001 @@ -17,7 +17,7 @@ | PHP 4.0 patches by Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: mod_php4.c,v 1.105 2001/06/06 13:05:53 rasmus Exp $ */ +/* $Id: mod_php4.c,v 1.106 2001/07/21 14:27:55 zeev Exp $ */ #define NO_REGEX_EXTRA_H #ifdef WIN32 @@ -506,83 +506,83 @@ return OK; } - if (setjmp(EG(bailout))!=0) { - return OK; - } - /* We don't accept OPTIONS requests, but take everything else */ - if (r->method_number == M_OPTIONS) { - r->allowed |= (1 << METHODS) - 1; - return DECLINED; - } + zend_try { + /* We don't accept OPTIONS requests, but take everything else */ + if (r->method_number == M_OPTIONS) { + r->allowed |= (1 << METHODS) - 1; + return DECLINED; + } - /* Make sure file exists */ - if (filename == NULL && r->finfo.st_mode == 0) { - return DECLINED; - } + /* Make sure file exists */ + if (filename == NULL && r->finfo.st_mode == 0) { + return DECLINED; + } - per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php4_module); - if (per_dir_conf) { - zend_hash_apply((HashTable *) per_dir_conf, (int (*)(void *)) php_apache_alter_ini_entries); - } + per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php4_module); + if (per_dir_conf) { + zend_hash_apply((HashTable *) per_dir_conf, (int (*)(void *)) php_apache_alter_ini_entries); + } - /* If PHP parser engine has been turned off with an "engine off" - * directive, then decline to handle this request - */ - if (!AP(engine)) { - r->content_type = php_apache_get_default_mimetype(r SLS_CC); - r->allowed |= (1 << METHODS) - 1; - if (setjmp(EG(bailout))==0) { - zend_ini_deactivate(ELS_C); + /* If PHP parser engine has been turned off with an "engine off" + * directive, then decline to handle this request + */ + if (!AP(engine)) { + r->content_type = php_apache_get_default_mimetype(r SLS_CC); + r->allowed |= (1 << METHODS) - 1; + zend_try { + zend_ini_deactivate(ELS_C); + } zend_end_try(); + return DECLINED; + } + if (filename == NULL) { + filename = r->filename; } - return DECLINED; - } - if (filename == NULL) { - filename = r->filename; - } - /* Apache 1.2 has a more complex mechanism for reading POST data */ + /* Apache 1.2 has a more complex mechanism for reading POST data */ #if MODULE_MAGIC_NUMBER > 19961007 - if ((retval = setup_client_block(r, REQUEST_CHUNKED_ERROR))) { - if (setjmp(EG(bailout))==0) { - zend_ini_deactivate(ELS_C); + if ((retval = setup_client_block(r, REQUEST_CHUNKED_ERROR))) { + zend_try { + zend_ini_deactivate(ELS_C); + } zend_end_try(); + return retval; } - return retval; - } #endif - if (AP(last_modified)) { + if (AP(last_modified)) { #if MODULE_MAGIC_NUMBER < 19970912 - if ((retval = set_last_modified(r, r->finfo.st_mtime))) { - if (setjmp(EG(bailout))==0) { - zend_ini_deactivate(ELS_C); + if ((retval = set_last_modified(r, r->finfo.st_mtime))) { + zend_try { + zend_ini_deactivate(ELS_C); + } zend_end_try(); + return retval; } - return retval; - } #else - update_mtime (r, r->finfo.st_mtime); - set_last_modified(r); - set_etag(r); + update_mtime (r, r->finfo.st_mtime); + set_last_modified(r); + set_etag(r); #endif - } - /* Assume output will be of the default MIME type. Individual - scripts may change this later in the request. */ - r->content_type = php_apache_get_default_mimetype(r SLS_CC); + } + /* Assume output will be of the default MIME type. Individual + scripts may change this later in the request. */ + r->content_type = php_apache_get_default_mimetype(r SLS_CC); - /* Init timeout */ - hard_timeout("send", r); + /* Init timeout */ + hard_timeout("send", r); + + SG(server_context) = r; + + php_save_umask(); + add_common_vars(r); + add_cgi_vars(r); + + init_request_info(SLS_C); + apache_php_module_main(r, display_source_mode CLS_CC ELS_CC PLS_CC SLS_CC); + + /* Done, restore umask, turn off timeout, close file and return */ + php_restore_umask(); + kill_timeout(r); + } zend_end_try(); - SG(server_context) = r; - - php_save_umask(); - add_common_vars(r); - add_cgi_vars(r); - - init_request_info(SLS_C); - apache_php_module_main(r, display_source_mode CLS_CC ELS_CC PLS_CC SLS_CC); - - /* Done, restore umask, turn off timeout, close file and return */ - php_restore_umask(); - kill_timeout(r); return OK; } /* }}} */ Index: php4/sapi/apache/sapi_apache.c diff -u php4/sapi/apache/sapi_apache.c:1.25 php4/sapi/apache/sapi_apache.c:1.26 --- php4/sapi/apache/sapi_apache.c:1.25 Wed Jun 6 09:05:54 2001 +++ php4/sapi/apache/sapi_apache.c Sat Jul 21 10:27:55 2001 @@ -19,7 +19,7 @@ | Stig Bakken <ssb@fast.no> | +----------------------------------------------------------------------+ */ -/* $Id: sapi_apache.c,v 1.25 2001/06/06 13:05:54 rasmus Exp $ */ +/* $Id: sapi_apache.c,v 1.26 2001/07/21 14:27:55 zeev Exp $ */ #define NO_REGEX_EXTRA_H #ifdef WIN32 @@ -89,12 +89,11 @@ (void) php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC); } - - if (setjmp(EG(bailout))!=0) { - return OK; + + zend_try { + php_end_ob_buffers(1); + php_header(); /* Make sure headers have been sent */ } - php_end_ob_buffers(1); - php_header(); /* Make sure headers have been sent */ return (OK); } /* }}} */ Index: php4/sapi/cgi/cgi_main.c diff -u php4/sapi/cgi/cgi_main.c:1.116 php4/sapi/cgi/cgi_main.c:1.117 --- php4/sapi/cgi/cgi_main.c:1.116 Sun Jul 15 10:08:58 2001 +++ php4/sapi/cgi/cgi_main.c Sat Jul 21 10:27:55 2001 @@ -398,11 +398,6 @@ #endif #endif -#ifndef ZTS - if (setjmp(EG(bailout))!=0) { - return -1; - } -#endif #ifdef ZTS tsrm_startup(1,1,0, NULL); @@ -487,307 +482,308 @@ executor_globals = ts_resource(executor_globals_id); core_globals = ts_resource(core_globals_id); sapi_globals = ts_resource(sapi_globals_id); - if (setjmp(EG(bailout))!=0) { - return -1; - } #endif - if (!cgi) { - while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) { - switch (c) { - case '?': - no_headers = 1; - php_output_startup(); - php_output_activate(); - SG(headers_sent) = 1; - php_cgi_usage(argv[0]); - php_end_ob_buffers(1); - exit(1); - break; + zend_try { + if (!cgi) { + while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) { + switch (c) { + case '?': + no_headers = 1; + php_output_startup(); + php_output_activate(); + SG(headers_sent) = 1; + php_cgi_usage(argv[0]); + php_end_ob_buffers(1); + exit(1); + break; + } } + ap_php_optind = orig_optind; + ap_php_optarg = orig_optarg; } - ap_php_optind = orig_optind; - ap_php_optarg = orig_optarg; - } - init_request_info(SLS_C); - SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */ - CG(extended_info) = 0; + init_request_info(SLS_C); + SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */ + CG(extended_info) = 0; - SG(request_info).argv0 = argv0; + SG(request_info).argv0 = argv0; - zend_llist_init(&global_vars, sizeof(char *), NULL, 0); + zend_llist_init(&global_vars, sizeof(char *), NULL, 0); - if (!cgi) { /* never execute the arguments if you are a CGI */ - if (SG(request_info).argv0) { - free(SG(request_info).argv0); - SG(request_info).argv0 = NULL; - } - while ((c = ap_php_getopt(argc, argv, OPTSTRING)) != -1) { - switch (c) { - - case 'a': /* interactive mode */ - printf("Interactive mode enabled\n\n"); - interactive=1; - break; - - case 'C': /* don't chdir to the script directory */ - SG(options) |= SAPI_OPTION_NO_CHDIR; - break; - case 'd': /* define ini entries on command line */ - define_command_line_ini_entry(ap_php_optarg); - break; + if (!cgi) { /* never execute the arguments if you are a CGI */ + if (SG(request_info).argv0) { + free(SG(request_info).argv0); + SG(request_info).argv0 = NULL; + } + while ((c = ap_php_getopt(argc, argv, OPTSTRING)) != -1) { + switch (c) { - case 'e': /* enable extended info output */ - CG(extended_info) = 1; - break; - - case 'f': /* parse file */ - script_file = estrdup(ap_php_optarg); - no_headers = 1; - break; - - case 'g': /* define global variables on command line */ - { - char *arg = estrdup(ap_php_optarg); - - zend_llist_add_element(&global_vars, &arg); - } - break; + case 'a': /* interactive mode */ + printf("Interactive mode enabled\n\n"); + interactive=1; + break; + + case 'C': /* don't chdir to the script directory */ + SG(options) |= SAPI_OPTION_NO_CHDIR; + break; + case 'd': /* define ini entries on command line */ + define_command_line_ini_entry(ap_php_optarg); + break; + + case 'e': /* enable extended info output */ + CG(extended_info) = 1; + break; + + case 'f': /* parse file */ + script_file = estrdup(ap_php_optarg); + no_headers = 1; + break; + + case 'g': /* define global variables on command line */ + { + char *arg = estrdup(ap_php_optarg); + + zend_llist_add_element(&global_vars, &arg); + } + break; + + case 'h': /* help & quit */ + case '?': + no_headers = 1; + php_output_startup(); + php_output_activate(); + SG(headers_sent) = 1; + php_cgi_usage(argv[0]); + php_end_ob_buffers(1); + exit(1); + break; + + case 'i': /* php info & quit */ + if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { + php_module_shutdown(); + return FAILURE; + } + if (no_headers) { + SG(headers_sent) = 1; + SG(request_info).no_headers = 1; + } + php_print_info(0xFFFFFFFF); + exit(1); + break; + + case 'l': /* syntax check mode */ + no_headers = 1; + behavior=PHP_MODE_LINT; + break; - case 'h': /* help & quit */ - case '?': - no_headers = 1; + case 'm': /* list compiled in modules */ php_output_startup(); php_output_activate(); SG(headers_sent) = 1; - php_cgi_usage(argv[0]); + php_printf("Running PHP %s\n%s\n", PHP_VERSION , get_zend_version()); + php_printf("[PHP Modules]\n"); + zend_hash_apply_with_argument(&module_registry, (int (*)(void *, void *)) _print_module_info, NULL); + php_printf("\n[Zend Modules]\n"); + zend_llist_apply_with_argument(&zend_extensions, (void (*)(void *, void *)) _print_module_info, NULL); + php_printf("\n"); php_end_ob_buffers(1); exit(1); break; - case 'i': /* php info & quit */ - if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { - php_module_shutdown(); - return FAILURE; - } - if (no_headers) { - SG(headers_sent) = 1; - SG(request_info).no_headers = 1; - } - php_print_info(0xFFFFFFFF); - exit(1); - break; - - case 'l': /* syntax check mode */ - no_headers = 1; - behavior=PHP_MODE_LINT; - break; - - case 'm': /* list compiled in modules */ - php_output_startup(); - php_output_activate(); - SG(headers_sent) = 1; - php_printf("Running PHP %s\n%s\n", PHP_VERSION , get_zend_version()); - php_printf("[PHP Modules]\n"); - zend_hash_apply_with_argument(&module_registry, (int (*)(void *, void *)) _print_module_info, NULL); - php_printf("\n[Zend Modules]\n"); - zend_llist_apply_with_argument(&zend_extensions, (void (*)(void *, void *)) _print_module_info, NULL); - php_printf("\n"); - php_end_ob_buffers(1); - exit(1); - break; - #if 0 /* not yet operational, see also below ... */ - case 'n': /* generate indented source mode*/ - behavior=PHP_MODE_INDENT; - break; + case 'n': /* generate indented source mode*/ + behavior=PHP_MODE_INDENT; + break; #endif - case 'q': /* do not generate HTTP headers */ - no_headers = 1; - break; - - case 's': /* generate highlighted HTML from source */ - behavior=PHP_MODE_HIGHLIGHT; - break; - - case 'v': /* show php version & quit */ - no_headers = 1; - if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { - php_module_shutdown(); - return FAILURE; - } - if (no_headers) { - SG(headers_sent) = 1; - SG(request_info).no_headers = 1; - } - php_printf("%s\n", PHP_VERSION); - php_end_ob_buffers(1); - exit(1); - break; - - case 'z': /* load extension file */ - zend_load_extension(ap_php_optarg); - break; + case 'q': /* do not generate HTTP headers */ + no_headers = 1; + break; + + case 's': /* generate highlighted HTML from source */ + behavior=PHP_MODE_HIGHLIGHT; + break; + + case 'v': /* show php version & quit */ + no_headers = 1; + if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { + php_module_shutdown(); + return FAILURE; + } + if (no_headers) { + SG(headers_sent) = 1; + SG(request_info).no_headers = 1; + } + php_printf("%s\n", PHP_VERSION); + php_end_ob_buffers(1); + exit(1); + break; + + case 'z': /* load extension file */ + zend_load_extension(ap_php_optarg); + break; - default: - break; + default: + break; + } } - } - } /* not cgi */ + } /* not cgi */ - CG(interactive) = interactive; + CG(interactive) = interactive; - if (!cgi) { - if (!SG(request_info).query_string) { - len = 0; - if (script_file) { - len += strlen(script_file) + 1; - } - for (i = ap_php_optind; i < argc; i++) { - len += strlen(argv[i]) + 1; - } + if (!cgi) { + if (!SG(request_info).query_string) { + len = 0; + if (script_file) { + len += strlen(script_file) + 1; + } + for (i = ap_php_optind; i < argc; i++) { + len += strlen(argv[i]) + 1; + } - s = malloc(len + 1); /* leak - but only for command line version, so ok */ - *s = '\0'; /* we are pretending it came from the environment */ - if (script_file) { - strcpy(s, script_file); - if (ap_php_optind<argc) { - strcat(s, "+"); + s = malloc(len + 1); /* leak - but only for command line version, so ok */ + *s = '\0'; /* we are pretending it came from the environment */ + if (script_file) { + strcpy(s, script_file); + if (ap_php_optind<argc) { + strcat(s, "+"); + } } - } - for (i = ap_php_optind, len = 0; i < argc; i++) { - strcat(s, argv[i]); - if (i < (argc - 1)) { - strcat(s, "+"); + for (i = ap_php_optind, len = 0; i < argc; i++) { + strcat(s, argv[i]); + if (i < (argc - 1)) { + strcat(s, "+"); + } } + SG(request_info).query_string = s; } - SG(request_info).query_string = s; } - } - if (script_file) { - SG(request_info).path_translated = script_file; - } - - if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { - php_module_shutdown(); - return FAILURE; - } - if (no_headers) { - SG(headers_sent) = 1; - SG(request_info).no_headers = 1; - } - file_handle.filename = "-"; - file_handle.type = ZEND_HANDLE_FP; - file_handle.handle.fp = stdin; - file_handle.opened_path = NULL; - - /* This actually destructs the elements of the list - ugly hack */ - zend_llist_apply(&global_vars, (llist_apply_func_t) php_register_command_line_global_vars); - zend_llist_destroy(&global_vars); - - if (!cgi) { - if (!SG(request_info).path_translated && argc > ap_php_optind) { - SG(request_info).path_translated = estrdup(argv[ap_php_optind]); + if (script_file) { + SG(request_info).path_translated = script_file; } - } else { - /* If for some reason the CGI interface is not setting the - PATH_TRANSLATED correctly, SG(request_info).path_translated is NULL. - We still call php_fopen_primary_script, because if you set doc_root - or user_dir configuration directives, PATH_INFO is used to construct - the filename as a side effect of php_fopen_primary_script. - */ - char *env_path_translated=NULL; -#if DISCARD_PATH - env_path_translated = getenv("SCRIPT_FILENAME"); -#else - env_path_translated = getenv("PATH_TRANSLATED"); -#endif - if(env_path_translated) { - SG(request_info).path_translated = estrdup(env_path_translated); - } - } - if (cgi || SG(request_info).path_translated) { - file_handle.handle.fp = php_fopen_primary_script(); - file_handle.filename = SG(request_info).path_translated; - } - if (cgi && !file_handle.handle.fp) { - if(!argv0 || !(file_handle.handle.fp = VCWD_FOPEN(argv0, "rb"))) { - PUTS("No input file specified.\n"); - php_request_shutdown((void *) 0); + if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { php_module_shutdown(); return FAILURE; } - file_handle.filename = argv0; - } else if (file_handle.handle.fp && file_handle.handle.fp!=stdin) { - /* #!php support */ - c = fgetc(file_handle.handle.fp); - if (c == '#') { - while (c != 10 && c != 13) { - c = fgetc(file_handle.handle.fp); /* skip to end of line */ + if (no_headers) { + SG(headers_sent) = 1; + SG(request_info).no_headers = 1; + } + file_handle.filename = "-"; + file_handle.type = ZEND_HANDLE_FP; + file_handle.handle.fp = stdin; + file_handle.opened_path = NULL; + + /* This actually destructs the elements of the list - ugly hack */ + zend_llist_apply(&global_vars, (llist_apply_func_t) php_register_command_line_global_vars); + zend_llist_destroy(&global_vars); + + if (!cgi) { + if (!SG(request_info).path_translated && argc > ap_php_optind) { + SG(request_info).path_translated = estrdup(argv[ap_php_optind]); } - CG(zend_lineno)++; } else { - rewind(file_handle.handle.fp); + /* If for some reason the CGI interface is not setting the + PATH_TRANSLATED correctly, SG(request_info).path_translated is NULL. + We still call php_fopen_primary_script, because if you set doc_root + or user_dir configuration directives, PATH_INFO is used to construct + the filename as a side effect of php_fopen_primary_script. + */ + char *env_path_translated=NULL; +#if DISCARD_PATH + env_path_translated = getenv("SCRIPT_FILENAME"); +#else + env_path_translated = getenv("PATH_TRANSLATED"); +#endif + if(env_path_translated) { + SG(request_info).path_translated = estrdup(env_path_translated); + } + } + if (cgi || SG(request_info).path_translated) { + file_handle.handle.fp = php_fopen_primary_script(); + file_handle.filename = SG(request_info).path_translated; } - } - file_handle.free_filename = 0; - switch (behavior) { - case PHP_MODE_STANDARD: - exit_status = php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC); - break; - case PHP_MODE_LINT: - PG(during_request_startup) = 0; - exit_status = php_lint_script(&file_handle CLS_CC ELS_CC PLS_CC); - if (exit_status==SUCCESS) { - zend_printf("No syntax errors detected in %s\n", file_handle.filename); - } else { - zend_printf("Errors parsing %s\n", file_handle.filename); + if (cgi && !file_handle.handle.fp) { + if(!argv0 || !(file_handle.handle.fp = VCWD_FOPEN(argv0, "rb"))) { + PUTS("No input file specified.\n"); + php_request_shutdown((void *) 0); + php_module_shutdown(); + return FAILURE; } - break; - case PHP_MODE_HIGHLIGHT: - { - zend_syntax_highlighter_ini syntax_highlighter_ini; - - if (open_file_for_scanning(&file_handle CLS_CC)==SUCCESS) { - php_get_highlight_struct(&syntax_highlighter_ini); - zend_highlight(&syntax_highlighter_ini); - fclose(file_handle.handle.fp); + file_handle.filename = argv0; + } else if (file_handle.handle.fp && file_handle.handle.fp!=stdin) { + /* #!php support */ + c = fgetc(file_handle.handle.fp); + if (c == '#') { + while (c != 10 && c != 13) { + c = fgetc(file_handle.handle.fp); /* skip to end of line */ } - return SUCCESS; + CG(zend_lineno)++; + } else { + rewind(file_handle.handle.fp); } - break; + } + + file_handle.free_filename = 0; + switch (behavior) { + case PHP_MODE_STANDARD: + exit_status = php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC); + break; + case PHP_MODE_LINT: + PG(during_request_startup) = 0; + exit_status = php_lint_script(&file_handle CLS_CC ELS_CC PLS_CC); + if (exit_status==SUCCESS) { + zend_printf("No syntax errors detected in %s\n", file_handle.filename); + } else { + zend_printf("Errors parsing %s\n", file_handle.filename); + } + break; + case PHP_MODE_HIGHLIGHT: + { + zend_syntax_highlighter_ini syntax_highlighter_ini; + + if (open_file_for_scanning(&file_handle CLS_CC)==SUCCESS) { + php_get_highlight_struct(&syntax_highlighter_ini); + zend_highlight(&syntax_highlighter_ini); + fclose(file_handle.handle.fp); + } + return SUCCESS; + } + break; #if 0 - /* Zeev might want to do something with this one day */ - case PHP_MODE_INDENT: - open_file_for_scanning(&file_handle CLS_CC); - zend_indent(); - fclose(file_handle.handle.fp); - return SUCCESS; - break; + /* Zeev might want to do something with this one day */ + case PHP_MODE_INDENT: + open_file_for_scanning(&file_handle CLS_CC); + zend_indent(); + fclose(file_handle.handle.fp); + return SUCCESS; + break; #endif - } + } - if (SG(request_info).path_translated) { - persist_alloc(SG(request_info).path_translated); - } + if (SG(request_info).path_translated) { + persist_alloc(SG(request_info).path_translated); + } - php_request_shutdown((void *) 0); - php_module_shutdown(); + php_request_shutdown((void *) 0); + php_module_shutdown(); - STR_FREE(SG(request_info).path_translated); + STR_FREE(SG(request_info).path_translated); - if (cgi_sapi_module.php_ini_path_override) { - free(cgi_sapi_module.php_ini_path_override); - } + if (cgi_sapi_module.php_ini_path_override) { + free(cgi_sapi_module.php_ini_path_override); + } #ifdef ZTS - tsrm_shutdown(); + tsrm_shutdown(); #endif + } zend_catch { + exit_status = -1; + } zend_end_try(); return exit_status; } Index: php4/sapi/isapi/php4isapi.c diff -u php4/sapi/isapi/php4isapi.c:1.70 php4/sapi/isapi/php4isapi.c:1.71 --- php4/sapi/isapi/php4isapi.c:1.70 Wed Mar 7 05:28:00 2001 +++ php4/sapi/isapi/php4isapi.c Sat Jul 21 10:27:56 2001 @@ -43,13 +43,16 @@ # define GetLastError() errno #endif +#ifdef PHP_WIN32 +#define PHP_ENABLE_SEH +#endif + /* uncomment the following lines to turn off exception trapping when running under a debugger - #ifdef _DEBUG -#define NO_EXCEPTION_HANDLERS +#undef PHP_ENABLE_SEH #endif */ @@ -701,11 +704,10 @@ } #ifdef PHP_WIN32 -/* - ___except can only call a function, so we have to do this - to retrieve the pointer. +/* ep is accessible only in the context of the __except expression, + * so we have to call this function to obtain it. */ -BOOL exceptionhandler(LPEXCEPTION_POINTERS *e,LPEXCEPTION_POINTERS ep) +BOOL exceptionhandler(LPEXCEPTION_POINTERS *e, LPEXCEPTION_POINTERS ep) { *e=ep; return TRUE; @@ -720,107 +722,105 @@ CLS_FETCH(); ELS_FETCH(); PLS_FETCH(); -#if !defined (NO_EXCEPTION_HANDLERS) && defined(PHP_WIN32) +#ifdef PHP_ENABLE_SEH LPEXCEPTION_POINTERS e; #endif - if (setjmp(EG(bailout))!=0) { - php_request_shutdown(NULL); - return HSE_STATUS_ERROR; - } - -#if !defined (NO_EXCEPTION_HANDLERS) - __try { + zend_try { +#ifdef PHP_ENABLE_SEH + __try { #endif - init_request_info(sapi_globals, lpECB); - SG(server_context) = lpECB; + init_request_info(sapi_globals, lpECB); + SG(server_context) = lpECB; #ifdef WITH_ZEUS - /* PATH_TRANSLATED can contain extra PATH_INFO stuff after the - * file being loaded, so we must use SCRIPT_FILENAME instead - */ - file_handle.filename = (char *)emalloc( ISAPI_SERVER_VAR_BUF_SIZE ); - file_handle.free_filename = 1; - { - DWORD filename_len = ISAPI_SERVER_VAR_BUF_SIZE; - if( !lpECB->GetServerVariable(lpECB->ConnID, "SCRIPT_FILENAME", file_handle.filename, &filename_len) || file_handle.filename[ 0 ] == '\0' ) { - /* If we're running on an earlier version of Zeus, this - * variable won't be present, so fall back to old behaviour. - */ - efree( file_handle.filename ); - file_handle.filename = sapi_globals->request_info.path_translated; - file_handle.free_filename = 0; - } - } -#else - file_handle.filename = sapi_globals->request_info.path_translated; - file_handle.free_filename = 0; -#endif - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.opened_path = NULL; - - php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC); - php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC); - if (SG(request_info).cookie_data) { - efree(SG(request_info).cookie_data); - } -#if !defined (NO_EXCEPTION_HANDLERS) -#ifdef PHP_WIN32 - } __except(exceptionhandler(&e,GetExceptionInformation())) { + /* PATH_TRANSLATED can contain extra PATH_INFO stuff after the + * file being loaded, so we must use SCRIPT_FILENAME instead + */ + file_handle.filename = (char *)emalloc( ISAPI_SERVER_VAR_BUF_SIZE ); + file_handle.free_filename = 1; + { + DWORD filename_len = ISAPI_SERVER_VAR_BUF_SIZE; + if( !lpECB->GetServerVariable(lpECB->ConnID, "SCRIPT_FILENAME", file_handle.filename, &filename_len) || file_handle.filename[ 0 ] == '\0' ) { + /* If we're running on an earlier version of Zeus, this + * variable won't be present, so fall back to old behaviour. + */ + efree( file_handle.filename ); + file_handle.filename = sapi_globals->request_info.path_translated; + file_handle.free_filename = 0; + } + } #else - } __except(EXCEPTION_EXECUTE_HANDLER) { + file_handle.filename = sapi_globals->request_info.path_translated; + file_handle.free_filename = 0; #endif -#ifdef PHP_WIN32 - char buf[1024]; - if (_exception_code()==EXCEPTION_STACK_OVERFLOW) { - LPBYTE lpPage; - static SYSTEM_INFO si; - static MEMORY_BASIC_INFORMATION mi; - static DWORD dwOldProtect; + file_handle.type = ZEND_HANDLE_FILENAME; + file_handle.opened_path = NULL; - GetSystemInfo(&si); - - /* Get page ESP is pointing to */ - _asm mov lpPage, esp; - - /* Get stack allocation base */ - VirtualQuery(lpPage, &mi, sizeof(mi)); - - /* Go to the page below the current page */ - lpPage = (LPBYTE) (mi.BaseAddress) - si.dwPageSize; + php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC); + php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC); + if (SG(request_info).cookie_data) { + efree(SG(request_info).cookie_data); + } +#ifdef PHP_ENABLE_SEH + } __except(exceptionhandler(&e, GetExceptionInformation())) { + char buf[1024]; + if (_exception_code()==EXCEPTION_STACK_OVERFLOW) { + LPBYTE lpPage; + static SYSTEM_INFO si; + static MEMORY_BASIC_INFORMATION mi; + static DWORD dwOldProtect; + + GetSystemInfo(&si); + + /* Get page ESP is pointing to */ + _asm mov lpPage, esp; + + /* Get stack allocation base */ + VirtualQuery(lpPage, &mi, sizeof(mi)); + + /* Go to the page below the current page */ + lpPage = (LPBYTE) (mi.BaseAddress) - si.dwPageSize; + + /* Free pages below current page */ + if (!VirtualFree(mi.AllocationBase, (LPBYTE)lpPage - (LPBYTE) mi.AllocationBase, MEM_DECOMMIT)) { + _endthread(); + } - /* Free pages below current page */ - if (!VirtualFree(mi.AllocationBase, (LPBYTE)lpPage - (LPBYTE) mi.AllocationBase, MEM_DECOMMIT)) { - _endthread(); - } + /* Restore the guard page */ + if (!VirtualProtect(lpPage, si.dwPageSize, PAGE_GUARD | PAGE_READWRITE, &dwOldProtect)) { + _endthread(); + } - /* Restore the guard page */ - if (!VirtualProtect(lpPage, si.dwPageSize, PAGE_GUARD | PAGE_READWRITE, &dwOldProtect)) { - _endthread(); + CG(unclean_shutdown)=1; + _snprintf(buf,sizeof(buf)-1,"PHP has encountered a Stack overflow"); + php_isapi_report_exception(buf, strlen(buf) SLS_CC); + } else if (_exception_code()==EXCEPTION_ACCESS_VIOLATION) { + _snprintf(buf,sizeof(buf)-1,"PHP has encountered an Access Violation at %p",e->ExceptionRecord->ExceptionAddress); + php_isapi_report_exception(buf, strlen(buf) SLS_CC); + my_endthread(); + } else { + _snprintf(buf,sizeof(buf)-1,"PHP has encountered an Unhandled Exception Code %d at %p",e->ExceptionRecord->ExceptionCode , e->ExceptionRecord->ExceptionAddress); + php_isapi_report_exception(buf, strlen(buf) SLS_CC); + my_endthread(); } - - CG(unclean_shutdown)=1; - _snprintf(buf,sizeof(buf)-1,"PHP has encountered a Stack overflow"); - php_isapi_report_exception(buf, strlen(buf) SLS_CC); - } else if (_exception_code()==EXCEPTION_ACCESS_VIOLATION) { - _snprintf(buf,sizeof(buf)-1,"PHP has encountered an Access Violation at %p",e->ExceptionRecord->ExceptionAddress); - php_isapi_report_exception(buf, strlen(buf) SLS_CC); - my_endthread(); - } else { - _snprintf(buf,sizeof(buf)-1,"PHP has encountered an Unhandled Exception Code %d at %p",e->ExceptionRecord->ExceptionCode , e->ExceptionRecord->ExceptionAddress); - php_isapi_report_exception(buf, strlen(buf) SLS_CC); +#endif + } +#ifdef PHP_ENABLE_SEH + __try { + php_request_shutdown(NULL); + } __except(EXCEPTION_EXECUTE_HANDLER) { my_endthread(); } -#endif - } - __try { - php_request_shutdown(NULL); - } __except(EXCEPTION_EXECUTE_HANDLER) { - my_endthread(); - } #else php_request_shutdown(NULL); #endif + } zend_catch { + zend_try { + php_request_shutdown(NULL); + } zend_end_try(); + return HSE_STATUS_ERROR; + } zend_end_try(); return HSE_STATUS_SUCCESS; } Index: php4/sapi/pi3web/pi3web_sapi.c diff -u php4/sapi/pi3web/pi3web_sapi.c:1.21 php4/sapi/pi3web/pi3web_sapi.c:1.22 --- php4/sapi/pi3web/pi3web_sapi.c:1.21 Sat Jul 21 08:23:23 2001 +++ php4/sapi/pi3web/pi3web_sapi.c Sat Jul 21 10:27:56 2001 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pi3web_sapi.c,v 1.21 2001/07/21 12:23:23 holger Exp $ */ +/* $Id: pi3web_sapi.c,v 1.22 2001/07/21 14:27:56 zeev Exp $ */ #include "pi3web_sapi.h" #include "php.h" @@ -78,7 +78,7 @@ PUTS("<table border=0 cellpadding=3 cellspacing=1 width=600 align=center>\n"); PUTS("<tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR "\">Pi3Web Server Information</th></tr>\n"); php_info_print_table_header(2, "Information Field", "Value"); - php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c,v 1.21 2001/07/21 12:23:23 holger Exp $"); + php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c,v 1.22 2001/07/21 14:27:56 zeev Exp $"); php_info_print_table_row(2, "Server Name Stamp", HTTPCore_getServerStamp()); snprintf(variable_buf, 511, "%d", HTTPCore_debugEnabled()); php_info_print_table_row(2, "Debug Enabled", variable_buf); @@ -382,63 +382,65 @@ ELS_FETCH(); PLS_FETCH(); - if (setjmp( EG(bailout)) != 0 ) return PIAPI_ERROR; - - file_handle.filename = lpCB->lpszFileName; - file_handle.free_filename = 0; - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.opened_path = NULL; - - CG(extended_info) = 0; - init_request_info(sapi_globals, lpCB); - php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC); - - hash_pi3web_variables(ELS_C SLS_CC); - - switch ( lpCB->dwBehavior ) { - case PHP_MODE_STANDARD: - iRet = ( php_execute_script( &file_handle CLS_CC ELS_CC PLS_CC ) == SUCCESS ) ? - PIAPI_COMPLETED : PIAPI_ERROR; - break; - case PHP_MODE_HIGHLIGHT: { - zend_syntax_highlighter_ini syntax_highlighter_ini; - if ( open_file_for_scanning( &file_handle CLS_CC ) == SUCCESS ) - { - php_get_highlight_struct( &syntax_highlighter_ini ); - zend_highlight( &syntax_highlighter_ini ); - } - else - { - iRet = PIAPI_ERROR; - }; - }; - break; - case PHP_MODE_INDENT: - header_line = (char *)estrdup("Content-Type: text/plain"); - sapi_add_header_ex(header_line, strlen(header_line), 1, 1); - if ( open_file_for_scanning( &file_handle CLS_CC ) == SUCCESS ) - { - zend_indent(); - } - else - { - iRet = PIAPI_ERROR; + zend_try { + file_handle.filename = lpCB->lpszFileName; + file_handle.free_filename = 0; + file_handle.type = ZEND_HANDLE_FILENAME; + file_handle.opened_path = NULL; + + CG(extended_info) = 0; + init_request_info(sapi_globals, lpCB); + php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC); + + hash_pi3web_variables(ELS_C SLS_CC); + + switch ( lpCB->dwBehavior ) { + case PHP_MODE_STANDARD: + iRet = ( php_execute_script( &file_handle CLS_CC ELS_CC PLS_CC ) == SUCCESS ) ? + PIAPI_COMPLETED : PIAPI_ERROR; + break; + case PHP_MODE_HIGHLIGHT: { + zend_syntax_highlighter_ini syntax_highlighter_ini; + if ( open_file_for_scanning( &file_handle CLS_CC ) == SUCCESS ) + { + php_get_highlight_struct( &syntax_highlighter_ini ); + zend_highlight( &syntax_highlighter_ini ); + } + else + { + iRet = PIAPI_ERROR; + }; }; - efree(header_line); - break; - case PHP_MODE_LINT: - iRet = (php_lint_script(&file_handle CLS_CC ELS_CC PLS_CC) == SUCCESS) ? - PIAPI_COMPLETED : PIAPI_ERROR; - break; - default: - iRet = PIAPI_ERROR;; - } - - if (SG(request_info).cookie_data) { - efree(SG(request_info).cookie_data); - }; + break; + case PHP_MODE_INDENT: + header_line = (char *)estrdup("Content-Type: text/plain"); + sapi_add_header_ex(header_line, strlen(header_line), 1, 1); + if ( open_file_for_scanning( &file_handle CLS_CC ) == SUCCESS ) + { + zend_indent(); + } + else + { + iRet = PIAPI_ERROR; + }; + efree(header_line); + break; + case PHP_MODE_LINT: + iRet = (php_lint_script(&file_handle CLS_CC ELS_CC PLS_CC) == SUCCESS) ? + PIAPI_COMPLETED : PIAPI_ERROR; + break; + default: + iRet = PIAPI_ERROR;; + } - php_request_shutdown(NULL); + if (SG(request_info).cookie_data) { + efree(SG(request_info).cookie_data); + }; + + php_request_shutdown(NULL); + } zend_catch { + iRet = PIAPI_ERROR; + } zend_end_try(); return iRet; } Index: php4/sapi/servlet/servlet.c diff -u php4/sapi/servlet/servlet.c:1.46 php4/sapi/servlet/servlet.c:1.47 --- php4/sapi/servlet/servlet.c:1.46 Mon Feb 26 01:07:37 2001 +++ php4/sapi/servlet/servlet.c Sat Jul 21 10:27:56 2001 @@ -251,11 +251,6 @@ #ifdef ZTS tsrm_startup(1, 1, 0, NULL); -#else - if (setjmp(EG(bailout))!=0) { - ThrowServletException(jenv,"bailout"); - return; - } #endif sapi_startup(&servlet_sapi_module); @@ -319,7 +314,6 @@ jstring contentType, jint contentLength, jstring authUser, jboolean display_source_mode) { - zend_file_handle file_handle; #ifndef VIRTUAL_DIR char cwd[MAXPATHLEN]; @@ -329,95 +323,92 @@ CLS_FETCH(); ELS_FETCH(); -#ifdef ZTS - if (setjmp(EG(bailout))!=0) { - ThrowServletException(jenv,"bailout"); - return; - } -#endif - - SG(server_context) = emalloc(sizeof(servlet_request)); - ((servlet_request*)SG(server_context))->jenv=jenv; - ((servlet_request*)SG(server_context))->servlet=self; - ((servlet_request*)SG(server_context))->cookies=0; - - CG(extended_info) = 0; - - /* - * Initialize the request - */ - SETSTRING( SG(request_info).auth_user, authUser ); - SETSTRING( SG(request_info).request_method, requestMethod ); - SETSTRING( SG(request_info).query_string, queryString ); - SETSTRING( SG(request_info).request_uri, requestURI ); - SETSTRING( SG(request_info).content_type, contentType ); - SG(sapi_headers).http_response_code = 200; - SG(request_info).content_length = contentLength; - SG(request_info).auth_password = NULL; - if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { - ThrowServletException(jenv,"request startup failure"); - return; - } - - /* - * Parse the file - */ - SETSTRING( SG(request_info).path_translated, pathTranslated ); + zend_try { + SG(server_context) = emalloc(sizeof(servlet_request)); + ((servlet_request*)SG(server_context))->jenv=jenv; + ((servlet_request*)SG(server_context))->servlet=self; + ((servlet_request*)SG(server_context))->cookies=0; + + CG(extended_info) = 0; + + /* + * Initialize the request + */ + SETSTRING( SG(request_info).auth_user, authUser ); + SETSTRING( SG(request_info).request_method, requestMethod ); + SETSTRING( SG(request_info).query_string, queryString ); + SETSTRING( SG(request_info).request_uri, requestURI ); + SETSTRING( SG(request_info).content_type, contentType ); + SG(sapi_headers).http_response_code = 200; + SG(request_info).content_length = contentLength; + SG(request_info).auth_password = NULL; + if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { + ThrowServletException(jenv,"request startup failure"); + return; + } + + /* + * Parse the file + */ + SETSTRING( SG(request_info).path_translated, pathTranslated ); #ifdef VIRTUAL_DIR - file_handle.handle.fp = php_fopen_primary_script(); + file_handle.handle.fp = php_fopen_primary_script(); #else - /* - * The java runtime doesn't like the working directory to be - * changed, so save it and change it back as quickly as possible - * in the hopes that Java doesn't notice. - */ - getcwd(cwd,MAXPATHLEN); - file_handle.handle.fp = php_fopen_primary_script(); - chdir(cwd); + /* + * The java runtime doesn't like the working directory to be + * changed, so save it and change it back as quickly as possible + * in the hopes that Java doesn't notice. + */ + getcwd(cwd,MAXPATHLEN); + file_handle.handle.fp = php_fopen_primary_script(); + chdir(cwd); #endif - file_handle.filename = SG(request_info).path_translated; - file_handle.opened_path = NULL; - file_handle.free_filename = 0; - file_handle.type = ZEND_HANDLE_FP; - - if (!file_handle.handle.fp) { - php_request_shutdown((void *) 0); - php_module_shutdown(); - ThrowIOException(jenv,file_handle.filename); - return; - } + file_handle.filename = SG(request_info).path_translated; + file_handle.opened_path = NULL; + file_handle.free_filename = 0; + file_handle.type = ZEND_HANDLE_FP; + + if (!file_handle.handle.fp) { + php_request_shutdown((void *) 0); + php_module_shutdown(); + ThrowIOException(jenv,file_handle.filename); + return; + } + + /* + * Execute the request + */ + Java_net_php_reflect_setEnv(jenv, 0); + + if (display_source_mode) { + zend_syntax_highlighter_ini syntax_highlighter_ini; + + if (open_file_for_scanning(&file_handle CLS_CC)==SUCCESS) { + php_get_highlight_struct(&syntax_highlighter_ini); + sapi_send_headers(); + zend_highlight(&syntax_highlighter_ini); + } + } else { + php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC); + php_header(); /* Make sure headers have been sent */ + } + + /* + * Clean up + */ + + FREESTRING(SG(request_info).request_method); + FREESTRING(SG(request_info).query_string); + FREESTRING(SG(request_info).request_uri); + FREESTRING(SG(request_info).path_translated); + FREESTRING(SG(request_info).content_type); + FREESTRING(((servlet_request*)SG(server_context))->cookies); + efree(SG(server_context)); + SG(server_context)=0; - /* - * Execute the request - */ - Java_net_php_reflect_setEnv(jenv, 0); - - if (display_source_mode) { - zend_syntax_highlighter_ini syntax_highlighter_ini; - - if (open_file_for_scanning(&file_handle CLS_CC)==SUCCESS) { - php_get_highlight_struct(&syntax_highlighter_ini); - sapi_send_headers(); - zend_highlight(&syntax_highlighter_ini); - } - } else { - php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC); - php_header(); /* Make sure headers have been sent */ - } - - /* - * Clean up - */ - - FREESTRING(SG(request_info).request_method); - FREESTRING(SG(request_info).query_string); - FREESTRING(SG(request_info).request_uri); - FREESTRING(SG(request_info).path_translated); - FREESTRING(SG(request_info).content_type); - FREESTRING(((servlet_request*)SG(server_context))->cookies); - efree(SG(server_context)); - SG(server_context)=0; - - if (!display_source_mode) php_request_shutdown((void *) 0); + if (!display_source_mode) php_request_shutdown((void *) 0); + } zend_catch { + ThrowServletException(jenv,"bailout"); + } zend_end_try(); }
« previous php.cvs (#6304) next »