version 1.6, 2001/07/12 05:17:10 |
version 1.7, 2001/11/02 19:41:06 |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
#include <err.h> |
#include "hexdump.h" |
#include "hexdump.h" |
|
|
enum _vflag vflag = FIRST; |
enum _vflag vflag = FIRST; |
|
|
length == -1 ? need : MIN(length, need), stdin); |
length == -1 ? need : MIN(length, need), stdin); |
if (!n) { |
if (!n) { |
if (ferror(stdin)) |
if (ferror(stdin)) |
(void)fprintf(stderr, "hexdump: %s: %s\n", |
warn("%s", _argv[-1]); |
_argv[-1], strerror(errno)); |
|
ateof = 1; |
ateof = 1; |
continue; |
continue; |
} |
} |
|
|
for (;;) { |
for (;;) { |
if (*_argv) { |
if (*_argv) { |
if (!(freopen(*_argv, "r", stdin))) { |
if (!(freopen(*_argv, "r", stdin))) { |
(void)fprintf(stderr, "hexdump: %s: %s\n", |
warn("%s", *_argv); |
*_argv, strerror(errno)); |
|
exitval = 1; |
exitval = 1; |
++_argv; |
++_argv; |
continue; |
continue; |
|
|
struct stat sbuf; |
struct stat sbuf; |
|
|
if (statok) { |
if (statok) { |
if (fstat(fileno(stdin), &sbuf)) { |
if (fstat(fileno(stdin), &sbuf)) |
(void)fprintf(stderr, "hexdump: %s: %s.\n", |
err(1, "%s", fname); |
fname, strerror(errno)); |
|
exit(1); |
|
} |
|
if (skip >= sbuf.st_size) { |
if (skip >= sbuf.st_size) { |
skip -= sbuf.st_size; |
skip -= sbuf.st_size; |
address += sbuf.st_size; |
address += sbuf.st_size; |
return; |
return; |
} |
} |
} |
} |
if (fseek(stdin, skip, SEEK_SET)) { |
if (fseek(stdin, skip, SEEK_SET)) |
(void)fprintf(stderr, "hexdump: %s: %s.\n", |
err(1, "%s", fname); |
fname, strerror(errno)); |
|
exit(1); |
|
} |
|
savaddress = address += skip; |
savaddress = address += skip; |
skip = 0; |
skip = 0; |
} |
} |
|
|
char *p; |
char *p; |
|
|
if (!(p = malloc((u_int)size))) |
if (!(p = malloc((u_int)size))) |
nomem(); |
err(1, "malloc"); |
bzero(p, size); |
bzero(p, size); |
return(p); |
return(p); |
} |
|
|
|
void |
|
nomem() |
|
{ |
|
(void)fprintf(stderr, "hexdump: %s.\n", strerror(errno)); |
|
exit(1); |
|
} |
} |