Lines Matching refs:fp
154 tailpos(register Sfio_t* fp, register Sfoff_t number, int delim)
164 last = sfsize(fp);
165 if ((first = sfseek(fp, (Sfoff_t)0, SEEK_CUR)) < 0)
166 return last || fstat(sffileno(fp), &st) || st.st_size || FIFO(st.st_mode) ? -1 : 0;
177 sfseek(fp, offset, SEEK_SET);
179 if (!(s = sfreserve(fp, n, SF_LOCKR)))
185 sfread(fp, s, 0);
188 sfread(fp, s, 0);
423 register Tail_t* fp;
613 if (!(fp = (Tail_t*)stakalloc(argc * sizeof(Tail_t))))
619 fp->name = s;
620 fp->sp = 0;
621 if (!init(fp, number, delim, flags, &format))
623 fp->expire = timeout ? (NOW + timeout + 1) : 0;
625 pp->next = fp;
627 files = fp;
628 pp = fp;
629 fp++;
637 while (fp = files)
644 while (fp)
646 if (fstat(sffileno(fp->sp), &st))
647 error(ERROR_system(0), "%s: cannot stat", fp->name);
648 else if (fp->fifo || fp->end < st.st_size)
652 fp->expire = NOW + timeout;
653 z = fp->fifo ? SF_UNBOUND : st.st_size - fp->cur;
655 if ((s = sfreserve(fp->sp, z, SF_LOCKR)) || (z = sfvalue(fp->sp)) && (s = sfreserve(fp->sp, z, SF_LOCKR)) && (i = 1))
657 z = sfvalue(fp->sp);
661 if ((flags & (HEADERS|VERBOSE)) && hp != fp)
663 hp = fp;
664 sfprintf(sfstdout, format, fp->name);
667 fp->cur += w;
672 sfread(fp->sp, s, w);
673 fp->end += w;
677 else if (!timeout || fp->expire > NOW)
684 while (--i && stat(fp->name, &st))
686 if (i && (fp->dev != st.st_dev || fp->ino != st.st_ino) && !init(fp, 0, 0, flags, &format))
689 error(ERROR_warn(0), "%s: log file change", fp->name);
690 fp->expire = NOW + timeout;
695 error(ERROR_warn(0), "%s: %s timeout", fp->name, fmtelapsed(timeout, 1));
697 if (fp->sp && fp->sp != sfstdin)
698 sfclose(fp->sp);
700 pp = pp->next = fp->next;
703 fp = fp->next;
706 pp = fp;
707 fp = fp->next;