/src/php-src/Zend/zend_stream.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | +----------------------------------------------------------------------+ |
3 | | | Zend Engine | |
4 | | +----------------------------------------------------------------------+ |
5 | | | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) | |
6 | | +----------------------------------------------------------------------+ |
7 | | | This source file is subject to version 2.00 of the Zend 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.zend.com/license/2_00.txt. | |
11 | | | If you did not receive a copy of the Zend license and are unable to | |
12 | | | obtain it through the world-wide-web, please send a note to | |
13 | | | license@zend.com so we can mail you a copy immediately. | |
14 | | +----------------------------------------------------------------------+ |
15 | | | Authors: Wez Furlong <wez@thebrainroom.com> | |
16 | | | Scott MacVicar <scottmac@php.net> | |
17 | | | Nuno Lopes <nlopess@php.net> | |
18 | | | Marcus Boerger <helly@php.net> | |
19 | | +----------------------------------------------------------------------+ |
20 | | */ |
21 | | |
22 | | #ifndef ZEND_STREAM_H |
23 | | #define ZEND_STREAM_H |
24 | | |
25 | | #include <sys/types.h> |
26 | | #include <sys/stat.h> |
27 | | |
28 | | /* Lightweight stream implementation for the ZE scanners. |
29 | | * These functions are private to the engine. |
30 | | * */ |
31 | | typedef size_t (*zend_stream_fsizer_t)(void* handle); |
32 | | typedef ssize_t (*zend_stream_reader_t)(void* handle, char *buf, size_t len); |
33 | | typedef void (*zend_stream_closer_t)(void* handle); |
34 | | |
35 | 1.25G | #define ZEND_MMAP_AHEAD 32 |
36 | | |
37 | | typedef enum { |
38 | | ZEND_HANDLE_FILENAME, |
39 | | ZEND_HANDLE_FP, |
40 | | ZEND_HANDLE_STREAM |
41 | | } zend_stream_type; |
42 | | |
43 | | typedef struct _zend_stream { |
44 | | void *handle; |
45 | | int isatty; |
46 | | zend_stream_reader_t reader; |
47 | | zend_stream_fsizer_t fsizer; |
48 | | zend_stream_closer_t closer; |
49 | | } zend_stream; |
50 | | |
51 | | typedef struct _zend_file_handle { |
52 | | union { |
53 | | FILE *fp; |
54 | | zend_stream stream; |
55 | | } handle; |
56 | | const char *filename; |
57 | | zend_string *opened_path; |
58 | | zend_stream_type type; |
59 | | /* free_filename is used by wincache */ |
60 | | /* TODO: Clean up filename vs opened_path mess */ |
61 | | zend_bool free_filename; |
62 | | char *buf; |
63 | | size_t len; |
64 | | } zend_file_handle; |
65 | | |
66 | | BEGIN_EXTERN_C() |
67 | | ZEND_API void zend_stream_init_fp(zend_file_handle *handle, FILE *fp, const char *filename); |
68 | | ZEND_API void zend_stream_init_filename(zend_file_handle *handle, const char *filename); |
69 | | ZEND_API zend_result zend_stream_open(const char *filename, zend_file_handle *handle); |
70 | | ZEND_API zend_result zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len); |
71 | | ZEND_API void zend_file_handle_dtor(zend_file_handle *fh); |
72 | | ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2); |
73 | | END_EXTERN_C() |
74 | | |
75 | | #ifdef ZEND_WIN32 |
76 | | # include "win32/ioutil.h" |
77 | | typedef php_win32_ioutil_stat_t zend_stat_t; |
78 | | #ifdef _WIN64 |
79 | | # define zend_fseek _fseeki64 |
80 | | # define zend_ftell _ftelli64 |
81 | | # define zend_lseek _lseeki64 |
82 | | # else |
83 | | # define zend_fseek fseek |
84 | | # define zend_ftell ftell |
85 | | # define zend_lseek lseek |
86 | | # endif |
87 | | # define zend_fstat php_win32_ioutil_fstat |
88 | | # define zend_stat php_win32_ioutil_stat |
89 | | #else |
90 | | typedef struct stat zend_stat_t; |
91 | 0 | # define zend_fseek fseek |
92 | 0 | # define zend_ftell ftell |
93 | 0 | # define zend_lseek lseek |
94 | 0 | # define zend_fstat fstat |
95 | | # define zend_stat stat |
96 | | #endif |
97 | | |
98 | | #endif |