2727#include <sys/types.h>
2828#include <sys/stat.h>
2929
30+ BEGIN_EXTERN_C ()
3031PHPAPI int php_file_le_stream (void );
3132PHPAPI int php_file_le_pstream (void );
33+ END_EXTERN_C ()
3234
3335/* {{{ Streams memory debugging stuff */
3436
@@ -226,8 +228,10 @@ struct _php_stream {
226228#define PHP_STREAM_FCLOSE_FOPENCOOKIE 2
227229
228230/* allocate a new stream for a particular ops */
231+ BEGIN_EXTERN_C ()
229232PHPAPI php_stream * _php_stream_alloc (php_stream_ops * ops , void * abstract ,
230233 const char * persistent_id , const char * mode STREAMS_DC TSRMLS_DC );
234+ END_EXTERN_C ()
231235#define php_stream_alloc (ops , thisptr , persistent_id , mode ) _php_stream_alloc((ops), (thisptr), (persistent_id), (mode) STREAMS_CC TSRMLS_CC)
232236
233237
@@ -247,6 +251,7 @@ PHPAPI php_stream *_php_stream_alloc(php_stream_ops *ops, void *abstract,
247251#define php_stream_from_zval (xstr , ppzval ) ZEND_FETCH_RESOURCE2((xstr), php_stream *, (ppzval), -1, "stream", php_file_le_stream(), php_file_le_pstream())
248252#define php_stream_from_zval_no_verify (xstr , ppzval ) (xstr) = (php_stream*)zend_fetch_resource((ppzval) TSRMLS_CC, -1, "stream", NULL, 2, php_file_le_stream(), php_file_le_pstream())
249253
254+ BEGIN_EXTERN_C ()
250255PHPAPI int php_stream_from_persistent_id (const char * persistent_id , php_stream * * stream TSRMLS_DC );
251256#define PHP_STREAM_PERSISTENT_SUCCESS 0 /* id exists */
252257#define PHP_STREAM_PERSISTENT_FAILURE 1 /* id exists but is not a stream! */
@@ -260,6 +265,7 @@ PHPAPI int php_stream_from_persistent_id(const char *persistent_id, php_stream *
260265#define PHP_STREAM_FREE_CLOSE (PHP_STREAM_FREE_CALL_DTOR | PHP_STREAM_FREE_RELEASE_STREAM)
261266#define PHP_STREAM_FREE_CLOSE_CASTED (PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_PRESERVE_HANDLE)
262267#define PHP_STREAM_FREE_CLOSE_PERSISTENT (PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_PERSISTENT)
268+
263269PHPAPI int _php_stream_free (php_stream * stream , int close_options TSRMLS_DC );
264270#define php_stream_free (stream , close_options ) _php_stream_free((stream), (close_options) TSRMLS_CC)
265271#define php_stream_close (stream ) _php_stream_free((stream), PHP_STREAM_FREE_CLOSE TSRMLS_CC)
@@ -337,6 +343,9 @@ PHPAPI int _php_stream_set_option(php_stream *stream, int option, int value, voi
337343
338344#define php_stream_set_chunk_size (stream , size ) _php_stream_set_option((stream), PHP_STREAM_OPTION_SET_CHUNK_SIZE, (size), NULL TSRMLS_CC)
339345
346+ END_EXTERN_C ()
347+
348+
340349/* Flags for mkdir method in wrapper ops */
341350#define PHP_STREAM_MKDIR_RECURSIVE 1
342351/* define REPORT ERRORS 8 (below) */
@@ -384,8 +393,10 @@ PHPAPI int _php_stream_set_option(php_stream *stream, int option, int value, voi
384393
385394#define php_stream_truncate_supported (stream ) (_php_stream_set_option((stream), PHP_STREAM_OPTION_TRUNCATE_API, PHP_STREAM_TRUNCATE_SUPPORTED, NULL TSRMLS_CC) == PHP_STREAM_OPTION_RETURN_OK ? 1 : 0)
386395
396+ BEGIN_EXTERN_C ()
387397PHPAPI int _php_stream_truncate_set_size (php_stream * stream , size_t newsize TSRMLS_DC );
388398#define php_stream_truncate_set_size (stream , size ) _php_stream_truncate_set_size((stream), (size) TSRMLS_CC)
399+ END_EXTERN_C ()
389400
390401#define PHP_STREAM_OPTION_META_DATA_API 11 /* ptrparam is a zval* to which to add meta data information */
391402#define php_stream_populate_meta_data (stream , zv ) (_php_stream_set_option((stream), PHP_STREAM_OPTION_META_DATA_API, 0, zv TSRMLS_CC) == PHP_STREAM_OPTION_RETURN_OK ? 1 : 0)
@@ -401,6 +412,7 @@ PHPAPI int _php_stream_truncate_set_size(php_stream *stream, size_t newsize TSRM
401412/* copy up to maxlen bytes from src to dest. If maxlen is PHP_STREAM_COPY_ALL, copy until eof(src).
402413 * Uses mmap if the src is a plain file and at offset 0 */
403414#define PHP_STREAM_COPY_ALL -1
415+ BEGIN_EXTERN_C ()
404416PHPAPI size_t _php_stream_copy_to_stream (php_stream * src , php_stream * dest , size_t maxlen STREAMS_DC TSRMLS_DC );
405417#define php_stream_copy_to_stream (src , dest , maxlen ) _php_stream_copy_to_stream((src), (dest), (maxlen) STREAMS_CC TSRMLS_CC)
406418
@@ -414,6 +426,7 @@ PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen
414426/* output all data from a stream */
415427PHPAPI size_t _php_stream_passthru (php_stream * src STREAMS_DC TSRMLS_DC );
416428#define php_stream_passthru (stream ) _php_stream_passthru((stream) STREAMS_CC TSRMLS_CC)
429+ END_EXTERN_C ()
417430
418431#include "streams/php_stream_transport.h"
419432#include "streams/php_stream_plain_wrapper.h"
@@ -435,7 +448,9 @@ PHPAPI size_t _php_stream_passthru(php_stream * src STREAMS_DC TSRMLS_DC);
435448#define PHP_STREAM_CAST_RELEASE 0x40000000 /* stream becomes invalid on success */
436449#define PHP_STREAM_CAST_INTERNAL 0x20000000 /* stream cast for internal use */
437450#define PHP_STREAM_CAST_MASK (PHP_STREAM_CAST_TRY_HARD | PHP_STREAM_CAST_RELEASE | PHP_STREAM_CAST_INTERNAL)
451+ BEGIN_EXTERN_C ()
438452PHPAPI int _php_stream_cast (php_stream * stream , int castas , void * * ret , int show_err TSRMLS_DC );
453+ END_EXTERN_C ()
439454/* use this to check if a stream can be cast into another form */
440455#define php_stream_can_cast (stream , as ) _php_stream_cast((stream), (as), NULL, 0 TSRMLS_CC)
441456#define php_stream_cast (stream , as , ret , show_err ) _php_stream_cast((stream), (as), (ret), (show_err) TSRMLS_CC)
@@ -491,6 +506,7 @@ int php_init_stream_wrappers(int module_number TSRMLS_DC);
491506int php_shutdown_stream_wrappers (int module_number TSRMLS_DC );
492507PHP_RSHUTDOWN_FUNCTION (streams );
493508
509+ BEGIN_EXTERN_C ()
494510PHPAPI int php_register_url_stream_wrapper (char * protocol , php_stream_wrapper * wrapper TSRMLS_DC );
495511PHPAPI int php_unregister_url_stream_wrapper (char * protocol TSRMLS_DC );
496512PHPAPI php_stream * _php_stream_open_wrapper_ex (char * path , char * mode , int options , char * * opened_path , php_stream_context * context STREAMS_DC TSRMLS_DC );
@@ -524,6 +540,7 @@ PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstr
524540/* Give other modules access to the url_stream_wrappers_hash and stream_filters_hash */
525541PHPAPI HashTable * php_stream_get_url_stream_wrappers_hash ();
526542PHPAPI HashTable * php_get_stream_filters_hash ();
543+ END_EXTERN_C ()
527544#endif
528545
529546/*
0 commit comments