Annotation of 43BSDReno/libexec/talkd/print.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1983 Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms are permitted
        !             6:  * provided that: (1) source distributions retain this entire copyright
        !             7:  * notice and comment, and (2) distributions including binaries display
        !             8:  * the following acknowledgement:  ``This product includes software
        !             9:  * developed by the University of California, Berkeley and its contributors''
        !            10:  * in the documentation or other materials provided with the distribution
        !            11:  * and in all advertising materials mentioning features or use of this
        !            12:  * software. Neither the name of the University nor the names of its
        !            13:  * contributors may be used to endorse or promote products derived
        !            14:  * from this software without specific prior written permission.
        !            15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            16:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            18:  */
        !            19: 
        !            20: #ifndef lint
        !            21: static char sccsid[] = "@(#)print.c    5.7 (Berkeley) 6/1/90";
        !            22: #endif /* not lint */
        !            23: 
        !            24: /* debug print routines */
        !            25: 
        !            26: #include <stdio.h>
        !            27: #include <syslog.h>
        !            28: #include <sys/param.h>
        !            29: 
        !            30: #include <protocols/talkd.h>
        !            31: 
        !            32: static char *types[] =
        !            33:     { "leave_invite", "look_up", "delete", "announce" };
        !            34: #define        NTYPES  (sizeof (types) / sizeof (types[0]))
        !            35: static char *answers[] = 
        !            36:     { "success", "not_here", "failed", "machine_unknown", "permission_denied",
        !            37:       "unknown_request", "badversion", "badaddr", "badctladdr" };
        !            38: #define        NANSWERS        (sizeof (answers) / sizeof (answers[0]))
        !            39: 
        !            40: print_request(cp, mp)
        !            41:        char *cp;
        !            42:        register CTL_MSG *mp;
        !            43: {
        !            44:        char tbuf[80], *tp;
        !            45:        
        !            46:        if (mp->type > NTYPES) {
        !            47:                (void)sprintf(tbuf, "type %d", mp->type);
        !            48:                tp = tbuf;
        !            49:        } else
        !            50:                tp = types[mp->type];
        !            51:        syslog(LOG_DEBUG, "%s: %s: id %d, l_user %s, r_user %s, r_tty %s",
        !            52:            cp, tp, mp->id_num, mp->l_name, mp->r_name, mp->r_tty);
        !            53: }
        !            54: 
        !            55: print_response(cp, rp)
        !            56:        char *cp;
        !            57:        register CTL_RESPONSE *rp;
        !            58: {
        !            59:        char tbuf[80], *tp, abuf[80], *ap;
        !            60:        
        !            61:        if (rp->type > NTYPES) {
        !            62:                (void)sprintf(tbuf, "type %d", rp->type);
        !            63:                tp = tbuf;
        !            64:        } else
        !            65:                tp = types[rp->type];
        !            66:        if (rp->answer > NANSWERS) {
        !            67:                (void)sprintf(abuf, "answer %d", rp->answer);
        !            68:                ap = abuf;
        !            69:        } else
        !            70:                ap = answers[rp->answer];
        !            71:        syslog(LOG_DEBUG, "%s: %s: %s, id %d", cp, tp, ap, ntohl(rp->id_num));
        !            72: }

unix.superglobalmegacorp.com

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