[BACK]Return to panic.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / at

Annotation of src/usr.bin/at/panic.c, Revision 1.6

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