xref: /PHP-7.4/main/streams/php_streams_int.h (revision 0cf7de1c)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 7                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) The PHP Group                                          |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 3.01 of the PHP license,      |
8   | that is bundled with this package in the file LICENSE, and is        |
9   | available through the world-wide-web at the following url:           |
10   | http://www.php.net/license/3_01.txt                                  |
11   | If you did not receive a copy of the PHP license and are unable to   |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@php.net so we can mail you a copy immediately.               |
14   +----------------------------------------------------------------------+
15   | Author: Wez Furlong <wez@thebrainroom.com>                           |
16   +----------------------------------------------------------------------+
17 */
18 
19 #if ZEND_DEBUG
20 
21 #define emalloc_rel_orig(size)	\
22 		( __php_stream_call_depth == 0 \
23 		? _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_RELAY_CC) \
24 		: _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC) )
25 
26 #define erealloc_rel_orig(ptr, size)	\
27 		( __php_stream_call_depth == 0 \
28 		? _erealloc((ptr), (size), 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_RELAY_CC) \
29 		: _erealloc((ptr), (size), 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC) )
30 
31 #define pemalloc_rel_orig(size, persistent)	((persistent) ? malloc((size)) : emalloc_rel_orig((size)))
32 #define perealloc_rel_orig(ptr, size, persistent)	((persistent) ? realloc((ptr), (size)) : erealloc_rel_orig((ptr), (size)))
33 #else
34 # define pemalloc_rel_orig(size, persistent)				pemalloc((size), (persistent))
35 # define perealloc_rel_orig(ptr, size, persistent)			perealloc((ptr), (size), (persistent))
36 # define emalloc_rel_orig(size)								emalloc((size))
37 #endif
38 
39 #define STREAM_DEBUG 0
40 #define STREAM_WRAPPER_PLAIN_FILES	((php_stream_wrapper*)-1)
41 
42 #ifndef MAP_FAILED
43 #define MAP_FAILED ((void *) -1)
44 #endif
45 
46 #define CHUNK_SIZE	8192
47 
48 #ifdef PHP_WIN32
49 # ifdef EWOULDBLOCK
50 #  undef EWOULDBLOCK
51 # endif
52 # define EWOULDBLOCK WSAEWOULDBLOCK
53 # ifdef EMSGSIZE
54 #  undef EMSGSIZE
55 # endif
56 # define EMSGSIZE WSAEMSGSIZE
57 #endif
58 
59 /* This functions transforms the first char to 'w' if it's not 'r', 'a' or 'w'
60  * and strips any subsequent chars except '+' and 'b'.
61  * Use this to sanitize stream->mode if you call e.g. fdopen, fopencookie or
62  * any other function that expects standard modes and you allow non-standard
63  * ones. result should be a char[5]. */
64 void php_stream_mode_sanitize_fdopen_fopencookie(php_stream *stream, char *result);
65 
66 void php_stream_tidy_wrapper_error_log(php_stream_wrapper *wrapper);
67 void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char *path, const char *caption);
68