1 /* -*- c-basic-offset: 8; -*- */
2 #include <errno.h> /* for definition of errno */
3 #include <stdarg.h> /* ANSI C header file */
6 static void err_doit(int, const char *, va_list);
8 char *pname
= NULL
; /* caller can set this from argv[0] */
10 /* Nonfatal error related to a system call.
11 * Print a message and return. */
15 err_ret(const char *fmt
, ...)
25 /* Fatal error related to a system call.
26 * Print a message and terminate. */
30 err_sys(const char *fmt
, ...)
40 /* Fatal error related to a system call.
41 * Print a message, dump core, and terminate. */
45 err_dump(const char *fmt
, ...)
52 abort(); /* dump core and terminate */
53 exit(1); /* shouldn't get here */
56 /* Nonfatal error unrelated to a system call.
57 * Print a message and return. */
61 err_msg(const char *fmt
, ...)
71 /* Fatal error unrelated to a system call.
72 * Print a message and terminate. */
76 err_quit(const char *fmt
, ...)
86 /* Print a message and return to caller.
87 * Caller specifies "errnoflag". */
90 err_doit(int errnoflag
, const char *fmt
, va_list ap
)
95 errno_save
= errno
; /* value caller might want printed */
96 vsprintf(buf
, fmt
, ap
);
98 sprintf(buf
+strlen(buf
), ": %s", strerror(errno_save
));
100 fflush(stdout
); /* in case stdout and stderr are the same */
102 fflush(stderr
); /* SunOS 4.1.* doesn't grok NULL argument */