xref: /csrg-svn/libexec/talkd/print.c (revision 61449)
122398Sdist /*
2*61449Sbostic  * Copyright (c) 1983, 1993
3*61449Sbostic  *	The Regents of the University of California.  All rights reserved.
434360Sbostic  *
542673Sbostic  * %sccs.include.redist.c%
622398Sdist  */
722398Sdist 
816365Skarels #ifndef lint
9*61449Sbostic static char sccsid[] = "@(#)print.c	8.1 (Berkeley) 06/04/93";
1034360Sbostic #endif /* not lint */
1116354Skarels 
1216354Skarels /* debug print routines */
1316354Skarels 
1446683Sbostic #include <sys/types.h>
1546683Sbostic #include <sys/socket.h>
1646683Sbostic #include <protocols/talkd.h>
1746683Sbostic #include <syslog.h>
1816354Skarels #include <stdio.h>
1916354Skarels 
2026839Smckusick static	char *types[] =
2126839Smckusick     { "leave_invite", "look_up", "delete", "announce" };
2226839Smckusick #define	NTYPES	(sizeof (types) / sizeof (types[0]))
2326839Smckusick static	char *answers[] =
2426839Smckusick     { "success", "not_here", "failed", "machine_unknown", "permission_denied",
2526839Smckusick       "unknown_request", "badversion", "badaddr", "badctladdr" };
2626839Smckusick #define	NANSWERS	(sizeof (answers) / sizeof (answers[0]))
2726839Smckusick 
print_request(cp,mp)2826839Smckusick print_request(cp, mp)
2926839Smckusick 	char *cp;
3026839Smckusick 	register CTL_MSG *mp;
3116354Skarels {
3226839Smckusick 	char tbuf[80], *tp;
3316365Skarels 
3426839Smckusick 	if (mp->type > NTYPES) {
3532466Sbostic 		(void)sprintf(tbuf, "type %d", mp->type);
3626839Smckusick 		tp = tbuf;
3726839Smckusick 	} else
3826839Smckusick 		tp = types[mp->type];
3926839Smckusick 	syslog(LOG_DEBUG, "%s: %s: id %d, l_user %s, r_user %s, r_tty %s",
4026839Smckusick 	    cp, tp, mp->id_num, mp->l_name, mp->r_name, mp->r_tty);
4116354Skarels }
4216354Skarels 
print_response(cp,rp)4326839Smckusick print_response(cp, rp)
4426839Smckusick 	char *cp;
4526839Smckusick 	register CTL_RESPONSE *rp;
4616354Skarels {
4726839Smckusick 	char tbuf[80], *tp, abuf[80], *ap;
4816465Slayer 
4926839Smckusick 	if (rp->type > NTYPES) {
5032466Sbostic 		(void)sprintf(tbuf, "type %d", rp->type);
5126839Smckusick 		tp = tbuf;
5226839Smckusick 	} else
5326839Smckusick 		tp = types[rp->type];
5426839Smckusick 	if (rp->answer > NANSWERS) {
5532466Sbostic 		(void)sprintf(abuf, "answer %d", rp->answer);
5626839Smckusick 		ap = abuf;
5726839Smckusick 	} else
5826839Smckusick 		ap = answers[rp->answer];
5926839Smckusick 	syslog(LOG_DEBUG, "%s: %s: %s, id %d", cp, tp, ap, ntohl(rp->id_num));
6016354Skarels }
61