svnno****@sourc*****
svnno****@sourc*****
2010年 3月 24日 (水) 00:11:47 JST
Revision: 3816 http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=3816 Author: yutakapon Date: 2010-03-24 00:11:47 +0900 (Wed, 24 Mar 2010) Log Message: ----------- YMODEM: ãã¡ã¤ã«åä¿¡ãµãã¼ã Modified Paths: -------------- trunk/teraterm/teraterm/vtwin.cpp trunk/teraterm/ttpfile/ttfile.c trunk/teraterm/ttpfile/ymodem.c -------------- next part -------------- Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2010-03-23 11:09:34 UTC (rev 3815) +++ trunk/teraterm/teraterm/vtwin.cpp 2010-03-23 15:11:47 UTC (rev 3816) @@ -1087,7 +1087,7 @@ // 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_YRCV, MF_BYCOMMAND); 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/ttfile.c =================================================================== --- trunk/teraterm/ttpfile/ttfile.c 2010-03-23 11:09:34 UTC (rev 3815) +++ trunk/teraterm/ttpfile/ttfile.c 2010-03-23 15:11:47 UTC (rev 3816) @@ -787,6 +787,14 @@ get_lang_msg("FILEDLG_TRANS_TITLE_XSEND", uimsg, sizeof(uimsg), TitXSend, UILanguageFile); strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, _TRUNCATE); break; + case OpYRcv: + get_lang_msg("FILEDLG_TRANS_TITLE_YRCV", uimsg, sizeof(uimsg), TitYRcv, UILanguageFile); + strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, _TRUNCATE); + break; + case OpYSend: + get_lang_msg("FILEDLG_TRANS_TITLE_YSEND", uimsg, sizeof(uimsg), TitYSend, UILanguageFile); + strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, _TRUNCATE); + break; case OpZRcv: get_lang_msg("FILEDLG_TRANS_TITLE_ZRCV", uimsg, sizeof(uimsg), TitZRcv, UILanguageFile); strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, _TRUNCATE); Modified: trunk/teraterm/ttpfile/ymodem.c =================================================================== --- trunk/teraterm/ttpfile/ymodem.c 2010-03-23 11:09:34 UTC (rev 3815) +++ trunk/teraterm/ttpfile/ymodem.c 2010-03-23 15:11:47 UTC (rev 3816) @@ -112,10 +112,10 @@ yv->NAKCount--; if (yv->NAKCount<0) { - if (yv->NAKMode==XnakC) + if (yv->NAKMode==YnakC) { YSetOpt(fv,yv,XoptCheck); - yv->NAKMode = XnakNAK; + yv->NAKMode = YnakC; yv->NAKCount = 9; } else { @@ -124,7 +124,7 @@ } } - if (yv->NAKMode==XnakNAK) + if (yv->NAKMode!=YnakC) { b = NAK; if ((yv->PktNum==0) && (yv->PktNumOffset==0)) @@ -179,12 +179,16 @@ { char inistr[MAXPATHLEN + 10]; - if (! GetNextFname(fv)) - { - return; + if (yv->YMode == IdYSend) { + if (! GetNextFname(fv)) + { + return; + } + /* file open */ + fv->FileHandle = _lopen(fv->FullName,OF_READ); + } else { + fv->FileHandle = -1; } - /* file open */ - fv->FileHandle = _lopen(fv->FullName,OF_READ); fv->FileOpen = fv->FileHandle>0; fv->LogFlag = ((ts->LogFlag & LOG_Y)!=0); @@ -240,18 +244,22 @@ yv->NAKCount = 10; } + if (fv->LogFlag) { + char buf[128]; + time_t tm = time(NULL); + + _snprintf_s(buf, sizeof(buf), _TRUNCATE, "YMODEM %s start: %s\n", + yv->YMode == IdYSend ? "Send" : "Recv", + ctime(&tm) + ); + _lwrite(fv->LogFile, buf, strlen(buf)); + } + switch (yv->YMode) { case IdYSend: yv->TextFlag = 0; - 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@CMJnOÉA"rb t@C¼"ð©®IÉÄÑo·B(2007.12.20 yutaka) //strcpy(ts->YModemRcvCommand, "rb"); if (ts->YModemRcvCommand[0] != '\0') { @@ -264,7 +272,14 @@ break; case IdYReceive: +#if 0 + strcpy(inistr, "sb teraterm2.ini\r\n"); +// strcpy(inistr, "sb foo.txt\r\n"); + YWrite(fv,yv,cv, inistr , strlen(inistr)); +#endif + YSendNAK(fv,yv,cv); + break; } } @@ -310,6 +325,7 @@ yv->PktReadMode = XpktBLK; if (yv->YOpt==Xopt1K) YSetOpt(fv,yv,XoptCRC); + yv->DataLen = 128; FTSetTimeOut(fv,yv->TOutShort); } else if (b==STX) @@ -317,6 +333,7 @@ yv->PktIn[0] = b; yv->PktReadMode = XpktBLK; YSetOpt(fv,yv,Xopt1K); + yv->DataLen = 1024; FTSetTimeOut(fv,yv->TOutShort); } else if (b==EOT) @@ -370,16 +387,18 @@ if (! GetPkt) return TRUE; +#if 0 if ((yv->PktIn[1]==0) && (yv->PktNum==0) && (yv->PktNumOffset==0)) { - if (yv->NAKMode==XnakNAK) + if (yv->NAKMode!=YnakC) yv->NAKCount = 10; else yv->NAKCount = 3; YSendNAK(fv,yv,cv); return TRUE; } +#endif GetPkt = YCheckPacket(yv); if (! GetPkt) @@ -398,10 +417,34 @@ /* send ACK */ b = ACK; YWrite(fv,yv,cv,&b, 1); - yv->NAKMode = XnakNAK; + yv->NAKMode = YnakC; yv->NAKCount = 10; - if (d==0) return TRUE; + // YMODEMÌêAblock#0ªut@CîñvÆÈéB + if (d == 0) { + long modtime; + long bytes_total; + int mode; + int ret; + BYTE *p; + char *name, *nameend; + + p = &(yv->PktIn[3]); + name = p; + strncpy_s(fv->FullName, sizeof(fv->FullName), name, _TRUNCATE); + nameend = name + 1 + strlen(name); + if (*nameend) { + ret = sscanf(nameend, "%ld%lo%o", &bytes_total, &modtime, &mode); + if (ret == 3) { + fv->FileSize = bytes_total; + } + } + fv->FileHandle = _lcreat(fv->FullName,0); + fv->FileOpen = fv->FileHandle>0; + + return TRUE; + } + yv->PktNum = yv->PktIn[1]; if (yv->PktNum==0) yv->PktNumOffset = yv->PktNumOffset + 256;