Lines Matching refs:entry

49 static char *phar_get_link_location(phar_entry_info *entry TSRMLS_DC) /* {{{ */  in phar_get_link_location()
52 if (!entry->link) { in phar_get_link_location()
55 if (entry->link[0] == '/') { in phar_get_link_location()
56 return estrdup(entry->link + 1); in phar_get_link_location()
58 p = strrchr(entry->filename, '/'); in phar_get_link_location()
61 spprintf(&ret, 0, "%s/%s", entry->filename, entry->link); in phar_get_link_location()
64 return entry->link; in phar_get_link_location()
68 phar_entry_info *phar_get_link_source(phar_entry_info *entry TSRMLS_DC) /* {{{ */ in phar_get_link_source()
73 if (!entry->link) { in phar_get_link_source()
74 return entry; in phar_get_link_source()
77 link = phar_get_link_location(entry TSRMLS_CC); in phar_get_link_source()
78 …if (SUCCESS == zend_hash_find(&(entry->phar->manifest), entry->link, strlen(entry->link), (void **… in phar_get_link_source()
79 SUCCESS == zend_hash_find(&(entry->phar->manifest), link, strlen(link), (void **)&link_entry)) { in phar_get_link_source()
80 if (link != entry->link) { in phar_get_link_source()
85 if (link != entry->link) { in phar_get_link_source()
94 php_stream *phar_get_efp(phar_entry_info *entry, int follow_links TSRMLS_DC) /* {{{ */ in phar_get_efp() argument
96 if (follow_links && entry->link) { in phar_get_efp()
97 phar_entry_info *link_entry = phar_get_link_source(entry TSRMLS_CC); in phar_get_efp()
99 if (link_entry && link_entry != entry) { in phar_get_efp()
104 if (phar_get_fp_type(entry TSRMLS_CC) == PHAR_FP) { in phar_get_efp()
105 if (!phar_get_entrypfp(entry TSRMLS_CC)) { in phar_get_efp()
107 phar_open_archive_fp(entry->phar TSRMLS_CC); in phar_get_efp()
109 return phar_get_entrypfp(entry TSRMLS_CC); in phar_get_efp()
110 } else if (phar_get_fp_type(entry TSRMLS_CC) == PHAR_UFP) { in phar_get_efp()
111 return phar_get_entrypufp(entry TSRMLS_CC); in phar_get_efp()
112 } else if (entry->fp_type == PHAR_MOD) { in phar_get_efp()
113 return entry->fp; in phar_get_efp()
116 if (!entry->fp) { in phar_get_efp()
117 entry->fp = php_stream_open_wrapper(entry->tmp, "rb", STREAM_MUST_SEEK|0, NULL); in phar_get_efp()
119 return entry->fp; in phar_get_efp()
124 int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t position, int follow_link… in phar_seek_efp() argument
126 php_stream *fp = phar_get_efp(entry, follow_links TSRMLS_CC); in phar_seek_efp()
135 t = phar_get_link_source(entry TSRMLS_CC); in phar_seek_efp()
137 entry = t; in phar_seek_efp()
141 if (entry->is_dir) { in phar_seek_efp()
145 eoffset = phar_get_fp_offset(entry TSRMLS_CC); in phar_seek_efp()
149 temp = eoffset + entry->uncompressed_filesize + offset; in phar_seek_efp()
161 if (temp > eoffset + (off_t) entry->uncompressed_filesize) { in phar_seek_efp()
176 phar_entry_info entry = {0}; in phar_mount_entry() local
192 entry.phar = phar; in phar_mount_entry()
193 entry.filename = estrndup(path, path_len); in phar_mount_entry()
195 phar_unixify_path_separators(entry.filename, path_len); in phar_mount_entry()
197 entry.filename_len = path_len; in phar_mount_entry()
199 entry.tmp = estrndup(filename, filename_len); in phar_mount_entry()
201 entry.tmp = expand_filepath(filename, NULL TSRMLS_CC); in phar_mount_entry()
202 if (!entry.tmp) { in phar_mount_entry()
203 entry.tmp = estrndup(filename, filename_len); in phar_mount_entry()
207 if (PG(safe_mode) && !is_phar && (!php_checkuid(entry.tmp, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { in phar_mount_entry()
208 efree(entry.tmp); in phar_mount_entry()
209 efree(entry.filename); in phar_mount_entry()
213 filename = entry.tmp; in phar_mount_entry()
217 efree(entry.tmp); in phar_mount_entry()
218 efree(entry.filename); in phar_mount_entry()
222 entry.is_mounted = 1; in phar_mount_entry()
223 entry.is_crc_checked = 1; in phar_mount_entry()
224 entry.fp_type = PHAR_TMP; in phar_mount_entry()
227 efree(entry.tmp); in phar_mount_entry()
228 efree(entry.filename); in phar_mount_entry()
233 entry.is_dir = 1; in phar_mount_entry()
234 …if (SUCCESS != zend_hash_add(&phar->mounted_dirs, entry.filename, path_len, (void *)&(entry.filena… in phar_mount_entry()
236 efree(entry.tmp); in phar_mount_entry()
237 efree(entry.filename); in phar_mount_entry()
241 entry.is_dir = 0; in phar_mount_entry()
242 entry.uncompressed_filesize = entry.compressed_filesize = ssb.sb.st_size; in phar_mount_entry()
245 entry.flags = ssb.sb.st_mode; in phar_mount_entry()
247 …if (SUCCESS == zend_hash_add(&phar->manifest, entry.filename, path_len, (void*)&entry, sizeof(phar… in phar_mount_entry()
251 efree(entry.tmp); in phar_mount_entry()
252 efree(entry.filename); in phar_mount_entry()
260 char *path, *fname, *arch, *entry, *ret, *test; in phar_find_in_include_path() local
284 …) || SUCCESS != phar_split_fname(fname, strlen(fname), &arch, &arch_len, &entry, &entry_len, 1, 0 … in phar_find_in_include_path()
288 efree(entry); in phar_find_in_include_path()
332 …if (SUCCESS != phar_split_fname(ret, ret_len, &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC… in phar_find_in_include_path()
343 efree(entry); in phar_find_in_include_path()
354 char *fname, *arch, *entry, *ret, *test; in phar_find_in_include_path()
368 …if (SUCCESS != phar_split_fname(fname, strlen(fname), &arch, &arch_len, &entry, &entry_len, 1, 0 T… in phar_find_in_include_path()
372 efree(entry); in phar_find_in_include_path()
489 char *arch, *entry; in phar_find_in_include_path()
495 …if (SUCCESS != phar_split_fname(trypath, ret_len, &arch, &arch_len, &entry, &entry_len, 1, 0 TSRML… in phar_find_in_include_path()
506 efree(entry); in phar_find_in_include_path()
578 phar_entry_info *entry; in phar_get_entry_data() local
613 …if ((entry = phar_get_entry_info_dir(phar, path, path_len, allow_dir, for_create && !PHAR_G(readon… in phar_get_entry_data()
620 …if ((entry = phar_get_entry_info(phar, path, path_len, for_create && !PHAR_G(readonly) && !phar->i… in phar_get_entry_data()
639 if (entry->is_modified && !for_write) { in phar_get_entry_data()
646 if (entry->fp_refcount && for_write) { in phar_get_entry_data()
653 if (entry->is_deleted) { in phar_get_entry_data()
657 entry->is_deleted = 0; in phar_get_entry_data()
660 if (entry->is_dir) { in phar_get_entry_data()
666 (*ret)->internal_file = entry; in phar_get_entry_data()
667 (*ret)->is_zip = entry->is_zip; in phar_get_entry_data()
668 (*ret)->is_tar = entry->is_tar; in phar_get_entry_data()
671 ++(entry->phar->refcount); in phar_get_entry_data()
672 ++(entry->fp_refcount); in phar_get_entry_data()
678 if (entry->fp_type == PHAR_MOD) { in phar_get_entry_data()
680 if (FAILURE == phar_create_writeable_entry(phar, entry, error TSRMLS_CC)) { in phar_get_entry_data()
684 phar_seek_efp(entry, 0, SEEK_END, 0, 0 TSRMLS_CC); in phar_get_entry_data()
688 if (entry->link) { in phar_get_entry_data()
689 efree(entry->link); in phar_get_entry_data()
690 entry->link = NULL; in phar_get_entry_data()
691 entry->tar_type = (entry->is_tar ? TAR_FILE : '\0'); in phar_get_entry_data()
695 if (FAILURE == phar_create_writeable_entry(phar, entry, error TSRMLS_CC)) { in phar_get_entry_data()
699 if (FAILURE == phar_separate_entry_fp(entry, error TSRMLS_CC)) { in phar_get_entry_data()
704 if (FAILURE == phar_open_entry_fp(entry, error, 1 TSRMLS_CC)) { in phar_get_entry_data()
714 (*ret)->internal_file = entry; in phar_get_entry_data()
715 (*ret)->is_zip = entry->is_zip; in phar_get_entry_data()
716 (*ret)->is_tar = entry->is_tar; in phar_get_entry_data()
717 (*ret)->fp = phar_get_efp(entry, 1 TSRMLS_CC); in phar_get_entry_data()
718 if (entry->link) { in phar_get_entry_data()
719 (*ret)->zero = phar_get_fp_offset(phar_get_link_source(entry TSRMLS_CC) TSRMLS_CC); in phar_get_entry_data()
721 (*ret)->zero = phar_get_fp_offset(entry TSRMLS_CC); in phar_get_entry_data()
725 ++(entry->fp_refcount); in phar_get_entry_data()
726 ++(entry->phar->refcount); in phar_get_entry_data()
739 phar_entry_info *entry, etemp; in phar_get_or_create_entry_data() local
817 …r->manifest, etemp.filename, path_len, (void*)&etemp, sizeof(phar_entry_info), (void **) &entry)) { in phar_get_or_create_entry_data()
827 if (!entry) { in phar_get_or_create_entry_data()
836 ret->fp = entry->fp; in phar_get_or_create_entry_data()
839 ret->is_zip = entry->is_zip; in phar_get_or_create_entry_data()
840 ret->is_tar = entry->is_tar; in phar_get_or_create_entry_data()
841 ret->internal_file = entry; in phar_get_or_create_entry_data()
918 int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TSRMLS_DC) /* {{{ */ in phar_open_entry_fp() argument
921 phar_archive_data *phar = entry->phar; in phar_open_entry_fp()
927 if (follow_links && entry->link) { in phar_open_entry_fp()
928 phar_entry_info *link_entry = phar_get_link_source(entry TSRMLS_CC); in phar_open_entry_fp()
929 if (link_entry && link_entry != entry) { in phar_open_entry_fp()
934 if (entry->is_modified) { in phar_open_entry_fp()
938 if (entry->fp_type == PHAR_TMP) { in phar_open_entry_fp()
939 if (!entry->fp) { in phar_open_entry_fp()
940 entry->fp = php_stream_open_wrapper(entry->tmp, "rb", STREAM_MUST_SEEK|0, NULL); in phar_open_entry_fp()
945 if (entry->fp_type != PHAR_FP) { in phar_open_entry_fp()
957 …if ((entry->old_flags && !(entry->old_flags & PHAR_ENT_COMPRESSION_MASK)) || !(entry->flags & PHAR… in phar_open_entry_fp()
958 dummy.internal_file = entry; in phar_open_entry_fp()
960 dummy.zero = entry->offset; in phar_open_entry_fp()
962 if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1 TSRMLS_CC)) { in phar_open_entry_fp()
968 if (!phar_get_entrypufp(entry TSRMLS_CC)) { in phar_open_entry_fp()
969 phar_set_entrypufp(entry, php_stream_fopen_tmpfile() TSRMLS_CC); in phar_open_entry_fp()
970 if (!phar_get_entrypufp(entry TSRMLS_CC)) { in phar_open_entry_fp()
971 …n temporary file for decompressing phar archive \"%s\" file \"%s\"", phar->fname, entry->filename); in phar_open_entry_fp()
976 dummy.internal_file = entry; in phar_open_entry_fp()
978 dummy.zero = entry->offset; in phar_open_entry_fp()
980 if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1 TSRMLS_CC)) { in phar_open_entry_fp()
984 ufp = phar_get_entrypufp(entry TSRMLS_CC); in phar_open_entry_fp()
986 if ((filtername = phar_decompress_filter(entry, 0)) != NULL) { in phar_open_entry_fp()
993 …while decompressing file \"%s\")", phar->fname, phar_decompress_filter(entry, 1), entry->filename); in phar_open_entry_fp()
1002 php_stream_seek(phar_get_entrypfp(entry TSRMLS_CC), phar_get_fp_offset(entry TSRMLS_CC), SEEK_SET); in phar_open_entry_fp()
1004 if (entry->uncompressed_filesize) { in phar_open_entry_fp()
1005 …if (SUCCESS != phar_stream_copy_to_stream(phar_get_entrypfp(entry TSRMLS_CC), ufp, entry->compress… in phar_open_entry_fp()
1006 …orruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename); in phar_open_entry_fp()
1016 if (php_stream_tell(ufp) - loc != (off_t) entry->uncompressed_filesize) { in phar_open_entry_fp()
1017 …orruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename); in phar_open_entry_fp()
1021 entry->old_flags = entry->flags; in phar_open_entry_fp()
1024 phar_set_fp_type(entry, PHAR_UFP, loc TSRMLS_CC); in phar_open_entry_fp()
1025 dummy.zero = entry->offset; in phar_open_entry_fp()
1027 if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 0 TSRMLS_CC)) { in phar_open_entry_fp()
1045 int phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry, char **error TSRML… in phar_create_writeable_entry() argument
1047 if (entry->fp_type == PHAR_MOD) { in phar_create_writeable_entry()
1050 php_stream_truncate_set_size(entry->fp, 0); in phar_create_writeable_entry()
1052 if (php_stream_is(entry->fp, PHP_STREAM_IS_TEMP)) { in phar_create_writeable_entry()
1053 if (php_stream_is(*(php_stream**)entry->fp->abstract, PHP_STREAM_IS_MEMORY)) { in phar_create_writeable_entry()
1054 php_stream *inner = *(php_stream**)entry->fp->abstract; in phar_create_writeable_entry()
1058 } else if (php_stream_is(*(php_stream**)entry->fp->abstract, PHP_STREAM_IS_STDIO)) { in phar_create_writeable_entry()
1059 php_stream_truncate_set_size(*(php_stream**)entry->fp->abstract, 0); in phar_create_writeable_entry()
1066 } else if (php_stream_is(entry->fp, PHP_STREAM_IS_STDIO)) { in phar_create_writeable_entry()
1067 php_stream_truncate_set_size(entry->fp, 0); in phar_create_writeable_entry()
1075 entry->old_flags = entry->flags; in phar_create_writeable_entry()
1076 entry->is_modified = 1; in phar_create_writeable_entry()
1079 entry->uncompressed_filesize = 0; in phar_create_writeable_entry()
1080 entry->compressed_filesize = 0; in phar_create_writeable_entry()
1081 entry->crc32 = 0; in phar_create_writeable_entry()
1082 entry->flags = PHAR_ENT_PERM_DEF_FILE; in phar_create_writeable_entry()
1083 entry->fp_type = PHAR_MOD; in phar_create_writeable_entry()
1084 entry->offset = 0; in phar_create_writeable_entry()
1093 if (entry->link) { in phar_create_writeable_entry()
1094 efree(entry->link); in phar_create_writeable_entry()
1095 entry->link = NULL; in phar_create_writeable_entry()
1096 entry->tar_type = (entry->is_tar ? TAR_FILE : '\0'); in phar_create_writeable_entry()
1099 entry->fp = php_stream_fopen_tmpfile(); in phar_create_writeable_entry()
1101 if (!entry->fp) { in phar_create_writeable_entry()
1108 entry->old_flags = entry->flags; in phar_create_writeable_entry()
1109 entry->is_modified = 1; in phar_create_writeable_entry()
1112 entry->uncompressed_filesize = 0; in phar_create_writeable_entry()
1113 entry->compressed_filesize = 0; in phar_create_writeable_entry()
1114 entry->crc32 = 0; in phar_create_writeable_entry()
1115 entry->flags = PHAR_ENT_PERM_DEF_FILE; in phar_create_writeable_entry()
1116 entry->fp_type = PHAR_MOD; in phar_create_writeable_entry()
1117 entry->offset = 0; in phar_create_writeable_entry()
1122 int phar_separate_entry_fp(phar_entry_info *entry, char **error TSRMLS_DC) /* {{{ */ in phar_separate_entry_fp() argument
1127 if (FAILURE == phar_open_entry_fp(entry, error, 1 TSRMLS_CC)) { in phar_separate_entry_fp()
1131 if (entry->fp_type == PHAR_MOD) { in phar_separate_entry_fp()
1140 phar_seek_efp(entry, 0, SEEK_SET, 0, 1 TSRMLS_CC); in phar_separate_entry_fp()
1141 link = phar_get_link_source(entry TSRMLS_CC); in phar_separate_entry_fp()
1144 link = entry; in phar_separate_entry_fp()
1149 …y file \"%s\" contents in phar archive \"%s\" for write access", entry->filename, entry->phar->fna… in phar_separate_entry_fp()
1154 if (entry->link) { in phar_separate_entry_fp()
1155 efree(entry->link); in phar_separate_entry_fp()
1156 entry->link = NULL; in phar_separate_entry_fp()
1157 entry->tar_type = (entry->is_tar ? TAR_FILE : '\0'); in phar_separate_entry_fp()
1160 entry->offset = 0; in phar_separate_entry_fp()
1161 entry->fp = fp; in phar_separate_entry_fp()
1162 entry->fp_type = PHAR_MOD; in phar_separate_entry_fp()
1163 entry->is_modified = 1; in phar_separate_entry_fp()
1171 phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error TSRML… in phar_open_jit() argument
1177 if (FAILURE == phar_open_entry_fp(entry, error, 1 TSRMLS_CC)) { in phar_open_jit()
1180 if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 1 TSRMLS_CC)) { in phar_open_jit()
1181 …spprintf(error, 4096, "phar error: cannot seek to start of file \"%s\" in phar \"%s\"", entry->fil… in phar_open_jit()
1184 return entry; in phar_open_jit()
1419 char * phar_compress_filter(phar_entry_info * entry, int return_unknown) /* {{{ */ in phar_compress_filter() argument
1421 switch (entry->flags & PHAR_ENT_COMPRESSION_MASK) { in phar_compress_filter()
1435 char * phar_decompress_filter(phar_entry_info * entry, int return_unknown) /* {{{ */ in phar_decompress_filter() argument
1439 if (entry->is_modified) { in phar_decompress_filter()
1440 flags = entry->old_flags; in phar_decompress_filter()
1442 flags = entry->flags; in phar_decompress_filter()
1472 phar_entry_info *entry; in phar_get_entry_info_dir() local
1517 if (SUCCESS == zend_hash_find(&phar->manifest, path, path_len, (void**)&entry)) { in phar_get_entry_info_dir()
1518 if (entry->is_deleted) { in phar_get_entry_info_dir()
1522 if (entry->is_dir && !dir) { in phar_get_entry_info_dir()
1528 if (!entry->is_dir && dir == 2) { in phar_get_entry_info_dir()
1535 return entry; in phar_get_entry_info_dir()
1541 entry = (phar_entry_info *) ecalloc(1, sizeof(phar_entry_info)); in phar_get_entry_info_dir()
1543 entry->is_temp_dir = entry->is_dir = 1; in phar_get_entry_info_dir()
1544 entry->filename = (char *) estrndup(path, path_len + 1); in phar_get_entry_info_dir()
1545 entry->filename_len = path_len; in phar_get_entry_info_dir()
1546 entry->phar = phar; in phar_get_entry_info_dir()
1547 return entry; in phar_get_entry_info_dir()
1573 if (SUCCESS != zend_hash_find(&phar->manifest, str_key, keylen, (void **) &entry)) { in phar_get_entry_info_dir()
1581 if (!entry->tmp || !entry->is_mounted) { in phar_get_entry_info_dir()
1590 test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, path + keylen); in phar_get_entry_info_dir()
1625 if (SUCCESS != zend_hash_find(&phar->manifest, path, path_len, (void**)&entry)) { in phar_get_entry_info_dir()
1631 return entry; in phar_get_entry_info_dir()
2255 phar_entry_info *entry = (phar_entry_info *)data; local
2258 entry->phar = (phar_archive_data *)argument;
2260 if (entry->link) {
2261 entry->link = estrdup(entry->link);
2264 if (entry->tmp) {
2265 entry->tmp = estrdup(entry->tmp);
2268 entry->metadata_str.c = 0;
2269 entry->filename = estrndup(entry->filename, entry->filename_len);
2270 entry->is_persistent = 0;
2272 if (entry->metadata) {
2273 if (entry->metadata_len) {
2274 char *buf = estrndup((char *) entry->metadata, entry->metadata_len);
2276 phar_parse_metadata((char **) &buf, &entry->metadata, entry->metadata_len TSRMLS_CC);
2281 t = entry->metadata;
2282 ALLOC_ZVAL(entry->metadata);
2283 *entry->metadata = *t;
2284 zval_copy_ctor(entry->metadata);
2286 entry->metadata->refcount = 1;
2288 Z_SET_REFCOUNT_P(entry->metadata, 1);
2290 entry->metadata_str.c = NULL;
2291 entry->metadata_str.len = 0;