Annotation of 43BSDReno/kerberosIV/compile_et/perror.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright 1987 by MIT Student Information Processing Board
        !             3:  *
        !             4:  * For copyright info, see mit-sipb-copyright.h.
        !             5:  */
        !             6: 
        !             7: #include <stdio.h>
        !             8: #include <sys/types.h>
        !             9: #include <sys/uio.h>
        !            10: #include "error_table.h"
        !            11: #include "mit-sipb-copyright.h"
        !            12: 
        !            13: typedef int (*int_func)();
        !            14: 
        !            15: #if defined(mips) && defined(ultrix)
        !            16: int errno;             /* this is needed to keep the loader from complaining */
        !            17: #endif
        !            18: 
        !            19: int_func com_err_hook = (int_func) NULL;
        !            20: char *error_message();
        !            21: 
        !            22: void
        !            23: com_err(whoami, code, message)
        !            24:        char *whoami;
        !            25:        int code;
        !            26:        char *message;
        !            27: {
        !            28:        struct iovec strings[6];
        !            29: 
        !            30:        if (com_err_hook) {
        !            31:                (*com_err_hook)(whoami, code, message);
        !            32:                return;
        !            33:        }
        !            34: 
        !            35:        strings[0].iov_base = whoami;
        !            36:        strings[0].iov_len = strlen(whoami);
        !            37:        if (whoami) {
        !            38:                strings[1].iov_base = ": ";
        !            39:                strings[1].iov_len = 2;
        !            40:        } else
        !            41:                strings[1].iov_len = 0;
        !            42:        if (code) {
        !            43:                register char *errmsg = error_message(code);
        !            44:                strings[2].iov_base = errmsg;
        !            45:                strings[2].iov_len = strlen(errmsg);
        !            46:        } else
        !            47:                strings[2].iov_len = 0;
        !            48:        strings[3].iov_base = " ";
        !            49:        strings[3].iov_len = 1;
        !            50:        strings[4].iov_base = message;
        !            51:        strings[4].iov_len = strlen(message);
        !            52:        strings[5].iov_base = "\n";
        !            53:        strings[5].iov_len = 1;
        !            54:        (void) writev(2, strings, 6);
        !            55: }
        !            56: 
        !            57: int_func
        !            58: set_com_err_hook(new_proc)
        !            59:        int_func new_proc;
        !            60: {
        !            61:        register int_func x = com_err_hook;
        !            62:        com_err_hook = new_proc;
        !            63:        return (x);
        !            64: }
        !            65: 
        !            66: reset_com_err_hook()
        !            67: {
        !            68:        com_err_hook = (int_func) NULL;
        !            69: }
        !            70: 
        !            71: void
        !            72: perror(msg)
        !            73:        register char *msg;
        !            74: {
        !            75:        com_err(msg, errno, (char *)NULL);
        !            76: }

unix.superglobalmegacorp.com

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