122398Sdist /* 222398Sdist * Copyright (c) 1983 Regents of the University of California. 3*34360Sbostic * All rights reserved. 4*34360Sbostic * 5*34360Sbostic * Redistribution and use in source and binary forms are permitted 6*34360Sbostic * provided that this notice is preserved and that due credit is given 7*34360Sbostic * to the University of California at Berkeley. The name of the University 8*34360Sbostic * may not be used to endorse or promote products derived from this 9*34360Sbostic * software without specific prior written permission. This software 10*34360Sbostic * is provided ``as is'' without express or implied warranty. 1122398Sdist */ 1222398Sdist 1316365Skarels #ifndef lint 14*34360Sbostic static char sccsid[] = "@(#)print.c 5.5 (Berkeley) 05/20/88"; 15*34360Sbostic #endif /* not lint */ 1616354Skarels 1716354Skarels /* debug print routines */ 1816354Skarels 1916354Skarels #include <stdio.h> 2026839Smckusick #include <syslog.h> 2132103Smckusick #include <sys/param.h> 2216354Skarels 2326839Smckusick #include <protocols/talkd.h> 2426839Smckusick 2526839Smckusick static char *types[] = 2626839Smckusick { "leave_invite", "look_up", "delete", "announce" }; 2726839Smckusick #define NTYPES (sizeof (types) / sizeof (types[0])) 2826839Smckusick static char *answers[] = 2926839Smckusick { "success", "not_here", "failed", "machine_unknown", "permission_denied", 3026839Smckusick "unknown_request", "badversion", "badaddr", "badctladdr" }; 3126839Smckusick #define NANSWERS (sizeof (answers) / sizeof (answers[0])) 3226839Smckusick 3326839Smckusick print_request(cp, mp) 3426839Smckusick char *cp; 3526839Smckusick register CTL_MSG *mp; 3616354Skarels { 3726839Smckusick char tbuf[80], *tp; 3816365Skarels 3926839Smckusick if (mp->type > NTYPES) { 4032466Sbostic (void)sprintf(tbuf, "type %d", mp->type); 4126839Smckusick tp = tbuf; 4226839Smckusick } else 4326839Smckusick tp = types[mp->type]; 4426839Smckusick syslog(LOG_DEBUG, "%s: %s: id %d, l_user %s, r_user %s, r_tty %s", 4526839Smckusick cp, tp, mp->id_num, mp->l_name, mp->r_name, mp->r_tty); 4616354Skarels } 4716354Skarels 4826839Smckusick print_response(cp, rp) 4926839Smckusick char *cp; 5026839Smckusick register CTL_RESPONSE *rp; 5116354Skarels { 5226839Smckusick char tbuf[80], *tp, abuf[80], *ap; 5316465Slayer 5426839Smckusick if (rp->type > NTYPES) { 5532466Sbostic (void)sprintf(tbuf, "type %d", rp->type); 5626839Smckusick tp = tbuf; 5726839Smckusick } else 5826839Smckusick tp = types[rp->type]; 5926839Smckusick if (rp->answer > NANSWERS) { 6032466Sbostic (void)sprintf(abuf, "answer %d", rp->answer); 6126839Smckusick ap = abuf; 6226839Smckusick } else 6326839Smckusick ap = answers[rp->answer]; 6426839Smckusick syslog(LOG_DEBUG, "%s: %s: %s, id %d", cp, tp, ap, ntohl(rp->id_num)); 6516354Skarels } 66