indeyets Sun Jun 22 14:13:02 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/exif exif.c
Log:
updated to the new parameter-parsing api
http://cvs.php.net/viewvc.cgi/php-src/ext/exif/exif.c?r1=1.173.2.5.2.20.2.5&r2=1.173.2.5.2.20.2.6&diff_format=u
Index: php-src/ext/exif/exif.c
diff -u php-src/ext/exif/exif.c:1.173.2.5.2.20.2.5
php-src/ext/exif/exif.c:1.173.2.5.2.20.2.6
--- php-src/ext/exif/exif.c:1.173.2.5.2.20.2.5 Wed Mar 12 17:32:01 2008
+++ php-src/ext/exif/exif.c Sun Jun 22 14:13:01 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: exif.c,v 1.173.2.5.2.20.2.5 2008/03/12 17:32:01 iliaa Exp $ */
+/* $Id: exif.c,v 1.173.2.5.2.20.2.6 2008/06/22 14:13:01 indeyets Exp $ */
/* ToDos
*
@@ -142,7 +142,7 @@
};
/* }}} */
-#define EXIF_VERSION "1.4 $Id: exif.c,v 1.173.2.5.2.20.2.5 2008/03/12 17:32:01
iliaa Exp $"
+#define EXIF_VERSION "1.4 $Id: exif.c,v 1.173.2.5.2.20.2.6 2008/06/22 14:13:01
indeyets Exp $"
/* {{{ PHP_MINFO_FUNCTION
*/
@@ -2360,22 +2360,20 @@
Get headername for index or false if not defined */
PHP_FUNCTION(exif_tagname)
{
- zval **p_num;
- int tag, ac = ZEND_NUM_ARGS();
+ long tag;
char *szTemp;
- if ((ac < 1 || ac > 1) || zend_get_parameters_ex(ac, &p_num) ==
FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &tag) ==
FAILURE) {
+ return;
}
- convert_to_long_ex(p_num);
- tag = Z_LVAL_PP(p_num);
szTemp = exif_get_tagname(tag, NULL, 0, tag_table_IFD TSRMLS_CC);
- if (tag<0 || !szTemp || !szTemp[0]) {
- RETURN_BOOL(FALSE);
- } else {
- RETURN_STRING(szTemp, 1)
+
+ if (tag < 0 || !szTemp || !szTemp[0]) {
+ RETURN_FALSE;
}
+
+ RETURN_STRING(szTemp, 1)
}
/* }}} */
@@ -3914,30 +3912,31 @@
Reads header data from the JPEG/TIFF image filename and optionally reads
the internal thumbnails */
PHP_FUNCTION(exif_read_data)
{
- zval **p_name, **p_sections_needed, **p_sub_arrays, **p_read_thumbnail,
**p_read_all;
- int i, ac = ZEND_NUM_ARGS(), ret, sections_needed=0, sub_arrays=0,
read_thumbnail=0, read_all=0;
+ char *p_name, *p_sections_needed;
+ long p_name_len, p_sections_needed_len;
+ zend_bool sub_arrays=0, read_thumbnail=0, read_all=0;
+
+ int i, ac = ZEND_NUM_ARGS(), ret, sections_needed=0;
image_info_type ImageInfo;
char tmp[64], *sections_str, *s;
- memset(&ImageInfo, 0, sizeof(ImageInfo));
-
- if ((ac < 1 || ac > 4) || zend_get_parameters_ex(ac, &p_name,
&p_sections_needed, &p_sub_arrays, &p_read_thumbnail, &p_read_all) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ac TSRMLS_CC, "s|sbb", &p_name, &p_name_len,
&p_sections_needed, &p_sections_needed_len, &sub_arrays, &read_thumbnail) ==
FAILURE) {
+ return;
}
- convert_to_string_ex(p_name);
+ memset(&ImageInfo, 0, sizeof(ImageInfo));
- if(ac >= 2) {
- convert_to_string_ex(p_sections_needed);
- spprintf(§ions_str, 0, ",%s,",
Z_STRVAL_PP(p_sections_needed));
+ if (ac >= 2) {
+ spprintf(§ions_str, 0, ",%s,", p_sections_needed);
/* sections_str DOES start with , and SPACES are NOT allowed in
names */
s = sections_str;
- while(*++s) {
- if(*s==' ') {
+ while (*++s) {
+ if (*s == ' ') {
*s = ',';
}
}
- for (i=0; i<SECTION_COUNT; i++) {
+
+ for (i = 0; i < SECTION_COUNT; i++) {
snprintf(tmp, sizeof(tmp), ",%s,",
exif_get_sectionname(i));
if (strstr(sections_str, tmp)) {
sections_needed |= 1<<i;
@@ -3954,24 +3953,9 @@
EFREE_IF(sections_str);
#endif
}
- if(ac >= 3) {
- convert_to_long_ex(p_sub_arrays);
- sub_arrays = Z_LVAL_PP(p_sub_arrays);
- }
- if(ac >= 4) {
- convert_to_long_ex(p_read_thumbnail);
- read_thumbnail = Z_LVAL_PP(p_read_thumbnail);
- }
- if(ac >= 5) {
- convert_to_long_ex(p_read_all);
- read_all = Z_LVAL_PP(p_read_all);
- }
- /* parameters 3,4 will be working in later versions.... */
- read_all = 0; /* just to make function work for 4.2 tree */
-
- ret = exif_read_file(&ImageInfo, Z_STRVAL_PP(p_name), read_thumbnail,
read_all TSRMLS_CC);
- sections_str = exif_get_sectionlist(ImageInfo.sections_found TSRMLS_CC);
+ ret = exif_read_file(&ImageInfo, p_name, read_thumbnail, read_all
TSRMLS_CC);
+ sections_str = exif_get_sectionlist(ImageInfo.sections_found TSRMLS_CC);
#ifdef EXIF_DEBUG
if (sections_str)
@@ -3980,7 +3964,7 @@
ImageInfo.sections_found |= FOUND_COMPUTED|FOUND_FILE;/* do not inform
about in debug*/
- if (ret==FALSE || (sections_needed &&
!(sections_needed&ImageInfo.sections_found))) {
+ if (ret == FALSE || (sections_needed &&
!(sections_needed&ImageInfo.sections_found))) {
/* array_init must be checked at last! otherwise the array must
be freed if a later test fails. */
exif_discard_imageinfo(&ImageInfo);
EFREE_IF(sections_str);
@@ -4170,18 +4154,16 @@
Get the type of an image */
PHP_FUNCTION(exif_imagetype)
{
- zval **arg1;
+ char *imagefile;
+ long imagefile_len;
php_stream * stream;
int itype = 0;
- if (ZEND_NUM_ARGS() != 1)
- WRONG_PARAM_COUNT;
-
- if (zend_get_parameters_ex(1, &arg1) == FAILURE)
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &imagefile,
&imagefile_len) == FAILURE) {
+ return;
+ }
- convert_to_string_ex(arg1);
- stream = php_stream_open_wrapper(Z_STRVAL_PP(arg1), "rb",
IGNORE_PATH|ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
+ stream = php_stream_open_wrapper(imagefile, "rb",
IGNORE_PATH|ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
if (stream == NULL) {
RETURN_FALSE;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php