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