Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Jul 2001 08:36:47 -0700
From:      Dima Dorfman <dima@unixfreak.org>
To:        ru@freebsd.org, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/libexec/talkd announce.c 
Message-ID:  <20010713153647.C5DF83E31@bazooka.unixfreak.org>
In-Reply-To: <20010713174937.B94179@sunbay.com>; from ru@FreeBSD.org on "Fri, 13 Jul 2001 17:49:37 %2B0300"

next in thread | previous in thread | raw e-mail | index | archive | help
Ruslan Ermilov <ru@FreeBSD.org> 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 <errno.h>
+#include <netdb.h>
+#include <stdlib.h>
 #include <string.h>
 #include <sys/filio.h>
 #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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010713153647.C5DF83E31>