[Ttssh2-commit] [7091] コマンドラインオプションで、ポート番号の代わりにサービス名を受け付けるようにした #38021

Back to archive index

scmno****@osdn***** scmno****@osdn*****
2018年 4月 3日 (火) 22:49:44 JST


Revision: 7091
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7091
Author:   doda
Date:     2018-04-03 22:49:43 +0900 (Tue, 03 Apr 2018)
Log Message:
-----------
コマンドラインオプションで、ポート番号の代わりにサービス名を受け付けるようにした #38021

Ticket Links:
------------
    http://sourceforge.jp/projects/ttssh2/tracker/detail/38021

Modified Paths:
--------------
    trunk/doc/en/html/about/history.html
    trunk/doc/ja/html/about/history.html
    trunk/teraterm/ttpset/ttset.c

-------------- next part --------------
Modified: trunk/doc/en/html/about/history.html
===================================================================
--- trunk/doc/en/html/about/history.html	2018-04-03 13:49:38 UTC (rev 7090)
+++ trunk/doc/en/html/about/history.html	2018-04-03 13:49:43 UTC (rev 7091)
@@ -33,6 +33,12 @@
 
 <h3><a name="teraterm_4.99">2018.05.xx (Ver 4.99)</a></h3>
 <ul class="history">
+  <li>Changes
+    <ul>
+      <li>Accept service name instead of the port number on the command line option.</li>
+    </ul>
+  </li>
+
   <li>Bug fixes
     <ul>
       <li>When the mouse tracking is enabled, the menu can not be selected after clicking the screen.</li>

Modified: trunk/doc/ja/html/about/history.html
===================================================================
--- trunk/doc/ja/html/about/history.html	2018-04-03 13:49:38 UTC (rev 7090)
+++ trunk/doc/ja/html/about/history.html	2018-04-03 13:49:43 UTC (rev 7091)
@@ -33,6 +33,12 @@
 
 <h3><a name="teraterm_4.99">2018.05.xx (Ver 4.99)</a></h3>
 <ul class="history">
+  <li>\x95ύX
+    <ul>
+      <li>\x83R\x83}\x83\x93\x83h\x83\x89\x83C\x83\x93\x83I\x83v\x83V\x83\x87\x83\x93\x82Ń|\x81[\x83g\x94ԍ\x86\x82̑\xE3\x82\xED\x82\xE8\x82ɃT\x81[\x83r\x83X\x96\xBC\x82\xF0\x8E󂯕t\x82\xAF\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B</li>
+    </ul>
+  </li>
+
   <li>\x83o\x83O\x8FC\x90\xB3
     <ul>
       <li>\x83}\x83E\x83X\x83g\x83\x89\x83b\x83L\x83\x93\x83O\x97L\x8C\xF8\x8E\x9E\x81A\x89\xE6\x96ʃN\x83\x8A\x83b\x83N\x8C\xE3\x82Ƀ\x81\x83j\x83\x85\x81[\x82\xAA\x8Eg\x82\xA6\x82Ȃ\xAD\x82Ȃ\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li>

Modified: trunk/teraterm/ttpset/ttset.c
===================================================================
--- trunk/teraterm/ttpset/ttset.c	2018-04-03 13:49:38 UTC (rev 7090)
+++ trunk/teraterm/ttpset/ttset.c	2018-04-03 13:49:43 UTC (rev 7091)
@@ -40,6 +40,7 @@
 #include <errno.h>
 #include "ttlib.h"
 #include "tt_res.h"
+#include "servicenames.h"
 
 #include "compat_w95.h"
 
@@ -3820,17 +3821,32 @@
 	return (strlen(Temp) > 0);
 }
 #endif
+
+static int ParsePortName(char *buff)
+{
+	int port = parse_port_from_buf(buff);
+
+	if (port > 0 || sscanf(buff, "%d", &port) == 1)
+		return port;
+	else
+		return 0;
+}
+
 static void ParseHostName(char *HostStr, WORD * port)
 {
 	/*
-	 * hostname.domain.com
-	 * hostname.domain.com:23
-	 * [3ffe:1234:1234::1]     IPv6 raw address
-	 * [3ffe:1234:1234::1]:23  IPv6 raw address and port#
-	 * telnet://hostname.domain.com/
-	 * telnet://hostname.domain.com:23/
+	 * hostname.example.jp
+	 * hostname.example.jp:23
+	 * hostname.example.jp:telnet
+	 * [3ffe:1234:1234::1]         IPv6 raw address
+	 * [3ffe:1234:1234::1]:23      IPv6 raw address and port#
+	 * [3ffe:1234:1234::1]:telnet  IPv6 raw address and service name
+	 * telnet://hostname.example.jp/
+	 * telnet://hostname.example.jp:23/
+	 * telnet://hostname.example.jp:telnet/
 	 * telnet://[3ffe:1234:1234::1]/
 	 * telnet://[3ffe:1234:1234::1]:23/
+	 * telnet://[3ffe:1234:1234::1]:telnet/
 	 * tn3270:// .... /
 	 */
 
@@ -3885,7 +3901,7 @@
 	 *                    |
 	 *                    s
 	 *
-	 *   hostname.domain.com
+	 *   hostname.example.jp
 	 *   |
 	 *   s
 	 */
@@ -3896,8 +3912,7 @@
 	} while (b != '\0' && b != ':');
 	if (b == ':') {
 		s[i - 1] = '\0';
-		if (sscanf(&(s[i]), "%hd", port) != 1)
-			*port = 65535;
+		*port = ParsePortName(&(s[i]));
 		is_port = 1;
 	}
 	if (is_telnet_handler == 1 && is_port == 0) {
@@ -4097,8 +4112,7 @@
 		}
 		else if (_strnicmp(Temp, "/P=", 3) == 0) {	/* TCP port num */
 			ParamPort = IdTCPIP;
-			if (sscanf(&Temp[3], "%hd", &ParamTCP) != 1)
-				ParamTCP = 0;
+			ParamTCP = ParsePortName(&Temp[3]);
 		}
 		else if (_stricmp(Temp, "/PIPE") == 0 ||
 		         _stricmp(Temp, "/NAMEDPIPE") == 0) {	/* \x96\xBC\x91O\x95t\x82\xAB\x83p\x83C\x83v */
@@ -4161,7 +4175,7 @@
 
 		}
 		else if ((Temp[0] != '/') && (strlen(Temp) > 0)) {
-			if (JustAfterHost && (sscanf(Temp, "%d", &c) == 1))
+			if (JustAfterHost && ((c=ParsePortName(Temp)) > 0))
 				ParamTCP = c;
 			else {
 				strncpy_s(ts->HostName, sizeof(ts->HostName), Temp, _TRUNCATE);	/* host name */



Ttssh2-commit メーリングリストの案内
Back to archive index