panic.c revision 7767
17767Sache/*
27767Sache *  panic.c - terminate fast in case of error
37767Sache *  Copyright (C) 1993  Thomas Koenig
4941Snate *
5941Snate * Redistribution and use in source and binary forms, with or without
6941Snate * modification, are permitted provided that the following conditions
7941Snate * are met:
8941Snate * 1. Redistributions of source code must retain the above copyright
9941Snate *    notice, this list of conditions and the following disclaimer.
10941Snate * 2. The name of the author(s) may not be used to endorse or promote
11941Snate *    products derived from this software without specific prior written
12941Snate *    permission.
13941Snate *
14941Snate * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15941Snate * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16941Snate * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17941Snate * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18941Snate * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19941Snate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20941Snate * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21941Snate * THEORY OF LIABILITY, WETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22941Snate * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23941Snate * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24941Snate */
25941Snate
26941Snate/* System Headers */
27941Snate
28941Snate#include <errno.h>
29941Snate#include <stdio.h>
30941Snate#include <stdlib.h>
31941Snate#include <unistd.h>
32941Snate
33941Snate/* Local headers */
34941Snate
35941Snate#include "panic.h"
36941Snate#include "at.h"
37941Snate
38941Snate/* File scope variables */
39941Snate
407767Sachestatic char rcsid[] = "$Id: panic.c,v 1.1 1994/05/10 18:23:08 kernel Exp $";
41941Snate
42941Snate/* External variables */
43941Snate
44941Snate/* Global functions */
45941Snate
46941Snatevoid
477767Sachepanic(char *a)
48941Snate{
49941Snate/* Something fatal has happened, print error message and exit.
50941Snate */
517767Sache	fprintf(stderr,"%s: %s\n",namep,a);
52941Snate	if (fcreated)
53941Snate		unlink(atfile);
54941Snate
557767Sache	exit (EXIT_FAILURE);
56941Snate}
57941Snate
58941Snatevoid
597767Sacheperr(char *a)
60941Snate{
61941Snate/* Some operating system error; print error message and exit.
62941Snate */
63941Snate	perror(a);
64941Snate	if (fcreated)
65941Snate		unlink(atfile);
66941Snate
67941Snate	exit(EXIT_FAILURE);
68941Snate}
69941Snate
70941Snatevoid
71941Snateusage(void)
72941Snate{
73941Snate/* Print usage and exit.
74941Snate*/
757767Sache    fprintf(stderr, "Usage: at [-V] [-q x] [-f file] [-m] time\n"
767767Sache		    "       atq [-V] [-q x] [-v]\n"
777767Sache		    "       atrm [-V] [-q x] job ...\n"
787767Sache		    "       batch [-V] [-f file] [-m]\n");
797767Sache    exit(EXIT_FAILURE);
80941Snate}
81