panic.c revision 1.2 1 /* $NetBSD: panic.c,v 1.2 1995/03/25 18:13:33 glass Exp $ */
2
3 /*
4 * panic.c - terminate fast in case of error
5 * Copyright (c) 1993 by Thomas Koenig
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. The name of the author(s) may not be used to endorse or promote
14 * products derived from this software without specific prior written
15 * permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 /* System Headers */
30
31 #include <errno.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <unistd.h>
35
36 /* Local headers */
37
38 #include "panic.h"
39 #include "at.h"
40
41 /* File scope variables */
42
43 #ifndef lint
44 static char rcsid[] = "$NetBSD: panic.c,v 1.2 1995/03/25 18:13:33 glass Exp $";
45 #endif
46
47 /* External variables */
48
49 /* Global functions */
50
51 void
52 panic(a)
53 char *a;
54 {
55 /* Something fatal has happened, print error message and exit.
56 */
57 fprintf(stderr, "%s: %s\n", namep, a);
58 if (fcreated)
59 unlink(atfile);
60
61 exit(EXIT_FAILURE);
62 }
63
64 void
65 perr(a)
66 char *a;
67 {
68 /* Some operating system error; print error message and exit.
69 */
70 perror(a);
71 if (fcreated)
72 unlink(atfile);
73
74 exit(EXIT_FAILURE);
75 }
76
77 void
78 perr2(a, b)
79 char *a, *b;
80 {
81 fprintf(stderr, "%s", a);
82 perr(b);
83 }
84
85 void
86 usage(void)
87 {
88 /* Print usage and exit.
89 */
90 fprintf(stderr, "Usage: at [-q x] [-f file] [-m] time\n"
91 " atq [-q x] [-v]\n"
92 " atrm [-q x] job ...\n"
93 " batch [-f file] [-m]\n");
94 exit(EXIT_FAILURE);
95 }
96