diff options
Diffstat (limited to 'ext/recode/recode.c')
-rw-r--r-- | ext/recode/recode.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/ext/recode/recode.c b/ext/recode/recode.c index fa1dcd46b8..488e3b3cfd 100644 --- a/ext/recode/recode.c +++ b/ext/recode/recode.c @@ -26,6 +26,7 @@ #include "php.h" #include "php_recode.h" +#include "php_streams.h" #if HAVE_LIBRECODE #include "ext/standard/info.h" @@ -162,28 +163,38 @@ PHP_FUNCTION(recode_file) int success; pval **req; pval **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; } - in_fp = zend_fetch_resource(input TSRMLS_CC,-1, "File-Handle", &in_type, - 2, php_file_le_fopen(), php_file_le_popen()); - if (!in_fp) { + 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; } - out_fp = zend_fetch_resource(output TSRMLS_CC,-1, "File-Handle", &out_type, - 2, php_file_le_fopen(), php_file_le_popen()); - if (!out_fp) { + if (!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 (!php_stream_cast(outstream, PHP_STREAM_AS_STDIO, (void**)&out_fp, REPORT_ERRORS)) { + RETURN_FALSE; + } + convert_to_string_ex(req); request = recode_new_request(ReSG(outer)); |