php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
phar_internal.h File Reference
#include <time.h>
#include "php.h"
#include "tar.h"
#include "pharzip.h"
#include "zend_hash.h"
#include "ext/spl/spl_directory.h"

Go to the source code of this file.

Data Structures

struct  _phar_metadata_tracker
 
struct  _phar_entry_info
 
struct  _phar_archive_data
 
struct  _phar_entry_fp_info
 
struct  _phar_entry_fp
 
struct  _phar_mime_type
 
struct  _phar_entry_data
 
union  _phar_archive_object
 
union  _phar_entry_object
 

Macros

#define PHP_PHAR_API_VERSION   "1.1.1"
 
#define PHAR_API_VERSION   0x1110
 
#define PHAR_API_VERSION_NODIR   0x1100
 
#define PHAR_API_MIN_DIR   0x1110
 
#define PHAR_API_MIN_READ   0x1000
 
#define PHAR_API_MAJORVERSION   0x1000
 
#define PHAR_API_MAJORVER_MASK   0xF000
 
#define PHAR_API_VER_MASK   0xFFF0
 
#define PHAR_HDR_COMPRESSION_MASK   0x0000F000
 
#define PHAR_HDR_COMPRESSED_NONE   0x00000000
 
#define PHAR_HDR_COMPRESSED_GZ   0x00001000
 
#define PHAR_HDR_COMPRESSED_BZ2   0x00002000
 
#define PHAR_HDR_SIGNATURE   0x00010000
 
#define PHAR_FILE_COMPRESSION_MASK   0x00F00000
 
#define PHAR_FILE_COMPRESSED_NONE   0x00000000
 
#define PHAR_FILE_COMPRESSED_GZ   0x00100000
 
#define PHAR_FILE_COMPRESSED_BZ2   0x00200000
 
#define PHAR_SIG_MD5   0x0001
 
#define PHAR_SIG_SHA1   0x0002
 
#define PHAR_SIG_SHA256   0x0003
 
#define PHAR_SIG_SHA512   0x0004
 
#define PHAR_SIG_OPENSSL   0x0010
 
#define PHAR_SIG_OPENSSL_SHA256   0x0011
 
#define PHAR_SIG_OPENSSL_SHA512   0x0012
 
#define PHAR_ENT_COMPRESSION_MASK   0x0000F000
 
#define PHAR_ENT_COMPRESSED_NONE   0x00000000
 
#define PHAR_ENT_COMPRESSED_GZ   0x00001000
 
#define PHAR_ENT_COMPRESSED_BZ2   0x00002000
 
#define PHAR_ENT_PERM_MASK   0x000001FF
 
#define PHAR_ENT_PERM_MASK_USR   0x000001C0
 
#define PHAR_ENT_PERM_SHIFT_USR   6
 
#define PHAR_ENT_PERM_MASK_GRP   0x00000038
 
#define PHAR_ENT_PERM_SHIFT_GRP   3
 
#define PHAR_ENT_PERM_MASK_OTH   0x00000007
 
#define PHAR_ENT_PERM_DEF_FILE   0x000001B6
 
#define PHAR_ENT_PERM_DEF_DIR   0x000001FF
 
#define PHAR_FORMAT_SAME   0
 
#define PHAR_FORMAT_PHAR   1
 
#define PHAR_FORMAT_TAR   2
 
#define PHAR_FORMAT_ZIP   3
 
#define TAR_FILE   '0'
 
#define TAR_LINK   '1'
 
#define TAR_SYMLINK   '2'
 
#define TAR_DIR   '5'
 
#define TAR_NEW   '8'
 
#define TAR_GLOBAL_HDR   'g'
 
#define TAR_FILE_HDR   'x'
 
#define PHAR_MUNG_PHP_SELF   (1<<0)
 
#define PHAR_MUNG_REQUEST_URI   (1<<1)
 
#define PHAR_MUNG_SCRIPT_NAME   (1<<2)
 
#define PHAR_MUNG_SCRIPT_FILENAME   (1<<3)
 
#define PHAR_G(v)
 
#define PHAR_MIME_PHP   '\0'
 
#define PHAR_MIME_PHPS   '\1'
 
#define PHAR_MIME_OTHER   '\2'
 

Typedefs

typedef struct _phar_entry_fp phar_entry_fp
 
typedef struct _phar_archive_data phar_archive_data
 
typedef union _phar_archive_object phar_archive_object
 
typedef union _phar_entry_object phar_entry_object
 
typedef struct _phar_metadata_tracker phar_metadata_tracker
 
typedef struct _phar_entry_info phar_entry_info
 
typedef struct _phar_entry_fp_info phar_entry_fp_info
 
typedef struct _phar_mime_type phar_mime_type
 
typedef struct _phar_entry_data phar_entry_data
 

Enumerations

enum  phar_fp_type { PHAR_FP , PHAR_UFP , PHAR_MOD , PHAR_TMP }
 
enum  phar_path_check_result {
  pcr_use_query , pcr_is_ok , pcr_err_double_slash , pcr_err_up_dir ,
  pcr_err_curr_dir , pcr_err_back_slash , pcr_err_star , pcr_err_illegal_char ,
  pcr_err_empty_entry
}
 

Functions

void phar_request_initialize (void)
 
void phar_object_init (void)
 
void phar_destroy_phar_data (phar_archive_data *phar)
 
zend_result phar_postprocess_file (phar_entry_data *idata, uint32_t crc32, char **error, int process_zip)
 
zend_result phar_open_from_filename (char *fname, size_t fname_len, char *alias, size_t alias_len, uint32_t options, phar_archive_data **pphar, char **error)
 
zend_result phar_open_or_create_filename (char *fname, size_t fname_len, char *alias, size_t alias_len, bool is_data, uint32_t options, phar_archive_data **pphar, char **error)
 
zend_result phar_create_or_parse_filename (char *fname, size_t fname_len, char *alias, size_t alias_len, bool is_data, uint32_t options, phar_archive_data **pphar, char **error)
 
zend_result phar_open_executed_filename (char *alias, size_t alias_len, char **error)
 
zend_result phar_free_alias (phar_archive_data *phar, char *alias, size_t alias_len)
 
zend_result phar_get_archive (phar_archive_data **archive, char *fname, size_t fname_len, char *alias, size_t alias_len, char **error)
 
zend_result phar_verify_signature (php_stream *fp, size_t end_of_phar, uint32_t sig_type, char *sig, size_t sig_len, char *fname, char **signature, size_t *signature_len, char **error)
 
zend_result phar_create_signature (phar_archive_data *phar, php_stream *fp, char **signature, size_t *signature_length, char **error)
 
zend_stringphar_create_default_stub (const char *index_php, const char *web_index, char **error)
 
char * phar_decompress_filter (phar_entry_info *entry, int return_unknown)
 
char * phar_compress_filter (phar_entry_info *entry, int return_unknown)
 
void phar_add_virtual_dirs (phar_archive_data *phar, char *filename, size_t filename_len)
 
zend_result phar_mount_entry (phar_archive_data *phar, char *filename, size_t filename_len, char *path, size_t path_len)
 
zend_stringphar_find_in_include_path (zend_string *file, phar_archive_data **pphar)
 
char * phar_fix_filepath (char *path, size_t *new_len, int use_cwd)
 
phar_entry_infophar_open_jit (phar_archive_data *phar, phar_entry_info *entry, char **error)
 
void phar_parse_metadata_lazy (const char *buffer, phar_metadata_tracker *tracker, uint32_t zip_metadata_len, bool persistent)
 
bool phar_metadata_tracker_has_data (const phar_metadata_tracker *tracker, bool persistent)
 
void phar_metadata_tracker_free (phar_metadata_tracker *val, bool persistent)
 
void phar_metadata_tracker_copy (phar_metadata_tracker *dest, const phar_metadata_tracker *source, bool persistent)
 
void phar_metadata_tracker_clone (phar_metadata_tracker *tracker)
 
void phar_metadata_tracker_try_ensure_has_serialized_data (phar_metadata_tracker *tracker, bool persistent)
 
zend_result phar_metadata_tracker_unserialize_or_copy (phar_metadata_tracker *tracker, zval *value, bool persistent, HashTable *unserialize_options, const char *method_name)
 
void destroy_phar_manifest_entry (zval *zv)
 
int phar_seek_efp (phar_entry_info *entry, zend_off_t offset, int whence, zend_off_t position, int follow_links)
 
php_streamphar_get_efp (phar_entry_info *entry, int follow_links)
 
zend_result phar_copy_entry_fp (phar_entry_info *source, phar_entry_info *dest, char **error)
 
zend_result phar_open_entry_fp (phar_entry_info *entry, char **error, int follow_links)
 
phar_entry_infophar_get_link_source (phar_entry_info *entry)
 
zend_result phar_open_archive_fp (phar_archive_data *phar)
 
zend_result phar_copy_on_write (phar_archive_data **pphar)
 
bool phar_is_tar (char *buf, char *fname)
 
zend_result phar_parse_tarfile (php_stream *fp, char *fname, size_t fname_len, char *alias, size_t alias_len, phar_archive_data **pphar, uint32_t compression, char **error)
 
zend_result phar_open_or_create_tar (char *fname, size_t fname_len, char *alias, size_t alias_len, int is_data, uint32_t options, phar_archive_data **pphar, char **error)
 
void phar_tar_flush (phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error)
 
int phar_parse_zipfile (php_stream *fp, char *fname, size_t fname_len, char *alias, size_t alias_len, phar_archive_data **pphar, char **error)
 
int phar_open_or_create_zip (char *fname, size_t fname_len, char *alias, size_t alias_len, int is_data, uint32_t options, phar_archive_data **pphar, char **error)
 
void phar_zip_flush (phar_archive_data *archive, zend_string *user_stub, bool is_default_stub, char **error)
 
bool phar_archive_delref (phar_archive_data *phar)
 
void phar_entry_delref (phar_entry_data *idata)
 
phar_entry_infophar_get_entry_info (phar_archive_data *phar, char *path, size_t path_len, char **error, int security)
 
phar_entry_infophar_get_entry_info_dir (phar_archive_data *phar, char *path, size_t path_len, char dir, char **error, int security)
 
phar_entry_dataphar_get_or_create_entry_data (char *fname, size_t fname_len, char *path, size_t path_len, const char *mode, char allow_dir, char **error, int security)
 
zend_result phar_get_entry_data (phar_entry_data **ret, char *fname, size_t fname_len, char *path, size_t path_len, const char *mode, char allow_dir, char **error, int security)
 
void phar_flush_ex (phar_archive_data *archive, zend_string *user_stub, bool is_default_stub, char **error)
 
void phar_flush (phar_archive_data *archive, char **error)
 
zend_result phar_detect_phar_fname_ext (const char *filename, size_t filename_len, const char **ext_str, size_t *ext_len, int executable, int for_create, int is_complete)
 
zend_result phar_split_fname (const char *filename, size_t filename_len, char **arch, size_t *arch_len, char **entry, size_t *entry_len, int executable, int for_create)
 
phar_path_check_result phar_path_check (char **p, size_t *len, const char **error)
 

Variables

HashTable phar_persist_map
 
HashTable phar_fname_map
 
phar_entry_fpcached_fp
 
HashTable phar_alias_map
 
int phar_SERVER_mung_list
 
char * cache_list
 
bool readonly
 
bool manifest_cached
 
bool persist
 
bool has_zlib
 
bool has_bz2
 
bool readonly_orig
 
bool require_hash_orig
 
bool intercepted
 
bool request_init
 
bool require_hash
 
bool request_done
 
bool request_ends
 
zif_handler orig_fopen
 
zif_handler orig_file_get_contents
 
zif_handler orig_is_file
 
zif_handler orig_is_link
 
zif_handler orig_is_dir
 
zif_handler orig_opendir
 
zif_handler orig_file_exists
 
zif_handler orig_fileperms
 
zif_handler orig_fileinode
 
zif_handler orig_filesize
 
zif_handler orig_fileowner
 
zif_handler orig_filegroup
 
zif_handler orig_fileatime
 
zif_handler orig_filemtime
 
zif_handler orig_filectime
 
zif_handler orig_filetype
 
zif_handler orig_is_writable
 
zif_handler orig_is_readable
 
zif_handler orig_is_executable
 
zif_handler orig_lstat
 
zif_handler orig_readfile
 
zif_handler orig_stat
 
char * cwd
 
uint32_t cwd_len
 
bool cwd_init
 
char * openssl_privatekey
 
uint32_t openssl_privatekey_len
 
char * last_phar_name
 
uint32_t last_phar_name_len
 
char * last_alias
 
uint32_t last_alias_len
 
phar_archive_datalast_phar
 
HashTable mime_types
 
HashTable cached_phars
 
HashTable cached_alias
 

Macro Definition Documentation

◆ PHAR_API_MAJORVER_MASK

#define PHAR_API_MAJORVER_MASK   0xF000

Definition at line 40 of file phar_internal.h.

◆ PHAR_API_MAJORVERSION

#define PHAR_API_MAJORVERSION   0x1000

Definition at line 39 of file phar_internal.h.

◆ PHAR_API_MIN_DIR

#define PHAR_API_MIN_DIR   0x1110

Definition at line 37 of file phar_internal.h.

◆ PHAR_API_MIN_READ

#define PHAR_API_MIN_READ   0x1000

Definition at line 38 of file phar_internal.h.

◆ PHAR_API_VER_MASK

#define PHAR_API_VER_MASK   0xFFF0

Definition at line 41 of file phar_internal.h.

◆ PHAR_API_VERSION

#define PHAR_API_VERSION   0x1110

Definition at line 34 of file phar_internal.h.

◆ PHAR_API_VERSION_NODIR

#define PHAR_API_VERSION_NODIR   0x1100

Definition at line 36 of file phar_internal.h.

◆ PHAR_ENT_COMPRESSED_BZ2

#define PHAR_ENT_COMPRESSED_BZ2   0x00002000

Definition at line 68 of file phar_internal.h.

◆ PHAR_ENT_COMPRESSED_GZ

#define PHAR_ENT_COMPRESSED_GZ   0x00001000

Definition at line 67 of file phar_internal.h.

◆ PHAR_ENT_COMPRESSED_NONE

#define PHAR_ENT_COMPRESSED_NONE   0x00000000

Definition at line 66 of file phar_internal.h.

◆ PHAR_ENT_COMPRESSION_MASK

#define PHAR_ENT_COMPRESSION_MASK   0x0000F000

Definition at line 65 of file phar_internal.h.

◆ PHAR_ENT_PERM_DEF_DIR

#define PHAR_ENT_PERM_DEF_DIR   0x000001FF

Definition at line 77 of file phar_internal.h.

◆ PHAR_ENT_PERM_DEF_FILE

#define PHAR_ENT_PERM_DEF_FILE   0x000001B6

Definition at line 76 of file phar_internal.h.

◆ PHAR_ENT_PERM_MASK

#define PHAR_ENT_PERM_MASK   0x000001FF

Definition at line 70 of file phar_internal.h.

◆ PHAR_ENT_PERM_MASK_GRP

#define PHAR_ENT_PERM_MASK_GRP   0x00000038

Definition at line 73 of file phar_internal.h.

◆ PHAR_ENT_PERM_MASK_OTH

#define PHAR_ENT_PERM_MASK_OTH   0x00000007

Definition at line 75 of file phar_internal.h.

◆ PHAR_ENT_PERM_MASK_USR

#define PHAR_ENT_PERM_MASK_USR   0x000001C0

Definition at line 71 of file phar_internal.h.

◆ PHAR_ENT_PERM_SHIFT_GRP

#define PHAR_ENT_PERM_SHIFT_GRP   3

Definition at line 74 of file phar_internal.h.

◆ PHAR_ENT_PERM_SHIFT_USR

#define PHAR_ENT_PERM_SHIFT_USR   6

Definition at line 72 of file phar_internal.h.

◆ PHAR_FILE_COMPRESSED_BZ2

#define PHAR_FILE_COMPRESSED_BZ2   0x00200000

Definition at line 53 of file phar_internal.h.

◆ PHAR_FILE_COMPRESSED_GZ

#define PHAR_FILE_COMPRESSED_GZ   0x00100000

Definition at line 52 of file phar_internal.h.

◆ PHAR_FILE_COMPRESSED_NONE

#define PHAR_FILE_COMPRESSED_NONE   0x00000000

Definition at line 51 of file phar_internal.h.

◆ PHAR_FILE_COMPRESSION_MASK

#define PHAR_FILE_COMPRESSION_MASK   0x00F00000

Definition at line 50 of file phar_internal.h.

◆ PHAR_FORMAT_PHAR

#define PHAR_FORMAT_PHAR   1

Definition at line 80 of file phar_internal.h.

◆ PHAR_FORMAT_SAME

#define PHAR_FORMAT_SAME   0

Definition at line 79 of file phar_internal.h.

◆ PHAR_FORMAT_TAR

#define PHAR_FORMAT_TAR   2

Definition at line 81 of file phar_internal.h.

◆ PHAR_FORMAT_ZIP

#define PHAR_FORMAT_ZIP   3

Definition at line 82 of file phar_internal.h.

◆ PHAR_G

#define PHAR_G ( v)
Value:
uint32_t v
Definition cdf.c:1237
#define ZEND_MODULE_GLOBALS_ACCESSOR(module_name, v)
Definition zend_API.h:274

Definition at line 160 of file phar_internal.h.

◆ PHAR_HDR_COMPRESSED_BZ2

#define PHAR_HDR_COMPRESSED_BZ2   0x00002000

Definition at line 46 of file phar_internal.h.

◆ PHAR_HDR_COMPRESSED_GZ

#define PHAR_HDR_COMPRESSED_GZ   0x00001000

Definition at line 45 of file phar_internal.h.

◆ PHAR_HDR_COMPRESSED_NONE

#define PHAR_HDR_COMPRESSED_NONE   0x00000000

Definition at line 44 of file phar_internal.h.

◆ PHAR_HDR_COMPRESSION_MASK

#define PHAR_HDR_COMPRESSION_MASK   0x0000F000

Definition at line 43 of file phar_internal.h.

◆ PHAR_HDR_SIGNATURE

#define PHAR_HDR_SIGNATURE   0x00010000

Definition at line 47 of file phar_internal.h.

◆ PHAR_MIME_OTHER

#define PHAR_MIME_OTHER   '\2'

Definition at line 328 of file phar_internal.h.

◆ PHAR_MIME_PHP

#define PHAR_MIME_PHP   '\0'

Definition at line 326 of file phar_internal.h.

◆ PHAR_MIME_PHPS

#define PHAR_MIME_PHPS   '\1'

Definition at line 327 of file phar_internal.h.

◆ PHAR_MUNG_PHP_SELF

#define PHAR_MUNG_PHP_SELF   (1<<0)

Definition at line 92 of file phar_internal.h.

◆ PHAR_MUNG_REQUEST_URI

#define PHAR_MUNG_REQUEST_URI   (1<<1)

Definition at line 93 of file phar_internal.h.

◆ PHAR_MUNG_SCRIPT_FILENAME

#define PHAR_MUNG_SCRIPT_FILENAME   (1<<3)

Definition at line 95 of file phar_internal.h.

◆ PHAR_MUNG_SCRIPT_NAME

#define PHAR_MUNG_SCRIPT_NAME   (1<<2)

Definition at line 94 of file phar_internal.h.

◆ PHAR_SIG_MD5

#define PHAR_SIG_MD5   0x0001

Definition at line 55 of file phar_internal.h.

◆ PHAR_SIG_OPENSSL

#define PHAR_SIG_OPENSSL   0x0010

Definition at line 59 of file phar_internal.h.

◆ PHAR_SIG_OPENSSL_SHA256

#define PHAR_SIG_OPENSSL_SHA256   0x0011

Definition at line 60 of file phar_internal.h.

◆ PHAR_SIG_OPENSSL_SHA512

#define PHAR_SIG_OPENSSL_SHA512   0x0012

Definition at line 61 of file phar_internal.h.

◆ PHAR_SIG_SHA1

#define PHAR_SIG_SHA1   0x0002

Definition at line 56 of file phar_internal.h.

◆ PHAR_SIG_SHA256

#define PHAR_SIG_SHA256   0x0003

Definition at line 57 of file phar_internal.h.

◆ PHAR_SIG_SHA512

#define PHAR_SIG_SHA512   0x0004

Definition at line 58 of file phar_internal.h.

◆ PHP_PHAR_API_VERSION

#define PHP_PHAR_API_VERSION   "1.1.1"

Definition at line 32 of file phar_internal.h.

◆ TAR_DIR

#define TAR_DIR   '5'

Definition at line 87 of file phar_internal.h.

◆ TAR_FILE

#define TAR_FILE   '0'

Definition at line 84 of file phar_internal.h.

◆ TAR_FILE_HDR

#define TAR_FILE_HDR   'x'

Definition at line 90 of file phar_internal.h.

◆ TAR_GLOBAL_HDR

#define TAR_GLOBAL_HDR   'g'

Definition at line 89 of file phar_internal.h.

◆ TAR_LINK

#define TAR_LINK   '1'

Definition at line 85 of file phar_internal.h.

◆ TAR_NEW

#define TAR_NEW   '8'

Definition at line 88 of file phar_internal.h.

◆ TAR_SYMLINK

#define TAR_SYMLINK   '2'

Definition at line 86 of file phar_internal.h.

Typedef Documentation

◆ phar_archive_data

Definition at line 98 of file phar_internal.h.

◆ phar_archive_object

Definition at line 166 of file phar_internal.h.

◆ phar_entry_data

◆ phar_entry_fp

typedef struct _phar_entry_fp phar_entry_fp

Definition at line 97 of file phar_internal.h.

◆ phar_entry_fp_info

◆ phar_entry_info

◆ phar_entry_object

Definition at line 167 of file phar_internal.h.

◆ phar_metadata_tracker

◆ phar_mime_type

Enumeration Type Documentation

◆ phar_fp_type

Enumerator
PHAR_FP 
PHAR_UFP 
PHAR_MOD 
PHAR_TMP 

Definition at line 172 of file phar_internal.h.

◆ phar_path_check_result

Enumerator
pcr_use_query 
pcr_is_ok 
pcr_err_double_slash 
pcr_err_up_dir 
pcr_err_curr_dir 
pcr_err_back_slash 
pcr_err_star 
pcr_err_illegal_char 
pcr_err_empty_entry 

Definition at line 476 of file phar_internal.h.

Function Documentation

◆ destroy_phar_manifest_entry()

void destroy_phar_manifest_entry ( zval * zv)

Definition at line 384 of file phar.c.

◆ phar_add_virtual_dirs()

void phar_add_virtual_dirs ( phar_archive_data * phar,
char * filename,
size_t filename_len )

Definition at line 2039 of file util.c.

◆ phar_archive_delref()

bool phar_archive_delref ( phar_archive_data * phar)

Delete refcount and destruct if needed. On destruct return 1 else 0.

Definition at line 246 of file phar.c.

◆ phar_compress_filter()

char * phar_compress_filter ( phar_entry_info * entry,
int return_unknown )

Determine which stream compression filter (if any) we need to read this file

Definition at line 1217 of file util.c.

◆ phar_copy_entry_fp()

zend_result phar_copy_entry_fp ( phar_entry_info * source,
phar_entry_info * dest,
char ** error )

Definition at line 774 of file util.c.

◆ phar_copy_on_write()

zend_result phar_copy_on_write ( phar_archive_data ** pphar)

Definition at line 2140 of file util.c.

◆ phar_create_default_stub()

zend_string * phar_create_default_stub ( const char * index_php,
const char * web_index,
char ** error )

Definition at line 2485 of file phar.c.

◆ phar_create_or_parse_filename()

zend_result phar_create_or_parse_filename ( char * fname,
size_t fname_len,
char * alias,
size_t alias_len,
bool is_data,
uint32_t options,
phar_archive_data ** pphar,
char ** error )

Definition at line 1389 of file phar.c.

◆ phar_create_signature()

zend_result phar_create_signature ( phar_archive_data * phar,
php_stream * fp,
char ** signature,
size_t * signature_length,
char ** error )

Definition at line 1857 of file util.c.

◆ phar_decompress_filter()

char * phar_decompress_filter ( phar_entry_info * entry,
int return_unknown )

Determine which stream decompression filter (if any) we need to read this file

Definition at line 1233 of file util.c.

◆ phar_destroy_phar_data()

void phar_destroy_phar_data ( phar_archive_data * phar)

When all uses of a phar have been concluded, this frees the manifest and the phar slot

Definition at line 195 of file phar.c.

◆ phar_detect_phar_fname_ext()

zend_result phar_detect_phar_fname_ext ( const char * filename,
size_t filename_len,
const char ** ext_str,
size_t * ext_len,
int executable,
int for_create,
int is_complete )

Definition at line 1967 of file phar.c.

◆ phar_entry_delref()

void phar_entry_delref ( phar_entry_data * idata)

Definition at line 392 of file phar.c.

◆ phar_find_in_include_path()

zend_string * phar_find_in_include_path ( zend_string * file,
phar_archive_data ** pphar )

Definition at line 266 of file util.c.

◆ phar_fix_filepath()

char * phar_fix_filepath ( char * path,
size_t * new_len,
int use_cwd )

Remove .. and . references within a phar filename

Definition at line 2128 of file phar.c.

◆ phar_flush()

void phar_flush ( phar_archive_data * archive,
char ** error )

Definition at line 2524 of file phar.c.

◆ phar_flush_ex()

void phar_flush_ex ( phar_archive_data * phar,
zend_string * user_stub,
bool is_default_stub,
char ** error )

Save phar contents to disk

if user_stub is NULL the default or existing stub should be used

Definition at line 2533 of file phar.c.

◆ phar_free_alias()

zend_result phar_free_alias ( phar_archive_data * phar,
char * alias,
size_t alias_len )

Definition at line 990 of file util.c.

◆ phar_get_archive()

zend_result phar_get_archive ( phar_archive_data ** archive,
char * fname,
size_t fname_len,
char * alias,
size_t alias_len,
char ** error )

Looks up a phar archive in the filename map, connecting it to the alias (if any) or returns null

Definition at line 1013 of file util.c.

◆ phar_get_efp()

php_stream * phar_get_efp ( phar_entry_info * entry,
int follow_links )

Definition at line 97 of file util.c.

◆ phar_get_entry_data()

zend_result phar_get_entry_data ( phar_entry_data ** ret,
char * fname,
size_t fname_len,
char * path,
size_t path_len,
const char * mode,
char allow_dir,
char ** error,
int security )

Retrieve a copy of the file information on a single file within a phar, or null. This also transfers the open file pointer, if any, to the entry.

If the file does not already exist, this will fail. Pre-existing files can be appended, truncated, or read. For read, if the entry is marked unmodified, it is assumed that the file pointer, if present, is opened for reading

Definition at line 474 of file util.c.

◆ phar_get_entry_info()

phar_entry_info * phar_get_entry_info ( phar_archive_data * phar,
char * path,
size_t path_len,
char ** error,
int security )

retrieve information on a file contained within a phar, or null if it ain't there

Definition at line 1257 of file util.c.

◆ phar_get_entry_info_dir()

phar_entry_info * phar_get_entry_info_dir ( phar_archive_data * phar,
char * path,
size_t path_len,
char dir,
char ** error,
int security )

retrieve information on a file or directory contained within a phar, or null if none found allow_dir is 0 for none, 1 for both empty directories in the phar and temp directories, and 2 for only valid pre-existing empty directory entries

Definition at line 1267 of file util.c.

◆ phar_get_link_source()

phar_entry_info * phar_get_link_source ( phar_entry_info * entry)

Definition at line 63 of file util.c.

◆ phar_get_or_create_entry_data()

phar_entry_data * phar_get_or_create_entry_data ( char * fname,
size_t fname_len,
char * path,
size_t path_len,
const char * mode,
char allow_dir,
char ** error,
int security )

Create a new dummy file slot within a writeable phar for a newly created file

Definition at line 634 of file util.c.

◆ phar_is_tar()

bool phar_is_tar ( char * buf,
char * fname )

Definition at line 103 of file tar.c.

◆ phar_metadata_tracker_clone()

void phar_metadata_tracker_clone ( phar_metadata_tracker * tracker)

Copy constructor for a non-persistent clone.

Definition at line 684 of file phar.c.

◆ phar_metadata_tracker_copy()

void phar_metadata_tracker_copy ( phar_metadata_tracker * dest,
const phar_metadata_tracker * source,
bool persistent )

Free memory used to track the metadata and set all fields to be null/undef.

Definition at line 666 of file phar.c.

◆ phar_metadata_tracker_free()

void phar_metadata_tracker_free ( phar_metadata_tracker * tracker,
bool persistent )

Free memory used to track the metadata and set all fields to be null/undef.

Definition at line 644 of file phar.c.

◆ phar_metadata_tracker_has_data()

bool phar_metadata_tracker_has_data ( const phar_metadata_tracker * tracker,
bool persistent )

Check if this has any data, serialized or as a raw value.

Definition at line 634 of file phar.c.

◆ phar_metadata_tracker_try_ensure_has_serialized_data()

void phar_metadata_tracker_try_ensure_has_serialized_data ( phar_metadata_tracker * tracker,
bool persistent )

Attempt to serialize the data. Callers are responsible for handling EG(exception) if one occurs.

Definition at line 567 of file phar.c.

◆ phar_metadata_tracker_unserialize_or_copy()

zend_result phar_metadata_tracker_unserialize_or_copy ( phar_metadata_tracker * tracker,
zval * metadata,
bool persistent,
HashTable * unserialize_options,
const char * method_name )

Parse out metadata when phar_metadata_tracker_has_data is true.

Precondition: phar_metadata_tracker_has_data is true

Definition at line 593 of file phar.c.

◆ phar_mount_entry()

zend_result phar_mount_entry ( phar_archive_data * phar,
char * filename,
size_t filename_len,
char * path,
size_t path_len )

Definition at line 190 of file util.c.

◆ phar_object_init()

void phar_object_init ( void )

Definition at line 5127 of file phar_object.c.

◆ phar_open_archive_fp()

zend_result phar_open_archive_fp ( phar_archive_data * phar)

Definition at line 753 of file util.c.

◆ phar_open_entry_fp()

zend_result phar_open_entry_fp ( phar_entry_info * entry,
char ** error,
int follow_links )

Definition at line 842 of file util.c.

◆ phar_open_executed_filename()

zend_result phar_open_executed_filename ( char * alias,
size_t alias_len,
char ** error )

Invoked when a user calls Phar::mapPhar() from within an executing .phar to set up its manifest directly

Definition at line 2317 of file phar.c.

◆ phar_open_from_filename()

zend_result phar_open_from_filename ( char * fname,
size_t fname_len,
char * alias,
size_t alias_len,
uint32_t options,
phar_archive_data ** pphar,
char ** error )

Return an already opened filename.

Or scan a phar file for the required __HALT_COMPILER(); ?> token and verify that the manifest is proper, then pass it to phar_parse_pharfile(). SUCCESS or FAILURE is returned and pphar is set to a pointer to the phar's manifest

Definition at line 1543 of file phar.c.

◆ phar_open_jit()

phar_entry_info * phar_open_jit ( phar_archive_data * phar,
phar_entry_info * entry,
char ** error )

helper function to open an internal file's fp just-in-time

Definition at line 961 of file util.c.

◆ phar_open_or_create_filename()

zend_result phar_open_or_create_filename ( char * fname,
size_t fname_len,
char * alias,
size_t alias_len,
bool is_data,
uint32_t options,
phar_archive_data ** pphar,
char ** error )

Create or open a phar for writing

Definition at line 1310 of file phar.c.

◆ phar_open_or_create_tar()

zend_result phar_open_or_create_tar ( char * fname,
size_t fname_len,
char * alias,
size_t alias_len,
int is_data,
uint32_t options,
phar_archive_data ** pphar,
char ** error )

Definition at line 130 of file tar.c.

◆ phar_open_or_create_zip()

int phar_open_or_create_zip ( char * fname,
size_t fname_len,
char * alias,
size_t alias_len,
int is_data,
uint32_t options,
phar_archive_data ** pphar,
char ** error )

Create or open a zip-based phar for writing

Definition at line 827 of file zip.c.

◆ phar_parse_metadata_lazy()

void phar_parse_metadata_lazy ( const char * buffer,
phar_metadata_tracker * tracker,
uint32_t zip_metadata_len,
bool persistent )

Parse out metadata from the manifest for a single file, saving it into a string.

Meta-data is in this format: [len32][data...]

data is the serialized zval

Definition at line 702 of file phar.c.

◆ phar_parse_tarfile()

zend_result phar_parse_tarfile ( php_stream * fp,
char * fname,
size_t fname_len,
char * alias,
size_t alias_len,
phar_archive_data ** pphar,
uint32_t compression,
char ** error )

Definition at line 205 of file tar.c.

◆ phar_parse_zipfile()

int phar_parse_zipfile ( php_stream * fp,
char * fname,
size_t fname_len,
char * alias,
size_t alias_len,
phar_archive_data ** pphar,
char ** error )

Does not check for a previously opened phar in the cache.

Parse a new one and add it to the cache, returning either SUCCESS or FAILURE, and setting pphar to the pointer to the manifest entry

This is used by phar_open_from_fp to process a zip-based phar, but can be called directly.

Definition at line 229 of file zip.c.

◆ phar_path_check()

phar_path_check_result phar_path_check ( char ** p,
size_t * len,
const char ** error )

◆ phar_postprocess_file()

zend_result phar_postprocess_file ( phar_entry_data * idata,
uint32_t crc32,
char ** error,
int process_zip )

Validate the CRC32 of a file opened from within the phar

Definition at line 2378 of file phar.c.

◆ phar_request_initialize()

void phar_request_initialize ( void )

Definition at line 3446 of file phar.c.

◆ phar_seek_efp()

int phar_seek_efp ( phar_entry_info * entry,
zend_off_t offset,
int whence,
zend_off_t position,
int follow_links )

Definition at line 140 of file util.c.

◆ phar_split_fname()

zend_result phar_split_fname ( const char * filename,
size_t filename_len,
char ** arch,
size_t * arch_len,
char ** entry,
size_t * entry_len,
int executable,
int for_create )

Process a phar stream name, ensuring we can handle any of:

  • whatever.phar
  • whatever.phar.gz
  • whatever.phar.bz2
  • whatever.phar.php

Optionally the name might start with 'phar://'

This is used by phar_parse_url()

Definition at line 2240 of file phar.c.

◆ phar_tar_flush()

void phar_tar_flush ( phar_archive_data * phar,
zend_string * user_stub,
bool is_default_stub,
char ** error )

Definition at line 962 of file tar.c.

◆ phar_verify_signature()

zend_result phar_verify_signature ( php_stream * fp,
size_t end_of_phar,
uint32_t sig_type,
char * sig,
size_t sig_len,
char * fname,
char ** signature,
size_t * signature_len,
char ** error )

Definition at line 1543 of file util.c.

◆ phar_zip_flush()

void phar_zip_flush ( phar_archive_data * archive,
zend_string * user_stub,
bool is_default_stub,
char ** error )

Definition at line 1254 of file zip.c.

Variable Documentation

◆ cache_list

char* cache_list

Definition at line 109 of file phar_internal.h.

◆ cached_alias

HashTable cached_alias
extern

Definition at line 91 of file phar.c.

◆ cached_fp

phar_entry_fp* cached_fp

Definition at line 106 of file phar_internal.h.

◆ cached_phars

HashTable cached_phars
extern

Definition at line 90 of file phar.c.

◆ cwd

char* cwd

Definition at line 145 of file phar_internal.h.

◆ cwd_init

bool cwd_init

Definition at line 147 of file phar_internal.h.

◆ cwd_len

uint32_t cwd_len

Definition at line 146 of file phar_internal.h.

◆ has_bz2

bool has_bz2

Definition at line 114 of file phar_internal.h.

◆ has_zlib

bool has_zlib

Definition at line 113 of file phar_internal.h.

◆ intercepted

bool intercepted

Definition at line 117 of file phar_internal.h.

◆ last_alias

char* last_alias

Definition at line 153 of file phar_internal.h.

◆ last_alias_len

uint32_t last_alias_len

Definition at line 154 of file phar_internal.h.

◆ last_phar

phar_archive_data* last_phar

Definition at line 155 of file phar_internal.h.

◆ last_phar_name

char* last_phar_name

Definition at line 151 of file phar_internal.h.

◆ last_phar_name_len

uint32_t last_phar_name_len

Definition at line 152 of file phar_internal.h.

◆ manifest_cached

bool manifest_cached

Definition at line 111 of file phar_internal.h.

◆ mime_types

HashTable mime_types

Definition at line 156 of file phar_internal.h.

◆ openssl_privatekey

char* openssl_privatekey

Definition at line 148 of file phar_internal.h.

◆ openssl_privatekey_len

uint32_t openssl_privatekey_len

Definition at line 149 of file phar_internal.h.

◆ orig_file_exists

zif_handler orig_file_exists

Definition at line 128 of file phar_internal.h.

◆ orig_file_get_contents

zif_handler orig_file_get_contents

Definition at line 123 of file phar_internal.h.

◆ orig_fileatime

zif_handler orig_fileatime

Definition at line 134 of file phar_internal.h.

◆ orig_filectime

zif_handler orig_filectime

Definition at line 136 of file phar_internal.h.

◆ orig_filegroup

zif_handler orig_filegroup

Definition at line 133 of file phar_internal.h.

◆ orig_fileinode

zif_handler orig_fileinode

Definition at line 130 of file phar_internal.h.

◆ orig_filemtime

zif_handler orig_filemtime

Definition at line 135 of file phar_internal.h.

◆ orig_fileowner

zif_handler orig_fileowner

Definition at line 132 of file phar_internal.h.

◆ orig_fileperms

zif_handler orig_fileperms

Definition at line 129 of file phar_internal.h.

◆ orig_filesize

zif_handler orig_filesize

Definition at line 131 of file phar_internal.h.

◆ orig_filetype

zif_handler orig_filetype

Definition at line 137 of file phar_internal.h.

◆ orig_fopen

zif_handler orig_fopen

Definition at line 122 of file phar_internal.h.

◆ orig_is_dir

zif_handler orig_is_dir

Definition at line 126 of file phar_internal.h.

◆ orig_is_executable

zif_handler orig_is_executable

Definition at line 140 of file phar_internal.h.

◆ orig_is_file

zif_handler orig_is_file

Definition at line 124 of file phar_internal.h.

◆ orig_is_link

zif_handler orig_is_link

Definition at line 125 of file phar_internal.h.

◆ orig_is_readable

zif_handler orig_is_readable

Definition at line 139 of file phar_internal.h.

◆ orig_is_writable

zif_handler orig_is_writable

Definition at line 138 of file phar_internal.h.

◆ orig_lstat

zif_handler orig_lstat

Definition at line 141 of file phar_internal.h.

◆ orig_opendir

zif_handler orig_opendir

Definition at line 127 of file phar_internal.h.

◆ orig_readfile

zif_handler orig_readfile

Definition at line 142 of file phar_internal.h.

◆ orig_stat

zif_handler orig_stat

Definition at line 143 of file phar_internal.h.

◆ persist

bool persist

Definition at line 112 of file phar_internal.h.

◆ phar_alias_map

HashTable phar_alias_map

Definition at line 107 of file phar_internal.h.

◆ phar_fname_map

HashTable phar_fname_map

Definition at line 104 of file phar_internal.h.

◆ phar_persist_map

HashTable phar_persist_map

Definition at line 103 of file phar_internal.h.

◆ phar_SERVER_mung_list

int phar_SERVER_mung_list

Definition at line 108 of file phar_internal.h.

◆ readonly

bool readonly

Definition at line 110 of file phar_internal.h.

◆ readonly_orig

bool readonly_orig

Definition at line 115 of file phar_internal.h.

◆ request_done

bool request_done

Definition at line 120 of file phar_internal.h.

◆ request_ends

bool request_ends

Definition at line 121 of file phar_internal.h.

◆ request_init

bool request_init

Definition at line 118 of file phar_internal.h.

◆ require_hash

bool require_hash

Definition at line 119 of file phar_internal.h.

◆ require_hash_orig

bool require_hash_orig

Definition at line 116 of file phar_internal.h.