|
|
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 the above copyright notice and this paragraph are
7: * duplicated in all such forms and that any documentation,
8: * advertising materials, and other materials related to such
9: * distribution and use acknowledge that the software was developed
10: * by the University of California, Berkeley. The name of the
11: * University may not be used to endorse or promote products derived
12: * from this software without specific prior written permission.
13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16: */
17:
18: #ifndef lint
19: static char sccsid[] = "@(#)print.c 5.6 (Berkeley) 6/18/88";
20: #endif /* not lint */
21:
22: /* debug print routines */
23:
24: #include <stdio.h>
25: #include <syslog.h>
26: #include <sys/param.h>
27:
28: #include <protocols/talkd.h>
29:
30: static char *types[] =
31: { "leave_invite", "look_up", "delete", "announce" };
32: #define NTYPES (sizeof (types) / sizeof (types[0]))
33: static char *answers[] =
34: { "success", "not_here", "failed", "machine_unknown", "permission_denied",
35: "unknown_request", "badversion", "badaddr", "badctladdr" };
36: #define NANSWERS (sizeof (answers) / sizeof (answers[0]))
37:
38: print_request(cp, mp)
39: char *cp;
40: register CTL_MSG *mp;
41: {
42: char tbuf[80], *tp;
43:
44: if (mp->type > NTYPES) {
45: (void)sprintf(tbuf, "type %d", mp->type);
46: tp = tbuf;
47: } else
48: tp = types[mp->type];
49: syslog(LOG_DEBUG, "%s: %s: id %d, l_user %s, r_user %s, r_tty %s",
50: cp, tp, mp->id_num, mp->l_name, mp->r_name, mp->r_tty);
51: }
52:
53: print_response(cp, rp)
54: char *cp;
55: register CTL_RESPONSE *rp;
56: {
57: char tbuf[80], *tp, abuf[80], *ap;
58:
59: if (rp->type > NTYPES) {
60: (void)sprintf(tbuf, "type %d", rp->type);
61: tp = tbuf;
62: } else
63: tp = types[rp->type];
64: if (rp->answer > NANSWERS) {
65: (void)sprintf(abuf, "answer %d", rp->answer);
66: ap = abuf;
67: } else
68: ap = answers[rp->answer];
69: syslog(LOG_DEBUG, "%s: %s: %s, id %d", cp, tp, ap, ntohl(rp->id_num));
70: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.