1d78e98d2SNate Williams /* 2d78e98d2SNate Williams * panic.c - terminate fast in case of error 3b89321a5SAndrey A. Chernov * Copyright (C) 1993 Thomas Koenig 4d78e98d2SNate Williams * 5d78e98d2SNate Williams * Redistribution and use in source and binary forms, with or without 6d78e98d2SNate Williams * modification, are permitted provided that the following conditions 7d78e98d2SNate Williams * are met: 8d78e98d2SNate Williams * 1. Redistributions of source code must retain the above copyright 9d78e98d2SNate Williams * notice, this list of conditions and the following disclaimer. 10d78e98d2SNate Williams * 2. The name of the author(s) may not be used to endorse or promote 11d78e98d2SNate Williams * products derived from this software without specific prior written 12d78e98d2SNate Williams * permission. 13d78e98d2SNate Williams * 14d78e98d2SNate Williams * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15d78e98d2SNate Williams * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16d78e98d2SNate Williams * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17d78e98d2SNate Williams * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18d78e98d2SNate Williams * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19d78e98d2SNate Williams * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20d78e98d2SNate Williams * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21d78e98d2SNate Williams * THEORY OF LIABILITY, WETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22d78e98d2SNate Williams * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23d78e98d2SNate Williams * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24d78e98d2SNate Williams */ 25d78e98d2SNate Williams 26d78e98d2SNate Williams /* System Headers */ 27d78e98d2SNate Williams 28d78e98d2SNate Williams #include <errno.h> 29d78e98d2SNate Williams #include <stdio.h> 30d78e98d2SNate Williams #include <stdlib.h> 31d78e98d2SNate Williams #include <unistd.h> 32d78e98d2SNate Williams 33d78e98d2SNate Williams /* Local headers */ 34d78e98d2SNate Williams 35d78e98d2SNate Williams #include "panic.h" 36d78e98d2SNate Williams #include "at.h" 37d78e98d2SNate Williams 38d78e98d2SNate Williams /* File scope variables */ 39d78e98d2SNate Williams 40b89321a5SAndrey A. Chernov static char rcsid[] = "$Id: panic.c,v 1.1 1994/05/10 18:23:08 kernel Exp $"; 41d78e98d2SNate Williams 42d78e98d2SNate Williams /* External variables */ 43d78e98d2SNate Williams 44d78e98d2SNate Williams /* Global functions */ 45d78e98d2SNate Williams 46d78e98d2SNate Williams void 47b89321a5SAndrey A. Chernov panic(char *a) 48d78e98d2SNate Williams { 49d78e98d2SNate Williams /* Something fatal has happened, print error message and exit. 50d78e98d2SNate Williams */ 51d78e98d2SNate Williams fprintf(stderr,"%s: %s\n",namep,a); 52d78e98d2SNate Williams if (fcreated) 53d78e98d2SNate Williams unlink(atfile); 54d78e98d2SNate Williams 55d78e98d2SNate Williams exit (EXIT_FAILURE); 56d78e98d2SNate Williams } 57d78e98d2SNate Williams 58d78e98d2SNate Williams void 59b89321a5SAndrey A. Chernov perr(char *a) 60d78e98d2SNate Williams { 61d78e98d2SNate Williams /* Some operating system error; print error message and exit. 62d78e98d2SNate Williams */ 63d78e98d2SNate Williams perror(a); 64d78e98d2SNate Williams if (fcreated) 65d78e98d2SNate Williams unlink(atfile); 66d78e98d2SNate Williams 67d78e98d2SNate Williams exit(EXIT_FAILURE); 68d78e98d2SNate Williams } 69d78e98d2SNate Williams 70d78e98d2SNate Williams void 71d78e98d2SNate Williams usage(void) 72d78e98d2SNate Williams { 73d78e98d2SNate Williams /* Print usage and exit. 74d78e98d2SNate Williams */ 75b89321a5SAndrey A. Chernov fprintf(stderr, "Usage: at [-V] [-q x] [-f file] [-m] time\n" 76b89321a5SAndrey A. Chernov " atq [-V] [-q x] [-v]\n" 77b89321a5SAndrey A. Chernov " atrm [-V] [-q x] job ...\n" 78b89321a5SAndrey A. Chernov " batch [-V] [-f file] [-m]\n"); 79d78e98d2SNate Williams exit(EXIT_FAILURE); 80d78e98d2SNate Williams } 81