summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/main.c63
-rw-r--r--main/php.h5
2 files changed, 67 insertions, 1 deletions
diff --git a/main/main.c b/main/main.c
index 68e90761d5..f5cce95558 100644
--- a/main/main.c
+++ b/main/main.c
@@ -385,6 +385,67 @@ PHPAPI int php_printf(const char *format, ...)
}
/* }}} */
+/* {{{ php_verror */
+PHPAPI void php_verror(int type, const char *format, va_list args TSRMLS_DC)
+{
+ char *buffer = NULL;
+
+ if (format)
+ vspprintf(&buffer, 0, format, args);
+ if (buffer) {
+ php_error(type, "%s", buffer);
+ efree(buffer);
+ } else {
+ php_error(E_ERROR, "%s(): Out of memory", get_active_function_name(TSRMLS_C));
+ }
+}
+/* }}} */
+
+/* {{{ php_error_func0 */
+PHPAPI void php_error_func0(int type TSRMLS_DC, const char *format, ...)
+{
+ char *message;
+ va_list args;
+
+ spprintf(&message, 0, "%s(): %s", get_active_function_name(TSRMLS_C), format);
+ va_start(args, format);
+ php_verror(type, message, args TSRMLS_CC);
+ va_end(args);
+ if (message)
+ efree(message);
+}
+/* }}} */
+
+/* {{{ php_error_func1 */
+PHPAPI void php_error_func1(int type, const char *param1 TSRMLS_DC, const char *format, ...)
+{
+ char *message;
+ va_list args;
+
+ spprintf(&message, 0, "%s(%s): %s", get_active_function_name(TSRMLS_C), param1, format);
+ va_start(args, format);
+ php_verror(type, message, args TSRMLS_CC);
+ va_end(args);
+ if (message)
+ efree(message);
+}
+/* }}} */
+
+/* {{{ php_error_func2 */
+PHPAPI void php_error_func2(int type, const char *param1, const char *param2 TSRMLS_DC, const char *format, ...)
+{
+ char *message;
+ va_list args;
+
+ spprintf(&message, 0, "%s(%s,%s): %s", get_active_function_name(TSRMLS_C), param1, param2, format);
+ va_start(args, format);
+ php_verror(type, message, args TSRMLS_CC);
+ va_end(args);
+ if (message)
+ efree(message);
+}
+/* }}} */
+
/* {{{ php_html_puts */
PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC)
{
@@ -1108,7 +1169,7 @@ static int php_hash_environment(TSRMLS_D)
char *p;
unsigned char _gpc_flags[3] = {0, 0, 0};
zend_bool have_variables_order;
- zval *dummy_track_vars_array;
+ zval *dummy_track_vars_array = NULL;
zend_bool initialized_dummy_track_vars_array=0;
int i;
char *variables_order;
diff --git a/main/php.h b/main/php.h
index 9fe824949e..dbf0fdd68a 100644
--- a/main/php.h
+++ b/main/php.h
@@ -255,6 +255,11 @@ int cfgparse(void);
#define php_error zend_error
+/* PHPAPI void php_error(int type, const char *format, ...); */
+PHPAPI void php_error_func0(int type TSRMLS_DC, const char *format, ...);
+PHPAPI void php_error_func1(int type, const char *param1 TSRMLS_DC, const char *format, ...);
+PHPAPI void php_error_func2(int type, const char *param1, const char *param2 TSRMLS_DC, const char *format, ...);
+
#define zenderror phperror
#define zendlex phplex