Lines Matching refs:stream

28 PHPAPI size_t php_stream_read(php_stream * stream, char * buf, size_t count);
29 PHPAPI size_t php_stream_write(php_stream * stream, const char * buf, size_t
31 PHPAPI size_t php_stream_printf(php_stream * stream TSRMLS_DC,
33 PHPAPI int php_stream_eof(php_stream * stream);
34 PHPAPI int php_stream_getc(php_stream * stream);
35 PHPAPI char *php_stream_gets(php_stream * stream, char *buf, size_t maxlen);
36 PHPAPI int php_stream_close(php_stream * stream);
37 PHPAPI int php_stream_flush(php_stream * stream);
38 PHPAPI int php_stream_seek(php_stream * stream, off_t offset, int whence);
39 PHPAPI off_t php_stream_tell(php_stream * stream);
40 PHPAPI int php_stream_lock(php_stream * stream, int mode);
61 STREAM_MUST_SEEK - If you really need to be able to seek the stream
63 file/URL, use this option to arrange for the stream
64 to be copied (if needed) into a stream that can
72 If you need to open a specific stream, or convert standard resources into
77 Convert a FILE * into a stream.
80 Open a FILE * with tmpfile() and convert into a stream.
89 Convert a socket into a stream.
93 Open a connection to a host and return a stream.
103 If you need to copy some data from one stream to another, you will be please
109 If you want to copy all remaining data from the src stream, pass
115 If you want to read the contents of a stream into an allocated memory buffer,
123 data remaining on the stream if you set maxlen to PHP_STREAM_COPY_ALL.
128 If you have an existing stream and need to be able to seek() it, you
129 can use this function to copy the contents into a new stream that can
135 #define PHP_STREAM_UNCHANGED 0 /* orig stream was seekable anyway */
140 make_seekable will always set newstream to be the stream that is valid
142 When you have finished, remember to close the stream.
148 NOTE: Writing to the stream may not affect the original source, so it
158 NOTE: If you are opening a stream and need it to be seekable, use the
161 PHPAPI int php_stream_supports_lock(php_stream * stream);
164 not a lock can be set on this stream. Typically you can only set locks on stdio streams.
169 You need to "cast" the stream into a FILE*, and this is how you do it:
172 php_stream * stream; /* already opened */
174 if (php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void*)&fp, REPORT_ERRORS) == FAILURE) {
180 PHPAPI int php_stream_cast(php_stream * stream, int castas, void ** ret, int
191 If you ask a socket stream for a FILE*, the abstraction will use fdopen to
193 if you mix ANSI stdio calls on the FILE* with php stream calls on the stream.
196 FILE* on top of any stream, which is useful for SSL sockets, memory based
199 In situations where this is not desirable, you should query the stream
203 if (php_stream_is(stream, PHP_STREAM_IS_STDIO)) {
209 PHPAPI int php_stream_can_cast(php_stream * stream, int castas)
211 to find out if a stream can be cast, without actually performing the cast, so
212 to check if a stream is a socket you might use:
214 if (php_stream_can_cast(stream, PHP_STREAM_AS_SOCKETD) == SUCCESS) {
219 stream_is tells you if the stream is a particular type of stream, whereas
220 can_cast tells you if the stream can be forced into the form you request.
222 state in the stream.
227 There are two main structures associated with a stream - the php_stream
240 The idea is that a stream implementation defines a php_stream_ops struct, and
263 A socket based stream would use code similar to that above to create a stream
273 of the stream,
274 bufsize is the size of the buffer to use - if 0, then buffering at the stream
284 The mode parameter is passed on to fdopen/fopencookie when the stream is cast
287 Writing your own stream implementation
299 RULE #2: Please use the stdio stream as a reference; it will help you
300 understand the semantics of the stream operations, and it will always
305 based streams, or if you were making a stream to read data from an RDBMS like
308 The stream has a field called abstract that you can use to hold this data.
327 /* now allocate the stream itself */
328 stream = php_stream_alloc(&my_ops, state, 0, persistent, "r");
330 /* now stream->abstract == state */
336 For example, for reading from this weird MySQL stream:
338 static size_t php_mysqlop_read(php_stream * stream, char * buf, size_t count)
340 struct my_state * state = (struct my_state*)stream->abstract;
351 /* pull out some data from the stream and put it in buf */
360 are all mandatory. The rest are optional. Declare your stream ops struct:
376 You may read the stream->persistent field to determine if your struct was