diff options
author | Wez Furlong <wez@php.net> | 2004-01-14 03:14:18 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2004-01-14 03:14:18 +0000 |
commit | 31f7699a857534d24990b1c7d5e06ed81e85ad9b (patch) | |
tree | 83ccca6f9fb494e4ae3d808b97cf2e2f992fab83 | |
parent | 604890702933a37814b379b0a947bb092e837b3e (diff) | |
download | php-git-31f7699a857534d24990b1c7d5e06ed81e85ad9b.tar.gz |
Add optional php-win.exe variation of the CLI sapi.
php-win.exe runs in the windows GUI subsystem, and thus
has no console; stdio handles are effectively set to /dev/null
and no "dos box" will appear on screen when running scripts
using this sapi (php-gtk people will be familiar with this concept).
Aside from those differences, php-win.exe is 100% identical to
regular CLI
-rw-r--r-- | sapi/cli/cli_win32.c | 2 | ||||
-rw-r--r-- | sapi/cli/config.w32 | 5 | ||||
-rw-r--r-- | sapi/cli/php_cli.c | 14 |
3 files changed, 21 insertions, 0 deletions
diff --git a/sapi/cli/cli_win32.c b/sapi/cli/cli_win32.c new file mode 100644 index 0000000000..4407fd088f --- /dev/null +++ b/sapi/cli/cli_win32.c @@ -0,0 +1,2 @@ +#define PHP_CLI_WIN32_NO_CONSOLE 1 +#include "php_cli.c" diff --git a/sapi/cli/config.w32 b/sapi/cli/config.w32 index 02f5f8b0fd..4f6ac8cc02 100644 --- a/sapi/cli/config.w32 +++ b/sapi/cli/config.w32 @@ -3,6 +3,7 @@ ARG_ENABLE('cli', 'Build CLI version of PHP', 'yes'); ARG_ENABLE('crt-debug', 'Extra CRT debugging', 'no'); +ARG_ENABLE('cli-win32', 'Build console-less CLI version of PHP', 'no'); if (PHP_CLI == "yes") { SAPI('cli', 'getopt.c php_cli.c', 'php.exe'); @@ -11,3 +12,7 @@ if (PHP_CLI == "yes") { } } +if (PHP_CLI_WIN32 == "yes") { + SAPI('cli_win32', 'getopt.c cli_win32.c', 'php-win.exe'); +} + diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 9fc233d304..9ee2dacf83 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -204,7 +204,11 @@ static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) { ret = sapi_cli_single_write(ptr, remaining); if (!ret) { +#ifdef PHP_CLI_WIN32_NO_CONSOLE + break; +#else php_handle_aborted_connection(); +#endif } ptr += ret; remaining -= ret; @@ -217,7 +221,9 @@ static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) static void sapi_cli_flush(void *server_context) { if (fflush(stdout)==EOF) { +#ifndef PHP_CLI_WIN32_NO_CONSOLE php_handle_aborted_connection(); +#endif } } @@ -510,7 +516,11 @@ static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file, /* {{{ main */ +#ifdef PHP_CLI_WIN32_NO_CONSOLE +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) +#else int main(int argc, char *argv[]) +#endif { int exit_status = SUCCESS; int c; @@ -536,6 +546,10 @@ int main(int argc, char *argv[]) sapi_globals_struct *sapi_globals; void ***tsrm_ls; #endif +#ifdef PHP_CLI_WIN32_NO_CONSOLE + int argc = __argc; + char **argv = __argv; +#endif #if defined(PHP_WIN32) && defined(_DEBUG) && defined(PHP_WIN32_DEBUG_HEAP) { |