cvs: embed /php-irssi php-core.c

[email protected] ("Tal Peer") Tue, 04 Mar 2003 14:10:13 -0000
Newsgroups php.embed.cvs
Message-ID <cvstal1046787013@cvsserver>
tal		Tue Mar  4 09:10:13 2003 EDT

  Modified files:              
    /embed/php-irssi	php-core.c 
  Log:
  Fix segfault on startup and some little fixes
  
  
Index: embed/php-irssi/php-core.c
diff -u embed/php-irssi/php-core.c:1.11 embed/php-irssi/php-core.c:1.12
--- embed/php-irssi/php-core.c:1.11	Sun Mar  2 11:25:21 2003
+++ embed/php-irssi/php-core.c	Tue Mar  4 09:10:13 2003
@@ -15,7 +15,7 @@
   | Authors: Wez Furlong <[email protected]>                                   |
   |          Tal Peer <[email protected]>                                      | 
   +----------------------------------------------------------------------+
-  $Id: php-core.c,v 1.11 2003/03/02 16:25:21 tal Exp $
+  $Id: php-core.c,v 1.12 2003/03/04 14:10:13 tal Exp $
 */
 #define MODULE_NAME "php/core"
 #include "common.h"
@@ -105,15 +105,15 @@
 
 }
 
-static int php_set_ini_entry(char *entry, char *value)
+static int php_set_ini_entry(char *entry, char *value, int stage)
 {
 	int retval;
 
-	retval = zend_alter_ini_entry(entry, strlen(entry)+1, value, strlen(value)+1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
+	retval = zend_alter_ini_entry(entry, strlen(entry)+1, value, strlen(value)+1, PHP_INI_USER, stage);
 	if (retval == SUCCESS) {
 		printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php: INI entry %s successfully set to %s", entry, value);
 	} else {
-		printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php: failed setting INI entry %s to %s", entry, value);
+		printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php: failed setting INI entry %s to %s (stage=%d)", entry, value, stage);
 	}
 
 	return retval;
@@ -130,7 +130,7 @@
 	php_embed_module.sapi_error = sapi_error;
 	
 	if (FAILURE == php_embed_init(1, argv PTSRMLS_CC)) {
-		printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- init php/embed failed");
+		printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php: failed initializing php/embed");
 		return;
 	}
 
@@ -183,7 +183,7 @@
 	entry = strtok(entry, " ");
 	val   = strtok(NULL, " ");
 
-	php_set_ini_entry(entry, val);
+	php_set_ini_entry(entry, val, PHP_INI_STAGE_RUNTIME);
 	
 	efree(entry);
 }
@@ -278,10 +278,13 @@
 	command_bind("php set", NULL, (SIGNAL_FUNC)cmd_php_set);
 	
 	/* XXX: We need to make that changeable... */
-	sprintf(include_path, "%s/scripts:%s", get_irssi_dir(), SCRIPTDIR);
+	spprintf(&include_path, -1, "%s/scripts:%s", get_irssi_dir(), SCRIPTDIR);
 	printtext_window(active_win, MSGLEVEL_CLIENTCRAP, "-!- php: setting include_path to %s", include_path);
 	
-	php_set_ini_entry("include_path", include_path);
+	php_set_ini_entry("include_path", include_path, PHP_INI_STAGE_ACTIVATE);
+	php_set_ini_entry("html_errors", "0", PHP_INI_STAGE_ACTIVATE);
+
+	efree(include_path);
 	
 	if (irssi_init_finished) {
 		/* if the module is being loaded manually execute autorun directly */