felipe Mon Aug 4 18:22:02 2008 UTC
Modified files:
/php-src/ext/gd gd.c gd_ctx.c
Log:
- Added new parameter parsing API (part II)
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/gd.c?r1=1.390&r2=1.391&diff_format=u
Index: php-src/ext/gd/gd.c
diff -u php-src/ext/gd/gd.c:1.390 php-src/ext/gd/gd.c:1.391
--- php-src/ext/gd/gd.c:1.390 Thu Jul 17 23:28:11 2008
+++ php-src/ext/gd/gd.c Mon Aug 4 18:22:02 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gd.c,v 1.390 2008/07/17 23:28:11 pajoye Exp $ */
+/* $Id: gd.c,v 1.391 2008/08/04 18:22:02 felipe Exp $ */
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
Cold Spring Harbor Labs. */
@@ -4528,12 +4528,12 @@
#ifdef HAVE_GD_BUNDLED
#define PHP_GD_SINGLE_RES \
- zval **SIM; \
+ zval *SIM; \
gdImagePtr im_src; \
- if (zend_get_parameters_ex(1, &SIM) == FAILURE) { \
+ if (zend_parse_parameters(1 TSRMLS_CC, "r", &SIM) == FAILURE) { \
RETURN_FALSE; \
} \
- ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
\
+ ZEND_FETCH_RESOURCE(im_src, gdImagePtr, &SIM, -1, "Image", le_gd);
\
if (im_src == NULL) { \
RETURN_FALSE; \
}
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/gd_ctx.c?r1=1.33&r2=1.34&diff_format=u
Index: php-src/ext/gd/gd_ctx.c
diff -u php-src/ext/gd/gd_ctx.c:1.33 php-src/ext/gd/gd_ctx.c:1.34
--- php-src/ext/gd/gd_ctx.c:1.33 Mon Dec 31 07:12:09 2007
+++ php-src/ext/gd/gd_ctx.c Mon Aug 4 18:22:02 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gd_ctx.c,v 1.33 2007/12/31 07:12:09 sebastian Exp $ */
+/* $Id: gd_ctx.c,v 1.34 2008/08/04 18:22:02 felipe Exp $ */
#include "php_gd.h"
@@ -49,9 +49,11 @@
/* {{{ _php_image_output_ctx */
static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int
image_type, char *tn, void (*func_p)())
{
- zval **imgind, **file, **quality, **basefilter;
+ zval *imgind;
+ char *file = NULL;
+ int file_len = 0;
+ long quality, basefilter;
gdImagePtr im;
- char *fn = NULL;
FILE *fp = NULL;
int argc = ZEND_NUM_ARGS();
int q = -1, i;
@@ -63,37 +65,37 @@
* from imagey<type>().
*/
- if (argc < 2 && image_type == PHP_GDIMG_TYPE_XBM) {
- WRONG_PARAM_COUNT;
- }
- if (argc < 1 || argc > 4 || zend_get_parameters_ex(argc, &imgind,
&file, &quality, &basefilter) == FAILURE)
- {
- WRONG_PARAM_COUNT;
+ if (image_type == PHP_GDIMG_TYPE_XBM) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!|ll",
&imgind, &file, &file_len, &quality, &basefilter) == FAILURE) {
+ return;
+ }
+ } else {
+ /* PHP_GDIMG_TYPE_GIF
+ * PHP_GDIMG_TYPE_PNG
+ * PHP_GDIMG_TYPE_JPG
+ * PHP_GDIMG_TYPE_WBM */
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|s!ll",
&imgind, &file, &file_len, &quality, &basefilter) == FAILURE) {
+ return;
+ }
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image",
phpi_get_le_gd());
+ ZEND_FETCH_RESOURCE(im, gdImagePtr, &imgind, -1, "Image",
phpi_get_le_gd());
if (argc > 1) {
- if (argc >= 2 && Z_TYPE_PP(file) != IS_NULL) {
- convert_to_string_ex(file);
- }
- fn = Z_STRVAL_PP(file);
if (argc >= 3) {
- convert_to_long_ex(quality);
- q = Z_LVAL_PP(quality);/* or colorindex for foreground
of BW images (defaults to black) */
+ q = quality; /* or colorindex for foreground of BW
images (defaults to black) */
if (argc == 4) {
- convert_to_long_ex(basefilter);
- f = Z_LVAL_PP(basefilter);
+ f = basefilter;
}
}
}
- if (argc > 1 && (Z_TYPE_PP(file) != IS_NULL && ((argc == 2) || (argc > 2
&& Z_STRLEN_PP(file))))) {
- PHP_GD_CHECK_OPEN_BASEDIR(fn, "Invalid filename");
+ if (argc > 1 && file_len) {
+ PHP_GD_CHECK_OPEN_BASEDIR(file, "Invalid filename");
- fp = VCWD_FOPEN(fn, "wb");
+ fp = VCWD_FOPEN(file, "wb");
if (!fp) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to
open '%s' for writing: %s", fn, strerror(errno));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to
open '%s' for writing: %s", file, strerror(errno));
RETURN_FALSE;
}
@@ -125,7 +127,7 @@
q = i;
}
if (image_type == PHP_GDIMG_TYPE_XBM) {
- (*func_p)(im, fn, q, ctx);
+ (*func_p)(im, file, q, ctx);
} else {
(*func_p)(im, q, ctx);
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php