diff options
author | Wez Furlong <wez@php.net> | 2002-08-25 10:26:58 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2002-08-25 10:26:58 +0000 |
commit | c7be7b55d1c2f9a1765daf470195a6be647f96ee (patch) | |
tree | ae045210583ae2311d1860443b4e374bcb6e04f9 | |
parent | 27adb755855c004c80484b744f9551ac1cac19b6 (diff) | |
download | php-git-c7be7b55d1c2f9a1765daf470195a6be647f96ee.tar.gz |
Add a "closing" parameter for filters to determine if a flush is the last
flush before the stream is closed. This allows filters to finish a chunk
and write footers etc.
-rw-r--r-- | ext/standard/string.c | 4 | ||||
-rwxr-xr-x | main/php_streams.h | 10 | ||||
-rwxr-xr-x | main/streams.c | 8 |
3 files changed, 11 insertions, 11 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c index 624706e6e3..68b3de8e84 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3964,9 +3964,9 @@ static size_t strfilter_rot13_read(php_stream *stream, php_stream_filter *thisfi return read; } -static int strfilter_rot13_flush(php_stream *stream, php_stream_filter *thisfilter TSRMLS_DC) +static int strfilter_rot13_flush(php_stream *stream, php_stream_filter *thisfilter, int closing TSRMLS_DC) { - return php_stream_filter_flush_next(stream, thisfilter); + return php_stream_filter_flush_next(stream, thisfilter, closing); } static int strfilter_rot13_eof(php_stream *stream, php_stream_filter *thisfilter TSRMLS_DC) diff --git a/main/php_streams.h b/main/php_streams.h index 94bc0c363a..9745105d65 100755 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -182,7 +182,7 @@ typedef struct _php_stream_filter_ops { const char *buf, size_t count TSRMLS_DC); size_t (*read)(php_stream *stream, php_stream_filter *thisfilter, char *buf, size_t count TSRMLS_DC); - int (*flush)(php_stream *stream, php_stream_filter *thisfilter TSRMLS_DC); + int (*flush)(php_stream *stream, php_stream_filter *thisfilter, int closing TSRMLS_DC); int (*eof)(php_stream *stream, php_stream_filter *thisfilter TSRMLS_DC); void (*dtor)(php_stream_filter *thisfilter TSRMLS_DC); const char *label; @@ -205,8 +205,8 @@ struct _php_stream_filter { (thisfilter)->next ? (thisfilter)->next->fops->read((stream), (thisfilter)->next, (buf), (size) TSRMLS_CC) \ : (stream)->ops->read((stream), (buf), (size) TSRMLS_CC) -#define php_stream_filter_flush_next(stream, thisfilter) \ - (thisfilter)->next ? (thisfilter)->next->fops->flush((stream), (thisfilter) TSRMLS_CC) \ +#define php_stream_filter_flush_next(stream, thisfilter, closing) \ + (thisfilter)->next ? (thisfilter)->next->fops->flush((stream), (thisfilter), (closing) TSRMLS_CC) \ : (stream)->ops->flush((stream) TSRMLS_CC) #define php_stream_filter_eof_next(stream, thisfilter) \ @@ -321,8 +321,8 @@ PHPAPI int _php_stream_getc(php_stream *stream TSRMLS_DC); PHPAPI int _php_stream_putc(php_stream *stream, int c TSRMLS_DC); #define php_stream_putc(stream, c) _php_stream_putc((stream), (c) TSRMLS_CC) -PHPAPI int _php_stream_flush(php_stream *stream TSRMLS_DC); -#define php_stream_flush(stream) _php_stream_flush((stream) TSRMLS_CC) +PHPAPI int _php_stream_flush(php_stream *stream, int closing TSRMLS_DC); +#define php_stream_flush(stream) _php_stream_flush((stream), 0 TSRMLS_CC) PHPAPI char *_php_stream_gets(php_stream *stream, char *buf, size_t maxlen TSRMLS_DC); #define php_stream_gets(stream, buf, maxlen) _php_stream_gets((stream), (buf), (maxlen) TSRMLS_CC) diff --git a/main/streams.c b/main/streams.c index 943c600d81..775986d360 100755 --- a/main/streams.c +++ b/main/streams.c @@ -111,7 +111,7 @@ fprintf(stderr, "stream_free: %s:%p in_free=%d opts=%08x\n", stream->ops->label, stream->in_free++; - php_stream_flush(stream); + _php_stream_flush(stream, 1 TSRMLS_CC); if ((close_options & PHP_STREAM_FREE_RSRC_DTOR) == 0) { /* Remove entry from the resource list */ @@ -401,10 +401,10 @@ PHPAPI char *_php_stream_gets(php_stream *stream, char *buf, size_t maxlen TSRML return NULL; } -PHPAPI int _php_stream_flush(php_stream *stream TSRMLS_DC) +PHPAPI int _php_stream_flush(php_stream *stream, int closing TSRMLS_DC) { if (stream->filterhead) - stream->filterhead->fops->flush(stream, stream->filterhead TSRMLS_CC); + stream->filterhead->fops->flush(stream, stream->filterhead, closing TSRMLS_CC); if (stream->ops->flush) { return stream->ops->flush(stream TSRMLS_CC); @@ -440,7 +440,7 @@ PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_ if (stream->ops->seek) { if (stream->filterhead) - stream->filterhead->fops->flush(stream, stream->filterhead TSRMLS_CC); + stream->filterhead->fops->flush(stream, stream->filterhead, 0 TSRMLS_CC); return stream->ops->seek(stream, offset, whence TSRMLS_CC); } |