Fix compiler warnings; include <sys/types.h> and <netinet/in.h> to satisfy
[dragonfly.git] / usr.bin / tconv / quit.c
1 /*
2  * quit.c
3  *
4  * By Ross Ridge
5  * Public Domain
6  * 92/02/01 07:30:14
7  *
8  * quit with a diagnostic message printed on stderr
9  *
10  * $DragonFly: src/usr.bin/tconv/Attic/quit.c,v 1.2 2003/10/04 20:36:52 hmp Exp $
11  */
12
13 #define NOTLIB
14 #include "defs.h"
15
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
19
20 char *prg_name;
21
22 #if defined(USE_PROTOTYPES) && !defined(lint)
23 void (*cleanup)(int);
24 #else
25 void (*cleanup)();
26 #endif
27
28 /* PRINTFLIKE2 */
29 noreturn
30 void
31 quit(int e, char *fmt, ...)
32 {
33         va_list ap;
34
35         va_start(ap, fmt);
36
37         (*cleanup)(e);
38
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]);
49         }
50         fflush(stderr);
51         exit(e);
52 }