From 19a5ac93b40016ccb166e674a9c55cd297f5b1bf Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sat, 9 Nov 2013 21:07:04 -0200 Subject: [PATCH] - WS changes --- phpdbg.c | 169 +++++++++++++++++++++++++++---------------------------- 1 file changed, 83 insertions(+), 86 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 7a9b419b9f..36319df2ed 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -15,6 +15,7 @@ | Authors: Joe Watkins | +----------------------------------------------------------------------+ */ + #include "php.h" #include "php_globals.h" #include "php_variables.h" @@ -23,11 +24,8 @@ #include "zend_ini_scanner.h" #include "zend_globals.h" #include "zend_stream.h" - #include "SAPI.h" - #include - #include "php_main.h" static zend_module_entry sapi_phpdbg_module_entry = { @@ -43,7 +41,8 @@ static zend_module_entry sapi_phpdbg_module_entry = { STANDARD_MODULE_PROPERTIES }; -static inline int php_sapi_phpdbg_module_startup(sapi_module_struct *module) { /* {{{ */ +static inline int php_sapi_phpdbg_module_startup(sapi_module_struct *module) /* {{{ */ +{ if (php_module_startup(module, &sapi_phpdbg_module_entry, 1) == FAILURE) { return FAILURE; } @@ -53,117 +52,115 @@ static inline int php_sapi_phpdbg_module_startup(sapi_module_struct *module) { / /* {{{ sapi_module_struct phpdbg_sapi_module */ static sapi_module_struct phpdbg_sapi_module = { - "phpdbg", /* name */ - "phpdbg", /* pretty name */ + "phpdbg", /* name */ + "phpdbg", /* pretty name */ php_sapi_phpdbg_module_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ - NULL, /* activate */ - NULL, /* deactivate */ + NULL, /* activate */ + NULL, /* deactivate */ - NULL, /* unbuffered write */ - NULL, /* flush */ - NULL, /* get uid */ - NULL, /* getenv */ + NULL, /* unbuffered write */ + NULL, /* flush */ + NULL, /* get uid */ + NULL, /* getenv */ - php_error, /* error handler */ + php_error, /* error handler */ - NULL, /* header handler */ - NULL, /* send headers handler */ - NULL, /* send header handler */ + NULL, /* header handler */ + NULL, /* send headers handler */ + NULL, /* send header handler */ - NULL, /* read POST data */ - NULL, /* read Cookies */ + NULL, /* read POST data */ + NULL, /* read Cookies */ - NULL, /* register server variables */ - NULL, /* Log message */ - NULL, /* Get request time */ - NULL, /* Child terminate */ + NULL, /* register server variables */ + NULL, /* Log message */ + NULL, /* Get request time */ + NULL, /* Child terminate */ STANDARD_SAPI_MODULE_PROPERTIES }; /* }}} */ -static inline int zend_machine(int argc, char **argv TSRMLS_DC) { /* {{{ */ +static inline int zend_machine(int argc, char **argv TSRMLS_DC) /* {{{ */ +{ php_printf("Hello World :)\n"); } /* }}} */ -int main(int argc, char **argv) { /* {{{ */ +int main(int argc, char **argv) /* {{{ */ +{ #ifdef ZTS - void ***tsrm_ls; - { - tsrm_startup( - 1, 1, 0, NULL); - - tsrm_ls = ts_resource(0); - } + void ***tsrm_ls; + tsrm_startup(1, 1, 0, NULL); + + tsrm_ls = ts_resource(0); #endif - sapi_module_struct *phpdbg = &phpdbg_sapi_module; - + sapi_module_struct *phpdbg = &phpdbg_sapi_module; + #ifdef PHP_WIN32 - _fmode = _O_BINARY; /*sets default for file streams to binary */ - setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */ - setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */ - setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */ + _fmode = _O_BINARY; /* sets default for file streams to binary */ + setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */ + setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */ + setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */ #endif - phpdbg->executable_location = argv[0]; - - sapi_startup(phpdbg); + phpdbg->executable_location = argv[0]; + + sapi_startup(phpdbg); + + if (phpdbg->startup(phpdbg) == SUCCESS) { + zend_activate(TSRMLS_C); - if (phpdbg->startup(phpdbg) == SUCCESS) - { - zend_activate(TSRMLS_C); - #ifdef ZEND_SIGNALS - zend_try { - zend_signals_activate(TSRMLS_C); - } zend_end_try(); + zend_try { + zend_signals_activate(TSRMLS_C); + } zend_end_try(); #endif - PG(modules_activated)=0; - - zend_try { - zend_activate_modules(TSRMLS_C); - } zend_end_try(); - - /* START: ZEND INITIALIZED */ - { - /* do the thing */ - zend_machine(argc, argv TSRMLS_CC); - } - /* END: ZEND BLOCK */ - - if (PG(modules_activated)) { - zend_try { - zend_deactivate_modules(TSRMLS_C); - } zend_end_try(); - } - - zend_deactivate(TSRMLS_C); - - zend_try { - zend_post_deactivate_modules(TSRMLS_C); - } zend_end_try(); - + PG(modules_activated) = 0; + + zend_try { + zend_activate_modules(TSRMLS_C); + } zend_end_try(); + + /* START: ZEND INITIALIZED */ + { + /* do the thing */ + zend_machine(argc, argv TSRMLS_CC); + } + /* END: ZEND BLOCK */ + + if (PG(modules_activated)) { + zend_try { + zend_deactivate_modules(TSRMLS_C); + } zend_end_try(); + } + + zend_deactivate(TSRMLS_C); + + zend_try { + zend_post_deactivate_modules(TSRMLS_C); + } zend_end_try(); + #ifdef ZEND_SIGNALS - zend_try { - zend_signal_deactivate(TSRMLS_C); - } zend_end_try(); + zend_try { + zend_signal_deactivate(TSRMLS_C); + } zend_end_try(); #endif - zend_try { - shutdown_memory_manager(CG(unclean_shutdown), 0 TSRMLS_CC); - } zend_end_try(); - - php_module_shutdown(TSRMLS_C); - - sapi_shutdown(); - } - + zend_try { + shutdown_memory_manager(CG(unclean_shutdown), 0 TSRMLS_CC); + } zend_end_try(); + + php_module_shutdown(TSRMLS_C); + + sapi_shutdown(); + } + #ifdef ZTS - tsrm_shutdown(); + tsrm_shutdown(); #endif - return 0; + return 0; } /* }}} */ -- 2.40.0