Commit | Line | Data |
---|---|---|
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 | |
1c15e888 C |
6 | * provided that: (1) source distributions retain this entire copyright |
7 | * notice and comment, and (2) distributions including binaries display | |
8 | * the following acknowledgement: ``This product includes software | |
9 | * developed by the University of California, Berkeley and its contributors'' | |
10 | * in the documentation or other materials provided with the distribution | |
11 | * and in all advertising materials mentioning features or use of this | |
12 | * software. Neither the name of the University nor the names of its | |
13 | * contributors may be used to endorse or promote products derived | |
b8c620d6 KB |
14 | * from this software without specific prior written permission. |
15 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
16 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
1c15e888 | 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
d0aeaf5a DF |
18 | */ |
19 | ||
963ce42e | 20 | #ifndef lint |
1c15e888 | 21 | static char sccsid[] = "@(#)print.c 5.7 (Berkeley) 6/1/90"; |
9e678aa5 | 22 | #endif /* not lint */ |
1f187e51 MK |
23 | |
24 | /* debug print routines */ | |
25 | ||
26 | #include <stdio.h> | |
595cdd5e | 27 | #include <syslog.h> |
7989a2e7 | 28 | #include <sys/param.h> |
1f187e51 | 29 | |
595cdd5e KM |
30 | #include <protocols/talkd.h> |
31 | ||
32 | static char *types[] = | |
33 | { "leave_invite", "look_up", "delete", "announce" }; | |
34 | #define NTYPES (sizeof (types) / sizeof (types[0])) | |
35 | static char *answers[] = | |
36 | { "success", "not_here", "failed", "machine_unknown", "permission_denied", | |
37 | "unknown_request", "badversion", "badaddr", "badctladdr" }; | |
38 | #define NANSWERS (sizeof (answers) / sizeof (answers[0])) | |
39 | ||
40 | print_request(cp, mp) | |
41 | char *cp; | |
42 | register CTL_MSG *mp; | |
1f187e51 | 43 | { |
595cdd5e | 44 | char tbuf[80], *tp; |
963ce42e | 45 | |
595cdd5e | 46 | if (mp->type > NTYPES) { |
9bd38ba8 | 47 | (void)sprintf(tbuf, "type %d", mp->type); |
595cdd5e KM |
48 | tp = tbuf; |
49 | } else | |
50 | tp = types[mp->type]; | |
51 | syslog(LOG_DEBUG, "%s: %s: id %d, l_user %s, r_user %s, r_tty %s", | |
52 | cp, tp, mp->id_num, mp->l_name, mp->r_name, mp->r_tty); | |
1f187e51 MK |
53 | } |
54 | ||
595cdd5e KM |
55 | print_response(cp, rp) |
56 | char *cp; | |
57 | register CTL_RESPONSE *rp; | |
1f187e51 | 58 | { |
595cdd5e | 59 | char tbuf[80], *tp, abuf[80], *ap; |
81379f80 | 60 | |
595cdd5e | 61 | if (rp->type > NTYPES) { |
9bd38ba8 | 62 | (void)sprintf(tbuf, "type %d", rp->type); |
595cdd5e KM |
63 | tp = tbuf; |
64 | } else | |
65 | tp = types[rp->type]; | |
66 | if (rp->answer > NANSWERS) { | |
9bd38ba8 | 67 | (void)sprintf(abuf, "answer %d", rp->answer); |
595cdd5e KM |
68 | ap = abuf; |
69 | } else | |
70 | ap = answers[rp->answer]; | |
71 | syslog(LOG_DEBUG, "%s: %s: %s, id %d", cp, tp, ap, ntohl(rp->id_num)); | |
1f187e51 | 72 | } |