/*- * Copyright (c) 1992 The Regents of the University of California. * All rights reserved. * * %sccs.include.redist.c% */ #ifndef lint static char sccsid[] = "@(#)misc.c 5.1 (Berkeley) 08/06/92"; #endif /* not lint */ #include #include #include #include #include #include extern char *special; #if __STDC__ #include #else #include #endif void #if __STDC__ err(const int fatal, const char *fmt, ...) #else err(fmt, va_alist) char *fmt; va_dcl #endif { va_list ap; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif (void)fprintf(stderr, "%s: ", special); (void)vfprintf(stderr, fmt, ap); va_end(ap); (void)fprintf(stderr, " %s\n", strerror(errno)); if (fatal) exit(1); } void get(fd, off, p, len) int fd; off_t off; void *p; size_t len; { int rbytes; if (lseek(fd, off, SEEK_SET) < 0) err(1, "%s: %s", special, strerror(errno)); if ((rbytes = read(fd, p, len)) < 0) err(1, "%s: %s", special, strerror(errno)); if (rbytes != len) err(1, "%s: short read (%d, not %d)", special, rbytes, len); }