about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2002-05-30 15:16:18 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2002-05-30 15:16:18 +0000
commit69b570e28c63a0e7e3f9caaad58aa3a14f9958d9 (patch)
treeeb135094a9ee5061b2631998d3cb24e1d98fe729 /Src
parent4446df3dff7c75b7c771435f2613ec1df3a77bbd (diff)
downloadzsh-69b570e28c63a0e7e3f9caaad58aa3a14f9958d9.tar.gz
zsh-69b570e28c63a0e7e3f9caaad58aa3a14f9958d9.tar.xz
zsh-69b570e28c63a0e7e3f9caaad58aa3a14f9958d9.zip
17253: ztcp -L gives parseable information on tcp session
Diffstat (limited to 'Src')
-rw-r--r--Src/Modules/tcp.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/Src/Modules/tcp.c b/Src/Modules/tcp.c
index a6af6ed8d..25a88ff76 100644
--- a/Src/Modules/tcp.c
+++ b/Src/Modules/tcp.c
@@ -369,7 +369,6 @@ bin_ztcp(char *nam, char **args, char *ops, int func)
 	dargs = args;
 
 
-    
     if (ops['c']) {
 	if (!dargs[0]) {
 	    tcp_cleanup();
@@ -575,13 +574,29 @@ bin_ztcp(char *nam, char **args, char *ops, int func)
 			remotename = ztpeer->h_name;
 		    else
 			remotename = ztrdup(inet_ntoa(sess->peer.in.sin_addr));
-		    printf("%s:%d %s %s:%d is on fd %d%s\n",
-			    localname, ntohs(sess->sock.in.sin_port),
-			    ((sess->flags & ZTCP_LISTEN) ? "-<" :
-			     ((sess->flags & ZTCP_INBOUND) ? "<-" : "->")),
-			    remotename, ntohs(sess->peer.in.sin_port),
-			    sess->fd,
-			    (sess->flags & ZTCP_ZFTP) ? " ZFTP" : "");
+		    if (ops['L']) {
+			int schar;
+			if (sess->flags & ZTCP_ZFTP)
+			    schar = 'Z';
+			else if (sess->flags & ZTCP_LISTEN)
+			    schar = 'L';
+			else if (sess->flags & ZTCP_INBOUND)
+			    schar = 'I';
+			else
+			    schar = 'O';
+			printf("%d %c %s %d %s %d\n",
+			       sess->fd, schar,
+			       localname, ntohs(sess->sock.in.sin_port),
+			       remotename, ntohs(sess->peer.in.sin_port));
+		    } else {
+			printf("%s:%d %s %s:%d is on fd %d%s\n",
+			       localname, ntohs(sess->sock.in.sin_port),
+			       ((sess->flags & ZTCP_LISTEN) ? "-<" :
+				((sess->flags & ZTCP_INBOUND) ? "<-" : "->")),
+			       remotename, ntohs(sess->peer.in.sin_port),
+			       sess->fd,
+			       (sess->flags & ZTCP_ZFTP) ? " ZFTP" : "");
+		    }
 		}
 	    }
 	    return 0;
@@ -660,7 +675,7 @@ bin_ztcp(char *nam, char **args, char *ops, int func)
 }
 
 static struct builtin bintab[] = {
-    BUILTIN("ztcp", 0, bin_ztcp, 0, 3, 0, "acdfltv", NULL),
+    BUILTIN("ztcp", 0, bin_ztcp, 0, 3, 0, "acdflLtv", NULL),
 };
 
 /* The load/unload routines required by the zsh library interface */