[Ttssh2-commit] [3815] YMODEM: ファイル送信サポート

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 3月 23日 (火) 20:09:34 JST


Revision: 3815
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=3815
Author:   yutakapon
Date:     2010-03-23 20:09:34 +0900 (Tue, 23 Mar 2010)

Log Message:
-----------
YMODEM: ファイル送信サポート

Modified Paths:
--------------
    trunk/teraterm/teraterm/vtwin.cpp
    trunk/teraterm/ttpfile/ymodem.c
    trunk/teraterm/ttpset/ttset.c


-------------- next part --------------
Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2010-03-23 10:07:43 UTC (rev 3814)
+++ trunk/teraterm/teraterm/vtwin.cpp	2010-03-23 11:09:34 UTC (rev 3815)
@@ -1084,13 +1084,10 @@
 	ModifyMenu(FileMenu, ID_FILE_XSEND, MF_BYCOMMAND, ID_FILE_XSEND, ts.UIMsg);
 
 	// TBD: YMODEM‚Í‚Ü‚¾–¢ƒTƒ|[ƒg‚Ȃ̂ŁAƒƒjƒ…[‚͉B‚·B(2008.5.15 yutaka)
-//#define YMODEM_TBD
-#ifndef YMODEM_TBD
-	DeleteMenu(TransMenu, 2, MF_BYPOSITION);
+	// ‘—M‚̂݃Tƒ|[ƒg (2010.3.23 yutaka)
+	//DeleteMenu(TransMenu, 2, MF_BYPOSITION);
+	//DeleteMenu(FileMenu, ID_FILE_YSEND, MF_BYCOMMAND);
 	DeleteMenu(FileMenu, ID_FILE_YRCV, MF_BYCOMMAND);
-	DeleteMenu(FileMenu, ID_FILE_YSEND, MF_BYCOMMAND);
-#endif
-#undef YMODEM_TBD
 
 	GetMenuString(FileMenu, ID_FILE_ZRCV, uimsg, sizeof(uimsg), MF_BYCOMMAND);
 	get_lang_msg("MENU_TRANS_Z_RCV", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);

Modified: trunk/teraterm/ttpfile/ymodem.c
===================================================================
--- trunk/teraterm/ttpfile/ymodem.c	2010-03-23 10:07:43 UTC (rev 3814)
+++ trunk/teraterm/ttpfile/ymodem.c	2010-03-23 11:09:34 UTC (rev 3815)
@@ -7,6 +7,7 @@
 #include "tttypes.h"
 #include "ttftypes.h"
 #include <stdio.h>
+#include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -243,15 +244,21 @@
 	case IdYSend:
 		yv->TextFlag = 0;
 
-#if 1
+		if (fv->LogFlag) {
+			char buf[128];
+			time_t tm = time(NULL);
+
+			_snprintf_s(buf, sizeof(buf), _TRUNCATE, "YMODEM start: %s\n", ctime(&tm));
+			_lwrite(fv->LogFile, buf, strlen(buf));
+		}
+
 		// ƒtƒ@ƒCƒ‹‘—MŠJŽn‘O‚ɁA"rb ƒtƒ@ƒCƒ‹–¼"‚ðŽ©“®“I‚ɌĂяo‚·B(2007.12.20 yutaka)
-		strcpy(ts->YModemRcvCommand, "rb");
+		//strcpy(ts->YModemRcvCommand, "rb");
 		if (ts->YModemRcvCommand[0] != '\0') {
 			_snprintf_s(inistr, sizeof(inistr), _TRUNCATE, "%s\015", 
 				ts->YModemRcvCommand);
 			YWrite(fv,yv,cv, inistr , strlen(inistr));
 		}
-#endif
 
 		FTSetTimeOut(fv,TimeOutVeryLong);
 		break;
@@ -435,6 +442,7 @@
 	int i;
 	BOOL SendFlag;
 	WORD Check;
+	BYTE firstch, lastrx;
 
 	SendFlag = FALSE;
 	if (yv->PktBufCount==0)
@@ -442,8 +450,16 @@
 		i = YRead1Byte(fv,yv,cv,&b);
 		do {
 			if (i==0) return TRUE;
+			firstch = b;
 			switch (b) {
 			case ACK:
+				// 1‰ñ–Ú‚ÌEOT‘—MŒã‚ÌACKŽóM‚ŁAI‚í‚è‚Æ‚·‚éB
+				if (yv->SendEot) {
+					yv->SendEot = 0;
+					yv->LastSendEot = 1;
+					break;
+				}
+
 				if (! fv->FileOpen)
 				{
 					fv->Success = TRUE;
@@ -456,6 +472,7 @@
 						yv->PktNumOffset = yv->PktNumOffset + 256;
 					SendFlag = TRUE;
 				}
+
 				break;
 
 			case NAK:
@@ -496,8 +513,18 @@
 		FTSetTimeOut(fv,TimeOutVeryLong);
 
 		do {
+			lastrx = firstch;
 			i = YRead1Byte(fv,yv,cv,&b);
-		} while (i!=0);
+			if (i != 0) {
+				firstch = b;
+				if (firstch == CAN && lastrx == CAN) {
+					// CAN(0x18)‚ª˜A‘±‚µ‚Ä‚­‚é‚ƁAƒtƒ@ƒCƒ‹‘—M‚ÌŽ¸”s‚ÆŒ©‚È‚·B
+					// ‚½‚Æ‚¦‚΁AƒT[ƒo‚É“¯–¼‚̃tƒ@ƒCƒ‹‚ª‘¶Ý‚·‚éê‡‚ȂǁB
+					// (2010.3.23 yutaka)
+					return FALSE;
+				}
+			}
+		} while (i != 0);
 
 		if (yv->LastSendEot) { // ƒI[ƒ‹ƒ[ƒ‚̃uƒƒbƒN‚𑗐M‚µ‚āA‚à‚¤ƒtƒ@ƒCƒ‹‚ª‚È‚¢‚±‚Æ‚ð’m‚点‚éB
 			if (yv->DataLen==128)
@@ -638,9 +665,20 @@
 	}
 	/* a NAK or C could have arrived while we were buffering.  Consume it. */
 	do {
+		lastrx = firstch;
 		i = YRead1Byte(fv,yv,cv,&b);
-	} while (i!=0);
+		if (i != 0) {
+			firstch = b;
+			if (firstch == CAN && lastrx == CAN) {
+				// CAN(0x18)‚ª˜A‘±‚µ‚Ä‚­‚é‚ƁAƒtƒ@ƒCƒ‹‘—M‚ÌŽ¸”s‚ÆŒ©‚È‚·B
+				// ‚½‚Æ‚¦‚΁AƒT[ƒo‚É“¯–¼‚̃tƒ@ƒCƒ‹‚ª‘¶Ý‚·‚éê‡‚ȂǁB
+				// (2010.3.23 yutaka)
+				return FALSE;
+			}
+		}
+	} while (i != 0);
 
+
 	i = 1;
 	while ((yv->PktBufCount>0) && (i>0))
 	{

Modified: trunk/teraterm/ttpset/ttset.c
===================================================================
--- trunk/teraterm/ttpset/ttset.c	2010-03-23 10:07:43 UTC (rev 3814)
+++ trunk/teraterm/ttpset/ttset.c	2010-03-23 11:09:34 UTC (rev 3815)
@@ -1065,6 +1065,10 @@
 	if (GetOnOff(Section, "YmodemLog", FName, FALSE))
 		ts->LogFlag |= LOG_Y;
 
+	/* YMODEM ŽóMƒRƒ}ƒ“ƒh (2010.3.23 yutaka) */
+	GetPrivateProfileString(Section, "YModemRcvCommand", "rb",
+	                        ts->YModemRcvCommand, sizeof(ts->YModemRcvCommand), FName);
+
 	/* Auto ZMODEM activation -- special option */
 	if (GetOnOff(Section, "ZmodemAuto", FName, FALSE))
 		ts->FTFlag |= FT_ZAUTO;
@@ -2151,6 +2155,9 @@
 	/* YMODEM log  -- special option */
 	WriteOnOff(Section, "YmodemLog", FName, (WORD) (ts->LogFlag & LOG_Y));
 
+	/* YMODEM ŽóMƒRƒ}ƒ“ƒh (2010.3.23 yutaka) */
+	WritePrivateProfileString(Section, "YmodemRcvCommand", ts->YModemRcvCommand, FName);
+
 	/* Auto ZMODEM activation -- special option */
 	WriteOnOff(Section, "ZmodemAuto", FName,
 	           (WORD) (ts->FTFlag & FT_ZAUTO));



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