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