update 'bread error' message, attempt read a sector at a time after error,
[unix-history] / usr / src / libexec / talkd / print.c
CommitLineData
d0aeaf5a
DF
1/*
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
963ce42e 7#ifndef lint
9bd38ba8 8static char sccsid[] = "@(#)print.c 5.4 (Berkeley) %G%";
d0aeaf5a 9#endif not lint
1f187e51
MK
10
11/* debug print routines */
12
13#include <stdio.h>
595cdd5e 14#include <syslog.h>
7989a2e7 15#include <sys/param.h>
1f187e51 16
595cdd5e
KM
17#include <protocols/talkd.h>
18
19static char *types[] =
20 { "leave_invite", "look_up", "delete", "announce" };
21#define NTYPES (sizeof (types) / sizeof (types[0]))
22static char *answers[] =
23 { "success", "not_here", "failed", "machine_unknown", "permission_denied",
24 "unknown_request", "badversion", "badaddr", "badctladdr" };
25#define NANSWERS (sizeof (answers) / sizeof (answers[0]))
26
27print_request(cp, mp)
28 char *cp;
29 register CTL_MSG *mp;
1f187e51 30{
595cdd5e 31 char tbuf[80], *tp;
963ce42e 32
595cdd5e 33 if (mp->type > NTYPES) {
9bd38ba8 34 (void)sprintf(tbuf, "type %d", mp->type);
595cdd5e
KM
35 tp = tbuf;
36 } else
37 tp = types[mp->type];
38 syslog(LOG_DEBUG, "%s: %s: id %d, l_user %s, r_user %s, r_tty %s",
39 cp, tp, mp->id_num, mp->l_name, mp->r_name, mp->r_tty);
1f187e51
MK
40}
41
595cdd5e
KM
42print_response(cp, rp)
43 char *cp;
44 register CTL_RESPONSE *rp;
1f187e51 45{
595cdd5e 46 char tbuf[80], *tp, abuf[80], *ap;
81379f80 47
595cdd5e 48 if (rp->type > NTYPES) {
9bd38ba8 49 (void)sprintf(tbuf, "type %d", rp->type);
595cdd5e
KM
50 tp = tbuf;
51 } else
52 tp = types[rp->type];
53 if (rp->answer > NANSWERS) {
9bd38ba8 54 (void)sprintf(abuf, "answer %d", rp->answer);
595cdd5e
KM
55 ap = abuf;
56 } else
57 ap = answers[rp->answer];
58 syslog(LOG_DEBUG, "%s: %s: %s, id %d", cp, tp, ap, ntohl(rp->id_num));
1f187e51 59}