Lines Matching refs:fn

110  		return apprentice_compile(ms, map, fn);
114 map = apprentice_map(ms, fn);
117 - file_magwarn(ms, "using regular magic file `%s'", fn);
118 - map = apprentice_load(ms, fn, action);
119 + if (fn) {
121 + file_magwarn(ms, "using regular magic file `%s'", fn);
122 + map = apprentice_load(ms, fn, action);
232 /* const char *fn: list of magic files and directories */
240 if ((fn = magic_getpath(fn, action)) == NULL)
246 - if ((mfn = strdup(fn)) == NULL) {
247 + if (fn == NULL)
248 + fn = getenv("MAGIC");
249 + if (fn == NULL) {
257 + return apprentice_1(ms, fn, action);
260 + if ((mfn = estrdup(fn)) == NULL) {
261 file_oomem(ms, strlen(fn));
274 fn = p;
292 load_1(struct magic_set *ms, int action, const char *fn, int *errs,
303 - FILE *f = fopen(ms->file = fn, "r");
309 + ms->file = fn;
311 + stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
313 + stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS, NULL);
319 fn);
368 apprentice_load(struct magic_set *ms, const char *fn, int action)
409 - if (stat(fn, &st) == 0 && S_ISDIR(st.st_mode)) {
410 - dir = opendir(fn);
413 + if (php_sys_stat(fn, &st) == 0 && S_ISDIR(st.st_mode)) {
417 + dir = php_stream_opendir((char *)fn, REPORT_ERRORS, NULL);
423 - if (asprintf(&mfn, "%s/%s", fn, d->d_name) < 0) {
425 + if ((mflen = snprintf(mfn, sizeof(mfn), "%s/%s", fn, d.d_name)) < 0) {
427 - strlen(fn) + strlen(d->d_name) + 2);
428 + strlen(fn) + strlen(d.d_name) + 2);
468 load_1(ms, action, fn, &errs, mentry, mentrycount);
561 apprentice_map(struct magic_set *ms, const char *fn)
585 + if (fn == NULL) {
593 + if (php_stream_stat_path_ex((char *)fn, 0, &st, NULL) == SUCCESS) {
600 dbname = mkdbname(ms, fn, 0);
606 + stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
608 + stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS, NULL);
682 + if (needsbyteswap && fn == NULL) {
687 + if (NULL != fn) {
704 + if (NULL != fn && entries != nentries + 1) {
742 - dbname = mkdbname(ms, fn, 1);
743 + dbname = mkdbname(ms, fn, 0);
752 + stream = php_stream_open_wrapper((char *)fn, "wb+", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
754 + stream = php_stream_open_wrapper((char *)fn, "wb+", REPORT_ERRORS, NULL);
808 if ((p = strrchr(fn, '/')) != NULL)
813 - if (asprintf(&buf, "%.*s.mime%s", (int)(q - fn), fn, ext) < 0)
816 + spprintf(&buf, MAXPATHLEN, "%.*s.mime%s", (int)(q - fn), fn, ext);
828 - if (asprintf(&buf, "%.*s%s", (int)(q - fn), fn, ext) < 0)
830 + spprintf(&buf, MAXPATHLEN, "%.*s%s", (int)(q - fn), fn, ext);
1596 -file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
1597 +file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb, php_stream *stream)
1610 - if (fn == NULL)
1612 + if (fn == NULL && !stream) {
1623 - ret = lstat(fn, sb);
1626 - ret = stat(fn, sb); /* don't merge into if; see "ret =" above */
1630 - file_error(ms, errno, "cannot stat `%s'", fn);
1637 + file_error(ms, errno, "cannot stat `%s'", fn);
1644 + if (php_sys_stat(fn, sb) != 0) {
1646 + file_error(ms, errno, "cannot stat `%s'", fn);
1652 - fn, strerror(errno)) == -1)
1782 - if ((nch = readlink(fn, buf, BUFSIZ-1)) <= 0) {
1786 - fn);
1787 + file_error(ms, errno, "unreadable symlink `%s'", fn);
1794 - "%sunreadable symlink `%s' (%s)", COMMA, fn,
1809 - if ((tmp = strrchr(fn, '/')) == NULL) {
1812 - if (tmp - fn + 1 > BUFSIZ) {
1824 - fn) == -1)
1829 - (void)strlcpy(buf2, fn, sizeof buf2);
1830 - buf2[tmp - fn + 1] = '\0';