version 1.28, 2015/11/20 01:15:22 |
version 1.29, 2015/11/21 13:58:56 |
|
|
#include "extern.h" |
#include "extern.h" |
|
|
static int rlines(struct tailfile *, off_t); |
static int rlines(struct tailfile *, off_t); |
|
static inline void tfprint(FILE *fp); |
static int tfqueue(struct tailfile *tf); |
static int tfqueue(struct tailfile *tf); |
static const struct timespec *tfreopen(struct tailfile *tf); |
static const struct timespec *tfreopen(struct tailfile *tf); |
|
|
static int kq = -1; |
static int kq = -1; |
|
|
static void |
|
printtail(FILE *fp) |
|
{ |
|
int ch; |
|
|
|
while (!feof(fp) && (ch = getc(fp)) != EOF) |
|
if (putchar(ch) == EOF) |
|
oerr(); |
|
} |
|
|
|
/* |
/* |
* forward -- display the file, from an offset, forward. |
* forward -- display the file, from an offset, forward. |
* |
* |
|
|
if (nfiles < 1) |
if (nfiles < 1) |
return; |
return; |
|
|
if ((kq = kqueue()) < 0) |
if (fflag && (kq = kqueue()) < 0) |
warn("kqueue"); |
warn("kqueue"); |
|
|
for (i = 0; i < nfiles; i++) { |
for (i = 0; i < nfiles; i++) { |
|
|
} |
} |
break; |
break; |
} |
} |
if (ch == '\n' && !--off) { |
if (ch == '\n' && !--off) |
if (!fflag) |
|
printtail(tf[i].fp); |
|
break; |
break; |
} |
|
} |
} |
break; |
break; |
case RBYTES: |
case RBYTES: |
|
|
err(1, "Unsupported style"); |
err(1, "Unsupported style"); |
} |
} |
|
|
if (tfqueue(&(tf[i])) == -1) |
tfprint(tf[i].fp); |
|
if (fflag && tfqueue(&(tf[i])) == -1) |
warn("Unable to follow %s", tf[i].fname); |
warn("Unable to follow %s", tf[i].fname); |
|
|
} |
} |
|
|
ltf = ctf; |
ltf = ctf; |
} |
} |
clearerr(ctf->fp); |
clearerr(ctf->fp); |
while (!feof(ctf->fp) && |
tfprint(ctf->fp); |
(ch = getc(ctf->fp)) != EOF) { |
|
if (putchar(ch) == EOF) |
|
oerr(); |
|
} |
|
if (ferror(ctf->fp)) { |
if (ferror(ctf->fp)) { |
ierr(ctf->fname); |
ierr(ctf->fname); |
fclose(ctf->fp); |
fclose(ctf->fp); |
|
|
} |
} |
|
|
return (0); |
return (0); |
|
} |
|
|
|
static inline void |
|
tfprint(FILE *fp) |
|
{ |
|
int ch; |
|
|
|
while (!feof(fp) && (ch = getc(fp)) != EOF) |
|
if (putchar(ch) == EOF) |
|
oerr(); |
} |
} |
|
|
static int |
static int |