]> granicus.if.org Git - php/commitdiff
MFH Synch: shutdown and ini defaults
authorMarcus Boerger <helly@php.net>
Wed, 23 Apr 2003 22:53:17 +0000 (22:53 +0000)
committerMarcus Boerger <helly@php.net>
Wed, 23 Apr 2003 22:53:17 +0000 (22:53 +0000)
sapi/cli/php_cli.c

index deb5ddba912e7289da3cb122863ccbbaffd01caa..2fc5026b4ad5df6741b251649324e2603db6edf9 100644 (file)
@@ -250,22 +250,24 @@ static int php_cli_startup(sapi_module_struct *sapi_module)
 
 /* {{{ sapi_cli_ini_defaults */
 
+/* overwriteable ini defaults must be set in sapi_cli_ini_defaults() */
 #define INI_DEFAULT(name,value)\
        ZVAL_STRING(tmp, value, 0);\
        zend_hash_update(configuration_hash, name, sizeof(name), tmp, sizeof(zval), (void**)&entry);\
        Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry))
 
+/* hard coded ini settings must be set in main() */
+#define INI_HARDCODED(name,value)\
+               zend_alter_ini_entry(name, sizeof(name), value, strlen(value), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
+
 static void sapi_cli_ini_defaults(HashTable *configuration_hash)
 {
        zval *tmp, *entry;
        
        MAKE_STD_ZVAL(tmp);
 
-       INI_DEFAULT("register_argc_argv", "1");
-       INI_DEFAULT("html_errors", "0");
+       INI_DEFAULT("report_zend_debug", "0");
        INI_DEFAULT("display_errors", "1");
-       INI_DEFAULT("implicit_flush", "1");
-       INI_DEFAULT("max_execution_time", "0");
 
        FREE_ZVAL(tmp);
 }
@@ -536,15 +538,21 @@ int main(int argc, char *argv[])
         /* 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 */
-               /*zend_alter_ini_entry("<name>", len, "<value>", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);*/
+               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;
 
                if (cli_sapi_module.php_ini_path_override && cli_sapi_module.php_ini_ignore) {
                        SG(headers_sent) = 1;
                        SG(request_info).no_headers = 1;
                        PUTS("You cannot use both -n and -c switch. Use -h for help.\n");
-                       exit(1);
+                       exit_status=1;
+                       goto out_err;
                }
        
                while ((c = ap_php_getopt(argc, argv, OPTSTRING)) != -1) {
@@ -591,8 +599,8 @@ int main(int argc, char *argv[])
                                SG(headers_sent) = 1;
                                php_cli_usage(argv[0]);
                                php_end_ob_buffers(1 TSRMLS_CC);
-                               exit(1);
-                               break;
+                               exit_status=1;
+                               goto out;
 
                        case 'i': /* php info & quit */
                                if (php_request_startup(TSRMLS_C)==FAILURE) {
@@ -604,8 +612,8 @@ int main(int argc, char *argv[])
                                }
                                php_print_info(0xFFFFFFFF TSRMLS_CC);
                                php_end_ob_buffers(1 TSRMLS_CC);
-                               exit(1);
-                               break;
+                               exit_status=1;
+                               goto out;
 
                        case 'l': /* syntax check mode */
                                if (behavior != PHP_MODE_STANDARD) {
@@ -625,8 +633,8 @@ int main(int argc, char *argv[])
                                print_extensions(TSRMLS_C);
                                php_printf("\n");
                                php_end_ob_buffers(1 TSRMLS_CC);
-                               exit(1);
-                       break;
+                               exit_status=1;
+                               goto out_err;
 
 #if 0 /* not yet operational, see also below ... */
                        case '': /* generate indented source mode*/
@@ -670,8 +678,8 @@ int main(int argc, char *argv[])
                                }
                                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(1);
-                               break;
+                               exit_status=1;
+                               goto out;
 
                        case 'w':
                                if (behavior == PHP_MODE_CLI_DIRECT) {
@@ -694,7 +702,8 @@ int main(int argc, char *argv[])
                        SG(headers_sent) = 1;
                        SG(request_info).no_headers = 1;
                        PUTS(param_error);
-                       exit(1);
+                       exit_status=1;
+                       goto out_err;
                }
 
                CG(interactive) = interactive;