print.c (fd8e4ebc8c18caec3eefac6527831f9ee6a92959) print.c (02a0965ef64123ce8c752d08176f2ec702d4aee6)
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 36 unchanged lines hidden (view full) ---

45#include <sys/socket.h>
46#include <arpa/inet.h>
47#include <protocols/talkd.h>
48#include <stdio.h>
49#include <syslog.h>
50
51#include "extern.h"
52
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 36 unchanged lines hidden (view full) ---

45#include <sys/socket.h>
46#include <arpa/inet.h>
47#include <protocols/talkd.h>
48#include <stdio.h>
49#include <syslog.h>
50
51#include "extern.h"
52
53static char *types[] =
53static const char *types[] =
54 { "leave_invite", "look_up", "delete", "announce" };
55#define NTYPES (sizeof (types) / sizeof (types[0]))
54 { "leave_invite", "look_up", "delete", "announce" };
55#define NTYPES (sizeof (types) / sizeof (types[0]))
56static char *answers[] =
56static const char *answers[] =
57 { "success", "not_here", "failed", "machine_unknown", "permission_denied",
58 "unknown_request", "badversion", "badaddr", "badctladdr" };
59#define NANSWERS (sizeof (answers) / sizeof (answers[0]))
60
61void
62print_request(const char *cp, CTL_MSG *mp)
63{
57 { "success", "not_here", "failed", "machine_unknown", "permission_denied",
58 "unknown_request", "badversion", "badaddr", "badctladdr" };
59#define NANSWERS (sizeof (answers) / sizeof (answers[0]))
60
61void
62print_request(const char *cp, CTL_MSG *mp)
63{
64 char tbuf[80], *tp;
64 const char *tp;
65 char tbuf[80];
65
66 if (mp->type > NTYPES) {
67 (void)snprintf(tbuf, sizeof(tbuf), "type %d", mp->type);
68 tp = tbuf;
69 } else
70 tp = types[mp->type];
71 syslog(LOG_DEBUG, "%s: %s: id %lu, l_user %s, r_user %s, r_tty %s",
66
67 if (mp->type > NTYPES) {
68 (void)snprintf(tbuf, sizeof(tbuf), "type %d", mp->type);
69 tp = tbuf;
70 } else
71 tp = types[mp->type];
72 syslog(LOG_DEBUG, "%s: %s: id %lu, l_user %s, r_user %s, r_tty %s",
72 cp, tp, mp->id_num, mp->l_name, mp->r_name, mp->r_tty);
73 cp, tp, (long)mp->id_num, mp->l_name, mp->r_name, mp->r_tty);
73}
74
75void
76print_response(const char *cp, CTL_RESPONSE *rp)
77{
74}
75
76void
77print_response(const char *cp, CTL_RESPONSE *rp)
78{
78 char tbuf[80], *tp, abuf[80], *ap;
79 const char *tp, *ap;
80 char tbuf[80], abuf[80];
79
80 if (rp->type > NTYPES) {
81 (void)snprintf(tbuf, sizeof(tbuf), "type %d", rp->type);
82 tp = tbuf;
83 } else
84 tp = types[rp->type];
85 if (rp->answer > NANSWERS) {
86 (void)snprintf(abuf, sizeof(abuf), "answer %d", rp->answer);
87 ap = abuf;
88 } else
89 ap = answers[rp->answer];
90 syslog(LOG_DEBUG, "%s: %s: %s, id %d", cp, tp, ap, ntohl(rp->id_num));
91}
81
82 if (rp->type > NTYPES) {
83 (void)snprintf(tbuf, sizeof(tbuf), "type %d", rp->type);
84 tp = tbuf;
85 } else
86 tp = types[rp->type];
87 if (rp->answer > NANSWERS) {
88 (void)snprintf(abuf, sizeof(abuf), "answer %d", rp->answer);
89 ap = abuf;
90 } else
91 ap = answers[rp->answer];
92 syslog(LOG_DEBUG, "%s: %s: %s, id %d", cp, tp, ap, ntohl(rp->id_num));
93}