Re: [PHP-DEV] Re: INI defaults for CLI

[email protected] ((Marcus Börger))
Newsgroups php.dev
Message-ID <[email protected]>
At 02:45 03.03.2003, [email protected] wrote:
>Nothing attached...


Try again...
20030303-1.diff.txt (text/plain, 2.9 KB)
Index: main/SAPI.h
===================================================================
RCS file: /repository/php4/main/SAPI.h,v
retrieving revision 1.100
diff -u -r1.100 SAPI.h
--- main/SAPI.h	20 Feb 2003 22:21:48 -0000	1.100
+++ main/SAPI.h	3 Mar 2003 00:13:21 -0000
@@ -241,6 +241,8 @@
 	int (*get_target_gid)(gid_t * TSRMLS_DC);
 
 	unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len TSRMLS_DC);
+	
+	void (*ini_defaults)(HashTable *configuration_hash);
 };
 
 
Index: main/php_ini.c
===================================================================
RCS file: /repository/php4/main/php_ini.c,v
retrieving revision 1.117
diff -u -r1.117 php_ini.c
--- main/php_ini.c	28 Feb 2003 20:48:38 -0000	1.117
+++ main/php_ini.c	3 Mar 2003 00:13:21 -0000
@@ -276,6 +276,10 @@
 		return FAILURE;
 	}
 
+	if (sapi_module.ini_defaults) {
+		sapi_module.ini_defaults(&configuration_hash);
+	}
+
 	zend_llist_init(&extension_lists.engine, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
 	zend_llist_init(&extension_lists.functions, sizeof(zval), (llist_dtor_func_t)  ZVAL_DESTRUCTOR, 1);
 	zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
Index: sapi/cli/php_cli.c
===================================================================
RCS file: /repository/php4/sapi/cli/php_cli.c,v
retrieving revision 1.71
diff -u -r1.71 php_cli.c
--- sapi/cli/php_cli.c	16 Feb 2003 01:23:11 -0000	1.71
+++ sapi/cli/php_cli.c	3 Mar 2003 00:13:21 -0000
@@ -277,6 +277,29 @@
 }
 
 
+/* {{{ sapi_cli_ini_defaults */
+
+#define INI_DEFAULT(name,name_len,value)\
+	ZVAL_STRING(tmp, value, 0);\
+	zend_hash_update(configuration_hash, name, name_len, tmp, sizeof(zval), (void**)&entry);\
+	Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry))
+
+static void sapi_cli_ini_defaults(HashTable *configuration_hash)
+{
+	zval *tmp, *entry;
+	
+	MAKE_STD_ZVAL(tmp);
+
+	INI_DEFAULT("register_argc_argv", 19, "1");
+/*	INI_DEFAULT("register_long_arrays", 21, "1");*/
+	INI_DEFAULT("html_errors", 12, "1");
+	INI_DEFAULT("implicit_flush", 15, "1");
+	INI_DEFAULT("max_execution_time", 19, "0");
+
+	FREE_ZVAL(tmp);
+}
+/* }}} */
+
 /* {{{ sapi_module_struct cli_sapi_module
  */
 static sapi_module_struct cli_sapi_module = {
@@ -526,6 +549,7 @@
 	tsrm_startup(1, 1, 0, NULL);
 #endif
 
+	cli_sapi_module.ini_defaults = sapi_cli_ini_defaults;
 	sapi_startup(&cli_sapi_module);
 
 #ifdef PHP_WIN32
@@ -576,10 +600,6 @@
 
         /* Set some CLI defaults */
 		SG(options) |= SAPI_OPTION_NO_CHDIR;
-		zend_alter_ini_entry("register_argc_argv", 19, "1", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
-		zend_alter_ini_entry("html_errors", 12, "0", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
-		zend_alter_ini_entry("implicit_flush", 15, "1", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
-		zend_alter_ini_entry("max_execution_time", 19, "0", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
 
 		zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.