Back to index

php5  5.3.10
zend_stream.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | Zend Engine                                                          |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 2.00 of the Zend license,     |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.zend.com/license/2_00.txt.                                |
00011    | If you did not receive a copy of the Zend license and are unable to  |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@zend.com so we can mail you a copy immediately.              |
00014    +----------------------------------------------------------------------+
00015    | Authors: Wez Furlong <wez@thebrainroom.com>                          |
00016    |          Scott MacVicar <scottmac@php.net>                           |
00017    |          Nuno Lopes <nlopess@php.net>                                |
00018    |          Marcus Boerger <helly@php.net>                              |
00019    +----------------------------------------------------------------------+
00020 */
00021 
00022 /* $Id: zend_stream.h 321634 2012-01-01 13:15:04Z felipe $ */
00023 
00024 #ifndef ZEND_STREAM_H
00025 #define ZEND_STREAM_H
00026 
00027 /* Lightweight stream implementation for the ZE scanners.
00028  * These functions are private to the engine.
00029  * */
00030 typedef size_t (*zend_stream_fsizer_t)(void* handle TSRMLS_DC);
00031 typedef size_t (*zend_stream_reader_t)(void* handle, char *buf, size_t len TSRMLS_DC);
00032 typedef void   (*zend_stream_closer_t)(void* handle TSRMLS_DC);
00033 
00034 #define ZEND_MMAP_AHEAD 32 
00035 
00036 typedef enum {
00037        ZEND_HANDLE_FILENAME,
00038        ZEND_HANDLE_FD,
00039        ZEND_HANDLE_FP,
00040        ZEND_HANDLE_STREAM,
00041        ZEND_HANDLE_MAPPED
00042 } zend_stream_type;
00043 
00044 typedef struct _zend_mmap {
00045        size_t      len;
00046        size_t      pos;
00047        void        *map;
00048        char        *buf;
00049        void                  *old_handle;
00050        zend_stream_closer_t   old_closer;
00051 } zend_mmap;
00052 
00053 typedef struct _zend_stream {
00054        void        *handle;
00055        int         isatty;
00056        zend_mmap   mmap;
00057        zend_stream_reader_t   reader;
00058        zend_stream_fsizer_t   fsizer;
00059        zend_stream_closer_t   closer;
00060 } zend_stream;
00061 
00062 typedef struct _zend_file_handle {
00063        zend_stream_type  type;
00064        char              *filename;
00065        char              *opened_path;
00066        union {
00067               int           fd;
00068               FILE          *fp;
00069               zend_stream   stream;
00070        } handle;
00071        zend_bool free_filename;
00072 } zend_file_handle;
00073 
00074 BEGIN_EXTERN_C()
00075 ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle TSRMLS_DC);
00076 ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len TSRMLS_DC);
00077 ZEND_API void zend_file_handle_dtor(zend_file_handle *fh TSRMLS_DC);
00078 ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2);
00079 END_EXTERN_C()
00080 
00081 #endif