From 81d232fed5795a2a229fc3e9255a3f68fe0f70f2 Mon Sep 17 00:00:00 2001 From: Gina Peter Bnayard Date: Sat, 17 Aug 2024 00:11:11 +0200 Subject: [PATCH] ext/phar: Move some header functions into util.c They were only used there, therefore mark them static --- ext/phar/phar_internal.h | 83 ---------------------------------------- ext/phar/util.c | 55 ++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 83 deletions(-) diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index 402e2f7d8c2..d447994acd9 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -339,34 +339,6 @@ static inline php_stream *phar_get_entrypfp(phar_entry_info *entry) return PHAR_G(cached_fp)[entry->phar->phar_pos].fp; } -static inline php_stream *phar_get_entrypufp(phar_entry_info *entry) -{ - if (!entry->is_persistent) { - return entry->phar->ufp; - } - return PHAR_G(cached_fp)[entry->phar->phar_pos].ufp; -} - -static inline void phar_set_entrypfp(phar_entry_info *entry, php_stream *fp) -{ - if (!entry->phar->is_persistent) { - entry->phar->fp = fp; - return; - } - - PHAR_G(cached_fp)[entry->phar->phar_pos].fp = fp; -} - -static inline void phar_set_entrypufp(phar_entry_info *entry, php_stream *fp) -{ - if (!entry->phar->is_persistent) { - entry->phar->ufp = fp; - return; - } - - PHAR_G(cached_fp)[entry->phar->phar_pos].ufp = fp; -} - static inline php_stream *phar_get_pharfp(phar_archive_data *phar) { if (!phar->is_persistent) { @@ -375,48 +347,6 @@ static inline php_stream *phar_get_pharfp(phar_archive_data *phar) return PHAR_G(cached_fp)[phar->phar_pos].fp; } -static inline php_stream *phar_get_pharufp(phar_archive_data *phar) -{ - if (!phar->is_persistent) { - return phar->ufp; - } - return PHAR_G(cached_fp)[phar->phar_pos].ufp; -} - -static inline void phar_set_pharfp(phar_archive_data *phar, php_stream *fp) -{ - if (!phar->is_persistent) { - phar->fp = fp; - return; - } - - PHAR_G(cached_fp)[phar->phar_pos].fp = fp; -} - -static inline void phar_set_pharufp(phar_archive_data *phar, php_stream *fp) -{ - if (!phar->is_persistent) { - phar->ufp = fp; - return; - } - - PHAR_G(cached_fp)[phar->phar_pos].ufp = fp; -} - -static inline void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type type, zend_off_t offset) -{ - phar_entry_fp_info *data; - - if (!entry->is_persistent) { - entry->fp_type = type; - entry->offset = offset; - return; - } - data = &(PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos]); - data->fp_type = type; - data->offset = offset; -} - static inline enum phar_fp_type phar_get_fp_type(phar_entry_info *entry) { if (!entry->is_persistent) { @@ -425,19 +355,6 @@ static inline enum phar_fp_type phar_get_fp_type(phar_entry_info *entry) return PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type; } -static inline zend_off_t phar_get_fp_offset(phar_entry_info *entry) -{ - if (!entry->is_persistent) { - return entry->offset; - } - if (PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type == PHAR_FP) { - if (!PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset) { - PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset = entry->offset; - } - } - return PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset; -} - #define PHAR_MIME_PHP '\0' #define PHAR_MIME_PHPS '\1' #define PHAR_MIME_OTHER '\2' diff --git a/ext/phar/util.c b/ext/phar/util.c index 3a366216650..7c2446d4852 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -82,6 +82,14 @@ phar_entry_info *phar_get_link_source(phar_entry_info *entry) /* {{{ */ } /* }}} */ +static php_stream *phar_get_entrypufp(const phar_entry_info *entry) +{ + if (!entry->is_persistent) { + return entry->phar->ufp; + } + return PHAR_G(cached_fp)[entry->phar->phar_pos].ufp; +} + /* retrieve a phar_entry_info's current file pointer for reading contents */ php_stream *phar_get_efp(phar_entry_info *entry, int follow_links) /* {{{ */ { @@ -113,6 +121,19 @@ php_stream *phar_get_efp(phar_entry_info *entry, int follow_links) /* {{{ */ } /* }}} */ +static zend_off_t phar_get_fp_offset(const phar_entry_info *entry) +{ + if (!entry->is_persistent) { + return entry->offset; + } + if (PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type == PHAR_FP) { + if (!PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset) { + PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset = entry->offset; + } + } + return PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset; +} + int phar_seek_efp(phar_entry_info *entry, zend_off_t offset, int whence, zend_off_t position, int follow_links) /* {{{ */ { php_stream *fp = phar_get_efp(entry, follow_links); @@ -616,6 +637,16 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, size_t fname_len, ch } /* }}} */ +static inline void phar_set_pharfp(phar_archive_data *phar, php_stream *fp) +{ + if (!phar->is_persistent) { + phar->fp = fp; + return; + } + + PHAR_G(cached_fp)[phar->phar_pos].fp = fp; +} + /* initialize a phar_archive_data's read-only fp for existing phar data */ int phar_open_archive_fp(phar_archive_data *phar) /* {{{ */ { @@ -680,6 +711,30 @@ int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **er } /* }}} */ +static void phar_set_entrypufp(const phar_entry_info *entry, php_stream *fp) +{ + if (!entry->phar->is_persistent) { + entry->phar->ufp = fp; + return; + } + + PHAR_G(cached_fp)[entry->phar->phar_pos].ufp = fp; +} + +static void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type type, zend_off_t offset) +{ + phar_entry_fp_info *data; + + if (!entry->is_persistent) { + entry->fp_type = type; + entry->offset = offset; + return; + } + data = &(PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos]); + data->fp_type = type; + data->offset = offset; +} + /* open and decompress a compressed phar entry */ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links) /* {{{ */