svnno****@sourc*****
svnno****@sourc*****
2016年 2月 24日 (水) 23:35:10 JST
Revision: 6318 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6318 Author: doda Date: 2016-02-24 23:35:10 +0900 (Wed, 24 Feb 2016) Log Message: ----------- XMODEM のタイムアウトを指定可能に。 https://osdn.jp/ticket/browse.php?group_id=1412&tid=33055 Modified Paths: -------------- trunk/installer/release/TERATERM.INI trunk/teraterm/common/ttftypes.h trunk/teraterm/common/ttlib.c trunk/teraterm/common/ttlib.h trunk/teraterm/common/tttypes.h trunk/teraterm/ttpfile/xmodem.c trunk/teraterm/ttpset/ttset.c -------------- next part -------------- Modified: trunk/installer/release/TERATERM.INI =================================================================== --- trunk/installer/release/TERATERM.INI 2016-02-23 12:47:49 UTC (rev 6317) +++ trunk/installer/release/TERATERM.INI 2016-02-24 14:35:10 UTC (rev 6318) @@ -703,6 +703,9 @@ ; XMODEM log XmodemLog=off +; XMODEM Timeout +XmodemTimeouts=10,3,10,20,60 + ; YMODEM log YmodemLog=off Modified: trunk/teraterm/common/ttftypes.h =================================================================== --- trunk/teraterm/common/ttftypes.h 2016-02-23 12:47:49 UTC (rev 6317) +++ trunk/teraterm/common/ttftypes.h 2016-02-24 14:35:10 UTC (rev 6318) @@ -185,6 +185,9 @@ BOOL CRRecv; int TOutShort; int TOutLong; + int TOutInit; + int TOutInitCRC; + int TOutVLong; int CANCount; } TXVar; typedef TXVar far *PXVar; Modified: trunk/teraterm/common/ttlib.c =================================================================== --- trunk/teraterm/common/ttlib.c 2016-02-23 12:47:49 UTC (rev 6317) +++ trunk/teraterm/common/ttlib.c 2016-02-24 14:35:10 UTC (rev 6318) @@ -804,6 +804,19 @@ } } +int GetNthNum2(PCHAR Source, int Nth, int defval) +{ + char T[15]; + int v; + + GetNthString(Source, Nth, sizeof(T), T); + if (sscanf(T, "%d", &v) != 1) { + v = defval; + } + + return v; +} + void WINAPI GetDefaultFName(char *home, char *file, char *dest, int destlen) { // My Documents \x82\xC9 file \x82\xAA\x82\xA0\x82\xE9\x8Fꍇ\x81A Modified: trunk/teraterm/common/ttlib.h =================================================================== --- trunk/teraterm/common/ttlib.h 2016-02-23 12:47:49 UTC (rev 6317) +++ trunk/teraterm/common/ttlib.h 2016-02-24 14:35:10 UTC (rev 6318) @@ -36,6 +36,7 @@ void RestoreNewLine(PCHAR Text); BOOL GetNthString(PCHAR Source, int Nth, int Size, PCHAR Dest); void GetNthNum(PCHAR Source, int Nth, int far *Num); +int GetNthNum2(PCHAR Source, int Nth, int defval); void WINAPI GetDefaultFName(char *home, char *file, char *dest, int destlen); void GetDefaultSetupFName(char *home, char *dest, int destlen); void GetUILanguageFile(char *buf, int buflen); Modified: trunk/teraterm/common/tttypes.h =================================================================== --- trunk/teraterm/common/tttypes.h 2016-02-23 12:47:49 UTC (rev 6317) +++ trunk/teraterm/common/tttypes.h 2016-02-24 14:35:10 UTC (rev 6318) @@ -591,6 +591,11 @@ WORD AutoComPortReconnect; WORD BGImgBrightness; cygterm_t CygtermSettings; + int XmodemTimeOutInit; + int XmodemTimeOutInitCRC; + int XmodemTimeOutShort; + int XmodemTimeOutLong; + int XmodemTimeOutVLong; }; typedef struct tttset TTTSet, *PTTSet; Modified: trunk/teraterm/ttpfile/xmodem.c =================================================================== --- trunk/teraterm/ttpfile/xmodem.c 2016-02-23 12:47:49 UTC (rev 6317) +++ trunk/teraterm/ttpfile/xmodem.c 2016-02-24 14:35:10 UTC (rev 6318) @@ -16,12 +16,6 @@ #include "xmodem.h" -#define TimeOutInit 10 -#define TimeOutC 3 -#define TimeOutShort 10 -#define TimeOutLong 20 -#define TimeOutVeryLong 60 - int XRead1Byte(PFileVar fv, PXVar xv, PComVar cv, LPBYTE b) { if (CommRead1Byte(cv, b) == 0) @@ -121,12 +115,12 @@ if (xv->NAKMode == XnakNAK) { b = NAK; if ((xv->PktNum == 0) && (xv->PktNumOffset == 0)) - t = TimeOutInit; + t = xv->TOutInit; else t = xv->TOutLong; } else { b = 'C'; - t = TimeOutC; + t = xv->TOutInitCRC; } XWrite(fv, xv, cv, &b, 1); xv->PktReadMode = XpktSOH; @@ -194,12 +188,16 @@ fv->ByteCount = 0; + xv->TOutInit = ts->XmodemTimeOutInit; + xv->TOutInitCRC = ts->XmodemTimeOutInitCRC; + xv->TOutVLong = ts->XmodemTimeOutVLong; + if (cv->PortType == IdTCPIP) { - xv->TOutShort = TimeOutVeryLong; - xv->TOutLong = TimeOutVeryLong; + xv->TOutShort = ts->XmodemTimeOutVLong; + xv->TOutLong = ts->XmodemTimeOutVLong; } else { - xv->TOutShort = TimeOutShort; - xv->TOutLong = TimeOutLong; + xv->TOutShort = ts->XmodemTimeOutShort; + xv->TOutLong = ts->XmodemTimeOutLong; } XSetOpt(fv, xv, xv->XOpt); @@ -224,7 +222,7 @@ XWrite(fv, xv, cv, inistr, strlen(inistr)); } - FTSetTimeOut(fv, TimeOutVeryLong); + FTSetTimeOut(fv, xv->TOutVLong); break; case IdXReceive: XSendNAK(fv, xv, cv); @@ -456,7 +454,7 @@ xv->CANCount = 0; } // reset timeout timer - FTSetTimeOut(fv, TimeOutVeryLong); + FTSetTimeOut(fv, xv->TOutVLong); do { i = XRead1Byte(fv, xv, cv, &b); Modified: trunk/teraterm/ttpset/ttset.c =================================================================== --- trunk/teraterm/ttpset/ttset.c 2016-02-23 12:47:49 UTC (rev 6317) +++ trunk/teraterm/ttpset/ttset.c 2016-02-24 14:35:10 UTC (rev 6318) @@ -1849,6 +1849,28 @@ ts->Debug = FALSE; } + // Xmodem Timeout + GetPrivateProfileString(Section, "XmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName); + ts->XmodemTimeOutInit = GetNthNum2(Temp, 1, 10); + if (ts->XmodemTimeOutInit < 1) + ts->XmodemTimeOutInit = 1; + ts->XmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3); + if (ts->XmodemTimeOutInitCRC < 1) + ts->XmodemTimeOutInitCRC = 1; + ts->XmodemTimeOutShort = GetNthNum2(Temp, 3, 10); + if (ts->XmodemTimeOutShort < 1) + ts->XmodemTimeOutShort = 1; + ts->XmodemTimeOutLong = GetNthNum2(Temp, 4, 20); + if (ts->XmodemTimeOutLong < 1) + ts->XmodemTimeOutLong = 1; + ts->XmodemTimeOutVLong = GetNthNum2(Temp, 5, 60); + if (ts->XmodemTimeOutVLong < 1) + ts->XmodemTimeOutVLong = 1; + + GetPrivateProfileString(Section, "VTPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName); /* default: random position */ + GetNthNum(Temp, 1, (int far *) (&ts->VTPos.x)); + GetNthNum(Temp, 2, (int far *) (&ts->VTPos.y)); + // CygTerm Configuration File ReadCygtermConfFile(ts); } @@ -3068,6 +3090,16 @@ } WritePrivateProfileString(Section, "DebugModes", Temp, FName); + // Xmodem Timeout + _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d,%d", + ts->XmodemTimeOutInit, + ts->XmodemTimeOutInitCRC, + ts->XmodemTimeOutShort, + ts->XmodemTimeOutLong, + ts->XmodemTimeOutVLong + ); + WritePrivateProfileString(Section, "XmodemTimeouts", Temp, FName); + // CygTerm Configuration File WriteCygtermConfFile(ts); }