[Ttssh2-commit] [4860]

svnno****@sourc***** svnno****@sourc*****
2012年 3月 10日 (土) 19:32:33 JST


Revision: 4860
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4860
Author:   yutakapon
Date:     2012-03-10 19:32:33 +0900 (Sat, 10 Mar 2012)
Log Message:
-----------

* Tera Term起動時、名前付きパイプはTCP/IP扱いとした。
* TCP/IPのホスト名で名前付きパイプを指定できるようにした。

Modified Paths:
--------------
    trunk/teraterm/teraterm/commlib.c
    trunk/teraterm/ttpdlg/ttdlg.c
    trunk/ttssh2/ttxssh/ttxssh.c

-------------- next part --------------
Modified: trunk/teraterm/teraterm/commlib.c
===================================================================
--- trunk/teraterm/teraterm/commlib.c	2012-03-09 15:50:50 UTC (rev 4859)
+++ trunk/teraterm/teraterm/commlib.c	2012-03-10 10:32:33 UTC (rev 4860)
@@ -229,6 +229,31 @@
 	SetCommMask(cv->ComID,EV_RXCHAR);
 }
 
+// \x96\xBC\x91O\x95t\x82\xAB\x83p\x83C\x83v\x82\xAA\x90\xB3\x82\xB5\x82\xA2\x8F\x91\x8E\xAE\x82\xA9\x82\xF0\x83`\x83F\x83b\x83N\x82\xB7\x82\xE9\x81B
+// \\ServerName\pipe\PipeName
+//
+// return  0: \x90\xB3\x82\xB5\x82\xA2
+//        -1: \x95s\x90\xB3
+// (2012.3.10 yutaka)
+int CheckNamedPipeFormat(char *p, int size)
+{
+	int ret = -1;
+	char *s;
+
+	if (size <= 8)
+		goto error;
+
+	if (p[0] == '\\' && p[1] == '\\') {
+		s = strchr(&p[2], '\\');
+		if (s && _strnicmp(s+1, "pipe\\", 5) == 0) {
+			ret = 0;
+		}
+	}
+
+error:
+	return (ret);
+}
+
 void CommOpen(HWND HW, PTTSet ts, PComVar cv)
 {
 #ifdef NO_INET6
@@ -254,6 +279,13 @@
 
 	char uimsg[MAX_UIMSG];
 
+	// \x83z\x83X\x83g\x96\xBC\x82\xAA\x96\xBC\x91O\x95t\x82\xAB\x83p\x83C\x83v\x82\xA9\x82ǂ\xA4\x82\xA9\x82𒲂ׂ\xE9\x81B
+	if (ts->PortType == IdTCPIP) {
+		if (CheckNamedPipeFormat(ts->HostName, strlen(ts->HostName)) == 0) {
+			ts->PortType = IdNamedPipe;
+		}
+	}
+
 	/* initialize ComVar */
 	cv->InBuffCount = 0;
 	cv->InPtr = 0;
@@ -559,21 +591,14 @@
 			strncpy_s(P, sizeof(P), ts->HostName, _TRUNCATE);
 
 			// \x96\xBC\x91O\x95t\x82\xAB\x83p\x83C\x83v\x82\xAA\x90\xB3\x82\xB5\x82\xA2\x8F\x91\x8E\xAE\x82\xA9\x82\xF0\x83`\x83F\x83b\x83N\x82\xB7\x82\xE9\x81B
-			// \\ServerName\pipe\PipeName
-			// (2012.3.10 yutaka)
-			InvalidHost = TRUE;
-			if (P[0] == '\\' && P[1] == '\\') {
-				char *s = strchr(&P[2], '\\');
-				if (s && _strnicmp(s+1, "pipe\\", 5) == 0) {
-					InvalidHost = FALSE;
-				}
-			}
-			if (InvalidHost) {
+			if (CheckNamedPipeFormat(P, strlen(P)) < 0) {
+				InvalidHost = TRUE;
+
 				_snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, 
-					"Invalid pipe name\n[%s]\n"
+					"Invalid pipe name\n\n"
 					"A valid pipe name has the form\n"
-					"\"\\\\<ServerName\\pipe\\<PipeName>\"", 
-					&P[0], GetLastError());
+					"\"\\\\<ServerName>\\pipe\\<PipeName>\"", 
+					GetLastError());
 				get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts->UILanguageFile);
 				MessageBox(cv->HWin,ErrMsg,uimsg,MB_TASKMODAL | MB_ICONEXCLAMATION);
 				break;

Modified: trunk/teraterm/ttpdlg/ttdlg.c
===================================================================
--- trunk/teraterm/ttpdlg/ttdlg.c	2012-03-09 15:50:50 UTC (rev 4859)
+++ trunk/teraterm/ttpdlg/ttdlg.c	2012-03-10 10:32:33 UTC (rev 4860)
@@ -1992,7 +1992,10 @@
 			get_lang_msg("BTN_HELP", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
 			SetDlgItemText(Dialog, IDC_HOSTHELP, uimsg);
 
-			if ( GetHNRec->PortType==IdFile ) {
+			// \x83t\x83@\x83C\x83\x8B\x82\xA8\x82\xE6\x82і\xBC\x91O\x95t\x82\xAB\x83p\x83C\x83v\x82̏ꍇ\x81ATCP/IP\x88\xB5\x82\xA2\x82Ƃ\xB7\x82\xE9\x81B
+			if ( GetHNRec->PortType==IdFile ||
+ 				 GetHNRec->PortType==IdNamedPipe
+				) {
 				GetHNRec->PortType = IdTCPIP;
 			}
 

Modified: trunk/ttssh2/ttxssh/ttxssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ttxssh.c	2012-03-09 15:50:50 UTC (rev 4859)
+++ trunk/ttssh2/ttxssh/ttxssh.c	2012-03-10 10:32:33 UTC (rev 4860)
@@ -1141,7 +1141,10 @@
 			SendMessage(GetDlgItem(dlg, IDC_HISTORY), BM_SETCHECK, BST_UNCHECKED, 0);
 		}
 
-		if (GetHNRec->PortType == IdFile)
+		// \x83t\x83@\x83C\x83\x8B\x82\xA8\x82\xE6\x82і\xBC\x91O\x95t\x82\xAB\x83p\x83C\x83v\x82̏ꍇ\x81ATCP/IP\x88\xB5\x82\xA2\x82Ƃ\xB7\x82\xE9\x81B
+		if (GetHNRec->PortType == IdFile ||
+			GetHNRec->PortType == IdNamedPipe
+			)
 			GetHNRec->PortType = IdTCPIP;
 
 		strncpy_s(EntName, sizeof(EntName), "Host", _TRUNCATE);



Ttssh2-commit メーリングリストの案内