[Ttssh2-commit] [6887] sendbroadcast, sendlnbroadcast が動かない問題を修正。 [Ttssh2-devel 3326], Ticket #37401

svnno****@sourc***** svnno****@sourc*****
2017年 7月 26日 (水) 12:47:55 JST


Revision: 6887
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6887
Author:   doda
Date:     2017-07-26 12:47:55 +0900 (Wed, 26 Jul 2017)
Log Message:
-----------
sendbroadcast, sendlnbroadcast が動かない問題を修正。[Ttssh2-devel 3326], Ticket #37401

・メインのループ部分が大きく違うので、ダイアログでの操作とマクロコマンドで関数を分離した
・parent_only の時にループ変数をいじって無理やり一回で抜けるのは判り辛いので、
  最初に parent_only かどうかを判定するようにした。
  parent_only の時はループしないというのを明示する意味もある。

ついでに sendmulticast の方も微修正
・malloc() に失敗した時に free() するのは意味が無いのでそのまま return する。
・memcpy() ⇒ memcpy_s()

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

Modified Paths:
--------------
    trunk/doc/en/html/about/history.html
    trunk/doc/ja/html/about/history.html
    trunk/teraterm/teraterm/ttdde.c
    trunk/teraterm/teraterm/vtwin.cpp
    trunk/teraterm/teraterm/vtwin.h

Added Paths:
-----------
    trunk/tests/#37401-sendbroadcast.ttl

-------------- next part --------------
Modified: trunk/doc/en/html/about/history.html
===================================================================
--- trunk/doc/en/html/about/history.html	2017-07-26 03:47:51 UTC (rev 6886)
+++ trunk/doc/en/html/about/history.html	2017-07-26 03:47:55 UTC (rev 6887)
@@ -50,6 +50,7 @@
   <li>Bug fixes
     <ul>
       <li>The response of DECLRMM status query by DECRQM was invalid.</li>
+      <li><a href="../macro/command/sendbroadcast.html">sendbroadcast</a> and <a href="../macro/command/sendlnbroadcast.html">sendlnbroadcast</a> macro command does not work.</li>
       <li><a href="../macro/command/sendbroadcast.html">sendbroadcast</a>, <a href="../macro/command/sendlnbroadcast.html">sendlnbroadcast</a> and <a href="../macro/command/sendmulticast.html">sendmulticast</a> macro command can't send the character of 0x00 or 0x01.</li>
     </ul>
   </li>

Modified: trunk/doc/ja/html/about/history.html
===================================================================
--- trunk/doc/ja/html/about/history.html	2017-07-26 03:47:51 UTC (rev 6886)
+++ trunk/doc/ja/html/about/history.html	2017-07-26 03:47:55 UTC (rev 6887)
@@ -50,6 +50,7 @@
   <li>\x83o\x83O\x8FC\x90\xB3
     <ul>
       <li>DECRQM \x90\xA7\x8C\xE4\x83V\x81[\x83P\x83\x93\x83X\x82\xC5 DECLRMM \x82̏\xF3\x91Ԃ𐳂\xB5\x82\xAD\x95Ԃ\xB3\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li>
+      <li><a href="../macro/command/sendbroadcast.html">sendbroadcast</a> / <a href="../macro/command/sendlnbroadcast.html">sendlnbroadcast</a> \x83}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82\xAA\x90\xB3\x82\xB5\x82\xAD\x93\xAD\x82\xA9\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li>
       <li><a href="../macro/command/sendbroadcast.html">sendbroadcast</a> / <a href="../macro/command/sendlnbroadcast.html">sendlnbroadcast</a> / <a href="../macro/command/sendmulticast.html">sendmulticast</a> \x83}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82ŁA0x00, 0x01 \x82\xAA\x90\xB3\x82\xB5\x82\xAD\x91\x97\x82\xEA\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li>
     </ul>
   </li>

Modified: trunk/teraterm/teraterm/ttdde.c
===================================================================
--- trunk/teraterm/teraterm/ttdde.c	2017-07-26 03:47:51 UTC (rev 6886)
+++ trunk/teraterm/teraterm/ttdde.c	2017-07-26 03:47:55 UTC (rev 6887)
@@ -964,7 +964,7 @@
 		break;
 
 	case CmdSendBroadcast: // 'sendbroadcast'
-		SendAllBroadcastMessage(HVTWin, HVTWin, 0, ParamFileName, strlen(ParamFileName));
+		SendBroadcastMessage(HVTWin, HVTWin, ParamFileName, strlen(ParamFileName));
 		break;
 
 	case CmdSendMulticast: // 'sendmulticast'

Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2017-07-26 03:47:51 UTC (rev 6886)
+++ trunk/teraterm/teraterm/vtwin.cpp	2017-07-26 03:47:55 UTC (rev 6887)
@@ -5580,11 +5580,10 @@
 }
 
 /*
- * \x91S Tera Term \x82փ\x81\x83b\x83Z\x81[\x83W\x82𑗐M\x82\xB7\x82\xE9\x83u\x83\x8D\x81[\x83h\x83L\x83\x83\x83X\x83g\x83\x82\x81[\x83h\x81B
- * "sendbroadcast"\x83}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82\xA9\x82\xE7\x82\xE0\x97\x98\x97p\x82\xB3\x82\xEA\x82\xE9\x81B
+ * \x83_\x83C\x83A\x83\x8D\x83O\x82őI\x91\xF0\x82\xB3\x82ꂽ\x83E\x83B\x83\x93\x83h\x83E\x82̂݁A\x82\xE0\x82\xB5\x82\xAD\x82͐e\x83E\x83B\x83\x93\x83h\x83E\x82݂̂ɑ\x97\x82\xE9\x83u\x83\x8D\x81[\x83h\x83L\x83\x83\x83X\x83g\x83\x82\x81[\x83h\x81B
+ * \x83\x8A\x83A\x83\x8B\x83^\x83C\x83\x80\x83\x82\x81[\x83h\x82\xAA off \x82̎\x9E\x82ɗ\x98\x97p\x82\xB3\x82\xEA\x82\xE9\x81B
  */
-extern "C"
-void SendAllBroadcastMessage(HWND HVTWin, HWND hWnd, int parent_only, char *buf, int buflen)
+void SendBroadcastMessageToSelected(HWND HVTWin, HWND hWnd, int parent_only, char *buf, int buflen)
 {
 	int i;
 	int count;
@@ -5596,28 +5595,52 @@
 	cds.cbData = buflen;
 	cds.lpData = buf;
 
-	// \x82\xB7\x82ׂĂ\xCCTera Term\x82Ƀ\x81\x83b\x83Z\x81[\x83W\x82ƃf\x81[\x83^\x82𑗂\xE9
-	count = SendMessage(BroadcastWindowList, LB_GETCOUNT, 0, 0);
-	for (i = 0 ; i < count ; i++) {
-		hd = NULL;
-		if (parent_only) {
-			hd = GetParent(hWnd);
-			i = MAXNWIN;		// 337: \x8B\xAD\x88\xF8\x82\xA9\x82’\xBC\x92l :P
-		} else {
+	if (parent_only) {
+		// \x90e\x83E\x83B\x83\x93\x83h\x83E\x82݂̂\xC9 WM_COPYDATA \x83\x81\x83b\x83Z\x81[\x83W\x82𑗂\xE9
+		SendMessage(GetParent(hWnd), WM_COPYDATA, (WPARAM)HVTWin, (LPARAM)&cds);
+	}
+	else {
+		// \x83_\x83C\x83A\x83\x8D\x83O\x82őI\x91\xF0\x82\xB3\x82ꂽ\x83E\x83B\x83\x93\x83h\x83E\x82Ƀ\x81\x83b\x83Z\x81[\x83W\x82𑗂\xE9
+		count = SendMessage(BroadcastWindowList, LB_GETCOUNT, 0, 0);
+		for (i = 0 ; i < count ; i++) {
 			// \x83\x8A\x83X\x83g\x83{\x83b\x83N\x83X\x82őI\x91\xF0\x82\xB3\x82\xEA\x82Ă\xA2\x82邩
 			if (SendMessage(BroadcastWindowList, LB_GETSEL, i, 0)) {
-				hd = GetNthWin(i);
+				if ((hd = GetNthWin(i)) != NULL) {
+					// WM_COPYDATA\x82\xF0\x8Eg\x82\xC1\x82āA\x83v\x83\x8D\x83Z\x83X\x8AԒʐM\x82\xF0\x8Ds\x82\xA4\x81B
+					SendMessage(hd, WM_COPYDATA, (WPARAM)HVTWin, (LPARAM)&cds);
+				}
 			}
 		}
-		if (hd == NULL) {
-			continue;
+	}
+}
+
+/*
+ * \x91S Tera Term \x82փ\x81\x83b\x83Z\x81[\x83W\x82𑗐M\x82\xB7\x82\xE9\x83u\x83\x8D\x81[\x83h\x83L\x83\x83\x83X\x83g\x83\x82\x81[\x83h\x81B
+ * "sendbroadcast"\x83}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82\xA9\x82\xE7\x82̂ݗ\x98\x97p\x82\xB3\x82\xEA\x82\xE9\x81B
+ */
+extern "C"
+void SendBroadcastMessage(HWND HVTWin, HWND hWnd, char *buf, int buflen)
+{
+	int i;
+	HWND hd;
+	COPYDATASTRUCT cds;
+
+	ZeroMemory(&cds, sizeof(cds));
+	cds.dwData = IPC_BROADCAST_COMMAND;
+	cds.cbData = buflen;
+	cds.lpData = buf;
+
+	// \x91S Tera Term \x82փ\x81\x83b\x83Z\x81[\x83W\x82𑗂\xE9\x81B
+	for (i = 0 ; i < MAXNWIN ; i++) {
+		if ((hd = GetNthWin(i)) == NULL) {
+			break;
 		}
-
 		// WM_COPYDATA\x82\xF0\x8Eg\x82\xC1\x82āA\x83v\x83\x8D\x83Z\x83X\x8AԒʐM\x82\xF0\x8Ds\x82\xA4\x81B
 		SendMessage(hd, WM_COPYDATA, (WPARAM)HVTWin, (LPARAM)&cds);
 	}
 }
 
+
 /*
  * \x94C\x88ӂ\xCC Tera Term \x8CQ\x82փ\x81\x83b\x83Z\x81[\x83W\x82𑗐M\x82\xB7\x82\xE9\x83}\x83\x8B\x83`\x83L\x83\x83\x83X\x83g\x83\x82\x81[\x83h\x81B\x8C\xB5\x96\xA7\x82ɂ́A
  * \x83u\x83\x8D\x81[\x83h\x83L\x83\x83\x83X\x83g\x91\x97\x90M\x82\xF0\x8Ds\x82\xA2\x81A\x8E\xF3\x90M\x91\xA4\x82Ń\x81\x83b\x83Z\x81[\x83W\x82\xF0\x8E\xE6\x8ȆI\x91\xF0\x82\xB7\x82\xE9\x81B
@@ -5644,12 +5667,11 @@
 	 */
 	nlen = strlen(name) + 1;
 	msglen = nlen + buflen;
-	msg = (char *)malloc(msglen);
-	if (msg == NULL) {
-		goto error;
+	if ((msg = (char *)malloc(msglen)) == NULL) {
+		return;
 	}
 	strcpy_s(msg, msglen, name);
-	memcpy(msg + nlen, buf, buflen);
+	memcpy_s(msg + nlen, msglen - nlen, buf, buflen);
 
 	ZeroMemory(&cds, sizeof(cds));
 	cds.dwData = IPC_MULTICAST_COMMAND;
@@ -5658,8 +5680,7 @@
 
 	// \x82\xB7\x82ׂĂ\xCCTera Term\x82Ƀ\x81\x83b\x83Z\x81[\x83W\x82ƃf\x81[\x83^\x82𑗂\xE9
 	for (i = 0 ; i < MAXNWIN ; i++) {
-		hd = GetNthWin(i);
-		if (hd == NULL) {
+		if ((hd = GetNthWin(i)) == NULL) {
 			break;
 		}
 
@@ -5667,7 +5688,6 @@
 		SendMessage(hd, WM_COPYDATA, (WPARAM)HVTWin, (LPARAM)&cds);
 	}
 
-error:
 	free(msg);
 }
 
@@ -5930,7 +5950,7 @@
 						// 337: 2007/03/20 \x83`\x83F\x83b\x83N\x82\xB3\x82\xEA\x82Ă\xA2\x82\xBD\x82\xE7\x90e\x83E\x83B\x83\x93\x83h\x83E\x82ɂ̂ݑ\x97\x90M
 						checked = SendMessage(GetDlgItem(hWnd, IDC_PARENT_ONLY), BM_GETCHECK, 0, 0);
 
-						SendAllBroadcastMessage(HVTWin, hWnd, checked, buf, strlen(buf));
+						SendBroadcastMessageToSelected(HVTWin, hWnd, checked, buf, strlen(buf));
 					}
 
 					// \x83\x82\x81[\x83h\x83\x8C\x83X\x83_\x83C\x83A\x83\x8D\x83O\x82͈\xEA\x93x\x90\xB6\x90\xAC\x82\xB3\x82\xEA\x82\xE9\x82ƁA\x83A\x83v\x83\x8A\x83P\x81[\x83V\x83\x87\x83\x93\x82\xAA\x8FI\x97\xB9\x82\xB7\x82\xE9\x82܂\xC5

Modified: trunk/teraterm/teraterm/vtwin.h
===================================================================
--- trunk/teraterm/teraterm/vtwin.h	2017-07-26 03:47:51 UTC (rev 6886)
+++ trunk/teraterm/teraterm/vtwin.h	2017-07-26 03:47:55 UTC (rev 6887)
@@ -224,7 +224,7 @@
 extern "C" {
 #endif
 
-void SendAllBroadcastMessage(HWND HVTWin, HWND hWnd, int parent_only, char *buf, int buflen);
+void SendBroadcastMessage(HWND HVTWin, HWND hWnd, char *buf, int buflen);
 void SendMulticastMessage(HWND HVTWin, HWND hWnd, char *name, char *buf, int buflen);
 void SetMulticastName(char *name);
 

Added: trunk/tests/#37401-sendbroadcast.ttl
===================================================================
--- trunk/tests/#37401-sendbroadcast.ttl	                        (rev 0)
+++ trunk/tests/#37401-sendbroadcast.ttl	2017-07-26 03:47:55 UTC (rev 6887)
@@ -0,0 +1,30 @@
+for i 1 3
+	call opentt
+	unlink
+next
+
+call opentt
+
+; Window - \x8F㉺\x82ɕ\xC0\x82ׂĕ\\x8E\xA6
+callmenu 50814
+
+sendbroadcast "pwd"#13#10
+
+pause 1
+
+sendbroadcast "echo "
+
+pause 1
+
+sendlnbroadcast "test"
+
+pause 1
+
+sendlnbroadcast "echo test" "date" "pwd"
+
+end
+
+:opentt
+	cygconnect
+	wait "%" "$" "#"
+	return


Property changes on: trunk/tests/#37401-sendbroadcast.ttl
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property



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