Commit | Line | Data |
---|---|---|
d0aeaf5a DF |
1 | /* |
2 | * Copyright (c) 1983 Regents of the University of California. | |
9e678aa5 KB |
3 | * All rights reserved. |
4 | * | |
836fe169 | 5 | * %sccs.include.redist.c% |
d0aeaf5a DF |
6 | */ |
7 | ||
963ce42e | 8 | #ifndef lint |
b26f7bc4 | 9 | static char sccsid[] = "@(#)print.c 5.8 (Berkeley) %G%"; |
9e678aa5 | 10 | #endif /* not lint */ |
1f187e51 MK |
11 | |
12 | /* debug print routines */ | |
13 | ||
b26f7bc4 KB |
14 | #include <sys/types.h> |
15 | #include <sys/socket.h> | |
595cdd5e | 16 | #include <protocols/talkd.h> |
b26f7bc4 KB |
17 | #include <syslog.h> |
18 | #include <stdio.h> | |
595cdd5e KM |
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 | ||
28 | print_request(cp, mp) | |
29 | char *cp; | |
30 | register CTL_MSG *mp; | |
1f187e51 | 31 | { |
595cdd5e | 32 | char tbuf[80], *tp; |
963ce42e | 33 | |
595cdd5e | 34 | if (mp->type > NTYPES) { |
9bd38ba8 | 35 | (void)sprintf(tbuf, "type %d", mp->type); |
595cdd5e KM |
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); | |
1f187e51 MK |
41 | } |
42 | ||
595cdd5e KM |
43 | print_response(cp, rp) |
44 | char *cp; | |
45 | register CTL_RESPONSE *rp; | |
1f187e51 | 46 | { |
595cdd5e | 47 | char tbuf[80], *tp, abuf[80], *ap; |
81379f80 | 48 | |
595cdd5e | 49 | if (rp->type > NTYPES) { |
9bd38ba8 | 50 | (void)sprintf(tbuf, "type %d", rp->type); |
595cdd5e KM |
51 | tp = tbuf; |
52 | } else | |
53 | tp = types[rp->type]; | |
54 | if (rp->answer > NANSWERS) { | |
9bd38ba8 | 55 | (void)sprintf(abuf, "answer %d", rp->answer); |
595cdd5e KM |
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)); | |
1f187e51 | 60 | } |