1 #include <errno.h> /* for definition of errno */
2 #include <stdarg.h> /* ANSI C header file */
5 static void err_doit(int, const char *, va_list);
7 char *pname
= NULL
; /* caller can set this from argv[0] */
9 /* Nonfatal error related to a system call.
10 * Print a message and return. */
13 err_ret(const char *fmt
, ...)
23 /* Fatal error related to a system call.
24 * Print a message and terminate. */
27 err_sys(const char *fmt
, ...)
37 /* Fatal error related to a system call.
38 * Print a message, dump core, and terminate. */
41 err_dump(const char *fmt
, ...)
48 abort(); /* dump core and terminate */
49 exit(1); /* shouldn't get here */
52 /* Nonfatal error unrelated to a system call.
53 * Print a message and return. */
56 err_msg(const char *fmt
, ...)
66 /* Fatal error unrelated to a system call.
67 * Print a message and terminate. */
70 err_quit(const char *fmt
, ...)
80 /* Print a message and return to caller.
81 * Caller specifies "errnoflag". */
84 err_doit(int errnoflag
, const char *fmt
, va_list ap
)
89 errno_save
= errno
; /* value caller might want printed */
90 vsprintf(buf
, fmt
, ap
);
92 sprintf(buf
+strlen(buf
), ": %s", strerror(errno_save
));
94 fflush(stdout
); /* in case stdout and stderr are the same */
96 fflush(NULL
); /* flushes all stdio output streams */