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