]> git.saurik.com Git - apple/system_cmds.git/blob - at.tproj/panic.c
b4d8b760da9bebbfa272344977c1cb33a539c43f
[apple/system_cmds.git] / at.tproj / panic.c
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * panic.c - terminate fast in case of error
27 * Copyright (c) 1993 by Thomas Koenig
28 * All rights reserved.
29 *
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
32 * are met:
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * 2. The name of the author(s) may not be used to endorse or promote
36 * products derived from this software without specific prior written
37 * permission.
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
40 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
41 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
42 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
43 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
45 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
46 * THEORY OF LIABILITY, WETHER IN CONTRACT, STRICT LIABILITY, OR TORT
47 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
48 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 */
50
51 /* System Headers */
52
53 #include <errno.h>
54 #include <stdio.h>
55 #include <stdlib.h>
56 #include <unistd.h>
57
58 /* Local headers */
59
60 #include "panic.h"
61 #include "at.h"
62
63 /* File scope variables */
64
65 static char rcsid[] = "$Id: panic.c,v 1.1.1.2 2000/01/11 02:10:05 wsanchez Exp $";
66
67 /* External variables */
68
69 /* Global functions */
70
71 #ifdef __APPLE__
72 __private_extern__
73 #endif
74 void
75 panic(a)
76 char *a;
77 {
78 /* Something fatal has happened, print error message and exit.
79 */
80 fprintf(stderr, "%s: %s\n", namep, a);
81 if (fcreated)
82 unlink(atfile);
83
84 exit(EXIT_FAILURE);
85 }
86
87 void
88 perr(a)
89 char *a;
90 {
91 /* Some operating system error; print error message and exit.
92 */
93 perror(a);
94 if (fcreated)
95 unlink(atfile);
96
97 exit(EXIT_FAILURE);
98 }
99
100 void
101 perr2(a, b)
102 char *a, *b;
103 {
104 fprintf(stderr, "%s", a);
105 perr(b);
106 }
107
108 void
109 usage(void)
110 {
111 /* Print usage and exit.
112 */
113 fprintf(stderr, "Usage: at [-q x] [-f file] [-m] time\n"
114 " atq [-q x] [-v]\n"
115 " atrm [-q x] job ...\n"
116 " batch [-f file] [-m]\n");
117 exit(EXIT_FAILURE);
118 }