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*32103Smckusick static char sccsid[] = "@(#)print.c 5.3 (Berkeley) 09/04/87"; 922398Sdist #endif not lint 1016354Skarels 1116354Skarels /* debug print routines */ 1216354Skarels 1316354Skarels #include <stdio.h> 1426839Smckusick #include <syslog.h> 15*32103Smckusick #include <sys/param.h> 1616354Skarels 1726839Smckusick #include <protocols/talkd.h> 1826839Smckusick 1926839Smckusick static char *types[] = 2026839Smckusick { "leave_invite", "look_up", "delete", "announce" }; 2126839Smckusick #define NTYPES (sizeof (types) / sizeof (types[0])) 2226839Smckusick static char *answers[] = 2326839Smckusick { "success", "not_here", "failed", "machine_unknown", "permission_denied", 2426839Smckusick "unknown_request", "badversion", "badaddr", "badctladdr" }; 2526839Smckusick #define NANSWERS (sizeof (answers) / sizeof (answers[0])) 2626839Smckusick 2726839Smckusick print_request(cp, mp) 2826839Smckusick char *cp; 2926839Smckusick register CTL_MSG *mp; 3016354Skarels { 3126839Smckusick char tbuf[80], *tp; 3216365Skarels 3326839Smckusick if (mp->type > NTYPES) { 3426839Smckusick sprintf(tbuf, "type %d", mp->type); 3526839Smckusick tp = tbuf; 3626839Smckusick } else 3726839Smckusick tp = types[mp->type]; 3826839Smckusick syslog(LOG_DEBUG, "%s: %s: id %d, l_user %s, r_user %s, r_tty %s", 3926839Smckusick cp, tp, mp->id_num, mp->l_name, mp->r_name, mp->r_tty); 4016354Skarels } 4116354Skarels 4226839Smckusick print_response(cp, rp) 4326839Smckusick char *cp; 4426839Smckusick register CTL_RESPONSE *rp; 4516354Skarels { 4626839Smckusick char tbuf[80], *tp, abuf[80], *ap; 4716465Slayer 4826839Smckusick if (rp->type > NTYPES) { 4926839Smckusick sprintf(tbuf, "type %d", rp->type); 5026839Smckusick tp = tbuf; 5126839Smckusick } else 5226839Smckusick tp = types[rp->type]; 5326839Smckusick if (rp->answer > NANSWERS) { 5426839Smckusick sprintf(abuf, "answer %d", rp->answer); 5526839Smckusick ap = abuf; 5626839Smckusick } else 5726839Smckusick ap = answers[rp->answer]; 5826839Smckusick syslog(LOG_DEBUG, "%s: %s: %s, id %d", cp, tp, ap, ntohl(rp->id_num)); 5916354Skarels } 60