31#if defined(HAVE_FUNOPEN) && !defined(HAVE_FOPENCOOKIE)
34# if defined(__NetBSD__) && (__NetBSD_Version__ >= 600000000)
35# define PHP_FPOS_T off_t
37# define PHP_FPOS_T fpos_t
41 int (*reader)(
void *,
char *, int);
42 int (*writer)(
void *,
const char *, int);
43 PHP_FPOS_T (*seeker)(
void *, PHP_FPOS_T, int);
44 int (*closer)(
void *);
45} cookie_io_functions_t;
47FILE *fopencookie(
void *cookie,
const char *
mode, cookie_io_functions_t *funcs)
49 FILE *
file = funopen(cookie, funcs->reader, funcs->writer, funcs->seeker, funcs->closer);
58# define HAVE_FOPENCOOKIE 1
59# define PHP_EMULATE_FOPENCOOKIE 1
60# define PHP_STREAM_COOKIE_FUNCTIONS &stream_cookie_functions
61#elif defined(HAVE_FOPENCOOKIE)
62# define PHP_STREAM_COOKIE_FUNCTIONS stream_cookie_functions
66#if defined(PHP_EMULATE_FOPENCOOKIE)
68static int stream_cookie_reader(
void *cookie,
char *
buffer,
int size)
76static int stream_cookie_writer(
void *cookie,
const char *
buffer,
int size)
82static PHP_FPOS_T stream_cookie_seeker(
void *cookie,
zend_off_t position,
int whence)
88static int stream_cookie_closer(
void *cookie)
97#elif defined(HAVE_FOPENCOOKIE)
98static ssize_t stream_cookie_reader(
void *cookie,
char *
buffer,
size_t size)
106static ssize_t stream_cookie_writer(
void *cookie,
const char *
buffer,
size_t size)
112# ifdef COOKIE_SEEKER_USES_OFF64_T
113static int stream_cookie_seeker(
void *cookie, off64_t *position,
int whence)
115static int stream_cookie_seeker(
void *cookie, off_t *position,
int whence)
121 if (*position == -1) {
127static int stream_cookie_closer(
void *cookie)
138#ifdef HAVE_FOPENCOOKIE
139static cookie_io_functions_t stream_cookie_functions =
141 stream_cookie_reader, stream_cookie_writer,
142 stream_cookie_seeker, stream_cookie_closer
155 const char *cur_mode = stream->
mode;
161 if (cur_mode[0] ==
'r' || cur_mode[0] ==
'w' || cur_mode[0] ==
'a') {
162 result[res_curs++] = cur_mode[0];
173 for (i = 1; i < 4 && cur_mode[i] !=
'\0'; i++) {
174 if (cur_mode[i] ==
'b') {
176 }
else if (cur_mode[i] ==
'+') {
230#ifdef HAVE_FOPENCOOKIE
239 *(FILE**)
ret = fopencookie(stream, fixed_mode, PHP_STREAM_COOKIE_FUNCTIONS);
311 static const char *cast_names[4] = {
315 "select()able descriptor"
357 if (stream ==
NULL) {
363 if (opened_path && *opened_path) {
375 if (newstream ==
NULL) {
381 *newstream = origstream;
393 if (*newstream ==
NULL) {
398 (*newstream)->open_filename = origstream->open_filename;
399 (*newstream)->open_lineno = origstream->open_lineno;
file(string $filename, int $flags=0, $context=null)
void php_stream_mode_sanitize_fdopen_fopencookie(php_stream *stream, char *result)
PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err)
PHPAPI FILE * _php_stream_open_wrapper_as_file(char *path, char *mode, int options, zend_string **opened_path STREAMS_DC)
PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstream, int flags STREAMS_DC)
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
unsigned const char * pos
PHP_JSON_API size_t int options
#define php_stream_temp_new()
#define php_stream_is_filtered(stream)
#define php_stream_fopen_tmpfile()
#define php_stream_cast(stream, as, ret, show_err)
#define PHP_STREAM_IS_STDIO
struct _php_stream php_stream
#define PHP_STREAM_CRITICAL
#define PHP_STREAM_FREE_CLOSE_CASTED
#define PHP_STREAM_FCLOSE_FOPENCOOKIE
#define php_stream_read(stream, buf, count)
#define PHP_STREAM_UNCHANGED
#define PHP_STREAM_AS_FD_FOR_SELECT
#define PHP_STREAM_CAST_TRY_HARD
#define PHP_STREAM_CAST_RELEASE
#define PHP_STREAM_COPY_ALL
#define PHP_STREAM_FLAG_NO_SEEK
#define php_stream_seek(stream, offset, whence)
#define PHP_STREAM_CAST_MASK
#define php_stream_flush(stream)
#define php_stream_open_wrapper_rel(path, mode, options, opened)
#define PHP_STREAM_FAILED
#define php_stream_free(stream, close_options)
#define php_stream_close(stream)
#define PHP_STREAM_FREE_CLOSE
#define php_stream_is(stream, anops)
#define php_stream_tell(stream)
#define PHP_STREAM_PREFER_STDIO
#define PHP_STREAM_FORCE_CONVERSION
#define PHP_STREAM_FREE_KEEP_RSRC
#define PHP_STREAM_FREE_RSRC_DTOR
#define PHP_STREAM_FCLOSE_NONE
#define php_stream_copy_to_stream_ex(src, dest, maxlen, len)
#define PHP_STREAM_AS_STDIO
#define php_stream_write(stream, buf, count)
#define PHP_STREAM_RELEASED
#define PHP_STREAM_CAST_INTERNAL
int(* cast)(php_stream *stream, int castas, void **ret)
int(* seek)(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset)
const php_stream_ops * ops
uint16_t fclose_stdiocast
zend_string_release_ex(func->internal_function.function_name, 0)
struct _zend_string zend_string