Lines Matching refs:entry

45 static char *phar_get_link_location(phar_entry_info *entry) /* {{{ */  in phar_get_link_location()  argument
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) /* {{{ */ in phar_get_link_source() argument
69 if (!entry->link) { in phar_get_link_source()
70 return entry; in phar_get_link_source()
73 link = phar_get_link_location(entry); in phar_get_link_source()
74 …if (NULL != (link_entry = zend_hash_str_find_ptr(&(entry->phar->manifest), entry->link, strlen(ent… in phar_get_link_source()
75 NULL != (link_entry = zend_hash_str_find_ptr(&(entry->phar->manifest), link, strlen(link)))) { 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) /* {{{ */ 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); in phar_get_efp()
95 if (link_entry && link_entry != entry) { in phar_get_efp()
100 if (phar_get_fp_type(entry) == PHAR_FP) { in phar_get_efp()
101 if (!phar_get_entrypfp(entry)) { in phar_get_efp()
103 phar_open_archive_fp(entry->phar); in phar_get_efp()
105 return phar_get_entrypfp(entry); in phar_get_efp()
106 } else if (phar_get_fp_type(entry) == PHAR_UFP) { in phar_get_efp()
107 return phar_get_entrypufp(entry); 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, zend_off_t offset, int whence, zend_off_t position, int f… in phar_seek_efp() argument
122 php_stream *fp = phar_get_efp(entry, follow_links); in phar_seek_efp()
131 t = phar_get_link_source(entry); 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); in phar_seek_efp()
145 temp = eoffset + entry->uncompressed_filesize + offset; in phar_seek_efp()
157 if (temp > eoffset + (zend_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); in phar_mount_entry()
198 if (!entry.tmp) { in phar_mount_entry()
199 entry.tmp = estrndup(filename, filename_len); in phar_mount_entry()
202 filename = entry.tmp; in phar_mount_entry()
206 efree(entry.tmp); in phar_mount_entry()
207 efree(entry.filename); in phar_mount_entry()
211 entry.is_mounted = 1; in phar_mount_entry()
212 entry.is_crc_checked = 1; in phar_mount_entry()
213 entry.fp_type = PHAR_TMP; in phar_mount_entry()
216 efree(entry.tmp); in phar_mount_entry()
217 efree(entry.filename); in phar_mount_entry()
222 entry.is_dir = 1; in phar_mount_entry()
223 …if (NULL == zend_hash_str_add_ptr(&phar->mounted_dirs, entry.filename, path_len, entry.filename)) { in phar_mount_entry()
225 efree(entry.tmp); in phar_mount_entry()
226 efree(entry.filename); in phar_mount_entry()
230 entry.is_dir = 0; in phar_mount_entry()
231 entry.uncompressed_filesize = entry.compressed_filesize = ssb.sb.st_size; in phar_mount_entry()
234 entry.flags = ssb.sb.st_mode; in phar_mount_entry()
236 …if (NULL != zend_hash_str_add_mem(&phar->manifest, entry.filename, path_len, (void*)&entry, sizeof… in phar_mount_entry()
240 efree(entry.tmp); in phar_mount_entry()
241 efree(entry.filename); in phar_mount_entry()
249 char *path, *fname, *arch, *entry, *test; in phar_find_in_include_path() local
273 …) || SUCCESS != phar_split_fname(fname, strlen(fname), &arch, &arch_len, &entry, &entry_len, 1, 0)… in phar_find_in_include_path()
277 efree(entry); in phar_find_in_include_path()
319 …if (SUCCESS != phar_split_fname(ZSTR_VAL(ret), ZSTR_LEN(ret), &arch, &arch_len, &entry, &entry_len… in phar_find_in_include_path()
330 efree(entry); in phar_find_in_include_path()
348 phar_entry_info *entry; in phar_get_entry_data() local
383 …if ((entry = phar_get_entry_info_dir(phar, path, path_len, allow_dir, for_create && !PHAR_G(readon… in phar_get_entry_data()
390 …if ((entry = phar_get_entry_info(phar, path, path_len, for_create && !PHAR_G(readonly) && !phar->i… in phar_get_entry_data()
409 if (entry->is_modified && !for_write) { in phar_get_entry_data()
416 if (entry->fp_refcount && for_write) { in phar_get_entry_data()
423 if (entry->is_deleted) { in phar_get_entry_data()
427 entry->is_deleted = 0; in phar_get_entry_data()
430 if (entry->is_dir) { in phar_get_entry_data()
436 (*ret)->internal_file = entry; in phar_get_entry_data()
437 (*ret)->is_zip = entry->is_zip; in phar_get_entry_data()
438 (*ret)->is_tar = entry->is_tar; in phar_get_entry_data()
441 ++(entry->phar->refcount); in phar_get_entry_data()
442 ++(entry->fp_refcount); in phar_get_entry_data()
448 if (entry->fp_type == PHAR_MOD) { in phar_get_entry_data()
450 if (FAILURE == phar_create_writeable_entry(phar, entry, error)) { in phar_get_entry_data()
454 phar_seek_efp(entry, 0, SEEK_END, 0, 0); in phar_get_entry_data()
458 if (entry->link) { in phar_get_entry_data()
459 efree(entry->link); in phar_get_entry_data()
460 entry->link = NULL; in phar_get_entry_data()
461 entry->tar_type = (entry->is_tar ? TAR_FILE : '\0'); in phar_get_entry_data()
465 if (FAILURE == phar_create_writeable_entry(phar, entry, error)) { in phar_get_entry_data()
469 if (FAILURE == phar_separate_entry_fp(entry, error)) { in phar_get_entry_data()
474 if (FAILURE == phar_open_entry_fp(entry, error, 1)) { in phar_get_entry_data()
484 (*ret)->internal_file = entry; in phar_get_entry_data()
485 (*ret)->is_zip = entry->is_zip; in phar_get_entry_data()
486 (*ret)->is_tar = entry->is_tar; in phar_get_entry_data()
487 (*ret)->fp = phar_get_efp(entry, 1); in phar_get_entry_data()
488 if (entry->link) { in phar_get_entry_data()
489 phar_entry_info *link = phar_get_link_source(entry); in phar_get_entry_data()
496 (*ret)->zero = phar_get_fp_offset(entry); in phar_get_entry_data()
500 ++(entry->fp_refcount); in phar_get_entry_data()
501 ++(entry->phar->refcount); in phar_get_entry_data()
514 phar_entry_info *entry, etemp; in phar_get_or_create_entry_data() local
592 …if (NULL == (entry = zend_hash_str_add_mem(&phar->manifest, etemp.filename, path_len, (void*)&etem… in phar_get_or_create_entry_data()
602 if (!entry) { in phar_get_or_create_entry_data()
611 ret->fp = entry->fp; in phar_get_or_create_entry_data()
614 ret->is_zip = entry->is_zip; in phar_get_or_create_entry_data()
615 ret->is_tar = entry->is_tar; in phar_get_or_create_entry_data()
616 ret->internal_file = entry; in phar_get_or_create_entry_data()
688 int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links) /* {{{ */ in phar_open_entry_fp() argument
691 phar_archive_data *phar = entry->phar; in phar_open_entry_fp()
697 if (follow_links && entry->link) { in phar_open_entry_fp()
698 phar_entry_info *link_entry = phar_get_link_source(entry); in phar_open_entry_fp()
699 if (link_entry && link_entry != entry) { in phar_open_entry_fp()
704 if (entry->is_modified) { in phar_open_entry_fp()
708 if (entry->fp_type == PHAR_TMP) { in phar_open_entry_fp()
709 if (!entry->fp) { in phar_open_entry_fp()
710 entry->fp = php_stream_open_wrapper(entry->tmp, "rb", STREAM_MUST_SEEK|0, NULL); in phar_open_entry_fp()
715 if (entry->fp_type != PHAR_FP) { in phar_open_entry_fp()
727 …if ((entry->old_flags && !(entry->old_flags & PHAR_ENT_COMPRESSION_MASK)) || !(entry->flags & PHAR… in phar_open_entry_fp()
728 dummy.internal_file = entry; in phar_open_entry_fp()
730 dummy.zero = entry->offset; in phar_open_entry_fp()
732 if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1)) { in phar_open_entry_fp()
738 if (!phar_get_entrypufp(entry)) { in phar_open_entry_fp()
739 phar_set_entrypufp(entry, php_stream_fopen_tmpfile()); in phar_open_entry_fp()
740 if (!phar_get_entrypufp(entry)) { in phar_open_entry_fp()
741 …n temporary file for decompressing phar archive \"%s\" file \"%s\"", phar->fname, entry->filename); in phar_open_entry_fp()
746 dummy.internal_file = entry; in phar_open_entry_fp()
748 dummy.zero = entry->offset; in phar_open_entry_fp()
750 if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1)) { in phar_open_entry_fp()
754 ufp = phar_get_entrypufp(entry); in phar_open_entry_fp()
756 if ((filtername = phar_decompress_filter(entry, 0)) != NULL) { in phar_open_entry_fp()
763 …while decompressing file \"%s\")", phar->fname, phar_decompress_filter(entry, 1), entry->filename); in phar_open_entry_fp()
772 php_stream_seek(phar_get_entrypfp(entry), phar_get_fp_offset(entry), SEEK_SET); in phar_open_entry_fp()
774 if (entry->uncompressed_filesize) { in phar_open_entry_fp()
775 …if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_entrypfp(entry), ufp, entry->compressed_files… in phar_open_entry_fp()
776 …orruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename); in phar_open_entry_fp()
786 if (php_stream_tell(ufp) - loc != (zend_off_t) entry->uncompressed_filesize) { in phar_open_entry_fp()
787 …orruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename); in phar_open_entry_fp()
791 entry->old_flags = entry->flags; in phar_open_entry_fp()
794 phar_set_fp_type(entry, PHAR_UFP, loc); in phar_open_entry_fp()
795 dummy.zero = entry->offset; in phar_open_entry_fp()
797 if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 0)) { in phar_open_entry_fp()
804 int phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry, char **error) /* {… in phar_create_writeable_entry() argument
806 if (entry->fp_type == PHAR_MOD) { in phar_create_writeable_entry()
808 php_stream_truncate_set_size(entry->fp, 0); in phar_create_writeable_entry()
810 entry->old_flags = entry->flags; in phar_create_writeable_entry()
811 entry->is_modified = 1; in phar_create_writeable_entry()
814 entry->uncompressed_filesize = 0; in phar_create_writeable_entry()
815 entry->compressed_filesize = 0; in phar_create_writeable_entry()
816 entry->crc32 = 0; in phar_create_writeable_entry()
817 entry->flags = PHAR_ENT_PERM_DEF_FILE; in phar_create_writeable_entry()
818 entry->fp_type = PHAR_MOD; in phar_create_writeable_entry()
819 entry->offset = 0; in phar_create_writeable_entry()
828 if (entry->link) { in phar_create_writeable_entry()
829 efree(entry->link); in phar_create_writeable_entry()
830 entry->link = NULL; in phar_create_writeable_entry()
831 entry->tar_type = (entry->is_tar ? TAR_FILE : '\0'); in phar_create_writeable_entry()
834 entry->fp = php_stream_fopen_tmpfile(); in phar_create_writeable_entry()
836 if (!entry->fp) { in phar_create_writeable_entry()
843 entry->old_flags = entry->flags; in phar_create_writeable_entry()
844 entry->is_modified = 1; in phar_create_writeable_entry()
847 entry->uncompressed_filesize = 0; in phar_create_writeable_entry()
848 entry->compressed_filesize = 0; in phar_create_writeable_entry()
849 entry->crc32 = 0; in phar_create_writeable_entry()
850 entry->flags = PHAR_ENT_PERM_DEF_FILE; in phar_create_writeable_entry()
851 entry->fp_type = PHAR_MOD; in phar_create_writeable_entry()
852 entry->offset = 0; in phar_create_writeable_entry()
857 int phar_separate_entry_fp(phar_entry_info *entry, char **error) /* {{{ */ in phar_separate_entry_fp() argument
862 if (FAILURE == phar_open_entry_fp(entry, error, 1)) { in phar_separate_entry_fp()
866 if (entry->fp_type == PHAR_MOD) { in phar_separate_entry_fp()
875 phar_seek_efp(entry, 0, SEEK_SET, 0, 1); in phar_separate_entry_fp()
876 link = phar_get_link_source(entry); in phar_separate_entry_fp()
879 link = entry; in phar_separate_entry_fp()
884 …y file \"%s\" contents in phar archive \"%s\" for write access", entry->filename, entry->phar->fna… in phar_separate_entry_fp()
889 if (entry->link) { in phar_separate_entry_fp()
890 efree(entry->link); in phar_separate_entry_fp()
891 entry->link = NULL; in phar_separate_entry_fp()
892 entry->tar_type = (entry->is_tar ? TAR_FILE : '\0'); in phar_separate_entry_fp()
895 entry->offset = 0; in phar_separate_entry_fp()
896 entry->fp = fp; in phar_separate_entry_fp()
897 entry->fp_type = PHAR_MOD; in phar_separate_entry_fp()
898 entry->is_modified = 1; in phar_separate_entry_fp()
906 phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error) /* {… in phar_open_jit() argument
912 if (FAILURE == phar_open_entry_fp(entry, error, 1)) { in phar_open_jit()
915 if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 1)) { in phar_open_jit()
916 …spprintf(error, 4096, "phar error: cannot seek to start of file \"%s\" in phar \"%s\"", entry->fil… in phar_open_jit()
919 return entry; in phar_open_jit()
1162 char * phar_compress_filter(phar_entry_info * entry, int return_unknown) /* {{{ */ in phar_compress_filter() argument
1164 switch (entry->flags & PHAR_ENT_COMPRESSION_MASK) { in phar_compress_filter()
1178 char * phar_decompress_filter(phar_entry_info * entry, int return_unknown) /* {{{ */ in phar_decompress_filter() argument
1182 if (entry->is_modified) { in phar_decompress_filter()
1183 flags = entry->old_flags; in phar_decompress_filter()
1185 flags = entry->flags; in phar_decompress_filter()
1215 phar_entry_info *entry; in phar_get_entry_info_dir() local
1260 if (NULL != (entry = zend_hash_str_find_ptr(&phar->manifest, path, path_len))) { in phar_get_entry_info_dir()
1261 if (entry->is_deleted) { in phar_get_entry_info_dir()
1265 if (entry->is_dir && !dir) { in phar_get_entry_info_dir()
1271 if (!entry->is_dir && dir == 2) { in phar_get_entry_info_dir()
1278 return entry; in phar_get_entry_info_dir()
1284 entry = (phar_entry_info *) ecalloc(1, sizeof(phar_entry_info)); in phar_get_entry_info_dir()
1286 entry->is_temp_dir = entry->is_dir = 1; in phar_get_entry_info_dir()
1287 entry->filename = (char *) estrndup(path, path_len + 1); in phar_get_entry_info_dir()
1288 entry->filename_len = path_len; in phar_get_entry_info_dir()
1289 entry->phar = phar; in phar_get_entry_info_dir()
1290 return entry; in phar_get_entry_info_dir()
1305 if (NULL == (entry = zend_hash_find_ptr(&phar->manifest, str_key))) { in phar_get_entry_info_dir()
1312 if (!entry->tmp || !entry->is_mounted) { in phar_get_entry_info_dir()
1319 test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, path + ZSTR_LEN(str_key)); in phar_get_entry_info_dir()
1354 if (NULL == (entry = zend_hash_str_find_ptr(&phar->manifest, path, path_len))) { in phar_get_entry_info_dir()
1360 return entry; in phar_get_entry_info_dir()
1963 phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(data); in phar_update_cached_entry() local
1965 entry->phar = (phar_archive_data *)argument; in phar_update_cached_entry()
1967 if (entry->link) { in phar_update_cached_entry()
1968 entry->link = estrdup(entry->link); in phar_update_cached_entry()
1971 if (entry->tmp) { in phar_update_cached_entry()
1972 entry->tmp = estrdup(entry->tmp); in phar_update_cached_entry()
1975 entry->metadata_str.s = NULL; in phar_update_cached_entry()
1976 entry->filename = estrndup(entry->filename, entry->filename_len); in phar_update_cached_entry()
1977 entry->is_persistent = 0; in phar_update_cached_entry()
1979 if (Z_TYPE(entry->metadata) != IS_UNDEF) { in phar_update_cached_entry()
1980 if (entry->metadata_len) { in phar_update_cached_entry()
1981 char *buf = estrndup((char *) Z_PTR(entry->metadata), entry->metadata_len); in phar_update_cached_entry()
1983 phar_parse_metadata((char **) &buf, &entry->metadata, entry->metadata_len); in phar_update_cached_entry()
1986 zval_copy_ctor(&entry->metadata); in phar_update_cached_entry()
1987 entry->metadata_str.s = NULL; in phar_update_cached_entry()