[Ttssh2-commit] [6875] sendbroadcast / sendmulticast で 0x00 , 0x01 が送れないのを修正 Ticket : #37048

svnno****@sourc***** svnno****@sourc*****
2017年 7月 24日 (月) 12:40:19 JST


Revision: 6875
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6875
Author:   doda
Date:     2017-07-24 12:40:19 +0900 (Mon, 24 Jul 2017)
Log Message:
-----------
sendbroadcast / sendmulticast で 0x00, 0x01 が送れないのを修正 Ticket: #37048

・0x00, 0x01 をエンコードして送るようにした。
・sendbroadcast, sendmulticast の処理の共通部分を関数にした。
・sendbroadcast と sendbroadcastln は TTLSendBroadcast を直接呼ぶようにした。

要検討: crlf = TRUE の時の動作

1. 改行が "\n" となっているが、これは妥当か?
   sendln では 0x0D 0x0A ("\r\n") となっている。
2. パラメータ毎に改行を挟んでいるが、これは妥当か?
   sendln では すべて出力後に改行している。

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

Modified Paths:
--------------
    trunk/doc/en/html/about/history.html
    trunk/doc/ja/html/about/history.html
    trunk/teraterm/ttpmacro/ttl.c

-------------- next part --------------
Modified: trunk/doc/en/html/about/history.html
===================================================================
--- trunk/doc/en/html/about/history.html	2017-07-24 03:40:13 UTC (rev 6874)
+++ trunk/doc/en/html/about/history.html	2017-07-24 03:40:19 UTC (rev 6875)
@@ -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>, <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-24 03:40:13 UTC (rev 6874)
+++ trunk/doc/ja/html/about/history.html	2017-07-24 03:40:19 UTC (rev 6875)
@@ -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> / <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/ttpmacro/ttl.c
===================================================================
--- trunk/teraterm/ttpmacro/ttl.c	2017-07-24 03:40:13 UTC (rev 6874)
+++ trunk/teraterm/ttpmacro/ttl.c	2017-07-24 03:40:19 UTC (rev 6875)
@@ -3982,67 +3982,86 @@
 	return 0;
 }
 
-static WORD DoSendBroadcast(BOOL crlf)
+/*
+ * TTLSendBroadcast / TTLSendMulticast \x82̉\xBA\x90\xBF\x82\xAF
+ *
+ * \x8Ae\x83p\x83\x89\x83\x81\x81[\x83^\x82\xF0\x98A\x8C\x8B\x82\xB5\x82\xBD\x95\xB6\x8E\x9A\x97\xF1\x82\xF0 buff \x82Ɋi\x94[\x82\xB5\x82ĕԂ\xB7\x81B
+ * crlf \x82\xAA TRUE \x82̎\x9E\x82͊e\x83p\x83\x89\x83\x81\x81[\x83^\x82̊Ԃ\xC9 "\n" \x82\xF0\x8B\xB2\x82ށB(\x97v\x8C\x9F\x93\xA2)
+ *
+ * \x83p\x83\x89\x83\x81\x81[\x83^\x82\xAA String \x82̏ꍇ\x82͂\xBB\x82̂܂܁AInteger \x82̏ꍇ\x82\xCD ASCII \x83R\x81[\x83h\x82Ƃ݂Ȃ\xB5\x82Ă\xBB\x82̕\xB6\x8E\x9A\x82𑗂\xE9\x81B
+ * Tera Term \x91\xA4\x82ł\xCD send \x93\x99\x82Ƌ\xA4\x92ʂ̃\x8B\x81[\x83`\x83\x93\x82\xAA\x8Eg\x82\xED\x82\xEA\x82\xE9\x88ׁADDE \x92ʐM\x82ׂ̈̃G\x83\x93\x83R\x81[\x83h\x82\xF0\x8Ds\x82\xA4\x95K\x97v\x97L\x82\xE8\x81B
+ *   0x00 -> 0x01 0x01
+ *   0x01 -> 0x01 0x02
+ */
+static WORD GetBroadcastString(char *buff, int bufflen, BOOL crlf)
 {
-	TStrVal buf;    // \x88\xEA\x8Ds\x83o\x83b\x83t\x83@
-	char asc[10];
 	TStrVal Str;
 	WORD Err, ValType;
 	int Val;
-	BOOL EndOfLine;
+	char tmp[3];
 
-	if (! Linked)
-		return ErrLinkFirst;
+	buff[0] = '\0';
 
-	buf[0] = '\0';
-	EndOfLine = FALSE;
-
-	do {
-		if (GetString(Str,&Err))
-		{
+	while (1) {
+		if (GetString(Str, &Err)) {
 			if (Err!=0) return Err;
-			strncat_s(buf, MaxStrLen, Str, _TRUNCATE);
-			if (crlf) 
-				strncat_s(buf, MaxStrLen, "\n", _TRUNCATE);
+			strncat_s(buff, bufflen, Str, _TRUNCATE);
 		}
-		else if (GetExpression(&ValType,&Val,&Err))
-		{
+		else if (GetExpression(&ValType, &Val, &Err)) {
 			if (Err!=0) return Err;
 			switch (ValType) {
-				case TypInteger:  // int\x82\xCDASCII\x83R\x81[\x83h\x82Ƃ݂Ȃ\xB7\x81B
-					asc[0] = LOBYTE(Val);
-					asc[1] = '\0';
-					strncat_s(buf, MaxStrLen, asc, _TRUNCATE);
-					if (crlf) 
-						strncat_s(buf, MaxStrLen, "\n", _TRUNCATE);
+				case TypInteger:
+					Val = LOBYTE(Val);
+					if (Val == 0 || Val == 1) {
+						tmp[0] = 1;
+						tmp[1] = Val + 1;
+						tmp[2] = 0;
+					}
+					else {
+						tmp[0] = Val;
+						tmp[1] = 0;
+					}
+					strncat_s(buff, bufflen, tmp, _TRUNCATE);
 					break;
 				case TypString: 
-					strncat_s(buf, MaxStrLen, StrVarPtr((TVarId)Val), _TRUNCATE);
-					if (crlf) 
-						strncat_s(buf, MaxStrLen, "\n", _TRUNCATE);
+					strncat_s(buff, bufflen, StrVarPtr((TVarId)Val), _TRUNCATE);
 					break;
 				default:
 					return ErrTypeMismatch;
 			}
 		}
-		else
-			EndOfLine = TRUE;
-	} while (! EndOfLine);
-
-	SetFile(buf);
-	return SendCmnd(CmdSendBroadcast,IdTTLWaitCmndEnd);
+		else {
+			break;
+		}
+		if (crlf) {
+			/*
+			 * \x8C\x9F\x93\xA2\x8E\x96\x8D\x80:
+			 *
+			 * 1. crlf \x82\xAA TRUE \x8E\x9E\x82ɑ\x97\x82\xE9\x82̂\xAA "\n" \x82Ȃ̂͑Ó\x96?
+			 *    sendln \x82ł\xCD 0x0A 0x0D ("\r\n") \x82𑗂\xC1\x82Ă\xA2\x82\xE9
+			 *
+			 * 2. \x83p\x83\x89\x83\x81\x81[\x83^\x88\xEA\x82–\x88\x82ɉ\xFC\x8Ds\x82\xB5\x82Ă\xA2\x82\xE9\x82̂͑Ó\x96?
+			 *    sendln \x82ł͂\xB7\x82ׂẴp\x83\x89\x83\x81\x81[\x83^\x82𑗂\xC1\x82\xBD\x8C\xE3\x82ɉ\xFC\x8Ds\x82\xB5\x82Ă\xA2\x82\xE9
+			 */
+			strncat_s(buff, bufflen, "\n", _TRUNCATE);
+		}
+	}
+	return 0;
 }
 
-// "sendbroadcast"\x83R\x83}\x83\x93\x83h (2009.3.3 yutaka)
-WORD TTLSendBroadcast()
+static WORD TTLSendBroadcast(BOOL crlf)
 {
-	return DoSendBroadcast(FALSE);
-}
+	TStrVal buf;
+	WORD Err;
 
-// "sendlnbroadcast"\x83R\x83}\x83\x93\x83h (2009.3.6 yutaka)
-WORD TTLSendlnBroadcast()
-{
-	return DoSendBroadcast(TRUE);
+	if (! Linked)
+		return ErrLinkFirst;
+
+	if ((Err = GetBroadcastString(buf, MaxStrLen, crlf)) != 0)
+		return Err;
+
+	SetFile(buf);
+	return SendCmnd(CmdSendBroadcast,IdTTLWaitCmndEnd);
 }
 
 // "setmulticastname"\x83R\x83}\x83\x93\x83h (2009.3.5 yutaka)
@@ -4062,12 +4081,8 @@
 // "sendmulticast"\x83R\x83}\x83\x93\x83h (2009.3.5 yutaka)
 WORD TTLSendMulticast()
 {
-	TStrVal buf;    // \x88\xEA\x8Ds\x83o\x83b\x83t\x83@
-	char asc[10];
-	TStrVal Str;
-	WORD Err, ValType;
-	int Val;
-	BOOL EndOfLine;
+	TStrVal buf, Str;
+	WORD Err;
 
 	if (! Linked)
 		return ErrLinkFirst;
@@ -4078,41 +4093,13 @@
 	if (Err!=0) return Err;
 	SetFile(Str);
 
-	buf[0] = '\0';
-	EndOfLine = FALSE;
+	if ((Err = GetBroadcastString(buf, MaxStrLen, FALSE)) != 0)
+		return Err;
 
-	do {
-		if (GetString(Str,&Err))
-		{
-			if (Err!=0) return Err;
-			strncat_s(buf, MaxStrLen, Str, _TRUNCATE);
-		}
-		else if (GetExpression(&ValType,&Val,&Err))
-		{
-			if (Err!=0) return Err;
-			switch (ValType) {
-				case TypInteger:  // int\x82\xCDASCII\x83R\x81[\x83h\x82Ƃ݂Ȃ\xB7\x81B
-					asc[0] = LOBYTE(Val);
-					asc[1] = '\0';
-					strncat_s(buf, MaxStrLen, asc, _TRUNCATE);
-					break;
-				case TypString: 
-					strncat_s(buf, MaxStrLen, StrVarPtr((TVarId)Val), _TRUNCATE);
-					break;
-				default:
-					return ErrTypeMismatch;
-			}
-		}
-		else
-			EndOfLine = TRUE;
-	} while (! EndOfLine);
-
 	SetSecondFile(buf);
 	return SendCmnd(CmdSendMulticast,IdTTLWaitCmndEnd);
 }
 
-
-
 WORD TTLSendFile()
 {
 	TStrVal Str;
@@ -6188,9 +6175,9 @@
 		case RsvSendBreak:
 			Err = TTLCommCmd(CmdSendBreak,0); break;
 		case RsvSendBroadcast:
-			Err = TTLSendBroadcast(); break;
+			Err = TTLSendBroadcast(FALSE); break;
 		case RsvSendlnBroadcast:
-			Err = TTLSendlnBroadcast(); break;
+			Err = TTLSendBroadcast(TRUE); break;
 		case RsvSendMulticast:
 			Err = TTLSendMulticast(); break;
 		case RsvSetMulticastName:



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