wez Wed Sep 25 11:46:46 2002 EDT Modified files: /php4/ext/bz2 bz2.c /php4/ext/ftp php_ftp.c /php4/ext/interbase interbase.c /php4/ext/ming ming.c /php4/ext/pdf pdf.c /php4/ext/posix posix.c /php4/ext/recode recode.c /php4/ext/standard exec.c file.c Log: Make these all work with persistent streams too.
Index: php4/ext/bz2/bz2.c diff -u php4/ext/bz2/bz2.c:1.58 php4/ext/bz2/bz2.c:1.59 --- php4/ext/bz2/bz2.c:1.58 Sun Sep 22 21:47:02 2002 +++ php4/ext/bz2/bz2.c Wed Sep 25 11:46:43 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: bz2.c,v 1.58 2002/09/23 01:47:02 wez Exp $ */ +/* $Id: bz2.c,v 1.59 2002/09/25 15:46:43 wez Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -259,7 +259,7 @@ RETURN_FALSE; } - ZEND_FETCH_RESOURCE(stream, php_stream *, &bz, -1, "File-Handle", php_file_le_stream()); + php_stream_from_zval(stream, &bz); if (len < 0) { zend_error(E_WARNING, "%s(): length may not be negative", get_active_function_name(TSRMLS_C)); @@ -311,17 +311,10 @@ NULL); } else { /* If it is a resource, than its a stream resource */ - int type; int fd; - - stream = (php_stream *) zend_fetch_resource(file - TSRMLS_CC, - -1, - "File-Handle", - &type, - 1, - php_file_le_stream()); - ZEND_VERIFY_RESOURCE(stream); + + php_stream_from_zval(stream, file); + if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_FD, (void*)&fd, REPORT_ERRORS)) RETURN_FALSE; @@ -507,7 +500,7 @@ zend_get_parameters_ex(1, &bzp) == FAILURE) { WRONG_PARAM_COUNT; } - ZEND_FETCH_RESOURCE(stream, php_stream *, bzp, -1, "File-Handle", php_file_le_stream()); + php_stream_from_zval(stream, bzp); if (!php_stream_is(stream, PHP_STREAM_IS_BZIP2)) { RETURN_FALSE; Index: php4/ext/ftp/php_ftp.c diff -u php4/ext/ftp/php_ftp.c:1.71 php4/ext/ftp/php_ftp.c:1.72 --- php4/ext/ftp/php_ftp.c:1.71 Thu Sep 5 06:13:27 2002 +++ php4/ext/ftp/php_ftp.c Wed Sep 25 11:46:43 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ftp.c,v 1.71 2002/09/05 10:13:27 hyanantha Exp $ */ +/* $Id: php_ftp.c,v 1.72 2002/09/25 15:46:43 wez Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -476,7 +476,7 @@ } 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 @@ } 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 @@ } 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 */ Index: php4/ext/interbase/interbase.c diff -u php4/ext/interbase/interbase.c:1.89 php4/ext/interbase/interbase.c:1.90 --- php4/ext/interbase/interbase.c:1.89 Thu Sep 12 07:18:47 2002 +++ php4/ext/interbase/interbase.c Wed Sep 25 11:46:44 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: interbase.c,v 1.89 2002/09/12 11:18:47 derick Exp $ */ +/* $Id: interbase.c,v 1.90 2002/09/25 15:46:44 wez Exp $ */ /* TODO: Arrays, roles? @@ -609,7 +609,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "Interbase Support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision: 1.89 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.90 $"); #ifdef COMPILE_DL_INTERBASE php_info_print_table_row(2, "Dynamic Module", "yes"); #endif @@ -2911,8 +2911,7 @@ 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]; Index: php4/ext/ming/ming.c diff -u php4/ext/ming/ming.c:1.37 php4/ext/ming/ming.c:1.38 --- php4/ext/ming/ming.c:1.37 Wed Aug 28 08:09:59 2002 +++ php4/ext/ming/ming.c Wed Sep 25 11:46:44 2002 @@ -195,13 +195,15 @@ 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 @@ 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 @@ } 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)); } Index: php4/ext/pdf/pdf.c diff -u php4/ext/pdf/pdf.c:1.111 php4/ext/pdf/pdf.c:1.112 --- php4/ext/pdf/pdf.c:1.111 Thu Aug 29 22:41:51 2002 +++ php4/ext/pdf/pdf.c Wed Sep 25 11:46:44 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdf.c,v 1.111 2002/08/30 02:41:51 sniper Exp $ */ +/* $Id: pdf.c,v 1.112 2002/09/25 15:46:44 wez Exp $ */ /* pdflib 2.02 ... 3.0x is subject to the ALADDIN FREE PUBLIC LICENSE. Copyright (C) 1997-1999 Thomas Merz. 2000-2001 PDFlib GmbH */ @@ -332,7 +332,7 @@ #else php_info_print_table_row(2, "PDFlib GmbH Version", tmp ); #endif - php_info_print_table_row(2, "Revision", "$Revision: 1.111 $" ); + php_info_print_table_row(2, "Revision", "$Revision: 1.112 $" ); php_info_print_table_end(); } @@ -449,30 +449,30 @@ 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); } Index: php4/ext/posix/posix.c diff -u php4/ext/posix/posix.c:1.50 php4/ext/posix/posix.c:1.51 --- php4/ext/posix/posix.c:1.50 Tue Jun 4 04:54:14 2002 +++ php4/ext/posix/posix.c Wed Sep 25 11:46:45 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: posix.c,v 1.50 2002/06/04 08:54:14 mfischer Exp $ */ +/* $Id: posix.c,v 1.51 2002/09/25 15:46:45 wez Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -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 @@ -131,7 +130,7 @@ static PHP_MINFO_FUNCTION(posix) { php_info_print_table_start(); - php_info_print_table_row(2, "Revision", "$Revision: 1.50 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.51 $"); php_info_print_table_end(); } /* }}} */ @@ -582,22 +581,21 @@ /* }}} */ /* 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 @@ 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 @@ 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; Index: php4/ext/recode/recode.c diff -u php4/ext/recode/recode.c:1.28 php4/ext/recode/recode.c:1.29 --- php4/ext/recode/recode.c:1.28 Mon Apr 29 11:40:16 2002 +++ php4/ext/recode/recode.c Wed Sep 25 11:46:45 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: recode.c,v 1.28 2002/04/29 15:40:16 sniper Exp $ */ +/* $Id: recode.c,v 1.29 2002/09/25 15:46:45 wez Exp $ */ /* {{{ includes & prototypes */ @@ -119,7 +119,7 @@ { php_info_print_table_start(); php_info_print_table_row(2, "Recode Support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision: 1.28 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.29 $"); php_info_print_table_end(); } @@ -184,28 +184,18 @@ 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; } Index: php4/ext/standard/exec.c diff -u php4/ext/standard/exec.c:1.81 php4/ext/standard/exec.c:1.82 --- php4/ext/standard/exec.c:1.81 Thu Sep 19 14:59:32 2002 +++ php4/ext/standard/exec.c Wed Sep 25 11:46:46 2002 @@ -15,7 +15,7 @@ | Author: Rasmus Lerdorf | +----------------------------------------------------------------------+ */ -/* $Id: exec.c,v 1.81 2002/09/19 18:59:32 iliaa Exp $ */ +/* $Id: exec.c,v 1.82 2002/09/25 15:46:46 wez Exp $ */ #include <stdio.h> #include "php.h" @@ -732,7 +732,7 @@ 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; Index: php4/ext/standard/file.c diff -u php4/ext/standard/file.c:1.258 php4/ext/standard/file.c:1.259 --- php4/ext/standard/file.c:1.258 Wed Sep 25 11:25:11 2002 +++ php4/ext/standard/file.c Wed Sep 25 11:46:46 2002 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.258 2002/09/25 15:25:11 wez Exp $ */ +/* $Id: file.c,v 1.259 2002/09/25 15:46:46 wez Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1243,7 +1243,7 @@ } /* }}} */ -/* {{{ 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) {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php