[Ttssh2-commit] [3826] XMODEM: 受信したバイナリファイルの末尾に、CPMEOF (0x1A) が除去されないままとなっていた問題を修正した。

svnno****@sourc***** svnno****@sourc*****
2010年 3月 26日 (金) 18:09:02 JST


Revision: 3826
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=3826
Author:   yutakapon
Date:     2010-03-26 18:09:02 +0900 (Fri, 26 Mar 2010)

Log Message:
-----------
XMODEM: 受信したバイナリファイルの末尾に、CPMEOF(0x1A)が除去されないままとなっていた問題を修正した。

Modified Paths:
--------------
    trunk/doc/en/html/about/history.html
    trunk/doc/ja/html/about/history.html
    trunk/teraterm/ttpfile/xmodem.c


-------------- next part --------------
Modified: trunk/doc/en/html/about/history.html
===================================================================
--- trunk/doc/en/html/about/history.html	2010-03-26 06:47:13 UTC (rev 3825)
+++ trunk/doc/en/html/about/history.html	2010-03-26 09:09:02 UTC (rev 3826)
@@ -30,7 +30,7 @@
 
 <h2><a name="teraterm">Tera Term</a></h2>
 
-<h3><a name="teraterm_4.66">2010.3.24 (Ver 4.66 unreleased)</a></h3>
+<h3><a name="teraterm_4.66">2010.3.26 (Ver 4.66 unreleased)</a></h3>
 <ul class="history">
   <li>Changes
     <ul>
@@ -51,6 +51,7 @@
       <!--li>‘ã‘ÖƒXƒNƒŠ[ƒ“ƒoƒbƒtƒ@‘Ήž‚̃J[ƒ\ƒ‹ˆÊ’u•Û‘¶§ŒäƒV[ƒPƒ“ƒX‚ŁA‘ã‘Ö‰æ–ʃoƒbƒtƒ@‚ւ̐؂è‘Ö‚¦A‚¨‚æ‚щæ–ʂ̃NƒŠƒA‚ªs‚í‚ê‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B</li-->
       <li>If ClearOnResize setting is on, DECCOLM (Change Column Mode) control sequence does not clear screen.</li>
       <!--li>ƒL[ƒ{[ƒhÝ’èƒtƒ@ƒCƒ‹‚Å Alt+ƒL[ ‚É‹@”\‚ðŠ„‚è“–‚Ä‚½ŽžA—]Œv‚È•¶Žš—ñ‚ª’ljÁ‚ŏo—Í‚³‚ê‚é‚Ì‚ðC³‚µ‚½B</li-->
+      <li>XMODEM: A received file may include the CPMEOF(0x1A) block at the end of the file.</li>
     </ul>
   </li>
 

Modified: trunk/doc/ja/html/about/history.html
===================================================================
--- trunk/doc/ja/html/about/history.html	2010-03-26 06:47:13 UTC (rev 3825)
+++ trunk/doc/ja/html/about/history.html	2010-03-26 09:09:02 UTC (rev 3826)
@@ -30,7 +30,7 @@
 
 <h2><a name="teraterm">Tera Term</a></h2>
 
-<h3><a name="teraterm_4.66">2010.3.24 (Ver 4.66 unreleased)</a></h3>
+<h3><a name="teraterm_4.66">2010.3.26 (Ver 4.66 unreleased)</a></h3>
 <ul class="history">
   <li>•ÏX
     <ul>
@@ -50,6 +50,7 @@
       <li>‘ã‘ÖƒXƒNƒŠ[ƒ“ƒoƒbƒtƒ@‘Ήž‚̃J[ƒ\ƒ‹ˆÊ’u•Û‘¶§ŒäƒV[ƒPƒ“ƒX‚ŁA‘ã‘Ö‰æ–ʃoƒbƒtƒ@‚ւ̐؂è‘Ö‚¦A‚¨‚æ‚щæ–ʂ̃NƒŠƒA‚ªs‚í‚ê‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B</li>
       <li>ClearOnResize ‚ª on ‚ÌŽžADECCOLM(Œ…”ƒ‚[ƒh•ÏX)§ŒäƒV[ƒPƒ“ƒX‚ʼnæ–Ê‚ªƒNƒŠƒA‚³‚ê‚È‚¢‚Ì‚ðC³‚µ‚½B</li>
       <li>ƒL[ƒ{[ƒhÝ’èƒtƒ@ƒCƒ‹‚Å Alt+ƒL[ ‚É‹@”\‚ðŠ„‚è“–‚Ä‚½ŽžA—]Œv‚È•¶Žš—ñ‚ª’ljÁ‚ŏo—Í‚³‚ê‚é‚Ì‚ðC³‚µ‚½B</li>
+      <li>XMODEM: ŽóM‚µ‚½ƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ì––”ö‚ɁACPMEOF(0x1A)‚ªœ‹Ž‚³‚ê‚È‚¢‚Ü‚Ü‚Æ‚È‚Á‚Ä‚¢‚½–â‘è‚ðC³‚µ‚½B</li>
     </ul>
   </li>
 

Modified: trunk/teraterm/ttpfile/xmodem.c
===================================================================
--- trunk/teraterm/ttpfile/xmodem.c	2010-03-26 06:47:13 UTC (rev 3825)
+++ trunk/teraterm/ttpfile/xmodem.c	2010-03-26 09:09:02 UTC (rev 3826)
@@ -7,6 +7,10 @@
 #include "tttypes.h"
 #include "ttftypes.h"
 #include <stdio.h>
+#include <io.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
 
 #include "tt_res.h"
 #include "ttcommon.h"
@@ -220,6 +224,12 @@
 		FTSetTimeOut(fv, TimeOutVeryLong);
 		break;
 	case IdXReceive:
+#if 0
+//		strcpy(inistr, "sx svnrev.exe\r\n");
+		strcpy(inistr, "sx -b lrzsz-0.12.20.tar.gz\r\n");
+		XWrite(fv, xv, cv, inistr, strlen(inistr));
+#endif
+
 		XSendNAK(fv, xv, cv);
 		break;
 	}
@@ -249,7 +259,7 @@
 BOOL XReadPacket(PFileVar fv, PXVar xv, PComVar cv)
 {
 	BYTE b, d;
-	int i, c;
+	int i, c, t;
 	BOOL GetPkt;
 
 	c = XRead1Byte(fv, xv, cv, &b);
@@ -271,6 +281,21 @@
 				XSetOpt(fv, xv, Xopt1K);
 				FTSetTimeOut(fv, xv->TOutShort);
 			} else if (b == EOT) {
+				// ƒoƒCƒiƒŠƒ‚[ƒh‚̏ꍇA––”ö‚ÌCPMEOF‚ðíœ‚·‚éB
+				if (xv->TextFlag == 0) {
+					int fd;
+
+					_lclose(fv->FileHandle);
+					fv->FileHandle = -1;
+					fv->FileOpen = 0;
+
+					fd = _open(fv->FullName, _O_RDWR);
+					if (fd != -1) {
+						_chsize_s(fd, fv->FileSize);
+						_close(fd);
+					}
+				}
+
 				b = ACK;
 				fv->Success = TRUE;
 				XWrite(fv, xv, cv, &b, 1);
@@ -351,10 +376,20 @@
 	if (xv->PktNum == 0)
 		xv->PktNumOffset = xv->PktNumOffset + 256;
 
-	c = xv->DataLen;
+	// XMODEM‚ÌŽd—l‚É‚æ‚ê‚΁AÅŒã‚̃uƒƒbƒN‚ª 128/1024 byte‚É–ž‚½‚È‚¢ê‡ACPMEOF(0x1A)‚Å
+	// ƒpƒfƒBƒ“ƒO‚·‚邱‚Æ‚É‚È‚Á‚Ä‚¢‚éBASCIIƒ‚[ƒhEƒoƒCƒiƒŠƒ‚[ƒh‚ÍŠÖŒW‚È‚­A–³ðŒ‚É
+	// ƒpƒfƒBƒ“ƒO‚³‚ê‚éB"lrzsz-0.12.20"‚Ì filbuf()#src/lsz.c ‚ÌŽÀ‘•‚à‚»‚¤‚È‚Á‚Ä‚¢‚éB
+	// ‚æ‚Á‚āA–³ðŒ‚É CPMEOF íœˆ—‚ª“®ì‚·‚é‚悤‚É‚µAƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ì––”ö‚ª‰ó‚ê‚é
+	// Œ»Û‚ð‰ñ”ð‚·‚éB
+	// (2010.3.26 yutaka)
+	t = xv->DataLen;
+	while ((t > 0) && (xv->PktIn[2 + t] == 0x1A))
+		t--;
 	if (xv->TextFlag > 0)
-		while ((c > 0) && (xv->PktIn[2 + c] == 0x1A))
-			c--;
+		c = t;
+	else
+		c = xv->DataLen;
+	fv->FileSize = fv->ByteCount + t;
 
 	if (xv->TextFlag > 0)
 		for (i = 0; i <= c - 1; i++) {



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