version 1.3, 1997/07/25 21:05:45 |
version 1.4, 1997/07/25 22:13:24 |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
#include <err.h> |
#include "extern.h" |
#include "extern.h" |
|
|
void |
void |
|
|
char buf[1024]; |
char buf[1024]; |
|
|
if ((fd = open(file, O_RDONLY, 0)) < 0) |
if ((fd = open(file, O_RDONLY, 0)) < 0) |
err("%s: %s", file, strerror(errno)); |
err(1, file); |
|
|
while ((nr = read(fd, buf, sizeof(buf))) > 0) |
while ((nr = read(fd, buf, sizeof(buf))) > 0) |
if ((nw = write(STDERR_FILENO, buf, nr)) == -1) |
if ((nw = write(STDERR_FILENO, buf, nr)) == -1) |
err("write to stderr: %s", strerror(errno)); |
err(1, "write to stderr"); |
if (nr != 0) |
if (nr != 0) |
err("%s: %s", file, strerror(errno)); |
err(1, file); |
(void)close(fd); |
(void)close(fd); |
} |
} |
|
|
|
|
int c; |
int c; |
{ |
{ |
(void)putc(c, stderr); |
(void)putc(c, stderr); |
} |
|
|
|
#ifdef __STDC__ |
|
#include <stdarg.h> |
|
#else |
|
#include <varargs.h> |
|
#endif |
|
|
|
void |
|
#ifdef __STDC__ |
|
err(const char *fmt, ...) |
|
#else |
|
err(fmt, va_alist) |
|
char *fmt; |
|
va_dcl |
|
#endif |
|
{ |
|
va_list ap; |
|
#ifdef __STDC__ |
|
va_start(ap, fmt); |
|
#else |
|
va_start(ap); |
|
#endif |
|
(void)fprintf(stderr, "tset: "); |
|
(void)vfprintf(stderr, fmt, ap); |
|
va_end(ap); |
|
(void)fprintf(stderr, "\n"); |
|
exit(1); |
|
/* NOTREACHED */ |
|
} |
} |