Lines Matching refs:fn

117  		rv = apprentice_compile(ms, &magic, &nmagic, fn);
124 if ((rv = apprentice_map(ms, &magic, &nmagic, fn)) == -1) {
126 - file_magwarn(ms, "using regular magic file `%s'", fn);
127 - rv = apprentice_load(ms, &magic, &nmagic, fn, action);
128 + if (fn) {
130 + file_magwarn(ms, "using regular magic file `%s'", fn);
131 + rv = apprentice_load(ms, &magic, &nmagic, fn, action);
194 if ((fn = magic_getpath(fn, action)) == NULL)
200 - if ((mfn = strdup(fn)) == NULL) {
201 - file_oomem(ms, strlen(fn));
203 + if (fn == NULL)
204 + fn = getenv("MAGIC");
205 + if (fn == NULL) {
208 + apprentice_1(ms, fn, action, mlist);
212 + mfn = estrdup(fn);
213 fn = mfn;
223 while (fn) {
225 fn = p;
261 load_1(struct magic_set *ms, int action, const char *fn, int *errs,
273 - FILE *f = fopen(ms->file = fn, "r");
278 + stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
280 + stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS, NULL);
286 fn);
315 const char *fn, int action)
350 - if (stat(fn, &st) == 0 && S_ISDIR(st.st_mode)) {
351 - dir = opendir(fn);
354 + if (php_sys_stat(fn, &st) == 0 && S_ISDIR(st.st_mode)) {
358 + dir = php_stream_opendir(fn, REPORT_ERRORS, NULL);
364 - if (asprintf(&mfn, "%s/%s", fn, d->d_name) < 0) {
366 - strlen(fn) + strlen(d->d_name) + 2);
368 + if ((mflen = snprintf(mfn, sizeof(mfn), "%s/%s", fn, d.d_name)) < 0) {
369 + file_oomem(ms, strlen(fn) + strlen(d.d_name) + 2);
534 const char *fn)
550 + if (fn == NULL) {
559 + if (php_stream_stat_path_ex(fn, 0, &st, NULL) == SUCCESS) {
566 dbname = mkdbname(ms, fn, 0);
572 + stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
574 + stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS, NULL);
644 + if (needsbyteswap && fn == NULL) {
651 + if (fn == NULL) {
701 uint32_t *nmagicp, const char *fn)
710 - dbname = mkdbname(ms, fn, 1);
711 + dbname = mkdbname(ms, fn, 0);
719 + stream = php_stream_open_wrapper((char *)fn, "wb+", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
721 + stream = php_stream_open_wrapper((char *)fn, "wb+", REPORT_ERRORS, NULL);
767 if ((p = strrchr(fn, '/')) != NULL)
772 - asprintf(&buf, "%.*s.mime%s", (int)(q - fn), fn, ext);
774 + spprintf(&buf, MAXPATHLEN, "%.*s.mime%s", (int)(q - fn), fn, ext);
786 - asprintf(&buf, "%.*s%s", (int)(q - fn), fn, ext);
787 + spprintf(&buf, MAXPATHLEN, "%.*s%s", (int)(q - fn), fn, ext);
1237 +protected int file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb, php_stream *stre…
1374 -file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
1375 +file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb, php_stream *stream)
1388 - if (fn == NULL)
1390 + if (!fn && !stream) {
1400 - ret = lstat(fn, sb);
1403 - ret = stat(fn, sb); /* don't merge into if; see "ret =" above */
1407 - file_error(ms, errno, "cannot stat `%s'", fn);
1413 + file_error(ms, errno, "cannot stat `%s'", fn);
1420 + if (php_sys_stat(fn, sb) != 0) {
1422 + file_error(ms, errno, "cannot stat `%s'", fn);
1428 - fn, strerror(errno)) == -1)
1551 - if ((nch = readlink(fn, buf, BUFSIZ-1)) <= 0) {
1555 - fn);
1556 + file_error(ms, errno, "unreadable symlink `%s'", fn);
1563 - "unreadable symlink `%s' (%s)", fn,
1578 - if ((tmp = strrchr(fn, '/')) == NULL) {
1581 - if (tmp - fn + 1 > BUFSIZ) {
1592 - "path too long: `%s'", fn) == -1)
1597 - (void)strlcpy(buf2, fn, sizeof buf2);
1598 - buf2[tmp - fn + 1] = '\0';