diff options
-rw-r--r-- | ext/ftp/php_ftp.c | 6 | ||||
-rw-r--r-- | ext/interbase/interbase.c | 3 | ||||
-rw-r--r-- | ext/ming/ming.c | 14 | ||||
-rw-r--r-- | ext/pdf/pdf.c | 18 | ||||
-rw-r--r-- | ext/posix/posix.c | 20 | ||||
-rw-r--r-- | ext/recode/recode.c | 14 | ||||
-rw-r--r-- | ext/standard/exec.c | 2 | ||||
-rw-r--r-- | ext/standard/file.c | 2 |
8 files changed, 34 insertions, 45 deletions
diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index d1aa51b45f..b7d00e57b9 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -476,7 +476,7 @@ PHP_FUNCTION(ftp_async_fget) } ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); - ZEND_FETCH_RESOURCE(stream, php_stream*, &z_file, -1, "File-Handle", php_file_le_stream()); + php_stream_from_zval(stream, &z_file); XTYPE(xtype, mode); /* ignore autoresume if autoseek is switched off */ @@ -702,7 +702,7 @@ PHP_FUNCTION(ftp_fput) } ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); - ZEND_FETCH_RESOURCE(stream, php_stream*, &z_file, -1, "File-Handle", php_file_le_stream()); + php_stream_from_zval(stream, &z_file); XTYPE(xtype, mode); /* ignore autoresume if autoseek is switched off */ @@ -748,7 +748,7 @@ PHP_FUNCTION(ftp_async_fput) } ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); - ZEND_FETCH_RESOURCE(stream, php_stream*, &z_file, -1, "File-Handle", php_file_le_stream()); + php_stream_from_zval(stream, &z_file); XTYPE(xtype, mode); /* ignore autoresume if autoseek is switched off */ diff --git a/ext/interbase/interbase.c b/ext/interbase/interbase.c index a194daca59..63e88bf7b2 100644 --- a/ext/interbase/interbase.c +++ b/ext/interbase/interbase.c @@ -2911,8 +2911,7 @@ PHP_FUNCTION(ibase_blob_import) RETURN_FALSE; } - stream = (php_stream*)zend_fetch_resource(file_arg TSRMLS_CC, -1, "File-Handle", &type, 1, php_file_le_stream()); - ZEND_VERIFY_RESOURCE(stream); + php_stream_from_zval(stream, file_arg); ib_blob.link = ib_link->link; ib_blob.trans_handle = ib_link->trans[trans_n]; diff --git a/ext/ming/ming.c b/ext/ming/ming.c index 4c0f5f6ce9..bcf81cd1ae 100644 --- a/ext/ming/ming.c +++ b/ext/ming/ming.c @@ -195,13 +195,15 @@ static void destroy_SWFInput_resource(zend_rsrc_list_entry *resource TSRMLS_DC) static SWFInput getInput(zval **zfile TSRMLS_DC) { FILE *file; - void *what; - int type; + php_stream *stream; SWFInput input; - what = zend_fetch_resource(zfile TSRMLS_CC, -1, "File-Handle", &type, 1, php_file_le_stream()); + php_stream_from_zval_no_verify(stream, zfile); + + if (stream == NULL) + return NULL; - if (php_stream_cast((php_stream*)what, PHP_STREAM_AS_STDIO, (void *) &file, REPORT_ERRORS) != SUCCESS) { + if (php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void *) &file, REPORT_ERRORS) != SUCCESS) { return NULL; } @@ -1449,7 +1451,7 @@ PHP_FUNCTION(swfmovie_saveToFile) if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &x) == FAILURE) { WRONG_PARAM_COUNT; } - ZEND_FETCH_RESOURCE(what, php_stream *, x, -1,"File-Handle",php_file_le_stream()); + php_stream_from_zval(what, x); RETURN_LONG(SWFMovie_output(movie, &phpStreamOutputMethod, what)); } /* }}} */ @@ -1467,7 +1469,7 @@ PHP_FUNCTION(swfmovie_save) } if (Z_TYPE_PP(x) == IS_RESOURCE) { - ZEND_FETCH_RESOURCE(stream, php_stream *, x, -1,"File-Handle",php_file_le_stream()); + php_stream_from_zval(stream, x); RETURN_LONG(SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, stream)); } diff --git a/ext/pdf/pdf.c b/ext/pdf/pdf.c index ddc7262aec..ce169f7bdd 100644 --- a/ext/pdf/pdf.c +++ b/ext/pdf/pdf.c @@ -449,30 +449,30 @@ PHP_FUNCTION(pdf_set_info_keywords) PHP_FUNCTION(pdf_open) { zval **file; - void *what; - int type; FILE *fp = NULL; PDF *pdf; int argc = ZEND_NUM_ARGS(); - if(argc > 1) + if(argc > 1) { WRONG_PARAM_COUNT; - if (argc != 1 || zend_get_parameters_ex(1, &file) == FAILURE) { + } else if (argc != 1 || zend_get_parameters_ex(1, &file) == FAILURE) { fp = NULL; } else { - what = zend_fetch_resource(file TSRMLS_CC, -1, "File-Handle", &type, 1, php_file_le_stream()); - ZEND_VERIFY_RESOURCE(what); + php_stream *stream; + + php_stream_from_zval(stream, file); - if (php_stream_cast((php_stream*)what, PHP_STREAM_AS_STDIO, (void*)&fp, 1) == FAILURE) { + if (php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void*)&fp, 1) == FAILURE) { RETURN_FALSE; } - /* XXX should do a zend_list_addref for <fp> here! */ } pdf = PDF_new2(custom_errorhandler, pdf_emalloc, pdf_realloc, pdf_efree, NULL); if(fp) { - if (PDF_open_fp(pdf, fp) < 0) RETURN_FALSE; + if (PDF_open_fp(pdf, fp) < 0) { + RETURN_FALSE; + } } else { PDF_open_mem(pdf, pdf_flushwrite); } diff --git a/ext/posix/posix.c b/ext/posix/posix.c index ba0fd292b7..519c177e79 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -25,7 +25,6 @@ #include "php.h" #include "ext/standard/info.h" #include "ext/standard/php_string.h" -#include "ext/standard/file.h" /* Provides php_file_le_stream() */ #include "php_posix.h" #if HAVE_POSIX @@ -582,22 +581,21 @@ PHP_FUNCTION(posix_ctermid) /* }}} */ /* Checks if the provides resource is a stream and if it provides a file descriptor */ -static int php_posix_stream_get_fd(long rsrc_id, int *fd TSRMLS_DC) +static int php_posix_stream_get_fd(zval *zfp, int *fd TSRMLS_DC) { php_stream *stream; - int rsrc_type; - stream = zend_list_find(rsrc_id, &rsrc_type); - if (!stream || rsrc_type != php_file_le_stream()) { - php_error(E_WARNING, "%s() expects argument 1 to be a valid stream resource", - get_active_function_name(TSRMLS_C)); + php_stream_from_zval_no_verify(stream, &zfp); + + if (stream == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "expects argument 1 to be a valid stream resource"); return 0; } if (php_stream_can_cast(stream, PHP_STREAM_AS_FD) == SUCCESS) { php_stream_cast(stream, PHP_STREAM_AS_FD, (void*)fd, 0); } else { - php_error(E_WARNING, "%s() could not use stream of type '%s'", - get_active_function_name(TSRMLS_C), stream->ops->label); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "could not use stream of type '%s'", + stream->ops->label); return 0; } return 1; @@ -616,7 +614,7 @@ PHP_FUNCTION(posix_ttyname) switch (Z_TYPE_P(z_fd)) { case IS_RESOURCE: - if (!php_posix_stream_get_fd(Z_RESVAL_P(z_fd), &fd TSRMLS_CC)) { + if (!php_posix_stream_get_fd(z_fd, &fd TSRMLS_CC)) { RETURN_FALSE; } break; @@ -646,7 +644,7 @@ PHP_FUNCTION(posix_isatty) switch (Z_TYPE_P(z_fd)) { case IS_RESOURCE: - if (!php_posix_stream_get_fd(Z_RESVAL_P(z_fd), &fd TSRMLS_CC)) { + if (!php_posix_stream_get_fd(z_fd, &fd TSRMLS_CC)) { RETURN_FALSE; } break; diff --git a/ext/recode/recode.c b/ext/recode/recode.c index 9c1c837440..cbcc6bf985 100644 --- a/ext/recode/recode.c +++ b/ext/recode/recode.c @@ -184,28 +184,18 @@ PHP_FUNCTION(recode_file) zval **input, **output; php_stream *instream, *outstream; FILE *in_fp, *out_fp; - int in_type, out_type; if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &req, &input, &output) == FAILURE) { WRONG_PARAM_COUNT; } - instream = zend_fetch_resource(input TSRMLS_CC,-1, "File-Handle", &in_type, 1, php_file_le_stream()); - - if (!instream) { - php_error(E_WARNING,"Unable to find input file identifier"); - RETURN_FALSE; - } + php_stream_from_zval(instream, input); + php_stream_from_zval(outstream, output); if (FAILURE == php_stream_cast(instream, PHP_STREAM_AS_STDIO, (void**)&in_fp, REPORT_ERRORS)) { RETURN_FALSE; } - outstream = zend_fetch_resource(output TSRMLS_CC,-1, "File-Handle", &out_type, 1, php_file_le_stream()); - if (!outstream) { - php_error(E_WARNING,"Unable to find output file identifier"); - RETURN_FALSE; - } if (FAILURE == php_stream_cast(outstream, PHP_STREAM_AS_STDIO, (void**)&out_fp, REPORT_ERRORS)) { RETURN_FALSE; } diff --git a/ext/standard/exec.c b/ext/standard/exec.c index a855040a99..441ae1f665 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -732,7 +732,7 @@ PHP_FUNCTION(proc_open) php_stream *stream; int fd; - ZEND_FETCH_RESOURCE(stream, php_stream *, descitem, -1, "File-Handle", php_file_le_stream()); + php_stream_from_zval(stream, descitem); if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_FD, (void **)&fd, REPORT_ERRORS)) { goto exit_fail; diff --git a/ext/standard/file.c b/ext/standard/file.c index 20ad89d413..75300986d8 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1243,7 +1243,7 @@ PHPAPI PHP_FUNCTION(fgetss) } /* }}} */ -/* {{{ proto mixed fscanf(string str, string format [, string ...]) +/* {{{ proto mixed fscanf(resource stream, string format [, string ...]) Implements a mostly ANSI compatible fscanf() */ PHP_FUNCTION(fscanf) { |