Re: cvs: php4 /main main.c php.h

From: Date: Wed, 07 Aug 2002 22:32:19 +0000
Subject: Re: cvs: php4 /main main.c php.h
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-86614@lists.php.net to get a copy of this message
Hi Marcus, This seems OK, but I have a suggestion: add a string parameter that refers to a location in the manual. This is listed in the TODO (somewhere!); the idea is that the error message can be formatted into a link to the docs that explains the cause/solutions for an error. This could be enhanced by adding a configuration directive that specifies the base path of the docs so that developers can redirect those links to their local copy of the docs. So, the C code would look something like this: php_error_docref(E_WARNING, "features.remote-files", "Cannot write to remote files using ftp"); with ini settings something like this: error_doc_base=http://php.net/manual/en/ error_doc_suffix=.php and php would generate a message like this (if html_errors is on): Warning: Cannot write to remote files using ftp. <a href="http://php.net/manual/en/features.remote-files.php">Click Here for more information.</a> or if html_errors is off: Warning: Cannot write to remote files using ftp. See http://php.net/manual/en/features.remote-files.php for more information. It might be an idea to pass this docref to user-space error handlers too. --Wez. On 08/07/02, "Marcus Börger" <marcus.boerger@t-online.de> wrote: > This patch introduces new functions php_error_func<n>. > These support unified error messages AND they allow to > show parameters in call. > > For example i plan to display the filename in all messages > generated by exif module as aparameter. > > I would have to use php_error(<type>, "%s(%s): <message>", > get_active_function_name(TSRMLS_C), filename); > now i call php_error_func1(<type>, filename TSRMLS_CC, "<message>"); > > Main advantage is the easy exchange way between old and > new messages (sorry for the late solution Derick) and the ability > to change ALL messages in php if required AND the unified handling > of parameters. > > regards > marcus > > > At 20:29 07.08.2002, Marcus Börger wrote: > >helly Wed Aug 7 14:29:36 2002 EDT > > > > Modified files: > > /php4/main main.c php.h > > Log: > > -new functions php_error_func<0> to support unified error messages > > #read followup > > > > > >Index: php4/main/main.c > >diff -u php4/main/main.c:1.470 php4/main/main.c:1.471 > >--- php4/main/main.c:1.470 Fri Aug 2 02:53:48 2002 > >+++ php4/main/main.c Wed Aug 7 14:29:35 2002 > >@@ -18,7 +18,7 @@ > > +----------------------------------------------------------------------+ > > */ > > > >-/* $Id: main.c,v 1.470 2002/08/02 06:53:48 hirokawa Exp $ */ > >+/* $Id: main.c,v 1.471 2002/08/07 18:29:35 helly Exp $ */ > > > > /* {{{ includes > > */ > >@@ -385,6 +385,67 @@ > > } > > /* }}} */ > > > >+/* {{{ 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 @@ > > 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; > >Index: php4/main/php.h > >diff -u php4/main/php.h:1.171 php4/main/php.h:1.172 > >--- php4/main/php.h:1.171 Fri May 31 00:49:45 2002 > >+++ php4/main/php.h Wed Aug 7 14:29:36 2002 > >@@ -17,7 +17,7 @@ > > +----------------------------------------------------------------------+ > > */ > > > >-/* $Id: php.h,v 1.171 2002/05/31 04:49:45 rvenkat Exp $ */ > >+/* $Id: php.h,v 1.172 2002/08/07 18:29:36 helly Exp $ */ > > > > #ifndef PHP_H > > #define PHP_H > >@@ -254,6 +254,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 > > > > > > > >-- > >PHP CVS Mailing List (http://www.php.net/) > >To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP CVS Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.dev (#86614) next »