1 /*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8 #ifndef lint
9 static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 06/04/93";
10 #endif /* not lint */
11
12 /* debug print routines */
13
14 #include <sys/types.h>
15 #include <sys/socket.h>
16 #include <protocols/talkd.h>
17 #include <syslog.h>
18 #include <stdio.h>
19
20 static char *types[] =
21 { "leave_invite", "look_up", "delete", "announce" };
22 #define NTYPES (sizeof (types) / sizeof (types[0]))
23 static char *answers[] =
24 { "success", "not_here", "failed", "machine_unknown", "permission_denied",
25 "unknown_request", "badversion", "badaddr", "badctladdr" };
26 #define NANSWERS (sizeof (answers) / sizeof (answers[0]))
27
print_request(cp,mp)28 print_request(cp, mp)
29 char *cp;
30 register CTL_MSG *mp;
31 {
32 char tbuf[80], *tp;
33
34 if (mp->type > NTYPES) {
35 (void)sprintf(tbuf, "type %d", mp->type);
36 tp = tbuf;
37 } else
38 tp = types[mp->type];
39 syslog(LOG_DEBUG, "%s: %s: id %d, l_user %s, r_user %s, r_tty %s",
40 cp, tp, mp->id_num, mp->l_name, mp->r_name, mp->r_tty);
41 }
42
print_response(cp,rp)43 print_response(cp, rp)
44 char *cp;
45 register CTL_RESPONSE *rp;
46 {
47 char tbuf[80], *tp, abuf[80], *ap;
48
49 if (rp->type > NTYPES) {
50 (void)sprintf(tbuf, "type %d", rp->type);
51 tp = tbuf;
52 } else
53 tp = types[rp->type];
54 if (rp->answer > NANSWERS) {
55 (void)sprintf(abuf, "answer %d", rp->answer);
56 ap = abuf;
57 } else
58 ap = answers[rp->answer];
59 syslog(LOG_DEBUG, "%s: %s: %s, id %d", cp, tp, ap, ntohl(rp->id_num));
60 }
61