diff options
| author | Wez Furlong <wez@php.net> | 2002-03-21 01:11:52 +0000 |
|---|---|---|
| committer | Wez Furlong <wez@php.net> | 2002-03-21 01:11:52 +0000 |
| commit | a662f012bba5a6fdc50533673f3fff47bf9af219 (patch) | |
| tree | b35b92af8c3cd58d62e4b5d86995af6404380f8d /ext/zlib/zlib_fopen_wrapper.c | |
| parent | 4094513915c995c593c418d654714f0496da4e8f (diff) | |
| download | php-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/zlib/zlib_fopen_wrapper.c')
| -rw-r--r-- | ext/zlib/zlib_fopen_wrapper.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ext/zlib/zlib_fopen_wrapper.c b/ext/zlib/zlib_fopen_wrapper.c index df2961c4be..d2acfa0e27 100644 --- a/ext/zlib/zlib_fopen_wrapper.c +++ b/ext/zlib/zlib_fopen_wrapper.c @@ -12,7 +12,8 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Author: Hartmut Holzgraefe <hartmut@six.de> | + | Author: Wez Furlong <wez@thebrainroom.com>, based on work by: | + | Hartmut Holzgraefe <hartmut@six.de> | +----------------------------------------------------------------------+ */ /* $Id$ */ @@ -57,6 +58,11 @@ static size_t php_gziop_write(php_stream *stream, const char *buf, size_t count static int php_gziop_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC) { struct php_gz_stream_data_t *self = (struct php_gz_stream_data_t *)stream->abstract; + + assert(self != NULL); + if (offset == 0 && whence == SEEK_CUR) + return gztell(self->gz_file); + return gzseek(self->gz_file, offset, whence); } @@ -90,14 +96,14 @@ php_stream *php_stream_gzopen(char *path, char *mode, int options, char **opened if (strncmp("zlib:", path, 5) == 0) path += 5; - self->stream = php_stream_open_wrapper(path, mode, options, opened_path); + self->stream = php_stream_open_wrapper(path, mode, STREAM_MUST_SEEK|options, opened_path); if (self->stream) { int fd; if (SUCCESS == php_stream_cast(self->stream, PHP_STREAM_AS_FD, (void**)&fd, REPORT_ERRORS)) { self->gz_file = gzdopen(fd, mode); if (self->gz_file) { - stream = php_stream_alloc(&php_stream_gzio_ops, self, 0, mode); + stream = php_stream_alloc_rel(&php_stream_gzio_ops, self, 0, mode); if (stream) return stream; gzclose(self->gz_file); |
