summaryrefslogtreecommitdiff
path: root/main/php_streams.h
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2002-09-23 01:47:04 +0000
committerWez Furlong <wez@php.net>2002-09-23 01:47:04 +0000
commit4d8a07d52908505e1516e6cef455debb07f1c2e2 (patch)
tree19a7390f43764582533dba4f4733479fc48cc9b6 /main/php_streams.h
parent625e7b202bee50d4d2689e23e326aef1f94f08b4 (diff)
downloadphp-git-4d8a07d52908505e1516e6cef455debb07f1c2e2.tar.gz
Implement read buffering in streams.
Eliminate similar code from network.c. Implement fgets equivalent at the streams level, which can detect the mac, dos and unix line endings and handle them appropriately. The default behaviour is unix (and dos) line endings. An ini option to control this behaviour will follow. # Don't forget to make clean! # I've done some testing but would appreciate feedback from # people with scripts/extensions that seek around a lot.
Diffstat (limited to 'main/php_streams.h')
-rwxr-xr-xmain/php_streams.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/main/php_streams.h b/main/php_streams.h
index fa57b5aff3..5cd12839f0 100755
--- a/main/php_streams.h
+++ b/main/php_streams.h
@@ -148,8 +148,7 @@ typedef struct _php_stream_ops {
const char *label; /* label for this ops structure */
/* these are optional */
- int (*seek)(php_stream *stream, off_t offset, int whence TSRMLS_DC);
- char *(*gets)(php_stream *stream, char *buf, size_t size TSRMLS_DC);
+ int (*seek)(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
int (*cast)(php_stream *stream, int castas, void **ret TSRMLS_DC);
int (*stat)(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
int (*set_option)(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC);
@@ -217,7 +216,12 @@ struct _php_stream_filter {
(thisfilter)->next ? (thisfilter)->next->fops->eof((stream), (thisfilter) TSRMLS_CC) \
: (stream)->ops->read((stream), NULL, 0 TSRMLS_CC) == EOF ? 1 : 0
+#define PHP_STREAM_FLAG_NO_SEEK 1
+#define PHP_STREAM_FLAG_NO_BUFFER 2
+#define PHP_STREAM_FLAG_EOL_UNIX 0 /* also includes DOS */
+#define PHP_STREAM_FLAG_DETECT_EOL 4
+#define PHP_STREAM_FLAG_EOL_MAC 8
struct _php_stream {
php_stream_ops *ops;
@@ -245,6 +249,17 @@ struct _php_stream {
#endif
php_stream_context *context;
+ int flags; /* PHP_STREAM_FLAG_XXX */
+
+ /* buffer */
+ off_t position; /* of underlying stream */
+ unsigned char *readbuf;
+ size_t readbuflen;
+ size_t readpos;
+ size_t writepos;
+
+ /* how much data to read when filling buffer */
+ size_t chunk_size;
}; /* php_stream */
/* state definitions when closing down; these are private to streams.c */