php_streams_int.h 2.9 KB

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