From: krakjoe Date: Sat, 9 Nov 2013 22:35:03 +0000 (+0000) Subject: import X-Git-Tag: php-5.6.0alpha1~110^2~561 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2fee7dce773dc365ef720d41568bcc2914065413;p=php import --- diff --git a/Makefile.frag b/Makefile.frag new file mode 100644 index 0000000000..2a56b947f8 --- /dev/null +++ b/Makefile.frag @@ -0,0 +1,11 @@ +phpdbg: $(BUILD_BINARY) + +$(BUILD_BINARY): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS) + $(BUILD_PHPDBG) + +install-phpdbg: $(BUILD_BINARY) + @echo "Installing phpdbg binary: $(INSTALL_ROOT)$(bindir)/" + @$(mkinstalldirs) $(INSTALL_ROOT)$(bindir) + @$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/log + @$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/run + @$(INSTALL) -m 0755 $(BUILD_BINARY) $(INSTALL_ROOT)$(sbindir)/$(program_prefix)phpdbg$(program_suffix)$(EXEEXT) diff --git a/config.m4 b/config.m4 new file mode 100644 index 0000000000..94e8727330 --- /dev/null +++ b/config.m4 @@ -0,0 +1,34 @@ +dnl +dnl $Id$ +dnl + +PHP_ARG_ENABLE(phpdbg, for phpdbg support, +[ --enable-phpdbg Build phpdbg], no, no) + +if test "$PHP_PHPDBG" != "no"; then + AC_DEFINE(HAVE_PHPDBG, 1, [ ]) + + PHP_PHPDBG_CFLAGS=-I$abs_srcdir/sapi/phpdbg + PHP_PHPDBG_FILES=phpdbg.c + + PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/phpdbg/Makefile.frag]) + PHP_SELECT_SAPI(phpdbg, program, $PHP_PHPDBG_FILES, $PHP_PHPDBG_CFLAGS, [$(SAPI_PHPDBG_PATH)]) + + BUILD_BINARY="sapi/phpdbg/phpdbg" + BUILD_PHPDBG="\$(LIBTOOL) --mode=link \ + \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \ + \$(PHP_GLOBAL_OBJS) \ + \$(PHP_BINARY_OBJS) \ + \$(PHP_PHPDBG_OBJS) \ + \$(EXTRA_LIBS) \ + \$(PHPDBG_EXTRA_LIBS) \ + \$(ZEND_EXTRA_LIBS) \ + -o \$(BUILD_BINARY)" + + PHP_SUBST(BUILD_BINARY) + PHP_SUBST(BUILD_PHPDBG) +fi + +dnl ## Local Variables: +dnl ## tab-width: 4 +dnl ## End: diff --git a/phpdbg.c b/phpdbg.c new file mode 100644 index 0000000000..ba1b0a3e75 --- /dev/null +++ b/phpdbg.c @@ -0,0 +1,160 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Joe Watkins | + +----------------------------------------------------------------------+ +*/ +#include "php.h" +#include "php_globals.h" +#include "php_variables.h" +#include "zend_modules.h" +#include "php.h" +#include "zend_ini_scanner.h" +#include "zend_globals.h" +#include "zend_stream.h" + +#include "SAPI.h" +#include "sapi/cgi/fastcgi.h" + +#include + +#include "php_main.h" + +static zend_module_entry sapi_server_module_entry = { + STANDARD_MODULE_HEADER, + "server", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + "0.1", + STANDARD_MODULE_PROPERTIES +}; + +static inline int php_sapi_server_module_startup(sapi_module_struct *module) { /* {{{ */ + if (php_module_startup(module, &sapi_server_module_entry, 1) == FAILURE) { + return FAILURE; + } + return SUCCESS; +} /* }}} */ + +/* {{{ sapi_module_struct server_sapi_module + */ +static sapi_module_struct server_sapi_module = { + "server", /* name */ + "SAPI server", /* pretty name */ + + php_sapi_server_module_startup, /* startup */ + php_module_shutdown_wrapper, /* shutdown */ + + NULL, /* activate */ + NULL, /* deactivate */ + + NULL, /* unbuffered write */ + NULL, /* flush */ + NULL, /* get uid */ + NULL, /* getenv */ + + php_error, /* error handler */ + + NULL, /* header handler */ + NULL, /* send headers handler */ + NULL, /* send header handler */ + + NULL, /* read POST data */ + NULL, /* read Cookies */ + + 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) { /* {{{ */ + php_printf("Hello World :)\n"); +} /* }}} */ + +int main(int argc, char **argv) { /* {{{ */ +#ifdef ZTS + void ***tsrm_ls; + { + tsrm_startup( + 1, 1, 0, NULL); + + tsrm_ls = ts_resource(0); + } +#endif + + sapi_startup(&server_sapi_module); + + if (server_sapi_module.startup(&server_sapi_module) == SUCCESS) + { + zend_activate(TSRMLS_C); + +#ifdef ZEND_SIGNALS + 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(); + +#ifdef ZEND_SIGNALS + 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(); + } + +#ifdef ZTS + tsrm_shutdown(); +#endif + + return 0; +} /* }}} */