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