Annotation of 43BSDTahoe/lib/libc/gen/perror.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1980 Regents of the University of California.
        !             3:  * All rights reserved.  The Berkeley software License Agreement
        !             4:  * specifies the terms and conditions for redistribution.
        !             5:  */
        !             6: 
        !             7: #if defined(LIBC_SCCS) && !defined(lint)
        !             8: static char sccsid[] = "@(#)perror.c   5.3 (Berkeley) 9/30/87";
        !             9: #endif LIBC_SCCS and not lint
        !            10: 
        !            11: /*
        !            12:  * Print the error indicated
        !            13:  * in the cerror cell.
        !            14:  */
        !            15: #include <sys/types.h>
        !            16: #include <sys/uio.h>
        !            17: 
        !            18: int    errno;
        !            19: extern int     sys_nerr;
        !            20: extern char    *sys_errlist[];
        !            21: perror(s)
        !            22:        char *s;
        !            23: {
        !            24:        struct iovec iov[4];
        !            25:        register struct iovec *v = iov;
        !            26: 
        !            27:        if (s && *s) {
        !            28:                v->iov_base = s;
        !            29:                v->iov_len = strlen(s);
        !            30:                v++;
        !            31:                v->iov_base = ": ";
        !            32:                v->iov_len = 2;
        !            33:                v++;
        !            34:        }
        !            35:        v->iov_base = errno < sys_nerr ? sys_errlist[errno] : "Unknown error";
        !            36:        v->iov_len = strlen(v->iov_base);
        !            37:        v++;
        !            38:        v->iov_base = "\n";
        !            39:        v->iov_len = 1;
        !            40:        writev(2, iov, (v - iov) + 1);
        !            41: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.