php_streams_int.h 2.8 KB

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