2003-02-18 17:37:54 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2019-01-30 17:23:29 +08:00
|
|
|
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
|
2003-02-18 17:37:54 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| This source file is subject to version 2.00 of the Zend license, |
|
2008-03-17 05:06:55 +08:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-11 04:04:29 +08:00
|
|
|
| available through the world-wide-web at the following url: |
|
2003-02-18 17:37:54 +08:00
|
|
|
| http://www.zend.com/license/2_00.txt. |
|
|
|
|
| If you did not receive a copy of the Zend license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@zend.com so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Authors: Wez Furlong <wez@thebrainroom.com> |
|
2008-03-17 05:06:55 +08:00
|
|
|
| Scott MacVicar <scottmac@php.net> |
|
|
|
|
| Nuno Lopes <nlopess@php.net> |
|
|
|
|
| Marcus Boerger <helly@php.net> |
|
2003-02-18 17:37:54 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ZEND_STREAM_H
|
|
|
|
#define ZEND_STREAM_H
|
|
|
|
|
2014-08-16 17:16:11 +08:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2003-02-18 17:37:54 +08:00
|
|
|
/* Lightweight stream implementation for the ZE scanners.
|
|
|
|
* These functions are private to the engine.
|
|
|
|
* */
|
2019-07-17 17:49:10 +08:00
|
|
|
typedef size_t (*zend_stream_fsizer_t)(void* handle);
|
2019-07-22 23:49:08 +08:00
|
|
|
typedef ssize_t (*zend_stream_reader_t)(void* handle, char *buf, size_t len);
|
2014-12-14 06:06:14 +08:00
|
|
|
typedef void (*zend_stream_closer_t)(void* handle);
|
2003-02-18 17:37:54 +08:00
|
|
|
|
2015-01-03 17:22:58 +08:00
|
|
|
#define ZEND_MMAP_AHEAD 32
|
2008-03-17 05:06:55 +08:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ZEND_HANDLE_FILENAME,
|
|
|
|
ZEND_HANDLE_FP,
|
2019-07-16 23:17:19 +08:00
|
|
|
ZEND_HANDLE_STREAM
|
2008-03-17 05:06:55 +08:00
|
|
|
} zend_stream_type;
|
|
|
|
|
2003-02-18 17:37:54 +08:00
|
|
|
typedef struct _zend_stream {
|
2008-03-17 05:06:55 +08:00
|
|
|
void *handle;
|
|
|
|
int isatty;
|
|
|
|
zend_stream_reader_t reader;
|
2019-07-17 17:49:10 +08:00
|
|
|
zend_stream_fsizer_t fsizer;
|
2008-03-17 05:06:55 +08:00
|
|
|
zend_stream_closer_t closer;
|
2003-02-18 17:37:54 +08:00
|
|
|
} zend_stream;
|
|
|
|
|
|
|
|
typedef struct _zend_file_handle {
|
|
|
|
union {
|
2008-03-17 05:06:55 +08:00
|
|
|
FILE *fp;
|
|
|
|
zend_stream stream;
|
2003-02-18 17:37:54 +08:00
|
|
|
} handle;
|
2014-09-13 04:06:10 +08:00
|
|
|
const char *filename;
|
2015-03-04 07:05:28 +08:00
|
|
|
zend_string *opened_path;
|
2014-09-13 04:06:10 +08:00
|
|
|
zend_stream_type type;
|
2019-07-24 16:42:19 +08:00
|
|
|
/* free_filename is used by wincache */
|
|
|
|
/* TODO: Clean up filename vs opened_path mess */
|
|
|
|
zend_bool free_filename;
|
2019-07-16 23:17:19 +08:00
|
|
|
char *buf;
|
|
|
|
size_t len;
|
2003-02-18 17:37:54 +08:00
|
|
|
} zend_file_handle;
|
|
|
|
|
2004-02-19 06:44:40 +08:00
|
|
|
BEGIN_EXTERN_C()
|
2019-07-16 22:21:45 +08:00
|
|
|
ZEND_API void zend_stream_init_fp(zend_file_handle *handle, FILE *fp, const char *filename);
|
2019-07-16 22:40:54 +08:00
|
|
|
ZEND_API void zend_stream_init_filename(zend_file_handle *handle, const char *filename);
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle);
|
|
|
|
ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len);
|
|
|
|
ZEND_API void zend_file_handle_dtor(zend_file_handle *fh);
|
2008-03-17 05:06:55 +08:00
|
|
|
ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2);
|
2004-02-19 06:44:40 +08:00
|
|
|
END_EXTERN_C()
|
2003-02-18 17:37:54 +08:00
|
|
|
|
2018-07-15 15:33:14 +08:00
|
|
|
#ifdef ZEND_WIN32
|
|
|
|
# include "win32/ioutil.h"
|
|
|
|
typedef php_win32_ioutil_stat_t zend_stat_t;
|
2014-08-16 17:16:11 +08:00
|
|
|
#ifdef _WIN64
|
2018-07-15 15:33:14 +08:00
|
|
|
# define zend_fseek _fseeki64
|
|
|
|
# define zend_ftell _ftelli64
|
|
|
|
# define zend_lseek _lseeki64
|
|
|
|
# else
|
|
|
|
# define zend_fseek fseek
|
|
|
|
# define zend_ftell ftell
|
|
|
|
# define zend_lseek lseek
|
|
|
|
# endif
|
|
|
|
# define zend_fstat php_win32_ioutil_fstat
|
|
|
|
# define zend_stat php_win32_ioutil_stat
|
2014-08-16 17:16:11 +08:00
|
|
|
#else
|
2018-07-15 15:33:14 +08:00
|
|
|
typedef struct stat zend_stat_t;
|
2014-08-16 17:16:11 +08:00
|
|
|
# define zend_fseek fseek
|
|
|
|
# define zend_ftell ftell
|
|
|
|
# define zend_lseek lseek
|
|
|
|
# define zend_fstat fstat
|
|
|
|
# define zend_stat stat
|
|
|
|
#endif
|
|
|
|
|
2003-02-18 17:37:54 +08:00
|
|
|
#endif
|