Skip to content

Commit 3ecfbe2

Browse files
committed
ext/phar: Move some header functions into util.c
They were only used there, therefore mark them static
1 parent 6836cae commit 3ecfbe2

File tree

2 files changed

+55
-83
lines changed

2 files changed

+55
-83
lines changed

ext/phar/phar_internal.h

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -339,34 +339,6 @@ static inline php_stream *phar_get_entrypfp(phar_entry_info *entry)
339339
return PHAR_G(cached_fp)[entry->phar->phar_pos].fp;
340340
}
341341

342-
static inline php_stream *phar_get_entrypufp(phar_entry_info *entry)
343-
{
344-
if (!entry->is_persistent) {
345-
return entry->phar->ufp;
346-
}
347-
return PHAR_G(cached_fp)[entry->phar->phar_pos].ufp;
348-
}
349-
350-
static inline void phar_set_entrypfp(phar_entry_info *entry, php_stream *fp)
351-
{
352-
if (!entry->phar->is_persistent) {
353-
entry->phar->fp = fp;
354-
return;
355-
}
356-
357-
PHAR_G(cached_fp)[entry->phar->phar_pos].fp = fp;
358-
}
359-
360-
static inline void phar_set_entrypufp(phar_entry_info *entry, php_stream *fp)
361-
{
362-
if (!entry->phar->is_persistent) {
363-
entry->phar->ufp = fp;
364-
return;
365-
}
366-
367-
PHAR_G(cached_fp)[entry->phar->phar_pos].ufp = fp;
368-
}
369-
370342
static inline php_stream *phar_get_pharfp(phar_archive_data *phar)
371343
{
372344
if (!phar->is_persistent) {
@@ -375,48 +347,6 @@ static inline php_stream *phar_get_pharfp(phar_archive_data *phar)
375347
return PHAR_G(cached_fp)[phar->phar_pos].fp;
376348
}
377349

378-
static inline php_stream *phar_get_pharufp(phar_archive_data *phar)
379-
{
380-
if (!phar->is_persistent) {
381-
return phar->ufp;
382-
}
383-
return PHAR_G(cached_fp)[phar->phar_pos].ufp;
384-
}
385-
386-
static inline void phar_set_pharfp(phar_archive_data *phar, php_stream *fp)
387-
{
388-
if (!phar->is_persistent) {
389-
phar->fp = fp;
390-
return;
391-
}
392-
393-
PHAR_G(cached_fp)[phar->phar_pos].fp = fp;
394-
}
395-
396-
static inline void phar_set_pharufp(phar_archive_data *phar, php_stream *fp)
397-
{
398-
if (!phar->is_persistent) {
399-
phar->ufp = fp;
400-
return;
401-
}
402-
403-
PHAR_G(cached_fp)[phar->phar_pos].ufp = fp;
404-
}
405-
406-
static inline void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type type, zend_off_t offset)
407-
{
408-
phar_entry_fp_info *data;
409-
410-
if (!entry->is_persistent) {
411-
entry->fp_type = type;
412-
entry->offset = offset;
413-
return;
414-
}
415-
data = &(PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos]);
416-
data->fp_type = type;
417-
data->offset = offset;
418-
}
419-
420350
static inline enum phar_fp_type phar_get_fp_type(phar_entry_info *entry)
421351
{
422352
if (!entry->is_persistent) {
@@ -425,19 +355,6 @@ static inline enum phar_fp_type phar_get_fp_type(phar_entry_info *entry)
425355
return PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type;
426356
}
427357

428-
static inline zend_off_t phar_get_fp_offset(phar_entry_info *entry)
429-
{
430-
if (!entry->is_persistent) {
431-
return entry->offset;
432-
}
433-
if (PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type == PHAR_FP) {
434-
if (!PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset) {
435-
PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset = entry->offset;
436-
}
437-
}
438-
return PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset;
439-
}
440-
441358
#define PHAR_MIME_PHP '\0'
442359
#define PHAR_MIME_PHPS '\1'
443360
#define PHAR_MIME_OTHER '\2'

ext/phar/util.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ phar_entry_info *phar_get_link_source(phar_entry_info *entry) /* {{{ */
8282
}
8383
/* }}} */
8484

85+
static php_stream *phar_get_entrypufp(const phar_entry_info *entry)
86+
{
87+
if (!entry->is_persistent) {
88+
return entry->phar->ufp;
89+
}
90+
return PHAR_G(cached_fp)[entry->phar->phar_pos].ufp;
91+
}
92+
8593
/* retrieve a phar_entry_info's current file pointer for reading contents */
8694
php_stream *phar_get_efp(phar_entry_info *entry, int follow_links) /* {{{ */
8795
{
@@ -113,6 +121,19 @@ php_stream *phar_get_efp(phar_entry_info *entry, int follow_links) /* {{{ */
113121
}
114122
/* }}} */
115123

124+
static zend_off_t phar_get_fp_offset(const phar_entry_info *entry)
125+
{
126+
if (!entry->is_persistent) {
127+
return entry->offset;
128+
}
129+
if (PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type == PHAR_FP) {
130+
if (!PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset) {
131+
PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset = entry->offset;
132+
}
133+
}
134+
return PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset;
135+
}
136+
116137
int phar_seek_efp(phar_entry_info *entry, zend_off_t offset, int whence, zend_off_t position, int follow_links) /* {{{ */
117138
{
118139
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
616637
}
617638
/* }}} */
618639

640+
static inline void phar_set_pharfp(phar_archive_data *phar, php_stream *fp)
641+
{
642+
if (!phar->is_persistent) {
643+
phar->fp = fp;
644+
return;
645+
}
646+
647+
PHAR_G(cached_fp)[phar->phar_pos].fp = fp;
648+
}
649+
619650
/* initialize a phar_archive_data's read-only fp for existing phar data */
620651
int phar_open_archive_fp(phar_archive_data *phar) /* {{{ */
621652
{
@@ -680,6 +711,30 @@ int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **er
680711
}
681712
/* }}} */
682713

714+
static void phar_set_entrypufp(const phar_entry_info *entry, php_stream *fp)
715+
{
716+
if (!entry->phar->is_persistent) {
717+
entry->phar->ufp = fp;
718+
return;
719+
}
720+
721+
PHAR_G(cached_fp)[entry->phar->phar_pos].ufp = fp;
722+
}
723+
724+
static void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type type, zend_off_t offset)
725+
{
726+
phar_entry_fp_info *data;
727+
728+
if (!entry->is_persistent) {
729+
entry->fp_type = type;
730+
entry->offset = offset;
731+
return;
732+
}
733+
data = &(PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos]);
734+
data->fp_type = type;
735+
data->offset = offset;
736+
}
737+
683738
/* open and decompress a compressed phar entry
684739
*/
685740
int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links) /* {{{ */

0 commit comments

Comments
 (0)