ANSIfication
[unix-history] / usr / src / libexec / talkd / print.c
CommitLineData
d0aeaf5a
DF
1/*
2 * Copyright (c) 1983 Regents of the University of California.
9e678aa5
KB
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
b8c620d6
KB
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.
d0aeaf5a
DF
16 */
17
963ce42e 18#ifndef lint
b8c620d6 19static char sccsid[] = "@(#)print.c 5.6 (Berkeley) %G%";
9e678aa5 20#endif /* not lint */
1f187e51
MK
21
22/* debug print routines */
23
24#include <stdio.h>
595cdd5e 25#include <syslog.h>
7989a2e7 26#include <sys/param.h>
1f187e51 27
595cdd5e
KM
28#include <protocols/talkd.h>
29
30static char *types[] =
31 { "leave_invite", "look_up", "delete", "announce" };
32#define NTYPES (sizeof (types) / sizeof (types[0]))
33static 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
38print_request(cp, mp)
39 char *cp;
40 register CTL_MSG *mp;
1f187e51 41{
595cdd5e 42 char tbuf[80], *tp;
963ce42e 43
595cdd5e 44 if (mp->type > NTYPES) {
9bd38ba8 45 (void)sprintf(tbuf, "type %d", mp->type);
595cdd5e
KM
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);
1f187e51
MK
51}
52
595cdd5e
KM
53print_response(cp, rp)
54 char *cp;
55 register CTL_RESPONSE *rp;
1f187e51 56{
595cdd5e 57 char tbuf[80], *tp, abuf[80], *ap;
81379f80 58
595cdd5e 59 if (rp->type > NTYPES) {
9bd38ba8 60 (void)sprintf(tbuf, "type %d", rp->type);
595cdd5e
KM
61 tp = tbuf;
62 } else
63 tp = types[rp->type];
64 if (rp->answer > NANSWERS) {
9bd38ba8 65 (void)sprintf(abuf, "answer %d", rp->answer);
595cdd5e
KM
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));
1f187e51 70}