version 1.17, 2003/07/14 08:06:06 |
version 1.18, 2004/02/16 19:48:21 |
|
|
|
|
#include "extern.h" |
#include "extern.h" |
|
|
static int rlines(FILE *, long, struct stat *); |
static int rlines(FILE *, off_t, struct stat *); |
|
|
/* |
/* |
* forward -- display the file, from an offset, forward. |
* forward -- display the file, from an offset, forward. |
|
|
forward(fp, style, off, sbp) |
forward(fp, style, off, sbp) |
FILE *fp; |
FILE *fp; |
enum STYLE style; |
enum STYLE style; |
long off; |
off_t off; |
struct stat *sbp; |
struct stat *sbp; |
{ |
{ |
int ch; |
int ch; |
|
|
if (S_ISREG(sbp->st_mode)) { |
if (S_ISREG(sbp->st_mode)) { |
if (sbp->st_size < off) |
if (sbp->st_size < off) |
off = sbp->st_size; |
off = sbp->st_size; |
if (fseek(fp, off, SEEK_SET) == -1) { |
if (fseeko(fp, off, SEEK_SET) == -1) { |
ierr(); |
ierr(); |
return; |
return; |
} |
} |
|
|
case RBYTES: |
case RBYTES: |
if (S_ISREG(sbp->st_mode)) { |
if (S_ISREG(sbp->st_mode)) { |
if (sbp->st_size >= off && |
if (sbp->st_size >= off && |
fseek(fp, -off, SEEK_END) == -1) { |
fseeko(fp, -off, SEEK_END) == -1) { |
ierr(); |
ierr(); |
return; |
return; |
} |
} |
|
|
case RLINES: |
case RLINES: |
if (S_ISREG(sbp->st_mode)) { |
if (S_ISREG(sbp->st_mode)) { |
if (!off) { |
if (!off) { |
if (fseek(fp, 0L, SEEK_END) == -1) { |
if (fseeko(fp, (off_t)0, SEEK_END) == -1) { |
ierr(); |
ierr(); |
return; |
return; |
} |
} |
|
|
* rlines -- display the last offset lines of the file. |
* rlines -- display the last offset lines of the file. |
*/ |
*/ |
static int |
static int |
rlines(FILE *fp, long off, struct stat *sbp) |
rlines(FILE *fp, off_t off, struct stat *sbp) |
{ |
{ |
off_t pos; |
off_t pos; |
int ch; |
int ch; |