summaryrefslogtreecommitdiff
path: root/ext/standard/file.c
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2002-03-21 01:11:52 +0000
committerWez Furlong <wez@php.net>2002-03-21 01:11:52 +0000
commita662f012bba5a6fdc50533673f3fff47bf9af219 (patch)
treeb35b92af8c3cd58d62e4b5d86995af6404380f8d /ext/standard/file.c
parent4094513915c995c593c418d654714f0496da4e8f (diff)
downloadphp-git-a662f012bba5a6fdc50533673f3fff47bf9af219.tar.gz
Convert the gzfile related functions into aliases for their equivalents
in ext/standard/file.c, so a gzopen()ed file pointer can be used in fread, fseek etc. Improved behaviour of zlib stream. Moved passthru code into streams.c # I'm not happy about BG(mmap_file) Nuked gzgetss_state as no longer needed.
Diffstat (limited to 'ext/standard/file.c')
-rw-r--r--ext/standard/file.c53
1 files changed, 2 insertions, 51 deletions
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 0a6d1716a9..801970b9fe 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -1326,55 +1326,6 @@ PHP_FUNCTION(rmdir)
}
/* }}} */
-/* {{{ php_passthru_stream */
-static size_t php_passthru_stream(php_stream *stream TSRMLS_DC)
-{
- size_t bcount = 0;
- int ready = 0;
- char buf[8192];
-#ifdef HAVE_MMAP
- int fd;
-#endif
-
-#ifdef HAVE_MMAP
- if (!php_stream_is(stream, PHP_STREAM_IS_SOCKET)
- && php_stream_cast(stream, PHP_STREAM_AS_FD, (void*)&fd, 0))
- {
- struct stat sbuf;
- off_t off;
- void *p;
- size_t len;
-
- fstat(fd, &sbuf);
-
- if (sbuf.st_size > sizeof(buf)) {
- off = php_stream_tell(stream);
- len = sbuf.st_size - off;
- p = mmap(0, len, PROT_READ, MAP_SHARED, fd, off);
- if (p != (void *) MAP_FAILED) {
- BG(mmap_file) = p;
- BG(mmap_len) = len;
- PHPWRITE(p, len);
- BG(mmap_file) = NULL;
- munmap(p, len);
- bcount += len;
- ready = 1;
- }
- }
- }
-#endif
- if(!ready) {
- int b;
-
- while ((b = php_stream_read(stream, buf, sizeof(buf))) > 0) {
- PHPWRITE(buf, b);
- bcount += b;
- }
- }
- return bcount;
-}
-/* }}} */
-
/* {{{ proto int readfile(string filename [, int use_include_path])
Output a file or a URL */
PHP_FUNCTION(readfile)
@@ -1407,7 +1358,7 @@ PHP_FUNCTION(readfile)
use_include_path | ENFORCE_SAFE_MODE | REPORT_ERRORS,
NULL);
if (stream) {
- size = php_passthru_stream(stream TSRMLS_CC);
+ size = php_stream_passthru(stream);
php_stream_close(stream);
RETURN_LONG(size);
}
@@ -1460,7 +1411,7 @@ PHP_FUNCTION(fpassthru)
what = zend_fetch_resource(arg1 TSRMLS_CC,-1, "File-Handle", &type, 1, le_stream);
ZEND_VERIFY_RESOURCE(what);
- size = php_passthru_stream((php_stream*)what TSRMLS_CC);
+ size = php_stream_passthru((php_stream*)what);
RETURN_LONG(size);
}
/* }}} */