122398Sdist /* 222398Sdist * Copyright (c) 1983 Regents of the University of California. 334360Sbostic * All rights reserved. 434360Sbostic * 5*42673Sbostic * %sccs.include.redist.c% 622398Sdist */ 722398Sdist 816365Skarels #ifndef lint 9*42673Sbostic static char sccsid[] = "@(#)print.c 5.7 (Berkeley) 06/01/90"; 1034360Sbostic #endif /* not lint */ 1116354Skarels 1216354Skarels /* debug print routines */ 1316354Skarels 1416354Skarels #include <stdio.h> 1526839Smckusick #include <syslog.h> 1632103Smckusick #include <sys/param.h> 1716354Skarels 1826839Smckusick #include <protocols/talkd.h> 1926839Smckusick 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 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 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