Lines Matching refs:entry

45 static char *phar_get_link_location(phar_entry_info *entry TSRMLS_DC) /* {{{ */  in phar_get_link_location()
48 if (!entry->link) { in phar_get_link_location()
51 if (entry->link[0] == '/') { in phar_get_link_location()
52 return estrdup(entry->link + 1); in phar_get_link_location()
54 p = strrchr(entry->filename, '/'); in phar_get_link_location()
57 spprintf(&ret, 0, "%s/%s", entry->filename, entry->link); in phar_get_link_location()
60 return entry->link; in phar_get_link_location()
64 phar_entry_info *phar_get_link_source(phar_entry_info *entry TSRMLS_DC) /* {{{ */ in phar_get_link_source()
69 if (!entry->link) { in phar_get_link_source()
70 return entry; in phar_get_link_source()
73 link = phar_get_link_location(entry TSRMLS_CC); in phar_get_link_source()
74 …if (SUCCESS == zend_hash_find(&(entry->phar->manifest), entry->link, strlen(entry->link), (void **… in phar_get_link_source()
75 SUCCESS == zend_hash_find(&(entry->phar->manifest), link, strlen(link), (void **)&link_entry)) { in phar_get_link_source()
76 if (link != entry->link) { in phar_get_link_source()
81 if (link != entry->link) { in phar_get_link_source()
90 php_stream *phar_get_efp(phar_entry_info *entry, int follow_links TSRMLS_DC) /* {{{ */ in phar_get_efp() argument
92 if (follow_links && entry->link) { in phar_get_efp()
93 phar_entry_info *link_entry = phar_get_link_source(entry TSRMLS_CC); in phar_get_efp()
95 if (link_entry && link_entry != entry) { in phar_get_efp()
100 if (phar_get_fp_type(entry TSRMLS_CC) == PHAR_FP) { in phar_get_efp()
101 if (!phar_get_entrypfp(entry TSRMLS_CC)) { in phar_get_efp()
103 phar_open_archive_fp(entry->phar TSRMLS_CC); in phar_get_efp()
105 return phar_get_entrypfp(entry TSRMLS_CC); in phar_get_efp()
106 } else if (phar_get_fp_type(entry TSRMLS_CC) == PHAR_UFP) { in phar_get_efp()
107 return phar_get_entrypufp(entry TSRMLS_CC); in phar_get_efp()
108 } else if (entry->fp_type == PHAR_MOD) { in phar_get_efp()
109 return entry->fp; in phar_get_efp()
112 if (!entry->fp) { in phar_get_efp()
113 entry->fp = php_stream_open_wrapper(entry->tmp, "rb", STREAM_MUST_SEEK|0, NULL); in phar_get_efp()
115 return entry->fp; in phar_get_efp()
120 int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t position, int follow_link… in phar_seek_efp() argument
122 php_stream *fp = phar_get_efp(entry, follow_links TSRMLS_CC); in phar_seek_efp()
131 t = phar_get_link_source(entry TSRMLS_CC); in phar_seek_efp()
133 entry = t; in phar_seek_efp()
137 if (entry->is_dir) { in phar_seek_efp()
141 eoffset = phar_get_fp_offset(entry TSRMLS_CC); in phar_seek_efp()
145 temp = eoffset + entry->uncompressed_filesize + offset; in phar_seek_efp()
157 if (temp > eoffset + (off_t) entry->uncompressed_filesize) { in phar_seek_efp()
172 phar_entry_info entry = {0}; in phar_mount_entry() local
188 entry.phar = phar; in phar_mount_entry()
189 entry.filename = estrndup(path, path_len); in phar_mount_entry()
191 phar_unixify_path_separators(entry.filename, path_len); in phar_mount_entry()
193 entry.filename_len = path_len; in phar_mount_entry()
195 entry.tmp = estrndup(filename, filename_len); in phar_mount_entry()
197 entry.tmp = expand_filepath(filename, NULL TSRMLS_CC); in phar_mount_entry()
198 if (!entry.tmp) { in phar_mount_entry()
199 entry.tmp = estrndup(filename, filename_len); in phar_mount_entry()
203 if (PG(safe_mode) && !is_phar && (!php_checkuid(entry.tmp, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { in phar_mount_entry()
204 efree(entry.tmp); in phar_mount_entry()
205 efree(entry.filename); in phar_mount_entry()
209 filename = entry.tmp; in phar_mount_entry()
213 efree(entry.tmp); in phar_mount_entry()
214 efree(entry.filename); in phar_mount_entry()
218 entry.is_mounted = 1; in phar_mount_entry()
219 entry.is_crc_checked = 1; in phar_mount_entry()
220 entry.fp_type = PHAR_TMP; in phar_mount_entry()
223 efree(entry.tmp); in phar_mount_entry()
224 efree(entry.filename); in phar_mount_entry()
229 entry.is_dir = 1; in phar_mount_entry()
230 …if (SUCCESS != zend_hash_add(&phar->mounted_dirs, entry.filename, path_len, (void *)&(entry.filena… in phar_mount_entry()
232 efree(entry.tmp); in phar_mount_entry()
233 efree(entry.filename); in phar_mount_entry()
237 entry.is_dir = 0; in phar_mount_entry()
238 entry.uncompressed_filesize = entry.compressed_filesize = ssb.sb.st_size; in phar_mount_entry()
241 entry.flags = ssb.sb.st_mode; in phar_mount_entry()
243 …if (SUCCESS == zend_hash_add(&phar->manifest, entry.filename, path_len, (void*)&entry, sizeof(phar… in phar_mount_entry()
247 efree(entry.tmp); in phar_mount_entry()
248 efree(entry.filename); in phar_mount_entry()
255 char *path, *fname, *arch, *entry, *ret, *test; in phar_find_in_include_path() local
279 …) || SUCCESS != phar_split_fname(fname, strlen(fname), &arch, &arch_len, &entry, &entry_len, 1, 0 … in phar_find_in_include_path()
283 efree(entry); in phar_find_in_include_path()
327 …if (SUCCESS != phar_split_fname(ret, ret_len, &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC… in phar_find_in_include_path()
338 efree(entry); in phar_find_in_include_path()
356 phar_entry_info *entry; in phar_get_entry_data() local
391 …if ((entry = phar_get_entry_info_dir(phar, path, path_len, allow_dir, for_create && !PHAR_G(readon… in phar_get_entry_data()
398 …if ((entry = phar_get_entry_info(phar, path, path_len, for_create && !PHAR_G(readonly) && !phar->i… in phar_get_entry_data()
417 if (entry->is_modified && !for_write) { in phar_get_entry_data()
424 if (entry->fp_refcount && for_write) { in phar_get_entry_data()
431 if (entry->is_deleted) { in phar_get_entry_data()
435 entry->is_deleted = 0; in phar_get_entry_data()
438 if (entry->is_dir) { in phar_get_entry_data()
444 (*ret)->internal_file = entry; in phar_get_entry_data()
445 (*ret)->is_zip = entry->is_zip; in phar_get_entry_data()
446 (*ret)->is_tar = entry->is_tar; in phar_get_entry_data()
449 ++(entry->phar->refcount); in phar_get_entry_data()
450 ++(entry->fp_refcount); in phar_get_entry_data()
456 if (entry->fp_type == PHAR_MOD) { in phar_get_entry_data()
458 if (FAILURE == phar_create_writeable_entry(phar, entry, error TSRMLS_CC)) { in phar_get_entry_data()
462 phar_seek_efp(entry, 0, SEEK_END, 0, 0 TSRMLS_CC); in phar_get_entry_data()
466 if (entry->link) { in phar_get_entry_data()
467 efree(entry->link); in phar_get_entry_data()
468 entry->link = NULL; in phar_get_entry_data()
469 entry->tar_type = (entry->is_tar ? TAR_FILE : '\0'); in phar_get_entry_data()
473 if (FAILURE == phar_create_writeable_entry(phar, entry, error TSRMLS_CC)) { in phar_get_entry_data()
477 if (FAILURE == phar_separate_entry_fp(entry, error TSRMLS_CC)) { in phar_get_entry_data()
482 if (FAILURE == phar_open_entry_fp(entry, error, 1 TSRMLS_CC)) { in phar_get_entry_data()
492 (*ret)->internal_file = entry; in phar_get_entry_data()
493 (*ret)->is_zip = entry->is_zip; in phar_get_entry_data()
494 (*ret)->is_tar = entry->is_tar; in phar_get_entry_data()
495 (*ret)->fp = phar_get_efp(entry, 1 TSRMLS_CC); in phar_get_entry_data()
496 if (entry->link) { in phar_get_entry_data()
497 phar_entry_info *link = phar_get_link_source(entry TSRMLS_CC); in phar_get_entry_data()
504 (*ret)->zero = phar_get_fp_offset(entry TSRMLS_CC); in phar_get_entry_data()
508 ++(entry->fp_refcount); in phar_get_entry_data()
509 ++(entry->phar->refcount); in phar_get_entry_data()
522 phar_entry_info *entry, etemp; in phar_get_or_create_entry_data() local
600 …r->manifest, etemp.filename, path_len, (void*)&etemp, sizeof(phar_entry_info), (void **) &entry)) { in phar_get_or_create_entry_data()
610 if (!entry) { in phar_get_or_create_entry_data()
619 ret->fp = entry->fp; in phar_get_or_create_entry_data()
622 ret->is_zip = entry->is_zip; in phar_get_or_create_entry_data()
623 ret->is_tar = entry->is_tar; in phar_get_or_create_entry_data()
624 ret->internal_file = entry; in phar_get_or_create_entry_data()
696 int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TSRMLS_DC) /* {{{ */ in phar_open_entry_fp() argument
699 phar_archive_data *phar = entry->phar; in phar_open_entry_fp()
705 if (follow_links && entry->link) { in phar_open_entry_fp()
706 phar_entry_info *link_entry = phar_get_link_source(entry TSRMLS_CC); in phar_open_entry_fp()
707 if (link_entry && link_entry != entry) { in phar_open_entry_fp()
712 if (entry->is_modified) { in phar_open_entry_fp()
716 if (entry->fp_type == PHAR_TMP) { in phar_open_entry_fp()
717 if (!entry->fp) { in phar_open_entry_fp()
718 entry->fp = php_stream_open_wrapper(entry->tmp, "rb", STREAM_MUST_SEEK|0, NULL); in phar_open_entry_fp()
723 if (entry->fp_type != PHAR_FP) { in phar_open_entry_fp()
735 …if ((entry->old_flags && !(entry->old_flags & PHAR_ENT_COMPRESSION_MASK)) || !(entry->flags & PHAR… in phar_open_entry_fp()
736 dummy.internal_file = entry; in phar_open_entry_fp()
738 dummy.zero = entry->offset; in phar_open_entry_fp()
740 if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1 TSRMLS_CC)) { in phar_open_entry_fp()
746 if (!phar_get_entrypufp(entry TSRMLS_CC)) { in phar_open_entry_fp()
747 phar_set_entrypufp(entry, php_stream_fopen_tmpfile() TSRMLS_CC); in phar_open_entry_fp()
748 if (!phar_get_entrypufp(entry TSRMLS_CC)) { in phar_open_entry_fp()
749 …n temporary file for decompressing phar archive \"%s\" file \"%s\"", phar->fname, entry->filename); in phar_open_entry_fp()
754 dummy.internal_file = entry; in phar_open_entry_fp()
756 dummy.zero = entry->offset; in phar_open_entry_fp()
758 if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1 TSRMLS_CC)) { in phar_open_entry_fp()
762 ufp = phar_get_entrypufp(entry TSRMLS_CC); in phar_open_entry_fp()
764 if ((filtername = phar_decompress_filter(entry, 0)) != NULL) { in phar_open_entry_fp()
771 …while decompressing file \"%s\")", phar->fname, phar_decompress_filter(entry, 1), entry->filename); in phar_open_entry_fp()
780 php_stream_seek(phar_get_entrypfp(entry TSRMLS_CC), phar_get_fp_offset(entry TSRMLS_CC), SEEK_SET); in phar_open_entry_fp()
782 if (entry->uncompressed_filesize) { in phar_open_entry_fp()
783 …if (SUCCESS != phar_stream_copy_to_stream(phar_get_entrypfp(entry TSRMLS_CC), ufp, entry->compress… in phar_open_entry_fp()
784 …orruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename); in phar_open_entry_fp()
794 if (php_stream_tell(ufp) - loc != (off_t) entry->uncompressed_filesize) { in phar_open_entry_fp()
795 …orruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename); in phar_open_entry_fp()
799 entry->old_flags = entry->flags; in phar_open_entry_fp()
802 phar_set_fp_type(entry, PHAR_UFP, loc TSRMLS_CC); in phar_open_entry_fp()
803 dummy.zero = entry->offset; in phar_open_entry_fp()
805 if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 0 TSRMLS_CC)) { in phar_open_entry_fp()
812 int phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry, char **error TSRML… in phar_create_writeable_entry() argument
814 if (entry->fp_type == PHAR_MOD) { in phar_create_writeable_entry()
816 php_stream_truncate_set_size(entry->fp, 0); in phar_create_writeable_entry()
818 entry->old_flags = entry->flags; in phar_create_writeable_entry()
819 entry->is_modified = 1; in phar_create_writeable_entry()
822 entry->uncompressed_filesize = 0; in phar_create_writeable_entry()
823 entry->compressed_filesize = 0; in phar_create_writeable_entry()
824 entry->crc32 = 0; in phar_create_writeable_entry()
825 entry->flags = PHAR_ENT_PERM_DEF_FILE; in phar_create_writeable_entry()
826 entry->fp_type = PHAR_MOD; in phar_create_writeable_entry()
827 entry->offset = 0; in phar_create_writeable_entry()
836 if (entry->link) { in phar_create_writeable_entry()
837 efree(entry->link); in phar_create_writeable_entry()
838 entry->link = NULL; in phar_create_writeable_entry()
839 entry->tar_type = (entry->is_tar ? TAR_FILE : '\0'); in phar_create_writeable_entry()
842 entry->fp = php_stream_fopen_tmpfile(); in phar_create_writeable_entry()
844 if (!entry->fp) { in phar_create_writeable_entry()
851 entry->old_flags = entry->flags; in phar_create_writeable_entry()
852 entry->is_modified = 1; in phar_create_writeable_entry()
855 entry->uncompressed_filesize = 0; in phar_create_writeable_entry()
856 entry->compressed_filesize = 0; in phar_create_writeable_entry()
857 entry->crc32 = 0; in phar_create_writeable_entry()
858 entry->flags = PHAR_ENT_PERM_DEF_FILE; in phar_create_writeable_entry()
859 entry->fp_type = PHAR_MOD; in phar_create_writeable_entry()
860 entry->offset = 0; in phar_create_writeable_entry()
865 int phar_separate_entry_fp(phar_entry_info *entry, char **error TSRMLS_DC) /* {{{ */ in phar_separate_entry_fp() argument
870 if (FAILURE == phar_open_entry_fp(entry, error, 1 TSRMLS_CC)) { in phar_separate_entry_fp()
874 if (entry->fp_type == PHAR_MOD) { in phar_separate_entry_fp()
883 phar_seek_efp(entry, 0, SEEK_SET, 0, 1 TSRMLS_CC); in phar_separate_entry_fp()
884 link = phar_get_link_source(entry TSRMLS_CC); in phar_separate_entry_fp()
887 link = entry; in phar_separate_entry_fp()
892 …y file \"%s\" contents in phar archive \"%s\" for write access", entry->filename, entry->phar->fna… in phar_separate_entry_fp()
897 if (entry->link) { in phar_separate_entry_fp()
898 efree(entry->link); in phar_separate_entry_fp()
899 entry->link = NULL; in phar_separate_entry_fp()
900 entry->tar_type = (entry->is_tar ? TAR_FILE : '\0'); in phar_separate_entry_fp()
903 entry->offset = 0; in phar_separate_entry_fp()
904 entry->fp = fp; in phar_separate_entry_fp()
905 entry->fp_type = PHAR_MOD; in phar_separate_entry_fp()
906 entry->is_modified = 1; in phar_separate_entry_fp()
914 phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error TSRML… in phar_open_jit() argument
920 if (FAILURE == phar_open_entry_fp(entry, error, 1 TSRMLS_CC)) { in phar_open_jit()
923 if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 1 TSRMLS_CC)) { in phar_open_jit()
924 …spprintf(error, 4096, "phar error: cannot seek to start of file \"%s\" in phar \"%s\"", entry->fil… in phar_open_jit()
927 return entry; in phar_open_jit()
1174 char * phar_compress_filter(phar_entry_info * entry, int return_unknown) /* {{{ */ in phar_compress_filter() argument
1176 switch (entry->flags & PHAR_ENT_COMPRESSION_MASK) { in phar_compress_filter()
1190 char * phar_decompress_filter(phar_entry_info * entry, int return_unknown) /* {{{ */ in phar_decompress_filter() argument
1194 if (entry->is_modified) { in phar_decompress_filter()
1195 flags = entry->old_flags; in phar_decompress_filter()
1197 flags = entry->flags; in phar_decompress_filter()
1227 phar_entry_info *entry; in phar_get_entry_info_dir() local
1272 if (SUCCESS == zend_hash_find(&phar->manifest, path, path_len, (void**)&entry)) { in phar_get_entry_info_dir()
1273 if (entry->is_deleted) { in phar_get_entry_info_dir()
1277 if (entry->is_dir && !dir) { in phar_get_entry_info_dir()
1283 if (!entry->is_dir && dir == 2) { in phar_get_entry_info_dir()
1290 return entry; in phar_get_entry_info_dir()
1296 entry = (phar_entry_info *) ecalloc(1, sizeof(phar_entry_info)); in phar_get_entry_info_dir()
1298 entry->is_temp_dir = entry->is_dir = 1; in phar_get_entry_info_dir()
1299 entry->filename = (char *) estrndup(path, path_len + 1); in phar_get_entry_info_dir()
1300 entry->filename_len = path_len; in phar_get_entry_info_dir()
1301 entry->phar = phar; in phar_get_entry_info_dir()
1302 return entry; in phar_get_entry_info_dir()
1328 if (SUCCESS != zend_hash_find(&phar->manifest, str_key, keylen, (void **) &entry)) { in phar_get_entry_info_dir()
1336 if (!entry->tmp || !entry->is_mounted) { in phar_get_entry_info_dir()
1345 test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, path + keylen); in phar_get_entry_info_dir()
1380 if (SUCCESS != zend_hash_find(&phar->manifest, path, path_len, (void**)&entry)) { in phar_get_entry_info_dir()
1386 return entry; in phar_get_entry_info_dir()
1989 phar_entry_info *entry = (phar_entry_info *)data; local
1992 entry->phar = (phar_archive_data *)argument;
1994 if (entry->link) {
1995 entry->link = estrdup(entry->link);
1998 if (entry->tmp) {
1999 entry->tmp = estrdup(entry->tmp);
2002 entry->metadata_str.c = 0;
2003 entry->filename = estrndup(entry->filename, entry->filename_len);
2004 entry->is_persistent = 0;
2006 if (entry->metadata) {
2007 if (entry->metadata_len) {
2008 char *buf = estrndup((char *) entry->metadata, entry->metadata_len);
2010 phar_parse_metadata((char **) &buf, &entry->metadata, entry->metadata_len TSRMLS_CC);
2015 t = entry->metadata;
2016 ALLOC_ZVAL(entry->metadata);
2017 *entry->metadata = *t;
2018 zval_copy_ctor(entry->metadata);
2019 Z_SET_REFCOUNT_P(entry->metadata, 1);
2020 entry->metadata_str.c = NULL;
2021 entry->metadata_str.len = 0;