file.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
  16. +----------------------------------------------------------------------+
  17. */
  18. #ifndef FILE_H
  19. #define FILE_H
  20. #include "php_network.h"
  21. PHP_MINIT_FUNCTION(file);
  22. PHP_MSHUTDOWN_FUNCTION(file);
  23. PHP_FUNCTION(tempnam);
  24. PHP_NAMED_FUNCTION(php_if_tmpfile);
  25. PHP_NAMED_FUNCTION(php_if_fopen);
  26. PHPAPI PHP_FUNCTION(fclose);
  27. PHP_FUNCTION(popen);
  28. PHP_FUNCTION(pclose);
  29. PHPAPI PHP_FUNCTION(feof);
  30. PHPAPI PHP_FUNCTION(fread);
  31. PHPAPI PHP_FUNCTION(fgetc);
  32. PHPAPI PHP_FUNCTION(fgets);
  33. PHP_FUNCTION(fscanf);
  34. PHPAPI PHP_FUNCTION(fgetss);
  35. PHP_FUNCTION(fgetcsv);
  36. PHP_FUNCTION(fputcsv);
  37. PHPAPI PHP_FUNCTION(fwrite);
  38. PHPAPI PHP_FUNCTION(fflush);
  39. PHPAPI PHP_FUNCTION(rewind);
  40. PHPAPI PHP_FUNCTION(ftell);
  41. PHPAPI PHP_FUNCTION(fseek);
  42. PHP_FUNCTION(mkdir);
  43. PHP_FUNCTION(rmdir);
  44. PHPAPI PHP_FUNCTION(fpassthru);
  45. PHP_FUNCTION(readfile);
  46. PHP_FUNCTION(umask);
  47. PHP_FUNCTION(rename);
  48. PHP_FUNCTION(unlink);
  49. PHP_FUNCTION(copy);
  50. PHP_FUNCTION(file);
  51. PHP_FUNCTION(file_get_contents);
  52. PHP_FUNCTION(file_put_contents);
  53. PHP_FUNCTION(get_meta_tags);
  54. PHP_FUNCTION(flock);
  55. PHP_FUNCTION(fd_set);
  56. PHP_FUNCTION(fd_isset);
  57. #if HAVE_REALPATH || defined(ZTS)
  58. PHP_FUNCTION(realpath);
  59. #endif
  60. #ifdef HAVE_FNMATCH
  61. PHP_FUNCTION(fnmatch);
  62. #endif
  63. PHP_NAMED_FUNCTION(php_if_ftruncate);
  64. PHP_NAMED_FUNCTION(php_if_fstat);
  65. PHP_FUNCTION(sys_get_temp_dir);
  66. PHP_MINIT_FUNCTION(user_streams);
  67. PHPAPI int php_le_stream_context(void);
  68. PHPAPI int php_set_sock_blocking(php_socket_t socketd, int block);
  69. PHPAPI int php_copy_file(const char *src, const char *dest);
  70. PHPAPI int php_copy_file_ex(const char *src, const char *dest, int src_chk);
  71. PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_chk, php_stream_context *ctx);
  72. PHPAPI int php_mkdir_ex(const char *dir, zend_long mode, int options);
  73. PHPAPI int php_mkdir(const char *dir, zend_long mode);
  74. PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char escape_char, size_t buf_len, char *buf, zval *return_value);
  75. PHPAPI size_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char);
  76. #define META_DEF_BUFSIZE 8192
  77. #define PHP_FILE_USE_INCLUDE_PATH 1
  78. #define PHP_FILE_IGNORE_NEW_LINES 2
  79. #define PHP_FILE_SKIP_EMPTY_LINES 4
  80. #define PHP_FILE_APPEND 8
  81. #define PHP_FILE_NO_DEFAULT_CONTEXT 16
  82. typedef enum _php_meta_tags_token {
  83. TOK_EOF = 0,
  84. TOK_OPENTAG,
  85. TOK_CLOSETAG,
  86. TOK_SLASH,
  87. TOK_EQUAL,
  88. TOK_SPACE,
  89. TOK_ID,
  90. TOK_STRING,
  91. TOK_OTHER
  92. } php_meta_tags_token;
  93. typedef struct _php_meta_tags_data {
  94. php_stream *stream;
  95. int ulc;
  96. int lc;
  97. char *input_buffer;
  98. char *token_data;
  99. int token_len;
  100. int in_meta;
  101. } php_meta_tags_data;
  102. php_meta_tags_token php_next_meta_token(php_meta_tags_data *);
  103. typedef struct {
  104. int pclose_ret;
  105. size_t def_chunk_size;
  106. zend_long auto_detect_line_endings;
  107. zend_long default_socket_timeout;
  108. char *user_agent; /* for the http wrapper */
  109. char *from_address; /* for the ftp and http wrappers */
  110. const char *user_stream_current_filename; /* for simple recursion protection */
  111. php_stream_context *default_context;
  112. HashTable *stream_wrappers; /* per-request copy of url_stream_wrappers_hash */
  113. HashTable *stream_filters; /* per-request copy of stream_filters_hash */
  114. HashTable *wrapper_errors; /* key: wrapper address; value: linked list of char* */
  115. int pclose_wait;
  116. #if defined(HAVE_GETHOSTBYNAME_R)
  117. struct hostent tmp_host_info;
  118. char *tmp_host_buf;
  119. size_t tmp_host_buf_len;
  120. #endif
  121. } php_file_globals;
  122. #ifdef ZTS
  123. #define FG(v) ZEND_TSRMG(file_globals_id, php_file_globals *, v)
  124. extern PHPAPI int file_globals_id;
  125. #else
  126. #define FG(v) (file_globals.v)
  127. extern PHPAPI php_file_globals file_globals;
  128. #endif
  129. #endif /* FILE_H */