file.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
  14. +----------------------------------------------------------------------+
  15. */
  16. #ifndef FILE_H
  17. #define FILE_H
  18. #include "php_network.h"
  19. PHP_MINIT_FUNCTION(file);
  20. PHP_MSHUTDOWN_FUNCTION(file);
  21. PHPAPI PHP_FUNCTION(fclose);
  22. PHPAPI PHP_FUNCTION(feof);
  23. PHPAPI PHP_FUNCTION(fread);
  24. PHPAPI PHP_FUNCTION(fgetc);
  25. PHPAPI PHP_FUNCTION(fgets);
  26. PHPAPI PHP_FUNCTION(fwrite);
  27. PHPAPI PHP_FUNCTION(fflush);
  28. PHPAPI PHP_FUNCTION(rewind);
  29. PHPAPI PHP_FUNCTION(ftell);
  30. PHPAPI PHP_FUNCTION(fseek);
  31. PHPAPI PHP_FUNCTION(fpassthru);
  32. PHP_MINIT_FUNCTION(user_streams);
  33. PHPAPI int php_le_stream_context(void);
  34. PHPAPI int php_set_sock_blocking(php_socket_t socketd, int block);
  35. PHPAPI int php_copy_file(const char *src, const char *dest);
  36. PHPAPI int php_copy_file_ex(const char *src, const char *dest, int src_chk);
  37. PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_chk, php_stream_context *ctx);
  38. PHPAPI int php_mkdir_ex(const char *dir, zend_long mode, int options);
  39. PHPAPI int php_mkdir(const char *dir, zend_long mode);
  40. PHPAPI void php_fstat(php_stream *stream, zval *return_value);
  41. PHPAPI void php_flock_common(php_stream *stream, zend_long operation, uint32_t operation_arg_num,
  42. zval *wouldblock, zval *return_value);
  43. #define PHP_CSV_NO_ESCAPE EOF
  44. PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, int escape_char, size_t buf_len, char *buf, zval *return_value);
  45. PHPAPI ssize_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, int escape_char, zend_string *eol_str);
  46. #define META_DEF_BUFSIZE 8192
  47. #define PHP_FILE_USE_INCLUDE_PATH 1
  48. #define PHP_FILE_IGNORE_NEW_LINES 2
  49. #define PHP_FILE_SKIP_EMPTY_LINES 4
  50. #define PHP_FILE_APPEND 8
  51. #define PHP_FILE_NO_DEFAULT_CONTEXT 16
  52. typedef enum _php_meta_tags_token {
  53. TOK_EOF = 0,
  54. TOK_OPENTAG,
  55. TOK_CLOSETAG,
  56. TOK_SLASH,
  57. TOK_EQUAL,
  58. TOK_SPACE,
  59. TOK_ID,
  60. TOK_STRING,
  61. TOK_OTHER
  62. } php_meta_tags_token;
  63. typedef struct _php_meta_tags_data {
  64. php_stream *stream;
  65. int ulc;
  66. int lc;
  67. char *input_buffer;
  68. char *token_data;
  69. int token_len;
  70. int in_meta;
  71. } php_meta_tags_data;
  72. php_meta_tags_token php_next_meta_token(php_meta_tags_data *);
  73. typedef struct {
  74. int pclose_ret;
  75. size_t def_chunk_size;
  76. bool auto_detect_line_endings;
  77. zend_long default_socket_timeout;
  78. char *user_agent; /* for the http wrapper */
  79. char *from_address; /* for the ftp and http wrappers */
  80. const char *user_stream_current_filename; /* for simple recursion protection */
  81. php_stream_context *default_context;
  82. HashTable *stream_wrappers; /* per-request copy of url_stream_wrappers_hash */
  83. HashTable *stream_filters; /* per-request copy of stream_filters_hash */
  84. HashTable *wrapper_errors; /* key: wrapper address; value: linked list of char* */
  85. int pclose_wait;
  86. #if defined(HAVE_GETHOSTBYNAME_R)
  87. struct hostent tmp_host_info;
  88. char *tmp_host_buf;
  89. size_t tmp_host_buf_len;
  90. #endif
  91. } php_file_globals;
  92. #ifdef ZTS
  93. #define FG(v) ZEND_TSRMG(file_globals_id, php_file_globals *, v)
  94. extern PHPAPI int file_globals_id;
  95. #else
  96. #define FG(v) (file_globals.v)
  97. extern PHPAPI php_file_globals file_globals;
  98. #endif
  99. #endif /* FILE_H */