110154Sache/* 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. 1710154Sache * IN NO EVENT SHALL THE AUTHOR(S) 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 2687230Smarkm#include <sys/cdefs.h> 2787230Smarkm__FBSDID("$FreeBSD$"); 2887230Smarkm 29941Snate/* System Headers */ 30941Snate 3154158Scharnier#include <err.h> 32941Snate#include <errno.h> 33941Snate#include <stdio.h> 34941Snate#include <stdlib.h> 35941Snate#include <unistd.h> 36941Snate 37941Snate/* Local headers */ 38941Snate 39941Snate#include "panic.h" 4082973Sru#include "privs.h" 41941Snate#include "at.h" 42941Snate 43941Snate/* External variables */ 44941Snate 45941Snate/* Global functions */ 46941Snate 47941Snatevoid 4887208Smarkmpanic(const char *a) 49941Snate{ 50941Snate/* Something fatal has happened, print error message and exit. 51941Snate */ 5282973Sru if (fcreated) { 5382973Sru PRIV_START 54941Snate unlink(atfile); 5582973Sru PRIV_END 5682973Sru } 57941Snate 5854158Scharnier errx(EXIT_FAILURE, "%s", a); 59941Snate} 60941Snate 61941Snatevoid 6287208Smarkmperr(const char *a) 63941Snate{ 64941Snate/* Some operating system error; print error message and exit. 65941Snate */ 6654158Scharnier int serrno = errno; 6754158Scharnier 6882973Sru if (fcreated) { 6982973Sru PRIV_START 70941Snate unlink(atfile); 7182973Sru PRIV_END 7282973Sru } 73941Snate 7454158Scharnier errno = serrno; 7554158Scharnier err(EXIT_FAILURE, "%s", a); 76941Snate} 77941Snate 78941Snatevoid 79941Snateusage(void) 80941Snate{ 8126835Scharnier /* Print usage and exit. */ 8289633Smike fprintf(stderr, "usage: at [-q x] [-f file] [-m] time\n" 8389633Smike " at -c job [job ...]\n" 8489633Smike " at [-f file] -t [[CC]YY]MMDDhhmm[.SS]\n" 8589633Smike " at -r job [job ...]\n" 8696701Stjr " at -l -q queuename\n" 8796701Stjr " at -l [job ...]\n" 8889633Smike " atq [-q x] [-v]\n" 8989633Smike " atrm job [job ...]\n" 9089633Smike " batch [-f file] [-m]\n"); 917767Sache exit(EXIT_FAILURE); 92941Snate} 93