zsh-workers
 help / color / mirror / code / Atom feed
From: Clint Adams <clint@zsh.org>
To: Oliver Kiddle <okiddle@yahoo.co.uk>
Cc: zsh-workers@sunsite.dk
Subject: Re: PATCH: ztcp
Date: Mon, 10 Sep 2001 11:37:56 -0400	[thread overview]
Message-ID: <20010910113756.A29629@dman.com> (raw)
In-Reply-To: <20010910112029.A29473@dman.com>; from clint@zsh.org on Mon, Sep 10, 2001 at 11:20:29AM -0400

> Well, here goes.  I am utterly perplexed because,
> if I am not hallucinating, the desthost = ztrdup(arg[0]);
> is actually passing the args[0] pointer, and thus
> it chokes.

I was hallucinating, so this is unnecessary.

Index: Src/Modules/tcp.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/tcp.c,v
retrieving revision 1.13
diff -u -r1.13 tcp.c
--- Src/Modules/tcp.c	2001/09/10 15:23:38	1.13
+++ Src/Modules/tcp.c	2001/09/10 15:36:07
@@ -386,7 +386,7 @@
 bin_ztcp(char *nam, char **args, char *ops, int func)
 {
     int herrno, err=1, destport, force=0, verbose=0, test=0, targetfd=0, len;
-    char **addrp, *desthost, *localname, *remotename, **arg = args;
+    char **addrp, *desthost, *localname, *remotename, **dargs;
     struct hostent *zthost = NULL, *ztpeer = NULL;
     struct servent *srv;
     Tcp_session sess = NULL;
@@ -401,25 +401,27 @@
         test = 1;
 
     if (ops['d']) {
-	targetfd = atoi(arg[0]);
-	arg++;
+	targetfd = atoi(args[0]);
+	dargs = args + 1;
 	if (!targetfd) {
 	    zwarnnam(nam, "%s is an invalid argument to -d", args[0], 0);
 	    return 1;
 	}
     }
+    else
+	dargs = args;
 
 
     
     if (ops['c']) {
-	if (!arg[0]) {
+	if (!dargs[0]) {
 	    tcp_cleanup();
 	}
 	else {
-	    targetfd = atoi(arg[0]);
+	    targetfd = atoi(dargs[0]);
 	    sess = zts_byfd(targetfd);
 	    if(!targetfd) {
-		zwarnnam(nam, "%s is an invalid argument to -c", arg[0], 0);
+		zwarnnam(nam, "%s is an invalid argument to -c", dargs[0], 0);
 		return 1;
 	    }
 
@@ -435,7 +437,7 @@
 	    }
 	    else
 	    {
-		zwarnnam(nam, "fd %s not found in tcp table", arg[0], 0);
+		zwarnnam(nam, "fd %s not found in tcp table", dargs[0], 0);
 		return 1;
 	    }
 	}
@@ -443,16 +445,16 @@
     else if (ops['l']) {
 	int lport = 0;
 
-	if (!arg[0]) {
+	if (!dargs[0]) {
 	    zwarnnam(nam, "-l requires an argument", NULL, 0);
 	    return 1;
 	}
 
-	srv = getservbyname(arg[0], "tcp");
+	srv = getservbyname(dargs[0], "tcp");
 	if (srv)
 	    lport = srv->s_port;
 	else
-	    lport = htons(atoi(arg[0]));
+	    lport = htons(atoi(dargs[0]));
 	if (!lport) { zwarnnam(nam, "bad service name or port number", NULL, 0);
 	return 1;
 	}
@@ -511,12 +513,12 @@
     {
 	int lfd, rfd;
 
-	if (!arg[0]) {
+	if (!dargs[0]) {
 	    zwarnnam(nam, "-a requires an argument", NULL, 0);
 	    return 1;
 	}
 
-	lfd = atoi(arg[0]);
+	lfd = atoi(dargs[0]);
 
 	if (!lfd) {
 	    zwarnnam(nam, "invalid numerical argument", NULL, 0);
@@ -525,7 +527,7 @@
 
 	sess = zts_byfd(lfd);
 	if (!sess) {
-	    zwarnnam(nam, "fd %s is not registered as a tcp connection", arg[0], 0);
+	    zwarnnam(nam, "fd %s is not registered as a tcp connection", dargs[0], 0);
 	    return 1;
 	}
 
@@ -575,7 +577,7 @@
     else
     {
 	
-	if (!arg[0]) {
+	if (!dargs[0]) {
 	    for(sess = zts_head(); sess != NULL; sess = zts_next(sess))
 	    {
 		if (sess->fd != -1)
@@ -595,19 +597,19 @@
 	    }
 	    return 0;
 	}
-	else if (!arg[1]) {
+	else if (!dargs[1]) {
 	    destport = htons(23);
 	}
 	else {
 
-	    srv = getservbyname(arg[1],"tcp");
+	    srv = getservbyname(dargs[1],"tcp");
 	    if (srv)
 		destport = srv->s_port;
 	    else
-		destport = htons(atoi(arg[1]));
+		destport = htons(atoi(dargs[1]));
 	}
 	
-	desthost = ztrdup(arg[0]);
+	desthost = ztrdup(dargs[0]);
 	
 	zthost = zsh_getipnodebyname(desthost, AF_INET, 0, &herrno);
 	if (!zthost || errflag) {


  reply	other threads:[~2001-09-10 15:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-08 21:07 Clint Adams
2001-09-09 18:31 ` Bart Schaefer
2001-09-09 22:01   ` Clint Adams
2001-09-09 23:30     ` Bart Schaefer
2001-09-10  0:06       ` Clint Adams
2001-09-10 11:09         ` Oliver Kiddle
2001-09-10 15:20           ` Clint Adams
2001-09-10 15:37             ` Clint Adams [this message]
2001-09-10  6:15 ` Module dependencies issue still open Borsenkow Andrej
2001-09-10 10:58   ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010910113756.A29629@dman.com \
    --to=clint@zsh.org \
    --cc=okiddle@yahoo.co.uk \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).