Lines 35-42
static char sccsid[] = "@(#)display.c 8.1 (Berkeley) 6/6/93";
Link Here
|
35 |
#include <sys/cdefs.h> |
35 |
#include <sys/cdefs.h> |
36 |
__FBSDID("$FreeBSD$"); |
36 |
__FBSDID("$FreeBSD$"); |
37 |
|
37 |
|
|
|
38 |
#include <sys/ioctl.h> |
38 |
#include <sys/param.h> |
39 |
#include <sys/param.h> |
39 |
#include <sys/stat.h> |
40 |
#include <sys/stat.h> |
|
|
41 |
#include <sys/conf.h> |
40 |
|
42 |
|
41 |
#include <ctype.h> |
43 |
#include <ctype.h> |
42 |
#include <err.h> |
44 |
#include <err.h> |
Lines 368-374
next(char **argv)
Link Here
|
368 |
void |
370 |
void |
369 |
doskip(const char *fname, int statok) |
371 |
doskip(const char *fname, int statok) |
370 |
{ |
372 |
{ |
371 |
int cnt; |
373 |
int type; |
372 |
struct stat sb; |
374 |
struct stat sb; |
373 |
|
375 |
|
374 |
if (statok) { |
376 |
if (statok) { |
Lines 380-395
doskip(const char *fname, int statok)
Link Here
|
380 |
return; |
382 |
return; |
381 |
} |
383 |
} |
382 |
} |
384 |
} |
383 |
if (S_ISREG(sb.st_mode)) { |
385 |
if (S_ISFIFO(sb.st_mode) || S_ISSOCK(sb.st_mode)) { |
384 |
if (fseeko(stdin, skip, SEEK_SET)) |
386 |
noseek(); |
|
|
387 |
return; |
388 |
} |
389 |
if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) { |
390 |
if (ioctl(fileno(stdin), FIODTYPE, &type)) |
385 |
err(1, "%s", fname); |
391 |
err(1, "%s", fname); |
386 |
address += skip; |
392 |
/* |
387 |
skip = 0; |
393 |
* Most tape drives don't support seeking, |
388 |
} else { |
394 |
* yet fseeko() would succeed. |
389 |
for (cnt = 0; cnt < skip; ++cnt) |
395 |
*/ |
390 |
if (getchar() == EOF) |
396 |
if (type & D_TAPE) { |
391 |
break; |
397 |
noseek(); |
392 |
address += cnt; |
398 |
return; |
393 |
skip -= cnt; |
399 |
} |
|
|
400 |
} |
401 |
if (fseeko(stdin, skip, SEEK_SET)) { |
402 |
noseek(); |
403 |
return; |
394 |
} |
404 |
} |
|
|
405 |
address += skip; |
406 |
skip = 0; |
407 |
} |
408 |
|
409 |
void |
410 |
noseek(void) |
411 |
{ |
412 |
int count; |
413 |
|
414 |
for (count = 0; count < skip; ++count) |
415 |
if (getchar() == EOF) |
416 |
break; |
417 |
address += count; |
418 |
skip -= count; |
395 |
} |
419 |
} |