Annotation of embedaddon/php/ext/spl/spl_directory.h, revision 1.1.1.2

1.1       misho       1: /*
                      2:    +----------------------------------------------------------------------+
                      3:    | PHP Version 5                                                        |
                      4:    +----------------------------------------------------------------------+
                      5:    | Copyright (c) 1997-2012 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:    | Authors: Marcus Boerger <helly@php.net>                              |
                     16:    +----------------------------------------------------------------------+
                     17:  */
                     18: 
1.1.1.2 ! misho      19: /* $Id$ */
1.1       misho      20: 
                     21: #ifndef SPL_DIRECTORY_H
                     22: #define SPL_DIRECTORY_H
                     23: 
                     24: #include "php.h"
                     25: #include "php_spl.h"
                     26: 
                     27: extern PHPAPI zend_class_entry *spl_ce_SplFileInfo;
                     28: extern PHPAPI zend_class_entry *spl_ce_DirectoryIterator;
                     29: extern PHPAPI zend_class_entry *spl_ce_FilesystemIterator;
                     30: extern PHPAPI zend_class_entry *spl_ce_RecursiveDirectoryIterator;
                     31: extern PHPAPI zend_class_entry *spl_ce_GlobIterator;
                     32: extern PHPAPI zend_class_entry *spl_ce_SplFileObject;
                     33: extern PHPAPI zend_class_entry *spl_ce_SplTempFileObject;
                     34: 
                     35: PHP_MINIT_FUNCTION(spl_directory);
                     36: 
                     37: typedef enum {
                     38:        SPL_FS_INFO, /* must be 0 */
                     39:        SPL_FS_DIR,
                     40:        SPL_FS_FILE
                     41: } SPL_FS_OBJ_TYPE;
                     42: 
                     43: typedef struct _spl_filesystem_object  spl_filesystem_object;
                     44: 
                     45: typedef void (*spl_foreign_dtor_t)(spl_filesystem_object *object TSRMLS_DC);
                     46: typedef void (*spl_foreign_clone_t)(spl_filesystem_object *src, spl_filesystem_object *dst TSRMLS_DC);
                     47: 
                     48: PHPAPI char* spl_filesystem_object_get_path(spl_filesystem_object *intern, int *len TSRMLS_DC);
                     49: 
                     50: typedef struct _spl_other_handler {
                     51:        spl_foreign_dtor_t     dtor;
                     52:        spl_foreign_clone_t    clone;
                     53: } spl_other_handler;
                     54: 
                     55: /* define an overloaded iterator structure */
                     56: typedef struct {
                     57:        zend_object_iterator  intern;
                     58:        zval                  *current;
                     59:        spl_filesystem_object *object;
                     60: } spl_filesystem_iterator;
                     61: 
                     62: struct _spl_filesystem_object {
                     63:        zend_object        std;
                     64:        void               *oth;
                     65:        spl_other_handler  *oth_handler;
                     66:        char               *_path;
                     67:        int                _path_len;
                     68:        char               *orig_path;
                     69:        char               *file_name;
                     70:        int                file_name_len;
                     71:        SPL_FS_OBJ_TYPE    type;
                     72:        long               flags;
                     73:        zend_class_entry   *file_class;
                     74:        zend_class_entry   *info_class;
                     75:        union {
                     76:                struct {
                     77:                        php_stream         *dirp;
                     78:                        php_stream_dirent  entry;
                     79:                        char               *sub_path;
                     80:                        int                sub_path_len;
                     81:                        int                index;
                     82:                        int                is_recursive;
                     83:                        zend_function      *func_rewind;
                     84:                        zend_function      *func_next;
                     85:                        zend_function      *func_valid;
                     86:                } dir;
                     87:                struct {
                     88:                        php_stream         *stream;
                     89:                        php_stream_context *context;
                     90:                        zval               *zcontext;
                     91:                        char               *open_mode;
                     92:                        int                open_mode_len;
                     93:                        zval               *current_zval;
                     94:                        char               *current_line;
                     95:                        size_t             current_line_len;
                     96:                        size_t             max_line_len;
                     97:                        long               current_line_num;
                     98:                        zval               zresource;
                     99:                        zend_function      *func_getCurr;
                    100:                        char               delimiter;
                    101:                        char               enclosure;
                    102:                        char               escape;
                    103:                } file;
                    104:        } u;
                    105:        spl_filesystem_iterator    it;
                    106: };
                    107: 
                    108: static inline spl_filesystem_iterator* spl_filesystem_object_to_iterator(spl_filesystem_object *obj)
                    109: {
                    110:        return &obj->it;
                    111: }
                    112: 
                    113: static inline spl_filesystem_object* spl_filesystem_iterator_to_object(spl_filesystem_iterator *it)
                    114: {
                    115:        return (spl_filesystem_object*)((char*)it - XtOffsetOf(spl_filesystem_object, it));
                    116: }
                    117: 
                    118: #define SPL_FILE_OBJECT_DROP_NEW_LINE      0x00000001 /* drop new lines */
                    119: #define SPL_FILE_OBJECT_READ_AHEAD         0x00000002 /* read on rewind/next */
                    120: #define SPL_FILE_OBJECT_SKIP_EMPTY         0x00000004 /* skip empty lines */
                    121: #define SPL_FILE_OBJECT_READ_CSV           0x00000008 /* read via fgetcsv */
                    122: #define SPL_FILE_OBJECT_MASK               0x0000000F /* read via fgetcsv */
                    123: 
                    124: #define SPL_FILE_DIR_CURRENT_AS_FILEINFO   0x00000000 /* make RecursiveDirectoryTree::current() return SplFileInfo */
                    125: #define SPL_FILE_DIR_CURRENT_AS_SELF       0x00000010 /* make RecursiveDirectoryTree::current() return getSelf() */
                    126: #define SPL_FILE_DIR_CURRENT_AS_PATHNAME   0x00000020 /* make RecursiveDirectoryTree::current() return getPathname() */
                    127: #define SPL_FILE_DIR_CURRENT_MODE_MASK     0x000000F0 /* mask RecursiveDirectoryTree::current() */
                    128: #define SPL_FILE_DIR_CURRENT(intern,mode)  ((intern->flags&SPL_FILE_DIR_CURRENT_MODE_MASK)==mode)
                    129: 
                    130: #define SPL_FILE_DIR_KEY_AS_PATHNAME       0x00000000 /* make RecursiveDirectoryTree::key() return getPathname() */
                    131: #define SPL_FILE_DIR_KEY_AS_FILENAME       0x00000100 /* make RecursiveDirectoryTree::key() return getFilename() */
                    132: #define SPL_FILE_DIR_FOLLOW_SYMLINKS       0x00000200 /* make RecursiveDirectoryTree::hasChildren() follow symlinks */
                    133: #define SPL_FILE_DIR_KEY_MODE_MASK         0x00000F00 /* mask RecursiveDirectoryTree::key() */
                    134: #define SPL_FILE_DIR_KEY(intern,mode)      ((intern->flags&SPL_FILE_DIR_KEY_MODE_MASK)==mode)
                    135: 
                    136: #define SPL_FILE_DIR_SKIPDOTS              0x00001000 /* Tells whether it should skip dots or not */
                    137: #define SPL_FILE_DIR_UNIXPATHS             0x00002000 /* Whether to unixify path separators */
                    138: #define SPL_FILE_DIR_OTHERS_MASK           0x00003000 /* mask used for get/setFlags */
                    139: 
                    140: #endif /* SPL_DIRECTORY_H */
                    141: 
                    142: /*
                    143:  * Local Variables:
                    144:  * c-basic-offset: 4
                    145:  * tab-width: 4
                    146:  * End:
                    147:  * vim600: fdm=marker
                    148:  * vim: noet sw=4 ts=4
                    149:  */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>