summaryrefslogtreecommitdiff
path: root/ext/recode
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2002-03-15 21:03:08 +0000
committerWez Furlong <wez@php.net>2002-03-15 21:03:08 +0000
commit0f65280cb5118d8c1a85db6626f7be365f3d1b26 (patch)
tree931b09acc5041eb771017e3ebf9ecb9aa833d722 /ext/recode
parent3a1ebd4f519facbd7ec769304857aad40e49cf1c (diff)
downloadphp-git-0f65280cb5118d8c1a85db6626f7be365f3d1b26.tar.gz
New PHP streams...
Diffstat (limited to 'ext/recode')
-rw-r--r--ext/recode/recode.c25
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));