diff options
author | Marcus Boerger <helly@php.net> | 2003-04-27 19:19:29 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2003-04-27 19:19:29 +0000 |
commit | 129d0898caa542d9b7e502255d8965a253146f46 (patch) | |
tree | 82dd2c5c757e80edfa42bdc3c3f15eda9a12111d /sapi/cli/php_cli.c | |
parent | cddface7f191945f4d6edbda5cadf099f8e31ec9 (diff) | |
download | php-git-129d0898caa542d9b7e502255d8965a253146f46.tar.gz |
split parameter parsing once more: do informal queries before others
#still a memleak in case of a parameter conflict
Diffstat (limited to 'sapi/cli/php_cli.c')
-rw-r--r-- | sapi/cli/php_cli.c | 105 |
1 files changed, 57 insertions, 48 deletions
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index e92f3e5de6..b9da7782bf 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -603,14 +603,6 @@ int main(int argc, char *argv[]) zend_first_try { zend_llist_init(&global_vars, sizeof(char *), NULL, 0); - /* Set some CLI defaults */ - SG(options) |= SAPI_OPTION_NO_CHDIR; - /* here is the place for hard coded defaults which cannot be overwritten in the ini file */ - INI_HARDCODED("register_argc_argv", "1"); - INI_HARDCODED("html_errors", "0"); - INI_HARDCODED("implicit_flush", "1"); - INI_HARDCODED("max_execution_time", "0"); - zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */ CG(in_compilation) = 0; /* not initialized but needed for several options */ EG(uninitialized_zval_ptr) = NULL; @@ -637,6 +629,63 @@ int main(int argc, char *argv[]) exit_status=1; goto out_err; + + case 'i': /* php info & quit */ + if (php_request_startup(TSRMLS_C)==FAILURE) { + goto err; + } + if (no_headers) { + SG(headers_sent) = 1; + SG(request_info).no_headers = 1; + } + php_print_info(0xFFFFFFFF TSRMLS_CC); + php_end_ob_buffers(1 TSRMLS_CC); + exit_status=1; + goto out; + + case 'm': /* list compiled in modules */ + php_output_startup(); + php_output_activate(TSRMLS_C); + SG(headers_sent) = 1; + php_printf("[PHP Modules]\n"); + print_modules(TSRMLS_C); + php_printf("\n[Zend Modules]\n"); + print_extensions(TSRMLS_C); + php_printf("\n"); + php_end_ob_buffers(1 TSRMLS_CC); + exit_status=1; + goto out_err; + + case 'v': /* show php version & quit */ + no_headers = 1; + if (php_request_startup(TSRMLS_C)==FAILURE) { + goto err; + } + if (no_headers) { + SG(headers_sent) = 1; + SG(request_info).no_headers = 1; + } + php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2003 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_end_ob_buffers(1 TSRMLS_CC); + exit_status=1; + goto out; + + default: + break; + } + } + + /* Set some CLI defaults */ + SG(options) |= SAPI_OPTION_NO_CHDIR; + /* here is the place for hard coded defaults which cannot be overwritten in the ini file */ + INI_HARDCODED("register_argc_argv", "1"); + INI_HARDCODED("html_errors", "0"); + INI_HARDCODED("implicit_flush", "1"); + INI_HARDCODED("max_execution_time", "0"); + + while ((c = php_getopt(argc, argv, OPTIONS, &optarg, &optind, 0)) != -1) { + switch (c) { + case 'a': /* interactive mode */ printf("Interactive mode enabled\n\n"); interactive=1; @@ -688,19 +737,6 @@ int main(int argc, char *argv[]) } break; - case 'i': /* php info & quit */ - if (php_request_startup(TSRMLS_C)==FAILURE) { - goto err; - } - if (no_headers) { - SG(headers_sent) = 1; - SG(request_info).no_headers = 1; - } - php_print_info(0xFFFFFFFF TSRMLS_CC); - php_end_ob_buffers(1 TSRMLS_CC); - exit_status=1; - goto out; - case 'l': /* syntax check mode */ if (behavior != PHP_MODE_STANDARD) { break; @@ -709,19 +745,6 @@ int main(int argc, char *argv[]) behavior=PHP_MODE_LINT; break; - case 'm': /* list compiled in modules */ - php_output_startup(); - php_output_activate(TSRMLS_C); - SG(headers_sent) = 1; - php_printf("[PHP Modules]\n"); - print_modules(TSRMLS_C); - php_printf("\n[Zend Modules]\n"); - print_extensions(TSRMLS_C); - php_printf("\n"); - php_end_ob_buffers(1 TSRMLS_CC); - exit_status=1; - goto out_err; - #if 0 /* not yet operational, see also below ... */ case '': /* generate indented source mode*/ if (behavior == PHP_MODE_CLI_DIRECT || behavior == PHP_MODE_PROCESS_STDIN) { @@ -801,20 +824,6 @@ int main(int argc, char *argv[]) behavior=PHP_MODE_HIGHLIGHT; break; - case 'v': /* show php version & quit */ - no_headers = 1; - if (php_request_startup(TSRMLS_C)==FAILURE) { - goto err; - } - if (no_headers) { - SG(headers_sent) = 1; - SG(request_info).no_headers = 1; - } - php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2003 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); - php_end_ob_buffers(1 TSRMLS_CC); - exit_status=1; - goto out; - case 'w': if (behavior == PHP_MODE_CLI_DIRECT || behavior == PHP_MODE_PROCESS_STDIN) { param_error = "Source stripping only works for files.\n"; |