From owner-cvs-all Fri Jul 13 8:37: 1 2001 Delivered-To: cvs-all@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id C59F737B405; Fri, 13 Jul 2001 08:36:52 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from hornet.unixfreak.org (hornet [63.198.170.140]) by bazooka.unixfreak.org (Postfix) with ESMTP id C5DF83E31; Fri, 13 Jul 2001 08:36:47 -0700 (PDT) To: ru@freebsd.org, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/libexec/talkd announce.c In-Reply-To: <20010713174937.B94179@sunbay.com>; from ru@FreeBSD.org on "Fri, 13 Jul 2001 17:49:37 +0300" Date: Fri, 13 Jul 2001 08:36:47 -0700 From: Dima Dorfman Message-Id: <20010713153647.C5DF83E31@bazooka.unixfreak.org> Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Ruslan Ermilov writes: > On Fri, Jul 13, 2001 at 07:11:49AM -0700, Dima Dorfman wrote: > > dd 2001/07/13 07:11:49 PDT > > > > Modified files: (Branch: RELENG_4) > > libexec/talkd announce.c > > Log: > > MFC 1.12: print the date in the announcement. > > > > Revision Changes Path > > 1.11.2.1 +4 -2 src/libexec/talkd/announce.c > > > What about my idea of also printing the party's IP address > (hostname) if it's different from the called one? I'm not sure what you're suggesting, or what it has to do with this commit. I've attached a rather crude patch that implements what I think you mean. It changes the "[Connection established.]" message to "[Connection established with user@host.]". Index: io.c =================================================================== RCS file: /stl/src/FreeBSD/src/usr.bin/talk/io.c,v retrieving revision 1.10 diff -u -r1.10 io.c --- io.c 2000/07/11 01:31:39 1.10 +++ io.c 2001/07/13 15:33:46 @@ -46,9 +46,12 @@ */ #include +#include +#include #include #include #include "talk.h" +#include "talk_ctl.h" #define A_LONG_TIME 10000000 @@ -58,12 +61,26 @@ void talk() { + struct hostent *hp; + in_addr_t ar; int nb; fd_set read_set, read_template; - char buf[BUFSIZ]; + char buf[BUFSIZ], *his_machine_name; struct timeval wait; - message("Connection established"); + hp = gethostbyaddr((const char *)&his_machine_addr.s_addr, + sizeof(his_machine_addr.s_addr), AF_INET); + if (hp == NULL) { + ar = his_machine_addr.s_addr; + snprintf(buf, sizeof(buf), "%u.%u.%u.%u", + ar >> 24, (ar >> 16) & 0xff, (ar >> 8) & 0xff, ar & 0xff); + his_machine_name = strdup(buf); + } else + his_machine_name = strdup(hp->h_name); + snprintf(buf, sizeof(buf), "Connection established with %s@%s.", + msg.r_name, his_machine_name); + free(his_machine_name); + message(buf); write(STDOUT_FILENO, "\007\007\007", 3); current_line = 0; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message