Lines Matching refs:entry

43 static char *phar_get_link_location(phar_entry_info *entry) /* {{{ */  in phar_get_link_location()  argument
46 if (!entry->link) { in phar_get_link_location()
49 if (entry->link[0] == '/') { in phar_get_link_location()
50 return estrdup(entry->link + 1); in phar_get_link_location()
52 p = strrchr(entry->filename, '/'); in phar_get_link_location()
55 spprintf(&ret, 0, "%s/%s", entry->filename, entry->link); in phar_get_link_location()
58 return entry->link; in phar_get_link_location()
62 phar_entry_info *phar_get_link_source(phar_entry_info *entry) /* {{{ */ in phar_get_link_source() argument
67 if (!entry->link) { in phar_get_link_source()
68 return entry; in phar_get_link_source()
71 link = phar_get_link_location(entry); in phar_get_link_source()
72 …if (NULL != (link_entry = zend_hash_str_find_ptr(&(entry->phar->manifest), entry->link, strlen(ent… in phar_get_link_source()
73 NULL != (link_entry = zend_hash_str_find_ptr(&(entry->phar->manifest), link, strlen(link)))) { in phar_get_link_source()
74 if (link != entry->link) { in phar_get_link_source()
79 if (link != entry->link) { in phar_get_link_source()
88 php_stream *phar_get_efp(phar_entry_info *entry, int follow_links) /* {{{ */ in phar_get_efp() argument
90 if (follow_links && entry->link) { in phar_get_efp()
91 phar_entry_info *link_entry = phar_get_link_source(entry); in phar_get_efp()
93 if (link_entry && link_entry != entry) { in phar_get_efp()
98 if (phar_get_fp_type(entry) == PHAR_FP) { in phar_get_efp()
99 if (!phar_get_entrypfp(entry)) { in phar_get_efp()
101 phar_open_archive_fp(entry->phar); in phar_get_efp()
103 return phar_get_entrypfp(entry); in phar_get_efp()
104 } else if (phar_get_fp_type(entry) == PHAR_UFP) { in phar_get_efp()
105 return phar_get_entrypufp(entry); in phar_get_efp()
106 } else if (entry->fp_type == PHAR_MOD) { in phar_get_efp()
107 return entry->fp; in phar_get_efp()
110 if (!entry->fp) { in phar_get_efp()
111 entry->fp = php_stream_open_wrapper(entry->tmp, "rb", STREAM_MUST_SEEK|0, NULL); in phar_get_efp()
113 return entry->fp; in phar_get_efp()
118 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
120 php_stream *fp = phar_get_efp(entry, follow_links); in phar_seek_efp()
129 t = phar_get_link_source(entry); in phar_seek_efp()
131 entry = t; in phar_seek_efp()
135 if (entry->is_dir) { in phar_seek_efp()
139 eoffset = phar_get_fp_offset(entry); in phar_seek_efp()
143 temp = eoffset + entry->uncompressed_filesize + offset; in phar_seek_efp()
155 if (temp > eoffset + (zend_off_t) entry->uncompressed_filesize) { in phar_seek_efp()
170 phar_entry_info entry = {0}; in phar_mount_entry() local
186 entry.phar = phar; in phar_mount_entry()
187 entry.filename = estrndup(path, path_len); in phar_mount_entry()
189 phar_unixify_path_separators(entry.filename, path_len); in phar_mount_entry()
191 entry.filename_len = path_len; in phar_mount_entry()
193 entry.tmp = estrndup(filename, filename_len); in phar_mount_entry()
195 entry.tmp = expand_filepath(filename, NULL); in phar_mount_entry()
196 if (!entry.tmp) { in phar_mount_entry()
197 entry.tmp = estrndup(filename, filename_len); in phar_mount_entry()
200 filename = entry.tmp; in phar_mount_entry()
204 efree(entry.tmp); in phar_mount_entry()
205 efree(entry.filename); in phar_mount_entry()
209 entry.is_mounted = 1; in phar_mount_entry()
210 entry.is_crc_checked = 1; in phar_mount_entry()
211 entry.fp_type = PHAR_TMP; in phar_mount_entry()
214 efree(entry.tmp); in phar_mount_entry()
215 efree(entry.filename); in phar_mount_entry()
220 entry.is_dir = 1; in phar_mount_entry()
221 …if (NULL == zend_hash_str_add_ptr(&phar->mounted_dirs, entry.filename, path_len, entry.filename)) { in phar_mount_entry()
223 efree(entry.tmp); in phar_mount_entry()
224 efree(entry.filename); in phar_mount_entry()
228 entry.is_dir = 0; in phar_mount_entry()
229 entry.uncompressed_filesize = entry.compressed_filesize = ssb.sb.st_size; in phar_mount_entry()
232 entry.flags = ssb.sb.st_mode; in phar_mount_entry()
234 …if (NULL != zend_hash_str_add_mem(&phar->manifest, entry.filename, path_len, (void*)&entry, sizeof… in phar_mount_entry()
238 efree(entry.tmp); in phar_mount_entry()
239 efree(entry.filename); in phar_mount_entry()
247 char *path, *fname, *arch, *entry, *test; in phar_find_in_include_path() local
271 …) || SUCCESS != phar_split_fname(fname, strlen(fname), &arch, &arch_len, &entry, &entry_len, 1, 0)… in phar_find_in_include_path()
275 efree(entry); in phar_find_in_include_path()
317 …if (SUCCESS != phar_split_fname(ZSTR_VAL(ret), ZSTR_LEN(ret), &arch, &arch_len, &entry, &entry_len… in phar_find_in_include_path()
328 efree(entry); in phar_find_in_include_path()
346 phar_entry_info *entry; in phar_get_entry_data() local
381 …if ((entry = phar_get_entry_info_dir(phar, path, path_len, allow_dir, for_create && !PHAR_G(readon… in phar_get_entry_data()
388 …if ((entry = phar_get_entry_info(phar, path, path_len, for_create && !PHAR_G(readonly) && !phar->i… in phar_get_entry_data()
407 if (entry->is_modified && !for_write) { in phar_get_entry_data()
414 if (entry->fp_refcount && for_write) { in phar_get_entry_data()
421 if (entry->is_deleted) { in phar_get_entry_data()
425 entry->is_deleted = 0; in phar_get_entry_data()
428 if (entry->is_dir) { in phar_get_entry_data()
434 (*ret)->internal_file = entry; in phar_get_entry_data()
435 (*ret)->is_zip = entry->is_zip; in phar_get_entry_data()
436 (*ret)->is_tar = entry->is_tar; in phar_get_entry_data()
439 ++(entry->phar->refcount); in phar_get_entry_data()
440 ++(entry->fp_refcount); in phar_get_entry_data()
446 if (entry->fp_type == PHAR_MOD) { in phar_get_entry_data()
448 if (FAILURE == phar_create_writeable_entry(phar, entry, error)) { in phar_get_entry_data()
452 phar_seek_efp(entry, 0, SEEK_END, 0, 0); in phar_get_entry_data()
456 if (entry->link) { in phar_get_entry_data()
457 efree(entry->link); in phar_get_entry_data()
458 entry->link = NULL; in phar_get_entry_data()
459 entry->tar_type = (entry->is_tar ? TAR_FILE : '\0'); in phar_get_entry_data()
463 if (FAILURE == phar_create_writeable_entry(phar, entry, error)) { in phar_get_entry_data()
467 if (FAILURE == phar_separate_entry_fp(entry, error)) { in phar_get_entry_data()
472 if (FAILURE == phar_open_entry_fp(entry, error, 1)) { in phar_get_entry_data()
482 (*ret)->internal_file = entry; in phar_get_entry_data()
483 (*ret)->is_zip = entry->is_zip; in phar_get_entry_data()
484 (*ret)->is_tar = entry->is_tar; in phar_get_entry_data()
485 (*ret)->fp = phar_get_efp(entry, 1); in phar_get_entry_data()
486 if (entry->link) { in phar_get_entry_data()
487 phar_entry_info *link = phar_get_link_source(entry); in phar_get_entry_data()
494 (*ret)->zero = phar_get_fp_offset(entry); in phar_get_entry_data()
498 ++(entry->fp_refcount); in phar_get_entry_data()
499 ++(entry->phar->refcount); in phar_get_entry_data()
512 phar_entry_info *entry, etemp; in phar_get_or_create_entry_data() local
590 …if (NULL == (entry = zend_hash_str_add_mem(&phar->manifest, etemp.filename, path_len, (void*)&etem… in phar_get_or_create_entry_data()
600 if (!entry) { in phar_get_or_create_entry_data()
609 ret->fp = entry->fp; in phar_get_or_create_entry_data()
612 ret->is_zip = entry->is_zip; in phar_get_or_create_entry_data()
613 ret->is_tar = entry->is_tar; in phar_get_or_create_entry_data()
614 ret->internal_file = entry; in phar_get_or_create_entry_data()
686 int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links) /* {{{ */ in phar_open_entry_fp() argument
689 phar_archive_data *phar = entry->phar; in phar_open_entry_fp()
695 if (follow_links && entry->link) { in phar_open_entry_fp()
696 phar_entry_info *link_entry = phar_get_link_source(entry); in phar_open_entry_fp()
697 if (link_entry && link_entry != entry) { in phar_open_entry_fp()
702 if (entry->is_modified) { in phar_open_entry_fp()
706 if (entry->fp_type == PHAR_TMP) { in phar_open_entry_fp()
707 if (!entry->fp) { in phar_open_entry_fp()
708 entry->fp = php_stream_open_wrapper(entry->tmp, "rb", STREAM_MUST_SEEK|0, NULL); in phar_open_entry_fp()
713 if (entry->fp_type != PHAR_FP) { in phar_open_entry_fp()
725 …if ((entry->old_flags && !(entry->old_flags & PHAR_ENT_COMPRESSION_MASK)) || !(entry->flags & PHAR… in phar_open_entry_fp()
726 dummy.internal_file = entry; in phar_open_entry_fp()
728 dummy.zero = entry->offset; in phar_open_entry_fp()
730 if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1)) { in phar_open_entry_fp()
736 if (!phar_get_entrypufp(entry)) { in phar_open_entry_fp()
737 phar_set_entrypufp(entry, php_stream_fopen_tmpfile()); in phar_open_entry_fp()
738 if (!phar_get_entrypufp(entry)) { in phar_open_entry_fp()
739 …n temporary file for decompressing phar archive \"%s\" file \"%s\"", phar->fname, entry->filename); in phar_open_entry_fp()
744 dummy.internal_file = entry; in phar_open_entry_fp()
746 dummy.zero = entry->offset; in phar_open_entry_fp()
748 if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1)) { in phar_open_entry_fp()
752 ufp = phar_get_entrypufp(entry); in phar_open_entry_fp()
754 if ((filtername = phar_decompress_filter(entry, 0)) != NULL) { in phar_open_entry_fp()
761 …while decompressing file \"%s\")", phar->fname, phar_decompress_filter(entry, 1), entry->filename); in phar_open_entry_fp()
770 php_stream_seek(phar_get_entrypfp(entry), phar_get_fp_offset(entry), SEEK_SET); in phar_open_entry_fp()
772 if (entry->uncompressed_filesize) { in phar_open_entry_fp()
773 …if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_entrypfp(entry), ufp, entry->compressed_files… in phar_open_entry_fp()
774 …orruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename); in phar_open_entry_fp()
784 if (php_stream_tell(ufp) - loc != (zend_off_t) entry->uncompressed_filesize) { in phar_open_entry_fp()
785 …orruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename); in phar_open_entry_fp()
789 entry->old_flags = entry->flags; in phar_open_entry_fp()
792 phar_set_fp_type(entry, PHAR_UFP, loc); in phar_open_entry_fp()
793 dummy.zero = entry->offset; in phar_open_entry_fp()
795 if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 0)) { in phar_open_entry_fp()
802 int phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry, char **error) /* {… in phar_create_writeable_entry() argument
804 if (entry->fp_type == PHAR_MOD) { in phar_create_writeable_entry()
806 php_stream_truncate_set_size(entry->fp, 0); in phar_create_writeable_entry()
808 entry->old_flags = entry->flags; in phar_create_writeable_entry()
809 entry->is_modified = 1; in phar_create_writeable_entry()
812 entry->uncompressed_filesize = 0; in phar_create_writeable_entry()
813 entry->compressed_filesize = 0; in phar_create_writeable_entry()
814 entry->crc32 = 0; in phar_create_writeable_entry()
815 entry->flags = PHAR_ENT_PERM_DEF_FILE; in phar_create_writeable_entry()
816 entry->fp_type = PHAR_MOD; in phar_create_writeable_entry()
817 entry->offset = 0; in phar_create_writeable_entry()
826 if (entry->link) { in phar_create_writeable_entry()
827 efree(entry->link); in phar_create_writeable_entry()
828 entry->link = NULL; in phar_create_writeable_entry()
829 entry->tar_type = (entry->is_tar ? TAR_FILE : '\0'); in phar_create_writeable_entry()
832 entry->fp = php_stream_fopen_tmpfile(); in phar_create_writeable_entry()
834 if (!entry->fp) { in phar_create_writeable_entry()
841 entry->old_flags = entry->flags; in phar_create_writeable_entry()
842 entry->is_modified = 1; in phar_create_writeable_entry()
845 entry->uncompressed_filesize = 0; in phar_create_writeable_entry()
846 entry->compressed_filesize = 0; in phar_create_writeable_entry()
847 entry->crc32 = 0; in phar_create_writeable_entry()
848 entry->flags = PHAR_ENT_PERM_DEF_FILE; in phar_create_writeable_entry()
849 entry->fp_type = PHAR_MOD; in phar_create_writeable_entry()
850 entry->offset = 0; in phar_create_writeable_entry()
855 int phar_separate_entry_fp(phar_entry_info *entry, char **error) /* {{{ */ in phar_separate_entry_fp() argument
860 if (FAILURE == phar_open_entry_fp(entry, error, 1)) { in phar_separate_entry_fp()
864 if (entry->fp_type == PHAR_MOD) { in phar_separate_entry_fp()
873 phar_seek_efp(entry, 0, SEEK_SET, 0, 1); in phar_separate_entry_fp()
874 link = phar_get_link_source(entry); in phar_separate_entry_fp()
877 link = entry; in phar_separate_entry_fp()
882 …y file \"%s\" contents in phar archive \"%s\" for write access", entry->filename, entry->phar->fna… in phar_separate_entry_fp()
887 if (entry->link) { in phar_separate_entry_fp()
888 efree(entry->link); in phar_separate_entry_fp()
889 entry->link = NULL; in phar_separate_entry_fp()
890 entry->tar_type = (entry->is_tar ? TAR_FILE : '\0'); in phar_separate_entry_fp()
893 entry->offset = 0; in phar_separate_entry_fp()
894 entry->fp = fp; in phar_separate_entry_fp()
895 entry->fp_type = PHAR_MOD; in phar_separate_entry_fp()
896 entry->is_modified = 1; in phar_separate_entry_fp()
904 phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error) /* {… in phar_open_jit() argument
910 if (FAILURE == phar_open_entry_fp(entry, error, 1)) { in phar_open_jit()
913 if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 1)) { in phar_open_jit()
914 …spprintf(error, 4096, "phar error: cannot seek to start of file \"%s\" in phar \"%s\"", entry->fil… in phar_open_jit()
917 return entry; in phar_open_jit()
1160 char * phar_compress_filter(phar_entry_info * entry, int return_unknown) /* {{{ */ in phar_compress_filter() argument
1162 switch (entry->flags & PHAR_ENT_COMPRESSION_MASK) { in phar_compress_filter()
1176 char * phar_decompress_filter(phar_entry_info * entry, int return_unknown) /* {{{ */ in phar_decompress_filter() argument
1180 if (entry->is_modified) { in phar_decompress_filter()
1181 flags = entry->old_flags; in phar_decompress_filter()
1183 flags = entry->flags; in phar_decompress_filter()
1213 phar_entry_info *entry; in phar_get_entry_info_dir() local
1258 if (NULL != (entry = zend_hash_str_find_ptr(&phar->manifest, path, path_len))) { in phar_get_entry_info_dir()
1259 if (entry->is_deleted) { in phar_get_entry_info_dir()
1263 if (entry->is_dir && !dir) { in phar_get_entry_info_dir()
1269 if (!entry->is_dir && dir == 2) { in phar_get_entry_info_dir()
1276 return entry; in phar_get_entry_info_dir()
1282 entry = (phar_entry_info *) ecalloc(1, sizeof(phar_entry_info)); in phar_get_entry_info_dir()
1284 entry->is_temp_dir = entry->is_dir = 1; in phar_get_entry_info_dir()
1285 entry->filename = (char *) estrndup(path, path_len + 1); in phar_get_entry_info_dir()
1286 entry->filename_len = path_len; in phar_get_entry_info_dir()
1287 entry->phar = phar; in phar_get_entry_info_dir()
1288 return entry; in phar_get_entry_info_dir()
1303 if (NULL == (entry = zend_hash_find_ptr(&phar->manifest, str_key))) { in phar_get_entry_info_dir()
1310 if (!entry->tmp || !entry->is_mounted) { in phar_get_entry_info_dir()
1317 test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, path + ZSTR_LEN(str_key)); in phar_get_entry_info_dir()
1352 if (NULL == (entry = zend_hash_str_find_ptr(&phar->manifest, path, path_len))) { in phar_get_entry_info_dir()
1358 return entry; in phar_get_entry_info_dir()
1974 phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(data); in phar_update_cached_entry() local
1976 entry->phar = (phar_archive_data *)argument; in phar_update_cached_entry()
1978 if (entry->link) { in phar_update_cached_entry()
1979 entry->link = estrdup(entry->link); in phar_update_cached_entry()
1982 if (entry->tmp) { in phar_update_cached_entry()
1983 entry->tmp = estrdup(entry->tmp); in phar_update_cached_entry()
1986 entry->metadata_str.s = NULL; in phar_update_cached_entry()
1987 entry->filename = estrndup(entry->filename, entry->filename_len); in phar_update_cached_entry()
1988 entry->is_persistent = 0; in phar_update_cached_entry()
1990 if (Z_TYPE(entry->metadata) != IS_UNDEF) { in phar_update_cached_entry()
1991 if (entry->metadata_len) { in phar_update_cached_entry()
1992 char *buf = estrndup((char *) Z_PTR(entry->metadata), entry->metadata_len); in phar_update_cached_entry()
1994 phar_parse_metadata((char **) &buf, &entry->metadata, entry->metadata_len); in phar_update_cached_entry()
1997 zval_copy_ctor(&entry->metadata); in phar_update_cached_entry()
1998 entry->metadata_str.s = NULL; in phar_update_cached_entry()