Annotation of researchv10dc/cmd/worm/scsi/tcl/strerror.c, revision 1.1

1.1     ! root        1: /* 
        !             2:  * strerror.c --
        !             3:  *
        !             4:  *     Source code for the "strerror" library routine.
        !             5:  *
        !             6:  * Copyright 1988 Regents of the University of California
        !             7:  * Permission to use, copy, modify, and distribute this
        !             8:  * software and its documentation for any purpose and without
        !             9:  * fee is hereby granted, provided that the above copyright
        !            10:  * notice appear in all copies.  The University of California
        !            11:  * makes no representations about the suitability of this
        !            12:  * software for any purpose.  It is provided "as is" without
        !            13:  * express or implied warranty.
        !            14:  */
        !            15: 
        !            16: #ifndef lint
        !            17: static char rcsid[] = "$Header: /sprite/src/lib/c/string/RCS/strerror.c,v 1.5 89/03/22 16:06:57 rab Exp Locker: shirriff $ SPRITE (Berkeley)";
        !            18: #endif /* not lint */
        !            19: 
        !            20: #include <stdio.h>
        !            21: #include <string.h>
        !            22: 
        !            23: /*
        !            24:  * List of known errors:
        !            25:  */
        !            26: 
        !            27: char *sys_errlist[] = {
        !            28:     "no error (operation succeeded",           /* 0 */
        !            29:     "not owner",                               /* EPERM */
        !            30:     "no such file or directory",               /* ENOENT */
        !            31:     "no such process",                         /* ESRCH */
        !            32:     "interrupted system call",                 /* EINTR */
        !            33:     "I/O error",                               /* EIO */
        !            34:     "no such device or address",               /* ENXIO */
        !            35:     "argument list too long",                  /* E2BIG */
        !            36:     "exec format error",                       /* ENOEXEC */
        !            37:     "bad file number",                         /* EBADF */
        !            38:     "no children",                             /* ECHILD */
        !            39:     "no more processes",                       /* EAGAIN */
        !            40:     "not enough memory",                       /* ENOMEM */
        !            41:     "permission denied",                       /* EACCESS */
        !            42:     "bad address in system call argument",     /* EFAULT */
        !            43:     "block device required",                   /* ENOTBLK */
        !            44:     "mount device busy",                       /* EBUSY */
        !            45:     "file already exists",                     /* EEXIST */
        !            46:     "cross-domain link",                       /* EXDEV */
        !            47:     "no such device",                          /* ENODEV */
        !            48:     "not a directory",                         /* ENOTDIR */
        !            49:     "illegal operation on a directory",                /* EISDIR */
        !            50:     "invalid argument",                                /* EINVAL */
        !            51:     "file table overflow",                     /* ENFILE */
        !            52:     "too many open files",                     /* EMFILE */
        !            53:     "inappropriate device for ioctl",          /* ENOTTY */
        !            54:     "text file or pseudo-device busy",         /* ETXTBSY */
        !            55:     "file too large",                          /* EFBIG */
        !            56:     "no space left in file system domain",     /* ENOSPC */
        !            57:     "illegal seek",                            /* ESPIPE */
        !            58:     "read-only file system",                   /* EROFS */
        !            59:     "too many links",                          /* EMLINK */
        !            60:     "broken pipe",                             /* EPIPE */
        !            61:     "math argument out of range",              /* EDOM */
        !            62:     "math result unrepresentable",             /* ERANGE */
        !            63:     "operation would block",                   /* EWOULDBLOCK */
        !            64:     "operation now in progress",               /* EINPROGRESS */
        !            65:     "operation already in progress",           /* EALREADY */
        !            66:     "socket operation on non-socket",          /* ENOTSOCK */
        !            67:     "destination address required",            /* EDESTADDRREQ */
        !            68:     "message too long",                                /* EMSGSIZE */
        !            69:     "protocol wrong type for socket",          /* EPROTOTYPE */
        !            70:     "bad proocol option",                      /* ENOPROTOOPT */
        !            71:     "protocol not suppored",                   /* EPROTONOSUPPORT */
        !            72:     "socket type not supported",               /* ESOCKTNOSUPPORT */
        !            73:     "operation not supported on socket",       /* EOPNOTSUPP */
        !            74:     "protocol family not supported",           /* EPFNOSUPPORT */
        !            75:     "address family not supported by protocol family", /* EAFNOSUPPORT */
        !            76:     "address already in use",                  /* EADDRINUSE */
        !            77:     "can't assign requested address",          /* EADDRNOTAVAIL */
        !            78:     "network is down",                         /* ENETDOWN */
        !            79:     "network is unreachable",                  /* ENETUNREACH */
        !            80:     "network dropped connection on reset",     /* ENETRESET */
        !            81:     "software caused connection abort",                /* ECONNABORTED */
        !            82:     "connection reset by peer",                        /* ECONNRESET */
        !            83:     "no buffer space available",               /* ENOBUFS */
        !            84:     "socket is already connected",             /* EISCONN */
        !            85:     "socket is not connected",                 /* ENOTCONN */
        !            86:     "can't send afer socket shutdown",         /* ESHUTDOWN */
        !            87:     "undefined error (59)",                    /* not used */
        !            88:     "connection timed out",                    /* ETIMEDOUT */
        !            89:     "connection refused",                      /* ECONNREFUSED */
        !            90:     "too many levels of symbolic links",       /* ELOOP */
        !            91:     "file name too long",                      /* ENAMETOOLONG */
        !            92:     "host is down",                            /* EHOSTDOWN */
        !            93:     "host is unreachable",                     /* EHOSTUNREACH */
        !            94:     "directory not empty",                     /* ENOTEMPTY */
        !            95:     "too many processes",                      /* EPROCLIM */
        !            96:     "too many users",                          /* EUSERS */
        !            97:     "disk quota exceeded",                     /* EDQUOT */
        !            98:     "stale remote file handle",                        /* ESTALE */
        !            99:     "pathname hit remote file system",         /* EREMOTE */
        !           100:     "undefined error (72)",                    /* not used */
        !           101:     "undefined error (73)",                    /* not used */
        !           102:     "undefined error (74)",                    /* not used */
        !           103:     "undefined error (75)",                    /* not used */
        !           104:     "undefined error (76)",                    /* not used */
        !           105:     "identifier removed",                      /* EIDRM */
        !           106: };
        !           107: int sys_nerr = sizeof(sys_errlist)/sizeof(char *);
        !           108: 
        !           109: /*
        !           110:  *----------------------------------------------------------------------
        !           111:  *
        !           112:  * strerror --
        !           113:  *
        !           114:  *     Map an integer error number into a printable string.
        !           115:  *
        !           116:  * Results:
        !           117:  *     The return value is a pointer to a string describing
        !           118:  *     error.  The first character of string isn't capitalized.
        !           119:  *
        !           120:  * Side effects:
        !           121:  *     Each call to this procedure may overwrite the value returned
        !           122:  *     by the previous call.
        !           123:  *
        !           124:  *----------------------------------------------------------------------
        !           125:  */
        !           126: 
        !           127: char *
        !           128: strerror(error)
        !           129:     int error;                 /* Integer identifying error (must be
        !           130:                                 * one of the officially-defined Sprite
        !           131:                                 * errors, as defined in errno.h). */
        !           132: {
        !           133:     static char defaultMsg[50];
        !           134: 
        !           135:     if ((error <= sys_nerr) && (error > 0)) {
        !           136:        return sys_errlist[error];
        !           137:     }
        !           138:     (void) sprintf(defaultMsg, "unknown error (%d)", error);
        !           139:     return defaultMsg;
        !           140: }

unix.superglobalmegacorp.com

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