OSDN Git Service

Fix no pic
[uclinux-h8/uClinux-dist.git] / user / at / panic.c
1 /* 
2  *  panic.c - terminate fast in case of error
3  *  Copyright (C) 1993  Thomas Koenig
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 /* System Headers */
25
26 #ifdef HAVE_ERRNO_H
27 #include <errno.h>
28 #endif
29
30 #include <stdio.h>
31 #include <stdlib.h>
32
33 #ifdef HAVE_UNISTD_H
34 #include <unistd.h>
35 #endif
36
37 #ifdef HAVE_STDARG_H
38 #include <stdarg.h>
39 #endif
40
41 /* Local headers */
42
43 #include "panic.h"
44 #include "at.h"
45
46 /* File scope variables */
47
48 static char rcsid[] = "$Id: panic.c,v 1.4 1997/03/12 19:36:05 ig25 Exp $";
49
50 /* External variables */
51
52 /* Global functions */
53
54 void
55 panic(char *a)
56 {
57 /* Something fatal has happened, print error message and exit.
58  */
59     fprintf(stderr, "%s: %s\n", namep, a);
60     if (fcreated)
61         unlink(atfile);
62
63     exit(EXIT_FAILURE);
64 }
65
66 void
67 perr(const char *fmt,...)
68 {
69 /* Some operating system error; print error message and exit.
70  */
71     char buf[1024];
72     va_list args;
73
74     va_start(args, fmt);
75     vsprintf(buf, fmt, args);
76     va_end(args);
77
78     perror(buf);
79     if (fcreated)
80         unlink(atfile);
81
82     exit(EXIT_FAILURE);
83 }
84
85 void
86 usage(void)
87 {
88 /* Print usage and exit.
89  */
90     fprintf(stderr, "Usage: at [-V] [-q x] [-f file] [-m] time\n"
91             "       atq [-V] [-q x] [-v]\n"
92             "       atrm [-V] [-q x] job ...\n"
93             "       batch [-V] [-f file] [-m]\n");
94     exit(EXIT_FAILURE);
95 }