More minor IPI work.
[dragonfly/vkernel-mp.git] / usr.bin / tconv / quit.c
blob67a2662ec9fd663d986a6f58105a7f63824a87fe
1 /*
2 * quit.c
4 * By Ross Ridge
5 * Public Domain
6 * 92/02/01 07:30:14
8 * quit with a diagnostic message printed on stderr
10 * $DragonFly: src/usr.bin/tconv/quit.c,v 1.2 2003/10/04 22:36:52 hmp Exp $
13 #define NOTLIB
14 #include "defs.h"
16 #ifdef USE_SCCS_IDS
17 static const char SCCSid[] = "@(#) mytinfo quit.c 3.2 92/02/01 public domain, By Ross Ridge";
18 #endif
20 char *prg_name;
22 #if defined(USE_PROTOTYPES) && !defined(lint)
23 void (*cleanup)(int);
24 #else
25 void (*cleanup)();
26 #endif
28 /* PRINTFLIKE2 */
29 noreturn
30 void
31 quit(int e, char *fmt, ...)
33 va_list ap;
35 va_start(ap, fmt);
37 (*cleanup)(e);
39 if (e != 0)
40 fprintf(stderr, "%s: ", prg_name);
41 #ifdef USE_DOPRNT
42 _doprnt(fmt, ap, stderr);
43 #else
44 vfprintf(stderr, fmt, ap);
45 #endif
46 putc('\n', stderr);
47 if (e > 0 && e < sys_nerr) {
48 fprintf(stderr, "%d - %s\n", e, sys_errlist[e]);
50 fflush(stderr);
51 exit(e);