122398Sdist /* 222398Sdist * Copyright (c) 1983 Regents of the University of California. 322398Sdist * All rights reserved. The Berkeley software License Agreement 422398Sdist * specifies the terms and conditions for redistribution. 522398Sdist */ 622398Sdist 716365Skarels #ifndef lint 8*26839Smckusick static char sccsid[] = "@(#)print.c 5.2 (Berkeley) 03/13/86"; 922398Sdist #endif not lint 1016354Skarels 1116354Skarels /* debug print routines */ 1216354Skarels 1316354Skarels #include <stdio.h> 14*26839Smckusick #include <syslog.h> 1516354Skarels 16*26839Smckusick #include <protocols/talkd.h> 17*26839Smckusick 18*26839Smckusick static char *types[] = 19*26839Smckusick { "leave_invite", "look_up", "delete", "announce" }; 20*26839Smckusick #define NTYPES (sizeof (types) / sizeof (types[0])) 21*26839Smckusick static char *answers[] = 22*26839Smckusick { "success", "not_here", "failed", "machine_unknown", "permission_denied", 23*26839Smckusick "unknown_request", "badversion", "badaddr", "badctladdr" }; 24*26839Smckusick #define NANSWERS (sizeof (answers) / sizeof (answers[0])) 25*26839Smckusick 26*26839Smckusick print_request(cp, mp) 27*26839Smckusick char *cp; 28*26839Smckusick register CTL_MSG *mp; 2916354Skarels { 30*26839Smckusick char tbuf[80], *tp; 3116365Skarels 32*26839Smckusick if (mp->type > NTYPES) { 33*26839Smckusick sprintf(tbuf, "type %d", mp->type); 34*26839Smckusick tp = tbuf; 35*26839Smckusick } else 36*26839Smckusick tp = types[mp->type]; 37*26839Smckusick syslog(LOG_DEBUG, "%s: %s: id %d, l_user %s, r_user %s, r_tty %s", 38*26839Smckusick cp, tp, mp->id_num, mp->l_name, mp->r_name, mp->r_tty); 3916354Skarels } 4016354Skarels 41*26839Smckusick print_response(cp, rp) 42*26839Smckusick char *cp; 43*26839Smckusick register CTL_RESPONSE *rp; 4416354Skarels { 45*26839Smckusick char tbuf[80], *tp, abuf[80], *ap; 4616465Slayer 47*26839Smckusick if (rp->type > NTYPES) { 48*26839Smckusick sprintf(tbuf, "type %d", rp->type); 49*26839Smckusick tp = tbuf; 50*26839Smckusick } else 51*26839Smckusick tp = types[rp->type]; 52*26839Smckusick if (rp->answer > NANSWERS) { 53*26839Smckusick sprintf(abuf, "answer %d", rp->answer); 54*26839Smckusick ap = abuf; 55*26839Smckusick } else 56*26839Smckusick ap = answers[rp->answer]; 57*26839Smckusick syslog(LOG_DEBUG, "%s: %s: %s, id %d", cp, tp, ap, ntohl(rp->id_num)); 5816354Skarels } 59