xref: /PHP-5.5/main/streams/php_streams_int.h (revision 73c1be26)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 5                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1997-2015 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 /* $Id$ */
20 
21 
22 #if ZEND_DEBUG
23 
24 #define emalloc_rel_orig(size)	\
25 		( __php_stream_call_depth == 0 \
26 		? _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_RELAY_CC) \
27 		: _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC) )
28 
29 #define erealloc_rel_orig(ptr, size)	\
30 		( __php_stream_call_depth == 0 \
31 		? _erealloc((ptr), (size), 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_RELAY_CC) \
32 		: _erealloc((ptr), (size), 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC) )
33 
34 #define pemalloc_rel_orig(size, persistent)	((persistent) ? malloc((size)) : emalloc_rel_orig((size)))
35 #define perealloc_rel_orig(ptr, size, persistent)	((persistent) ? realloc((ptr), (size)) : erealloc_rel_orig((ptr), (size)))
36 #else
37 # define pemalloc_rel_orig(size, persistent)				pemalloc((size), (persistent))
38 # define perealloc_rel_orig(ptr, size, persistent)			perealloc((ptr), (size), (persistent))
39 # define emalloc_rel_orig(size)								emalloc((size))
40 #endif
41 
42 #define STREAM_DEBUG 0
43 #define STREAM_WRAPPER_PLAIN_FILES	((php_stream_wrapper*)-1)
44 
45 #ifndef MAP_FAILED
46 #define MAP_FAILED ((void *) -1)
47 #endif
48 
49 #define CHUNK_SIZE	8192
50 
51 #ifdef PHP_WIN32
52 # ifdef EWOULDBLOCK
53 #  undef EWOULDBLOCK
54 # endif
55 # define EWOULDBLOCK WSAEWOULDBLOCK
56 #endif
57 
58 #ifndef S_ISREG
59 #define S_ISREG(mode)	(((mode)&S_IFMT) == S_IFREG)
60 #endif
61 
62 /* This functions transforms the first char to 'w' if it's not 'r', 'a' or 'w'
63  * and strips any subsequent chars except '+' and 'b'.
64  * Use this to sanitize stream->mode if you call e.g. fdopen, fopencookie or
65  * any other function that expects standard modes and you allow non-standard
66  * ones. result should be a char[5]. */
67 void php_stream_mode_sanitize_fdopen_fopencookie(php_stream *stream, char *result);
68 
69 void php_stream_tidy_wrapper_error_log(php_stream_wrapper *wrapper TSRMLS_DC);
70 void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char *path, const char *caption TSRMLS_DC);
71 
72