Use the argument as a file name only if no section was specified.
[dragonfly.git] / usr.bin / tconv / quit.c
blob92de609ec65ef1fa0e93fe5f26958be94434d69b
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/Attic/quit.c,v 1.2 2003/10/04 20: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);