]> granicus.if.org Git - php/commitdiff
ported ext/phar
authorAnatol Belski <ab@php.net>
Tue, 19 Aug 2014 13:12:13 +0000 (15:12 +0200)
committerAnatol Belski <ab@php.net>
Tue, 19 Aug 2014 13:12:13 +0000 (15:12 +0200)
ext/phar/dirstream.c
ext/phar/dirstream.h
ext/phar/func_interceptors.c
ext/phar/phar.c
ext/phar/phar_internal.h
ext/phar/phar_object.c
ext/phar/stream.c
ext/phar/stream.h
ext/phar/tar.c
ext/phar/util.c
ext/phar/zip.c

index d24a4c76da15396d19a095c91ba7c0808cf385c7..53e6175ecb1aa7ecefe08234b1ebb16d66711d5a 100644 (file)
@@ -58,7 +58,7 @@ static int phar_dir_close(php_stream *stream, int close_handle TSRMLS_DC)  /* {{
 /**
  * Used for seeking on a phar directory handle
  */
-static int phar_dir_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) /* {{{ */
+static int phar_dir_seek(php_stream *stream, php_off_t offset, int whence, php_off_t *newoffset TSRMLS_DC) /* {{{ */
 {
        HashTable *data = (HashTable *)stream->abstract;
 
@@ -95,7 +95,7 @@ static size_t phar_dir_read(php_stream *stream, char *buf, size_t count TSRMLS_D
        size_t to_read;
        HashTable *data = (HashTable *)stream->abstract;
        zend_string *str_key;
-       ulong unused;
+       php_uint_t unused;
 
        if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(data, &str_key, &unused, 0, &data->nInternalPointer)) {
                return 0;
@@ -184,7 +184,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
        char *entry, *found, *save;
        zend_string *str_key;
        uint keylen;
-       ulong unused;
+       php_uint_t unused;
 
        ALLOC_HASHTABLE(data);
        zend_hash_init(data, 64, NULL, NULL, 0);
@@ -306,7 +306,7 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path,
        php_stream *ret;
        char *internal_file, *error;
        zend_string *str_key;
-       ulong unused;
+       php_uint_t unused;
        phar_archive_data *phar;
        phar_entry_info *entry = NULL;
        uint host_len;
@@ -550,7 +550,7 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options
        php_url *resource = NULL;
        uint host_len;
        zend_string *str_key;
-       ulong unused;
+       php_uint_t unused;
        uint path_len;
 
        /* pre-readonly check, we need to know if this is a data phar */
index fd12ea1698ebae7507310adb15c322fabf09f396..27d236aca41373855d35afb1a28d3166144c1720 100644 (file)
@@ -31,7 +31,7 @@ static size_t phar_dir_write(php_stream *stream, const char *buf, size_t count T
 static size_t phar_dir_read( php_stream *stream, char *buf, size_t count TSRMLS_DC);
 static int    phar_dir_close(php_stream *stream, int close_handle TSRMLS_DC);
 static int    phar_dir_flush(php_stream *stream TSRMLS_DC);
-static int    phar_dir_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
+static int    phar_dir_seek( php_stream *stream, php_off_t offset, int whence, php_off_t *newoffset TSRMLS_DC);
 #else
 php_stream* phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
 #endif
index 995d919505cdc0c6cf29f89edb078e03263518b5..b548516fc73767433aa64003d3efe263e3457df3 100644 (file)
@@ -98,8 +98,8 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */
        zend_string *contents;
        zend_bool use_include_path = 0;
        php_stream *stream;
-       long offset = -1;
-       long maxlen = PHP_STREAM_COPY_ALL;
+       php_int_t offset = -1;
+       php_int_t maxlen = PHP_STREAM_COPY_ALL;
        zval *zcontext = NULL;
 
        if (!PHAR_G(intercepted)) {
@@ -112,7 +112,7 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */
        }
 
        /* Parse arguments */
-       if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "p|br!ll", &filename, &filename_len, &use_include_path, &zcontext, &offset, &maxlen) == FAILURE) {
+       if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "p|br!ii", &filename, &filename_len, &use_include_path, &zcontext, &offset, &maxlen) == FAILURE) {
                goto skip_phar;
        }
 
@@ -195,7 +195,7 @@ phar_it:
                        }
 
                        if (offset > 0 && php_stream_seek(stream, offset, SEEK_SET) < 0) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", offset);
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %pd in the stream", offset);
                                php_stream_close(stream);
                                RETURN_FALSE;
                        }
@@ -433,7 +433,7 @@ skip_phar:
 
 /* {{{ php_stat
  */
-static void phar_fancy_stat(struct stat *stat_sb, int type, zval *return_value TSRMLS_DC)
+static void phar_fancy_stat(php_stat_t *stat_sb, int type, zval *return_value TSRMLS_DC)
 {
        zval stat_dev, stat_ino, stat_mode, stat_nlink, stat_uid, stat_gid, stat_rdev,
                 stat_size, stat_atime, stat_mtime, stat_ctime, stat_blksize, stat_blocks;
@@ -477,32 +477,32 @@ static void phar_fancy_stat(struct stat *stat_sb, int type, zval *return_value T
 
        switch (type) {
        case FS_PERMS:
-               RETURN_INT((long)stat_sb->st_mode);
+               RETURN_INT((php_int_t)stat_sb->st_mode);
        case FS_INODE:
-               RETURN_INT((long)stat_sb->st_ino);
+               RETURN_INT((php_int_t)stat_sb->st_ino);
        case FS_SIZE:
-               RETURN_INT((long)stat_sb->st_size);
+               RETURN_INT((php_int_t)stat_sb->st_size);
        case FS_OWNER:
-               RETURN_INT((long)stat_sb->st_uid);
+               RETURN_INT((php_int_t)stat_sb->st_uid);
        case FS_GROUP:
-               RETURN_INT((long)stat_sb->st_gid);
+               RETURN_INT((php_int_t)stat_sb->st_gid);
        case FS_ATIME:
 #ifdef NETWARE
-               RETURN_INT((long)stat_sb->st_atime.tv_sec);
+               RETURN_INT((php_int_t)stat_sb->st_atime.tv_sec);
 #else
-               RETURN_INT((long)stat_sb->st_atime);
+               RETURN_INT((php_int_t)stat_sb->st_atime);
 #endif
        case FS_MTIME:
 #ifdef NETWARE
-               RETURN_INT((long)stat_sb->st_mtime.tv_sec);
+               RETURN_INT((php_int_t)stat_sb->st_mtime.tv_sec);
 #else
-               RETURN_INT((long)stat_sb->st_mtime);
+               RETURN_INT((php_int_t)stat_sb->st_mtime);
 #endif
        case FS_CTIME:
 #ifdef NETWARE
-               RETURN_INT((long)stat_sb->st_ctime.tv_sec);
+               RETURN_INT((php_int_t)stat_sb->st_ctime.tv_sec);
 #else
-               RETURN_INT((long)stat_sb->st_ctime);
+               RETURN_INT((php_int_t)stat_sb->st_ctime);
 #endif
        case FS_TYPE:
                if (S_ISLNK(stat_sb->st_mode)) {
@@ -611,7 +611,7 @@ static void phar_file_stat(const char *filename, php_stat_len filename_length, i
        if (!IS_ABSOLUTE_PATH(filename, filename_length) && !strstr(filename, "://")) {
                char *arch, *entry, *fname;
                int arch_len, entry_len, fname_len;
-               struct stat sb = {0};
+               php_stat_t sb = {0};
                phar_entry_info *data = NULL;
                phar_archive_data *phar;
 
index 03686108d7cf5341a6261b9c6ee27e492267f981..c0df89fc5c06603deb8793c50279c21309a32a74 100644 (file)
@@ -662,14 +662,14 @@ int phar_parse_metadata(char **buffer, zval *metadata, int zip_metadata_len TSRM
  * This is used by phar_open_from_filename to process the manifest, but can be called
  * directly.
  */
-static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, long halt_offset, phar_archive_data** pphar, php_uint32 compression, char **error TSRMLS_DC) /* {{{ */
+static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, php_int_t halt_offset, phar_archive_data** pphar, php_uint32 compression, char **error TSRMLS_DC) /* {{{ */
 {
        char b32[4], *buffer, *endbuffer, *savebuf;
        phar_archive_data *mydata = NULL;
        phar_entry_info entry;
        php_uint32 manifest_len, manifest_count, manifest_flags, manifest_index, tmp_len, sig_flags;
        php_uint16 manifest_ver;
-       long offset;
+       php_int_t offset;
        int sig_len, register_alias = 0, temp_alias = 0;
        char *signature = NULL;
 
@@ -771,7 +771,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
        /* be ignored on reading because it is being generated anyways. */
        if (manifest_flags & PHAR_HDR_SIGNATURE) {
                char sig_buf[8], *sig_ptr = sig_buf;
-               off_t read_len;
+               php_off_t read_len;
                size_t end_of_phar;
 
                if (-1 == php_stream_seek(fp, -8, SEEK_END)
@@ -792,7 +792,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
                        case PHAR_SIG_OPENSSL: {
                                php_uint32 signature_len;
                                char *sig;
-                               off_t whence;
+                               php_off_t whence;
 
                                /* we store the signature followed by the signature length */
                                if (-1 == php_stream_seek(fp, -12, SEEK_CUR)
@@ -1535,7 +1535,7 @@ int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_l
 static inline char *phar_strnstr(const char *buf, int buf_len, const char *search, int search_len) /* {{{ */
 {
        const char *c;
-       int so_far = 0;
+       ptrdiff_t so_far = 0;
 
        if (buf_len < search_len) {
                return NULL;
@@ -1575,9 +1575,9 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a
        char *pos, test = '\0';
        const int window_size = 1024;
        char buffer[1024 + sizeof(token)]; /* a 1024 byte window + the size of the halt_compiler token (moving window) */
-       const long readsize = sizeof(buffer) - sizeof(token);
-       const long tokenlen = sizeof(token) - 1;
-       long halt_offset;
+       const php_int_t readsize = sizeof(buffer) - sizeof(token);
+       const php_int_t tokenlen = sizeof(token) - 1;
+       php_int_t halt_offset;
        size_t got;
        php_uint32 compression = PHAR_FILE_COMPRESSED_NONE;
 
@@ -1960,7 +1960,7 @@ woohoo:
                        }
                } else {
                        zend_string *str_key;
-                       ulong unused;
+                       php_uint_t unused;
 
                        for (zend_hash_internal_pointer_reset(&(PHAR_GLOBALS->phar_fname_map));
                                HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&(PHAR_GLOBALS->phar_fname_map), &str_key, &unused, 0, &PHAR_GLOBALS->phar_fname_map.nInternalPointer);
@@ -2534,7 +2534,7 @@ char *phar_create_default_stub(const char *index_php, const char *web_index, siz
  * user_stub contains either a string, or a resource pointer, if len is a negative length.
  * user_stub and len should be both 0 if the default or existing stub should be used
  */
-int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, char **error TSRMLS_DC) /* {{{ */
+int phar_flush(phar_archive_data *phar, char *user_stub, php_int_t len, int convert, char **error TSRMLS_DC) /* {{{ */
 {
        char halt_stub[] = "__HALT_COMPILER();";
        char *newstub, *tmp;
@@ -2542,8 +2542,8 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
        int halt_offset, restore_alias_len, global_flags = 0, closeoldfile;
        char *pos, has_dirs = 0;
        char manifest[18], entry_buffer[24];
-       off_t manifest_ftell;
-       long offset;
+       php_off_t manifest_ftell;
+       php_int_t offset;
        size_t wrote;
        php_uint32 manifest_len, mytime, loc, new_manifest_count;
        php_uint32 newcrc32;
index b7dc155a9690e7ab4d13a1f1b5c068cd8c2670b8..ff750d07cd94a94675ba726509af15558e3c1dd7 100644 (file)
@@ -249,11 +249,11 @@ typedef struct _phar_entry_info {
        char                     *filename;
        enum phar_fp_type        fp_type;
        /* offset within original phar file of the file contents */
-       long                     offset_abs;
+       php_int_t                     offset_abs;
        /* offset within fp of the file contents */
-       long                     offset;
+       php_int_t                     offset;
        /* offset within original phar file of the file header (for zip-based/tar-based) */
-       long                     header_offset;
+       php_int_t                     header_offset;
        php_stream               *fp;
        php_stream               *cfp;
        int                      fp_refcount;
@@ -334,7 +334,7 @@ struct _phar_archive_data {
 typedef struct _phar_entry_fp_info {
        enum phar_fp_type        fp_type;
        /* offset within fp of the file contents */
-       long                     offset;
+       php_int_t                     offset;
 } phar_entry_fp_info;
 
 struct _phar_entry_fp {
@@ -415,7 +415,7 @@ static inline void phar_set_pharufp(phar_archive_data *phar, php_stream *fp TSRM
        PHAR_GLOBALS->cached_fp[phar->phar_pos].ufp = fp;
 }
 
-static inline void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type type, off_t offset TSRMLS_DC)
+static inline void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type type, php_off_t offset TSRMLS_DC)
 {
        phar_entry_fp_info *data;
 
@@ -437,7 +437,7 @@ static inline enum phar_fp_type phar_get_fp_type(phar_entry_info *entry TSRMLS_D
        return PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type;
 }
 
-static inline off_t phar_get_fp_offset(phar_entry_info *entry TSRMLS_DC)
+static inline php_off_t phar_get_fp_offset(phar_entry_info *entry TSRMLS_DC)
 {
        if (!entry->is_persistent) {
                return entry->offset;
@@ -466,9 +466,9 @@ typedef struct _phar_entry_data {
        phar_archive_data        *phar;
        php_stream               *fp;
        /* stream position proxy, allows multiple open streams referring to the same fp */
-       off_t                    position;
+       php_off_t                    position;
        /* for copies of the phar fp, defines where 0 is */
-       off_t                    zero;
+       php_off_t                    zero;
        unsigned int             for_write:1;
        unsigned int             is_zip:1;
        unsigned int             is_tar:1;
@@ -564,7 +564,7 @@ char *phar_fix_filepath(char *path, int *new_len, int use_cwd TSRMLS_DC);
 phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC);
 int phar_parse_metadata(char **buffer, zval *metadata, int zip_metadata_len TSRMLS_DC);
 void destroy_phar_manifest_entry(zval *zv);
-int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t position, int follow_links TSRMLS_DC);
+int phar_seek_efp(phar_entry_info *entry, php_off_t offset, int whence, php_off_t position, int follow_links TSRMLS_DC);
 php_stream *phar_get_efp(phar_entry_info *entry, int follow_links TSRMLS_DC);
 int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **error TSRMLS_DC);
 int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TSRMLS_DC);
@@ -578,12 +578,12 @@ int phar_copy_on_write(phar_archive_data **pphar TSRMLS_DC);
 int phar_is_tar(char *buf, char *fname);
 int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, int is_data, php_uint32 compression, char **error TSRMLS_DC);
 int phar_open_or_create_tar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
-int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC);
+int phar_tar_flush(phar_archive_data *phar, char *user_stub, php_int_t len, int defaultstub, char **error TSRMLS_DC);
 
 /* zip functions in zip.c */
 int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, char **error TSRMLS_DC);
 int phar_open_or_create_zip(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
-int phar_zip_flush(phar_archive_data *archive, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC);
+int phar_zip_flush(phar_archive_data *archive, char *user_stub, php_int_t len, int defaultstub, char **error TSRMLS_DC);
 
 #ifdef PHAR_MAIN
 static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, int is_data, char **error TSRMLS_DC);
@@ -600,7 +600,7 @@ phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int pa
 phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, int path_len, char dir, char **error, int security TSRMLS_DC);
 phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC);
 int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC);
-int phar_flush(phar_archive_data *archive, char *user_stub, long len, int convert, char **error TSRMLS_DC);
+int phar_flush(phar_archive_data *archive, char *user_stub, php_int_t len, int convert, char **error TSRMLS_DC);
 int phar_detect_phar_fname_ext(const char *filename, int filename_len, const char **ext_str, int *ext_len, int executable, int for_create, int is_complete TSRMLS_DC);
 int phar_split_fname(const char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create TSRMLS_DC);
 
index abb29fef72aaf1baab1c9366f5cec6b01a1896d3..00b4969a2a873528fdbc3b9160714376c537e02c 100755 (executable)
@@ -155,7 +155,7 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char
        zend_op_array *new_op_array;
        zval result;
        php_stream *fp;
-       off_t position;
+       php_off_t position;
 
        switch (code) {
                case PHAR_MIME_PHPS:
@@ -211,7 +211,7 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char
                                if (got > 0) {
                                        PHPWRITE(buf, got);
                                        position += got;
-                                       if (position == (off_t) info->uncompressed_filesize) {
+                                       if (position == (php_off_t) info->uncompressed_filesize) {
                                                break;
                                        }
                                }
@@ -947,9 +947,9 @@ PHP_METHOD(Phar, mapPhar)
 {
        char *alias = NULL, *error;
        int alias_len = 0;
-       long dataoffset = 0;
+       php_int_t dataoffset = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!l", &alias, &alias_len, &dataoffset) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!i", &alias, &alias_len, &dataoffset) == FAILURE) {
                return;
        }
 
@@ -999,9 +999,9 @@ PHP_METHOD(Phar, apiVersion)
  * Returns whether phar extension supports compression using zlib/bzip2 */
 PHP_METHOD(Phar, canCompress)
 {
-       long method = 0;
+       php_int_t method = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &method) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &method) == FAILURE) {
                return;
        }
 
@@ -1109,8 +1109,8 @@ PHP_METHOD(Phar, __construct)
 #else
        char *fname, *alias = NULL, *error, *arch = NULL, *entry = NULL, *save_fname;
        int fname_len, alias_len = 0, arch_len, entry_len, is_data;
-       long flags = SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS;
-       long format = 0;
+       php_int_t flags = SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS;
+       php_int_t format = 0;
        phar_archive_object *phar_obj;
        phar_archive_data   *phar_data;
        zval *zobj = getThis(), arg1, arg2;
@@ -1120,11 +1120,11 @@ PHP_METHOD(Phar, __construct)
        is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data TSRMLS_CC);
 
        if (is_data) {
-               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|is!i", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
                        return;
                }
        } else {
-               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|is!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
                        return;
                }
        }
@@ -1900,10 +1900,10 @@ PHP_METHOD(Phar, buildFromIterator)
 PHP_METHOD(Phar, count)
 {
        /* mode can be ignored, maximum depth is 1 */
-       long mode;
+       php_int_t mode;
        PHAR_ARCHIVE_OBJECT();
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &mode) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &mode) == FAILURE) {
                RETURN_FALSE;
        }
 
@@ -1917,10 +1917,10 @@ PHP_METHOD(Phar, count)
  */
 PHP_METHOD(Phar, isFileFormat)
 {
-       long type;
+       php_int_t type;
        PHAR_ARCHIVE_OBJECT();
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &type) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &type) == FAILURE) {
                RETURN_FALSE;
        }
 
@@ -1940,7 +1940,7 @@ PHP_METHOD(Phar, isFileFormat)
 static int phar_copy_file_contents(phar_entry_info *entry, php_stream *fp TSRMLS_DC) /* {{{ */
 {
        char *error;
-       off_t offset;
+       php_off_t offset;
        phar_entry_info *link;
 
        if (FAILURE == phar_open_entry_fp(entry, &error, 1 TSRMLS_CC)) {
@@ -2300,10 +2300,10 @@ PHP_METHOD(Phar, convertToExecutable)
        php_uint32 flags;
        zend_object *ret;
        /* a number that is not 0, 1 or 2 (Which is also Greg's birthday, so there) */
-       long format = 9021976, method = 9021976;
+       php_int_t format = 9021976, method = 9021976;
        PHAR_ARCHIVE_OBJECT();
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lls", &format, &method, &ext, &ext_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|iis", &format, &method, &ext, &ext_len) == FAILURE) {
                return;
        }
 
@@ -2403,10 +2403,10 @@ PHP_METHOD(Phar, convertToData)
        php_uint32 flags;
        zend_object *ret;
        /* a number that is not 0, 1 or 2 (Which is also Greg's birthday so there) */
-       long format = 9021976, method = 9021976;
+       php_int_t format = 9021976, method = 9021976;
        PHAR_ARCHIVE_OBJECT();
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lls", &format, &method, &ext, &ext_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|iis", &format, &method, &ext, &ext_len) == FAILURE) {
                return;
        }
 
@@ -2812,7 +2812,7 @@ PHP_METHOD(Phar, setStub)
        zval *zstub;
        char *stub, *error;
        int stub_len;
-       long len = -1;
+       php_int_t len = -1;
        php_stream *stream;
        PHAR_ARCHIVE_OBJECT();
 
@@ -2833,7 +2833,7 @@ PHP_METHOD(Phar, setStub)
                return;
        }
 
-       if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &zstub, &len) == SUCCESS) {
+       if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "r|i", &zstub, &len) == SUCCESS) {
                if ((php_stream_from_zval_no_verify(stream, zstub)) != NULL) {
                        if (len > 0) {
                                len = -len;
@@ -2962,7 +2962,7 @@ PHP_METHOD(Phar, setDefaultStub)
  */
 PHP_METHOD(Phar, setSignatureAlgorithm)
 {
-       long algo;
+       php_int_t algo;
        char *error, *key = NULL;
        int key_len = 0;
 
@@ -2974,7 +2974,7 @@ PHP_METHOD(Phar, setSignatureAlgorithm)
                return;
        }
 
-       if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "l|s", &algo, &key, &key_len) != SUCCESS) {
+       if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "i|s", &algo, &key, &key_len) != SUCCESS) {
                return;
        }
 
@@ -3133,14 +3133,14 @@ static int pharobj_cancompress(HashTable *manifest TSRMLS_DC) /* {{{ */
  */
 PHP_METHOD(Phar, compress)
 {
-       long method;
+       php_int_t method;
        char *ext = NULL;
        int ext_len = 0;
        php_uint32 flags;
        zend_object *ret;
        PHAR_ARCHIVE_OBJECT();
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|s", &method, &ext, &ext_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i|s", &method, &ext, &ext_len) == FAILURE) {
                return;
        }
 
@@ -3246,10 +3246,10 @@ PHP_METHOD(Phar, compressFiles)
 {
        char *error;
        php_uint32 flags;
-       long method;
+       php_int_t method;
        PHAR_ARCHIVE_OBJECT();
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &method) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &method) == FAILURE) {
                return;
        }
 
@@ -4429,10 +4429,10 @@ PHP_METHOD(PharFileInfo, getCompressedSize)
 PHP_METHOD(PharFileInfo, isCompressed)
 {
        /* a number that is not Phar::GZ or Phar::BZ2 */
-       long method = 9021976;
+       php_int_t method = 9021976;
        PHAR_ENTRY_OBJECT();
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &method) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &method) == FAILURE) {
                return;
        }
 
@@ -4512,7 +4512,7 @@ PHP_METHOD(PharFileInfo, getPharFlags)
 PHP_METHOD(PharFileInfo, chmod)
 {
        char *error;
-       long perms;
+       php_int_t perms;
        PHAR_ENTRY_OBJECT();
 
        if (entry_obj->entry->is_temp_dir) {
@@ -4526,7 +4526,7 @@ PHP_METHOD(PharFileInfo, chmod)
                return;
        }
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &perms) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &perms) == FAILURE) {
                return;
        }
 
@@ -4774,11 +4774,11 @@ PHP_METHOD(PharFileInfo, getContent)
  */
 PHP_METHOD(PharFileInfo, compress)
 {
-       long method;
+       php_int_t method;
        char *error;
        PHAR_ENTRY_OBJECT();
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &method) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &method) == FAILURE) {
                return;
        }
 
index d4ff1efc7606af78bd2d49e93a1e645f940bb60e..a5007584201961798e87348f0f06509267623f6d 100644 (file)
@@ -377,7 +377,7 @@ static size_t phar_stream_read(php_stream *stream, char *buf, size_t count TSRML
 
        got = php_stream_read(data->fp, buf, MIN(count, entry->uncompressed_filesize - data->position));
        data->position = php_stream_tell(data->fp) - data->zero;
-       stream->eof = (data->position == (off_t) entry->uncompressed_filesize);
+       stream->eof = (data->position == (php_off_t) entry->uncompressed_filesize);
 
        return got;
 }
@@ -386,12 +386,12 @@ static size_t phar_stream_read(php_stream *stream, char *buf, size_t count TSRML
 /**
  * Used for fseek($fp) on a phar file handle
  */
-static int phar_stream_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) /* {{{ */
+static int phar_stream_seek(php_stream *stream, php_off_t offset, int whence, php_off_t *newoffset TSRMLS_DC) /* {{{ */
 {
        phar_entry_data *data = (phar_entry_data *)stream->abstract;
        phar_entry_info *entry;
        int res;
-       off_t temp;
+       php_off_t temp;
 
        if (data->internal_file->link) {
                entry = phar_get_link_source(data->internal_file TSRMLS_CC);
@@ -412,7 +412,7 @@ static int phar_stream_seek(php_stream *stream, off_t offset, int whence, off_t
                default:
                        temp = 0;
        }
-       if (temp > data->zero + (off_t) entry->uncompressed_filesize) {
+       if (temp > data->zero + (php_off_t) entry->uncompressed_filesize) {
                *newoffset = -1;
                return -1;
        }
@@ -440,7 +440,7 @@ static size_t phar_stream_write(php_stream *stream, const char *buf, size_t coun
                return -1;
        }
        data->position = php_stream_tell(data->fp);
-       if (data->position > (off_t)data->internal_file->uncompressed_filesize) {
+       if (data->position > (php_off_t)data->internal_file->uncompressed_filesize) {
                data->internal_file->uncompressed_filesize = data->position;
        }
        data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize;
index 2b786965601764ce4bb16d43a0fad2724cad2400..20cf68d9d74fef1bd57f06bf38fb2932124612dc 100644 (file)
@@ -34,7 +34,7 @@ static size_t phar_stream_write(php_stream *stream, const char *buf, size_t coun
 static size_t phar_stream_read( php_stream *stream, char *buf, size_t count TSRMLS_DC);
 static int    phar_stream_close(php_stream *stream, int close_handle TSRMLS_DC);
 static int    phar_stream_flush(php_stream *stream TSRMLS_DC);
-static int    phar_stream_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
+static int    phar_stream_seek( php_stream *stream, php_off_t offset, int whence, php_off_t *newoffset TSRMLS_DC);
 static int    phar_stream_stat( php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
 END_EXTERN_C()
 
index e2237cc9baf1251432dcaf5e1fe4285078604a3e..fd571eae481a58a5043dce90a856f2a9c83df1ac 100644 (file)
@@ -256,7 +256,7 @@ int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias,
                        phar_tar_number(hdr->size, sizeof(hdr->size));
 
                if (((!old && hdr->prefix[0] == 0) || old) && strlen(hdr->name) == sizeof(".phar/signature.bin")-1 && !strncmp(hdr->name, ".phar/signature.bin", sizeof(".phar/signature.bin")-1)) {
-                       off_t curloc;
+                       php_off_t curloc;
 
                        if (size > 511) {
                                if (error) {
@@ -921,7 +921,7 @@ static int phar_tar_setupmetadata(zval *zv, void *argument TSRMLS_DC) /* {{{ */
 }
 /* }}} */
 
-int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
+int phar_tar_flush(phar_archive_data *phar, char *user_stub, php_int_t len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
 {
        phar_entry_info entry = {0};
        static const char newstub[] = "<?php // tar-based phar archive stub file\n__HALT_COMPILER();";
index ba8eb7ba247c3b915fadfe5246aebd1ced93617e..c2a398d787288f521b16de941ab4666f53ac3923 100644 (file)
@@ -38,7 +38,7 @@
 #include <openssl/ssl.h>
 #include <openssl/pkcs12.h>
 #else
-static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC);
+static int phar_call_openssl_signverify(int is_sign, php_stream *fp, php_off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC);
 #endif
 
 /* for links to relative location, prepend cwd of the entry */
@@ -117,10 +117,10 @@ php_stream *phar_get_efp(phar_entry_info *entry, int follow_links TSRMLS_DC) /*
 }
 /* }}} */
 
-int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t position, int follow_links TSRMLS_DC) /* {{{ */
+int phar_seek_efp(phar_entry_info *entry, php_off_t offset, int whence, php_off_t position, int follow_links TSRMLS_DC) /* {{{ */
 {
        php_stream *fp = phar_get_efp(entry, follow_links TSRMLS_CC);
-       off_t temp, eoffset;
+       php_off_t temp, eoffset;
 
        if (!fp) {
                return -1;
@@ -154,7 +154,7 @@ int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t positi
                        temp = 0;
        }
 
-       if (temp > eoffset + (off_t) entry->uncompressed_filesize) {
+       if (temp > eoffset + (php_off_t) entry->uncompressed_filesize) {
                return -1;
        }
 
@@ -693,7 +693,7 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS
        php_stream_filter *filter;
        phar_archive_data *phar = entry->phar;
        char *filtername;
-       off_t loc;
+       php_off_t loc;
        php_stream *ufp;
        phar_entry_data dummy;
 
@@ -786,7 +786,7 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS
        php_stream_flush(ufp);
        php_stream_filter_remove(filter, 1 TSRMLS_CC);
 
-       if (php_stream_tell(ufp) - loc != (off_t) entry->uncompressed_filesize) {
+       if (php_stream_tell(ufp) - loc != (php_off_t) entry->uncompressed_filesize) {
                spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename);
                return FAILURE;
        }
@@ -1388,7 +1388,7 @@ static int phar_hex_str(const char *digest, size_t digest_len, char **signature
 /* }}} */
 
 #ifndef PHAR_HAVE_OPENSSL
-static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC) /* {{{ */
+static int phar_call_openssl_signverify(int is_sign, php_stream *fp, php_off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC) /* {{{ */
 {
        zend_fcall_info fci;
        zend_fcall_info_cache fcc;
@@ -1479,7 +1479,7 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end,
 int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_type, char *sig, int sig_len, char *fname, char **signature, int *signature_len, char **error TSRMLS_DC) /* {{{ */
 {
        int read_size, len;
-       off_t read_len;
+       php_off_t read_len;
        unsigned char buf[1024];
 
        php_stream_rewind(fp);
@@ -1576,7 +1576,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
 
                        while (read_size && (len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
                                EVP_VerifyUpdate (&md_ctx, buf, len);
-                               read_len -= (off_t)len;
+                               read_len -= (php_off_t)len;
 
                                if (read_len < read_size) {
                                        read_size = (int)read_len;
@@ -1616,7 +1616,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
 
                        while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
                                PHP_SHA512Update(&context, buf, len);
-                               read_len -= (off_t)len;
+                               read_len -= (php_off_t)len;
                                if (read_len < read_size) {
                                        read_size = (int)read_len;
                                }
@@ -1649,7 +1649,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
 
                        while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
                                PHP_SHA256Update(&context, buf, len);
-                               read_len -= (off_t)len;
+                               read_len -= (php_off_t)len;
                                if (read_len < read_size) {
                                        read_size = (int)read_len;
                                }
@@ -1690,7 +1690,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
 
                        while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
                                PHP_SHA1Update(&context, buf, len);
-                               read_len -= (off_t)len;
+                               read_len -= (php_off_t)len;
                                if (read_len < read_size) {
                                        read_size = (int)read_len;
                                }
@@ -1723,7 +1723,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
 
                        while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
                                PHP_MD5Update(&context, buf, len);
-                               read_len -= (off_t)len;
+                               read_len -= (php_off_t)len;
                                if (read_len < read_size) {
                                        read_size = (int)read_len;
                                }
index 10becce09f6017b3da022a2d9ebc39efd80566bf..2eb48f45a4228b9d78d7e1ac1cbc9194096b91b1 100644 (file)
@@ -167,7 +167,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
 {
        phar_zip_dir_end locator;
        char buf[sizeof(locator) + 65536];
-       long size;
+       php_int_t size;
        php_uint16 i;
        phar_archive_data *mydata = NULL;
        phar_entry_info entry = {0};
@@ -338,7 +338,7 @@ foundit:
        /* add each central directory item to the manifest */
        for (i = 0; i < PHAR_GET_16(locator.count); ++i) {
                phar_zip_central_dir_file zipentry;
-               off_t beforeus = php_stream_tell(fp);
+               php_off_t beforeus = php_stream_tell(fp);
 
                if (sizeof(zipentry) != php_stream_read(fp, (char *) &zipentry, sizeof(zipentry))) {
                        PHAR_ZIP_FAIL("unable to read central directory entry, truncated");
@@ -393,7 +393,7 @@ foundit:
                if (entry.filename_len == sizeof(".phar/signature.bin")-1 && !strncmp(entry.filename, ".phar/signature.bin", sizeof(".phar/signature.bin")-1)) {
                        size_t read;
                        php_stream *sigfile;
-                       off_t now;
+                       php_off_t now;
                        char *sig;
 
                        now = php_stream_tell(fp);
@@ -448,7 +448,7 @@ foundit:
                phar_add_virtual_dirs(mydata, entry.filename, entry.filename_len TSRMLS_CC);
 
                if (PHAR_GET_16(zipentry.extra_len)) {
-                       off_t loc = php_stream_tell(fp);
+                       php_off_t loc = php_stream_tell(fp);
                        if (FAILURE == phar_zip_process_extra(fp, &entry, PHAR_GET_16(zipentry.extra_len) TSRMLS_CC)) {
                                pefree(entry.filename, entry.is_persistent);
                                PHAR_ZIP_FAIL("Unable to process extra field header for file in central directory");
@@ -537,7 +537,7 @@ foundit:
 
                if (!actual_alias && entry.filename_len == sizeof(".phar/alias.txt")-1 && !strncmp(entry.filename, ".phar/alias.txt", sizeof(".phar/alias.txt")-1)) {
                        php_stream_filter *filter;
-                       off_t saveloc;
+                       php_off_t saveloc;
                        /* verify local file header */
                        phar_zip_file_header local;
 
@@ -790,7 +790,7 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg TSRMLS_D
        phar_zip_central_dir_file central;
        struct _phar_zip_pass *p;
        php_uint32 newcrc32;
-       off_t offset;
+       php_off_t offset;
        int not_really_modified = 0;
        p = (struct _phar_zip_pass*) arg;
 
@@ -1108,7 +1108,7 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas
                char *signature, sigbuf[8];
                phar_entry_info entry = {0};
                php_stream *newfile;
-               off_t tell, st;
+               php_off_t tell, st;
 
                newfile = php_stream_fopen_tmpfile();
                if (newfile == NULL) {
@@ -1177,7 +1177,7 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas
 }
 /* }}} */
 
-int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
+int phar_zip_flush(phar_archive_data *phar, char *user_stub, php_int_t len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
 {
        char *pos;
        smart_str main_metadata_str = {0};