php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
memory.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Author: Marcus Boerger <helly@php.net> |
14 +----------------------------------------------------------------------+
15 */
16
17#ifndef _GNU_SOURCE
18# define _GNU_SOURCE
19#endif
20#include "php.h"
21#include "ext/standard/base64.h"
22
23PHPAPI size_t php_url_decode(char *str, size_t len);
24
25/* Memory streams use a dynamic memory buffer to emulate a stream.
26 * You can use php_stream_memory_open to create a readonly stream
27 * from an existing memory buffer.
28 */
29
30/* Temp streams are streams that uses memory streams as long their
31 * size is less than a given memory amount. When a write operation
32 * exceeds that limit the content is written to a temporary file.
33 */
34
35/* {{{ ------- MEMORY stream implementation -------*/
36
37typedef struct {
39 size_t fpos;
40 int mode;
42
43
44/* {{{ */
45static ssize_t php_stream_memory_write(php_stream *stream, const char *buf, size_t count)
46{
48 assert(ms != NULL);
49
50 if (ms->mode & TEMP_STREAM_READONLY) {
51 return (ssize_t) -1;
52 }
53 size_t data_len = ZSTR_LEN(ms->data);
54 if (ms->mode & TEMP_STREAM_APPEND) {
55 ms->fpos = data_len;
56 }
57 if (ms->fpos + count > data_len) {
58 ms->data = zend_string_realloc(ms->data, ms->fpos + count, 0);
59 if (ms->fpos > data_len) {
60 /* zero the bytes added due to seek past end position */
61 memset(ZSTR_VAL(ms->data) + data_len, 0, ms->fpos - data_len);
62 }
63 } else {
64 ms->data = zend_string_separate(ms->data, 0);
65 }
66 if (count) {
68 memcpy(ZSTR_VAL(ms->data) + ms->fpos, (char*) buf, count);
69 ZSTR_VAL(ms->data)[ZSTR_LEN(ms->data)] = '\0';
70 ms->fpos += count;
71 }
72 return count;
73}
74/* }}} */
75
76
77/* {{{ */
78static ssize_t php_stream_memory_read(php_stream *stream, char *buf, size_t count)
79{
81 assert(ms != NULL);
82
83 if (ms->fpos >= ZSTR_LEN(ms->data)) {
84 stream->eof = 1;
85 count = 0;
86 } else {
87 if (ms->fpos + count > ZSTR_LEN(ms->data)) {
88 count = ZSTR_LEN(ms->data) - ms->fpos;
89 }
90 if (count) {
92 memcpy(buf, ZSTR_VAL(ms->data) + ms->fpos, count);
93 ms->fpos += count;
94 }
95 }
96 return count;
97}
98/* }}} */
99
100
101/* {{{ */
102static int php_stream_memory_close(php_stream *stream, int close_handle)
103{
105 ZEND_ASSERT(ms != NULL);
106 zend_string_release(ms->data);
107 efree(ms);
108 return 0;
109}
110/* }}} */
111
112
113/* {{{ */
114static int php_stream_memory_flush(php_stream *stream)
115{
116 /* nothing to do here */
117 return 0;
118}
119/* }}} */
120
121
122/* {{{ */
123static int php_stream_memory_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs)
124{
126 assert(ms != NULL);
127
128 switch(whence) {
129 case SEEK_CUR:
130 if (offset < 0) {
131 if (ms->fpos < (size_t)(-offset)) {
132 ms->fpos = 0;
133 *newoffs = -1;
134 return -1;
135 } else {
136 ms->fpos = ms->fpos + offset;
137 *newoffs = ms->fpos;
138 stream->eof = 0;
139 return 0;
140 }
141 } else {
142 stream->eof = 0;
143 ms->fpos = ms->fpos + offset;
144 *newoffs = ms->fpos;
145 return 0;
146 }
147 case SEEK_SET:
148 if (offset < 0) {
149 ms->fpos = 0;
150 *newoffs = -1;
151 return -1;
152 } else {
153 ms->fpos = offset;
154 *newoffs = ms->fpos;
155 stream->eof = 0;
156 return 0;
157 }
158 case SEEK_END:
159 if (offset > 0) {
160 ms->fpos = ZSTR_LEN(ms->data) + offset;
161 *newoffs = ms->fpos;
162 stream->eof = 0;
163 return 0;
164 } else if (ZSTR_LEN(ms->data) < (size_t)(-offset)) {
165 ms->fpos = 0;
166 *newoffs = -1;
167 return -1;
168 } else {
169 ms->fpos = ZSTR_LEN(ms->data) + offset;
170 *newoffs = ms->fpos;
171 stream->eof = 0;
172 return 0;
173 }
174 default:
175 *newoffs = ms->fpos;
176 return -1;
177 }
178}
179/* }}} */
180
181/* {{{ */
182static int php_stream_memory_cast(php_stream *stream, int castas, void **ret)
183{
184 return FAILURE;
185}
186/* }}} */
187
188static int php_stream_memory_stat(php_stream *stream, php_stream_statbuf *ssb) /* {{{ */
189{
190 time_t timestamp = 0;
192 assert(ms != NULL);
193
194 memset(ssb, 0, sizeof(php_stream_statbuf));
195 /* read-only across the board */
196
197 ssb->sb.st_mode = ms->mode & TEMP_STREAM_READONLY ? 0444 : 0666;
198
199 ssb->sb.st_size = ZSTR_LEN(ms->data);
200 ssb->sb.st_mode |= S_IFREG; /* regular file */
201 ssb->sb.st_mtime = timestamp;
202 ssb->sb.st_atime = timestamp;
203 ssb->sb.st_ctime = timestamp;
204 ssb->sb.st_nlink = 1;
205 ssb->sb.st_rdev = -1;
206 /* this is only for APC, so use /dev/null device - no chance of conflict there! */
207 ssb->sb.st_dev = 0xC;
208 /* generate unique inode number for alias/filename, so no phars will conflict */
209 ssb->sb.st_ino = 0;
210
211#ifndef PHP_WIN32
212 ssb->sb.st_blksize = -1;
213 ssb->sb.st_blocks = -1;
214#endif
215
216 return 0;
217}
218/* }}} */
219
220static int php_stream_memory_set_option(php_stream *stream, int option, int value, void *ptrparam) /* {{{ */
221{
223 size_t newsize;
224
225 switch(option) {
227 switch (value) {
230
232 if (ms->mode & TEMP_STREAM_READONLY) {
234 }
235 newsize = *(size_t*)ptrparam;
236 if (newsize <= ZSTR_LEN(ms->data)) {
237 ms->data = zend_string_truncate(ms->data, newsize, 0);
238 if (newsize < ms->fpos) {
239 ms->fpos = newsize;
240 }
241 } else {
242 size_t old_size = ZSTR_LEN(ms->data);
243 ms->data = zend_string_realloc(ms->data, newsize, 0);
244 memset(ZSTR_VAL(ms->data) + old_size, 0, newsize - old_size);
245 ZSTR_VAL(ms->data)[ZSTR_LEN(ms->data)] = '\0';
246 }
248 }
249 }
250
252}
253/* }}} */
254
256 php_stream_memory_write, php_stream_memory_read,
257 php_stream_memory_close, php_stream_memory_flush,
258 "MEMORY",
259 php_stream_memory_seek,
260 php_stream_memory_cast,
261 php_stream_memory_stat,
262 php_stream_memory_set_option
263};
264
265/* {{{ */
267{
268 if (strpbrk(mode, "a")) {
269 return TEMP_STREAM_APPEND;
270 } else if (strpbrk(mode, "w+")) {
271 return TEMP_STREAM_DEFAULT;
272 }
274}
275/* }}} */
276
277/* {{{ */
279{
280 if (mode == TEMP_STREAM_READONLY) {
281 return "rb";
282 } else if (mode == TEMP_STREAM_APPEND) {
283 return "a+b";
284 }
285 return "w+b";
286}
287/* }}} */
288
289/* {{{ */
291{
293 php_stream *stream;
294
295 self = emalloc(sizeof(*self));
296 self->data = ZSTR_EMPTY_ALLOC();
297 self->fpos = 0;
298 self->mode = mode;
299
302 return stream;
303}
304/* }}} */
305
306
307/* {{{ */
309{
310 php_stream *stream;
312
313 if ((stream = php_stream_memory_create_rel(mode)) != NULL) {
314 ms = (php_stream_memory_data*)stream->abstract;
315 ms->data = zend_string_copy(buf);
316 }
317 return stream;
318}
319/* }}} */
320
321
322/* {{{ */
329/* }}} */
330
331/* }}} */
332
333/* {{{ ------- TEMP stream implementation -------*/
334
342
343
344/* {{{ */
345static ssize_t php_stream_temp_write(php_stream *stream, const char *buf, size_t count)
346{
348 assert(ts != NULL);
349
350 if (!ts->innerstream) {
351 return -1;
352 }
355
356 if (pos + count >= ts->smax) {
359 if (file == NULL) {
360 php_error_docref(NULL, E_WARNING, "Unable to create temporary file, Check permissions in temporary files directory.");
361 return 0;
362 }
363 php_stream_write(file, ZSTR_VAL(membuf), ZSTR_LEN(membuf));
365 ts->innerstream = file;
366 php_stream_encloses(stream, ts->innerstream);
368 }
369 }
371}
372/* }}} */
373
374
375/* {{{ */
376static ssize_t php_stream_temp_read(php_stream *stream, char *buf, size_t count)
377{
379 size_t got;
380
381 assert(ts != NULL);
382
383 if (!ts->innerstream) {
384 return -1;
385 }
386
388
389 stream->eof = ts->innerstream->eof;
390
391 return got;
392}
393/* }}} */
394
395
396/* {{{ */
397static int php_stream_temp_close(php_stream *stream, int close_handle)
398{
400 int ret;
401
402 assert(ts != NULL);
403
404 if (ts->innerstream) {
406 } else {
407 ret = 0;
408 }
409
410 zval_ptr_dtor(&ts->meta);
411
412 if (ts->tmpdir) {
413 efree(ts->tmpdir);
414 }
415
416 efree(ts);
417
418 return ret;
419}
420/* }}} */
421
422
423/* {{{ */
424static int php_stream_temp_flush(php_stream *stream)
425{
427 assert(ts != NULL);
428
429 return ts->innerstream ? php_stream_flush(ts->innerstream) : -1;
430}
431/* }}} */
432
433
434/* {{{ */
435static int php_stream_temp_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs)
436{
438 int ret;
439
440 assert(ts != NULL);
441
442 if (!ts->innerstream) {
443 *newoffs = -1;
444 return -1;
445 }
446 ret = php_stream_seek(ts->innerstream, offset, whence);
447 *newoffs = php_stream_tell(ts->innerstream);
448 stream->eof = ts->innerstream->eof;
449
450 return ret;
451}
452/* }}} */
453
454/* {{{ */
455static int php_stream_temp_cast(php_stream *stream, int castas, void **ret)
456{
459 zend_string *membuf;
461
462 assert(ts != NULL);
463
464 if (!ts->innerstream) {
465 return FAILURE;
466 }
468 return php_stream_cast(ts->innerstream, castas, ret, 0);
469 }
470
471 /* we are still using a memory based backing. If they are if we can be
472 * a FILE*, say yes because we can perform the conversion.
473 * If they actually want to perform the conversion, we need to switch
474 * the memory stream to a tmpfile stream */
475
476 if (ret == NULL && castas == PHP_STREAM_AS_STDIO) {
477 return SUCCESS;
478 }
479
480 /* say "no" to other stream forms */
481 if (ret == NULL) {
482 return FAILURE;
483 }
484
486 if (file == NULL) {
487 php_error_docref(NULL, E_WARNING, "Unable to create temporary file.");
488 return FAILURE;
489 }
490
491 /* perform the conversion and then pass the request on to the innerstream */
493 php_stream_write(file, ZSTR_VAL(membuf), ZSTR_LEN(membuf));
495
497 ts->innerstream = file;
498 php_stream_encloses(stream, ts->innerstream);
500
501 return php_stream_cast(ts->innerstream, castas, ret, 1);
502}
503/* }}} */
504
505static int php_stream_temp_stat(php_stream *stream, php_stream_statbuf *ssb) /* {{{ */
506{
508
509 if (!ts || !ts->innerstream) {
510 return -1;
511 }
512 return php_stream_stat(ts->innerstream, ssb);
513}
514/* }}} */
515
516static int php_stream_temp_set_option(php_stream *stream, int option, int value, void *ptrparam) /* {{{ */
517{
519
520 switch(option) {
522 if (Z_TYPE(ts->meta) != IS_UNDEF) {
524 }
526 default:
527 if (ts->innerstream) {
528 return php_stream_set_option(ts->innerstream, option, value, ptrparam);
529 }
531 }
532}
533/* }}} */
534
536 php_stream_temp_write, php_stream_temp_read,
537 php_stream_temp_close, php_stream_temp_flush,
538 "TEMP",
539 php_stream_temp_seek,
540 php_stream_temp_cast,
541 php_stream_temp_stat,
542 php_stream_temp_set_option
543};
544
545/* }}} */
546
547/* {{{ _php_stream_temp_create_ex */
548PHPAPI php_stream *_php_stream_temp_create_ex(int mode, size_t max_memory_usage, const char *tmpdir STREAMS_DC)
549{
551 php_stream *stream;
552
553 self = ecalloc(1, sizeof(*self));
554 self->smax = max_memory_usage;
555 self->mode = mode;
556 ZVAL_UNDEF(&self->meta);
557 if (tmpdir) {
558 self->tmpdir = estrdup(tmpdir);
559 }
563 php_stream_encloses(stream, self->innerstream);
564
565 return stream;
566}
567/* }}} */
568
569/* {{{ _php_stream_temp_create */
571{
572 return php_stream_temp_create_ex(mode, max_memory_usage, NULL);
573}
574/* }}} */
575
576/* {{{ _php_stream_temp_open */
577PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, const char *buf, size_t length STREAMS_DC)
578{
579 php_stream *stream;
581 zend_off_t newoffs;
582
583 if ((stream = php_stream_temp_create_rel(mode, max_memory_usage)) != NULL) {
584 if (length) {
585 assert(buf != NULL);
586 php_stream_temp_write(stream, buf, length);
587 php_stream_temp_seek(stream, 0, SEEK_SET, &newoffs);
588 }
589 ts = (php_stream_temp_data*)stream->abstract;
590 assert(ts != NULL);
591 ts->mode = mode;
592 }
593 return stream;
594}
595/* }}} */
596
598 NULL, php_stream_temp_read,
599 php_stream_temp_close, php_stream_temp_flush,
600 "RFC2397",
601 php_stream_temp_seek,
602 php_stream_temp_cast,
603 php_stream_temp_stat,
604 php_stream_temp_set_option
605};
606
607static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, const char *path,
608 const char *mode, int options, zend_string **opened_path,
610{
611 php_stream *stream;
613 char *comma, *semi, *sep;
614 size_t mlen, dlen, plen, vlen, ilen;
615 zend_off_t newoffs;
616 zval meta;
617 int base64 = 0;
618 zend_string *base64_comma = NULL;
619
621
622 ZVAL_NULL(&meta);
623 if (memcmp(path, "data:", 5)) {
624 return NULL;
625 }
626
627 path += 5;
628 dlen = strlen(path);
629
630 if (dlen >= 2 && path[0] == '/' && path[1] == '/') {
631 dlen -= 2;
632 path += 2;
633 }
634
635 if ((comma = memchr(path, ',', dlen)) == NULL) {
636 php_stream_wrapper_log_error(wrapper, options, "rfc2397: no comma in URL");
637 return NULL;
638 }
639
640 if (comma != path) {
641 /* meta info */
642 mlen = comma - path;
643 dlen -= mlen;
644 semi = memchr(path, ';', mlen);
645 sep = memchr(path, '/', mlen);
646
647 if (!semi && !sep) {
648 php_stream_wrapper_log_error(wrapper, options, "rfc2397: illegal media type");
649 return NULL;
650 }
651
652 array_init(&meta);
653 if (!semi) { /* there is only a mime type */
654 add_assoc_stringl(&meta, "mediatype", (char *) path, mlen);
655 mlen = 0;
656 } else if (sep && sep < semi) { /* there is a mime type */
657 plen = semi - path;
658 add_assoc_stringl(&meta, "mediatype", (char *) path, plen);
659 mlen -= plen;
660 path += plen;
661 } else if (semi != path || mlen != sizeof(";base64")-1 || memcmp(path, ";base64", sizeof(";base64")-1)) { /* must be error since parameters are only allowed after mediatype */
662 zval_ptr_dtor(&meta);
663 php_stream_wrapper_log_error(wrapper, options, "rfc2397: illegal media type");
664 return NULL;
665 }
666 /* get parameters and potentially ';base64' */
667 while(semi && (semi == path)) {
668 path++;
669 mlen--;
670 sep = memchr(path, '=', mlen);
671 semi = memchr(path, ';', mlen);
672 if (!sep || (semi && semi < sep)) { /* must be ';base64' or failure */
673 if (mlen != sizeof("base64")-1 || memcmp(path, "base64", sizeof("base64")-1)) {
674 /* must be error since parameters are only allowed after mediatype and we have no '=' sign */
675 zval_ptr_dtor(&meta);
676 php_stream_wrapper_log_error(wrapper, options, "rfc2397: illegal parameter");
677 return NULL;
678 }
679 base64 = 1;
680 mlen -= sizeof("base64") - 1;
681 path += sizeof("base64") - 1;
682 break;
683 }
684 /* found parameter ... the heart of cs ppl lies in +1/-1 or was it +2 this time? */
685 plen = sep - path;
686 vlen = (semi ? (size_t)(semi - sep) : (mlen - plen)) - 1 /* '=' */;
687 if (plen != sizeof("mediatype")-1 || memcmp(path, "mediatype", sizeof("mediatype")-1)) {
688 add_assoc_stringl_ex(&meta, path, plen, sep + 1, vlen);
689 }
690 plen += vlen + 1;
691 mlen -= plen;
692 path += plen;
693 }
694 if (mlen) {
695 zval_ptr_dtor(&meta);
696 php_stream_wrapper_log_error(wrapper, options, "rfc2397: illegal URL");
697 return NULL;
698 }
699 } else {
700 array_init(&meta);
701 }
702 add_assoc_bool(&meta, "base64", base64);
703
704 /* skip ',' */
705 comma++;
706 dlen--;
707
708 if (base64) {
709 base64_comma = php_base64_decode_ex((const unsigned char *)comma, dlen, 1);
710 if (!base64_comma) {
711 zval_ptr_dtor(&meta);
712 php_stream_wrapper_log_error(wrapper, options, "rfc2397: unable to decode");
713 return NULL;
714 }
715 comma = ZSTR_VAL(base64_comma);
716 ilen = ZSTR_LEN(base64_comma);
717 } else {
718 comma = estrndup(comma, dlen);
719 dlen = php_url_decode(comma, dlen);
720 ilen = dlen;
721 }
722
723 if ((stream = php_stream_temp_create_rel(0, ~0u)) != NULL) {
724 /* store data */
725 php_stream_temp_write(stream, comma, ilen);
726 php_stream_temp_seek(stream, 0, SEEK_SET, &newoffs);
727 /* set special stream stuff (enforce exact mode) */
728 vlen = strlen(mode);
729 if (vlen >= sizeof(stream->mode)) {
730 vlen = sizeof(stream->mode) - 1;
731 }
732 memcpy(stream->mode, mode, vlen);
733 stream->mode[vlen] = '\0';
734 stream->ops = &php_stream_rfc2397_ops;
735 ts = (php_stream_temp_data*)stream->abstract;
736 assert(ts != NULL);
737 ts->mode = mode[0] == 'r' && mode[1] != '+' ? TEMP_STREAM_READONLY : 0;
738 ZVAL_COPY_VALUE(&ts->meta, &meta);
739 }
740 if (base64_comma) {
741 zend_string_free(base64_comma);
742 } else {
743 efree(comma);
744 }
745
746 return stream;
747}
748
750 php_stream_url_wrap_rfc2397,
751 NULL, /* close */
752 NULL, /* fstat */
753 NULL, /* stat */
754 NULL, /* opendir */
755 "RFC2397",
756 NULL, /* unlink */
757 NULL, /* rename */
758 NULL, /* mkdir */
759 NULL, /* rmdir */
760 NULL, /* stream_metadata */
761};
762
size_t len
Definition apprentice.c:174
PHPAPI zend_string * php_base64_decode_ex(const unsigned char *str, size_t length, bool strict)
Definition base64.c:1210
file(string $filename, int $flags=0, $context=null)
strpbrk(string $string, string $characters)
count(Countable|array $value, int $mode=COUNT_NORMAL)
assert(mixed $assertion, Throwable|string|null $description=null)
uint32_t u
Definition cdf.c:78
memcpy(ptr1, ptr2, size)
memset(ptr, 0, type->size)
zend_ffi_ctype_name_buf buf
Definition ffi.c:4685
const SEEK_CUR
Definition file.stub.php:16
const SEEK_END
Definition file.stub.php:21
zend_long offset
char * mode
#define SEEK_SET
Definition gd_io_file.c:20
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
PHPAPI size_t php_url_decode(char *str, size_t len)
Definition url.c:582
PHPAPI const char * _php_stream_mode_to_str(int mode)
Definition memory.c:278
PHPAPI php_stream * _php_stream_temp_open(int mode, size_t max_memory_usage, const char *buf, size_t length STREAMS_DC)
Definition memory.c:577
PHPAPI php_stream * _php_stream_temp_create_ex(int mode, size_t max_memory_usage, const char *tmpdir STREAMS_DC)
Definition memory.c:548
PHPAPI php_stream * _php_stream_memory_create(int mode STREAMS_DC)
Definition memory.c:290
PHPAPI php_stream * _php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC)
Definition memory.c:570
PHPAPI zend_string * _php_stream_memory_get_buffer(php_stream *stream STREAMS_DC)
Definition memory.c:323
PHPAPI php_stream * _php_stream_memory_open(int mode, zend_string *buf STREAMS_DC)
Definition memory.c:308
PHPAPI int php_stream_mode_from_str(const char *mode)
Definition memory.c:266
PHPAPI const php_stream_wrapper_ops php_stream_rfc2397_wops
Definition memory.c:749
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
Definition main.c:1173
#define PHPAPI
Definition php.h:71
unsigned const char * pos
Definition php_ffi.h:52
PHP_JSON_API size_t int options
Definition php_json.h:102
#define TEMP_STREAM_DEFAULT
PHPAPI const php_stream_wrapper php_stream_rfc2397_wrapper
Definition memory.c:763
#define TEMP_STREAM_APPEND
#define php_stream_memory_create_rel(mode)
PHPAPI const php_stream_ops php_stream_rfc2397_ops
Definition memory.c:597
PHPAPI const php_stream_ops php_stream_memory_ops
Definition memory.c:255
#define php_stream_temp_create_rel(mode, max_memory_usage)
#define php_stream_temp_create_ex(mode, max_memory_usage, tmpdir)
PHPAPI const php_stream_ops php_stream_temp_ops
Definition memory.c:535
#define php_stream_memory_get_buffer(stream)
#define PHP_STREAM_IS_MEMORY
#define TEMP_STREAM_READONLY
#define php_stream_fopen_tmpfile()
#define php_stream_fopen_temporary_file(dir, pfx, opened_path)
#define php_stream_cast(stream, as, ret, show_err)
#define PHP_STREAM_IS_STDIO
struct _php_stream_wrapper_ops php_stream_wrapper_ops
struct _php_stream php_stream
Definition php_streams.h:96
struct _php_stream_context php_stream_context
Definition php_streams.h:98
#define php_stream_read(stream, buf, count)
#define PHP_STREAM_TRUNCATE_SET_SIZE
#define PHP_STREAM_FREE_PRESERVE_HANDLE
#define STREAMS_DC
Definition php_streams.h:53
#define PHP_STREAM_FLAG_NO_BUFFER
#define php_stream_alloc_rel(ops, thisptr, persistent, mode)
Definition php_streams.h:60
#define php_stream_seek(stream, offset, whence)
#define php_stream_flush(stream)
#define PHP_STREAM_OPTION_RETURN_NOTIMPL
#define PHP_STREAM_FREE_CLOSE
#define php_stream_is(stream, anops)
#define php_stream_tell(stream)
PHPAPI php_stream * php_stream_encloses(php_stream *enclosing, php_stream *enclosed)
Definition streams.c:102
struct _php_stream_ops php_stream_ops
#define PHP_STREAM_OPTION_META_DATA_API
#define PHP_STREAM_OPTION_RETURN_ERR
#define php_stream_stat(stream, ssb)
#define PHP_STREAM_OPTION_TRUNCATE_API
struct _php_stream_wrapper php_stream_wrapper
Definition php_streams.h:97
#define php_stream_free_enclosed(stream_enclosed, close_options)
#define PHP_STREAM_TRUNCATE_SUPPORTED
#define php_stream_set_option(stream, option, value, ptrvalue)
#define PHP_STREAM_OPTION_RETURN_OK
#define PHP_STREAM_AS_STDIO
struct _php_stream_statbuf php_stream_statbuf
#define php_stream_write(stream, buf, count)
PHPAPI void php_stream_wrapper_log_error(const php_stream_wrapper *wrapper, int options, const char *fmt,...) PHP_ATTRIBUTE_FORMAT(printf
const php_stream_ops * ops
uint16_t eof
uint32_t flags
void * abstract
char mode[16]
Definition dce.c:49
zend_string * data
Definition memory.c:38
php_stream * innerstream
Definition memory.c:336
ZEND_API void add_assoc_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length)
Definition zend_API.c:1991
#define array_init(arg)
Definition zend_API.h:537
#define estrndup(s, length)
Definition zend_alloc.h:165
#define ecalloc(nmemb, size)
Definition zend_alloc.h:158
#define efree(ptr)
Definition zend_alloc.h:155
#define estrdup(s)
Definition zend_alloc.h:164
#define emalloc(size)
Definition zend_alloc.h:151
struct _zval_struct zval
strlen(string $string)
#define E_WARNING
Definition zend_errors.h:24
ZEND_API void ZEND_FASTCALL zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor)
Definition zend_hash.c:2240
int32_t zend_off_t
Definition zend_long.h:44
struct _zend_string zend_string
#define ZEND_ASSERT(c)
#define ZSTR_VAL(zstr)
Definition zend_string.h:68
#define ZSTR_EMPTY_ALLOC()
#define ZSTR_LEN(zstr)
Definition zend_string.h:69
#define ZVAL_UNDEF(z)
#define IS_UNDEF
Definition zend_types.h:600
#define Z_ARRVAL_P(zval_p)
Definition zend_types.h:987
#define ZVAL_NULL(z)
@ FAILURE
Definition zend_types.h:61
#define Z_TYPE(zval)
Definition zend_types.h:659
#define Z_ARRVAL(zval)
Definition zend_types.h:986
#define ZVAL_COPY_VALUE(z, v)
ZEND_API void zval_ptr_dtor(zval *zval_ptr)
ZEND_API void zval_add_ref(zval *p)
zval * ret
value