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