Revision: 8998 https://osdn.net/projects/ttssh2/scm/svn/commits/8998 Author: zmatsuo Date: 2020-11-02 00:35:53 +0900 (Mon, 02 Nov 2020) Log Message: ----------- ymodem の YMODEMStart() API を使用しないようにした - YMODEMStart(), YMODEMStartReceive() に統一 Modified Paths: -------------- branches/proto_unicode/teraterm/teraterm/filesys.h branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp branches/proto_unicode/teraterm/teraterm/ttdde.c branches/proto_unicode/teraterm/teraterm/vtwin.cpp branches/proto_unicode/teraterm/ttpfile/ymodem.c -------------- next part -------------- Modified: branches/proto_unicode/teraterm/teraterm/filesys.h =================================================================== --- branches/proto_unicode/teraterm/teraterm/filesys.h 2020-11-01 15:35:39 UTC (rev 8997) +++ branches/proto_unicode/teraterm/teraterm/filesys.h 2020-11-01 15:35:53 UTC (rev 8998) @@ -52,8 +52,7 @@ BOOL KermitFinish(BOOL macro); BOOL XMODEMStartReceive(const char *fiename, WORD ParamBinaryFlag, WORD ParamXmodemOpt); BOOL XMODEMStartSend(const char *fiename, WORD ParamXmodemOpt); -void YMODEMStart(int mode); -BOOL YMODEMStartReceive(void); +BOOL YMODEMStartReceive(BOOL macro); BOOL YMODEMStartSend(const char *fiename); void ZMODEMStart(int mode); BOOL ZMODEMStartReceive(void); Modified: branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp =================================================================== --- branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp 2020-11-01 15:35:39 UTC (rev 8997) +++ branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp 2020-11-01 15:35:53 UTC (rev 8998) @@ -1246,62 +1246,48 @@ return TRUE; } -void YMODEMStart(int mode) +BOOL YMODEMStartReceive(BOOL macro) { - WORD Opt; - char uimsg[MAX_UIMSG]; - const char *UILanguageFile = ts.UILanguageFile; + if (FileVar != NULL) { + return FALSE; + } + if (!NewFileVar_(&FileVar)) { + return FALSE; + } - if (! ProtoStart()) - return; - TFileVarProto *fv = FileVar; - if (mode==IdYSend) - { - strncpy_s(fv->DlgCaption, sizeof(fv->DlgCaption),"Tera Term: ", _TRUNCATE); - get_lang_msg("FILEDLG_TRANS_TITLE_YSEND", uimsg, sizeof(uimsg), TitYSend, UILanguageFile); - strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, _TRUNCATE); - - // \x83t\x83@\x83C\x83\x8B\x93]\x91\x97\x8E\x9E\x82̃I\x83v\x83V\x83\x87\x83\x93\x82\xCD"Yopt1K"\x82Ɍ\x88\x82ߑł\xBF\x81B - // TODO: "Yopt1K", "YoptG", "YoptSingle"\x82\xF0\x8B\xE6\x95ʂ\xB5\x82\xBD\x82\xA2\x82Ȃ\xE7\x82AIDD_FOPT\x82\xF0\x8Ag\x92\xA3\x82\xB7\x82\xE9\x95K\x97v\x82\xA0\x82\xE8\x81B - Opt = Yopt1K; - FileVar->OpId = OpYSend; - if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) - { - if (! _GetMultiFname(fv->HMainWin, GMF_Y, fv->DlgCaption, &Opt) || - (FileVar->NumFname==0)) - { - ProtoEnd(); - return; - } - //ts.XmodemBin = Opt; - } - else - _SetFileVar(FileVar); + if (macro) { + FileVar->NoMsg = TRUE; } - else { - FileVar->OpId = OpYRcv; - strncpy_s(fv->DlgCaption, sizeof(fv->DlgCaption),"Tera Term: ", _TRUNCATE); - get_lang_msg("FILEDLG_TRANS_TITLE_YRCV", uimsg, sizeof(uimsg), TitYRcv, UILanguageFile); - strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, _TRUNCATE); + if (! ProtoStart()) + return FALSE; - // \x83t\x83@\x83C\x83\x8B\x93]\x91\x97\x8E\x9E\x82̃I\x83v\x83V\x83\x87\x83\x93\x82\xCD"Yopt1K"\x82Ɍ\x88\x82ߑł\xBF\x81B - Opt = Yopt1K; - _SetFileVar(FileVar); - } + FileVar->OpId = OpYRcv; + char uimsg[MAX_UIMSG]; + const char *UILanguageFile = ts.UILanguageFile; + strncpy_s(fv->DlgCaption, sizeof(fv->DlgCaption),"Tera Term: ", _TRUNCATE); + get_lang_msg("FILEDLG_TRANS_TITLE_YRCV", uimsg, sizeof(uimsg), TitYRcv, UILanguageFile); + strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, _TRUNCATE); + + // \x83t\x83@\x83C\x83\x8B\x93]\x91\x97\x8E\x9E\x82̃I\x83v\x83V\x83\x87\x83\x93\x82\xCD"Yopt1K"\x82Ɍ\x88\x82ߑł\xBF\x81B + WORD Opt = Yopt1K; + _SetFileVar(FileVar); + TalkStatus = IdTalkQuiet; /* disable transmit delay (serial port) */ cv.DelayFlag = FALSE; - if (! OpenProtoDlg(FileVar,PROTO_YM,mode,Opt,0)) + if (! OpenProtoDlg(FileVar,PROTO_YM,IdYReceive,Opt,0)) ProtoEnd(); + + return TRUE; } -BOOL YMODEMStartReceive() +BOOL YMODEMStartSend(const char *filename) { if (FileVar != NULL) { return FALSE; @@ -1309,25 +1295,47 @@ if (!NewFileVar_(&FileVar)) { return FALSE; } - FileVar->NoMsg = TRUE; - YMODEMStart(IdYReceive); - return TRUE; -} -BOOL YMODEMStartSend(const char *fiename) -{ - if (FileVar != NULL) { + if (! ProtoStart()) return FALSE; + + TFileVarProto *fv = FileVar; + + char uimsg[MAX_UIMSG]; + const char *UILanguageFile = ts.UILanguageFile; + strncpy_s(fv->DlgCaption, sizeof(fv->DlgCaption),"Tera Term: ", _TRUNCATE); + get_lang_msg("FILEDLG_TRANS_TITLE_YSEND", uimsg, sizeof(uimsg), TitYSend, UILanguageFile); + strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, _TRUNCATE); + + // \x83t\x83@\x83C\x83\x8B\x93]\x91\x97\x8E\x9E\x82̃I\x83v\x83V\x83\x87\x83\x93\x82\xCD"Yopt1K"\x82Ɍ\x88\x82ߑł\xBF\x81B + // TODO: "Yopt1K", "YoptG", "YoptSingle"\x82\xF0\x8B\xE6\x95ʂ\xB5\x82\xBD\x82\xA2\x82Ȃ\xE7\x82AIDD_FOPT\x82\xF0\x8Ag\x92\xA3\x82\xB7\x82\xE9\x95K\x97v\x82\xA0\x82\xE8\x81B + WORD Opt = Yopt1K; + FileVar->OpId = OpYSend; + if (filename == NULL) { + char **filenames = _GetMultiFname(fv->HMainWin, GMF_Y, fv->DlgCaption, &Opt); + if (filenames == NULL) { + ProtoEnd(); + return FALSE; + } + //ts.XmodemBin = Opt; + fv->FileNames = filenames; } - if (!NewFileVar_(&FileVar)) { - return FALSE; + else { + fv->FileNames = MakeStrArrayFromStr(filename); + FileVar->DirLen = 0; + strncpy_s(FileVar->FullName, sizeof(FileVar->FullName),filename, _TRUNCATE); + FileVar->NumFname = 1; + FileVar->NoMsg = TRUE; } - FileVar->DirLen = 0; - strncpy_s(FileVar->FullName, sizeof(FileVar->FullName),fiename, _TRUNCATE); - FileVar->NumFname = 1; - FileVar->NoMsg = TRUE; - YMODEMStart(IdYSend); + TalkStatus = IdTalkQuiet; + + /* disable transmit delay (serial port) */ + cv.DelayFlag = FALSE; + + if (! OpenProtoDlg(FileVar,PROTO_YM, IdYSend,Opt,0)) + ProtoEnd(); + return TRUE; } Modified: branches/proto_unicode/teraterm/teraterm/ttdde.c =================================================================== --- branches/proto_unicode/teraterm/teraterm/ttdde.c 2020-11-01 15:35:39 UTC (rev 8997) +++ branches/proto_unicode/teraterm/teraterm/ttdde.c 2020-11-01 15:35:53 UTC (rev 8998) @@ -696,7 +696,7 @@ break; case CmdYmodemRecv: - if (YMODEMStartReceive()) + if (YMODEMStartReceive(TRUE)) { DdeCmnd = TRUE; } Modified: branches/proto_unicode/teraterm/teraterm/vtwin.cpp =================================================================== --- branches/proto_unicode/teraterm/teraterm/vtwin.cpp 2020-11-01 15:35:39 UTC (rev 8997) +++ branches/proto_unicode/teraterm/teraterm/vtwin.cpp 2020-11-01 15:35:53 UTC (rev 8998) @@ -4346,13 +4346,13 @@ void CVTWindow::OnFileYRcv() { HelpId = HlpFileYmodemRecv; - YMODEMStart(IdYReceive); + YMODEMStartReceive(FALSE); } void CVTWindow::OnFileYSend() { HelpId = HlpFileYmodemSend; - YMODEMStart(IdYSend); + YMODEMStartSend(NULL); } void CVTWindow::OnFileZRcv() Modified: branches/proto_unicode/teraterm/ttpfile/ymodem.c =================================================================== --- branches/proto_unicode/teraterm/ttpfile/ymodem.c 2020-11-01 15:35:39 UTC (rev 8997) +++ branches/proto_unicode/teraterm/ttpfile/ymodem.c 2020-11-01 15:35:53 UTC (rev 8998) @@ -141,7 +141,7 @@ return i; } -void YSetOpt(PFileVarProto fv, PYVar yv, WORD Opt) +static void YSetOpt(PFileVarProto fv, PYVar yv, WORD Opt) { char Tmp[21]; @@ -171,7 +171,7 @@ SetDlgItemText(fv->HWin, IDC_PROTOPROT, Tmp); } -void YSendNAK(PFileVarProto fv, PYVar yv, PComVar cv) +static void YSendNAK(PFileVarProto fv, PYVar yv, PComVar cv) { BYTE b; int t; @@ -212,7 +212,7 @@ FTSetTimeOut(fv,t); } -void YSendNAKTimeout(PFileVarProto fv, PYVar yv, PComVar cv) +static void YSendNAKTimeout(PFileVarProto fv, PYVar yv, PComVar cv) { BYTE b; int t; @@ -254,7 +254,7 @@ FTSetTimeOut(fv,t); } -WORD YCalcCheck(PYVar yv, const PCHAR PktBuf, const WORD len) +static WORD YCalcCheck(PYVar yv, const PCHAR PktBuf, const WORD len) { int i; WORD Check; @@ -278,7 +278,7 @@ } } -BOOL YCheckPacket(PYVar yv, const WORD len) +static BOOL YCheckPacket(PYVar yv, const WORD len) { WORD Check; @@ -316,7 +316,7 @@ fv->ProgStat = -1; } fv->StartTime = GetTickCount(); - SetDlgItemText(fv->HWin, IDC_PROTOFNAME, &(fv->FullName[fv->DirLen])); + fv->SetDlgProtoFileName(fv, fv->FullName); yv->PktNumOffset = 0; yv->PktNum = 0; @@ -330,9 +330,8 @@ yv->LastMessage = 0; } -BOOL YInit(PFileVarProto fv, PComVar cv, PTTSet ts) +static BOOL YInit(PFileVarProto fv, PComVar cv, PTTSet ts) { - char inistr[MAX_PATH + 10]; PYVar yv = fv->data; if (yv->YMode == IdYSend) { @@ -348,8 +347,6 @@ log->LogState = 0; } - SetWindowText(fv->HWin, fv->DlgCaption); - initialize_file_info(fv, yv); yv->TOutInit = ts->YmodemTimeOutInit; @@ -397,6 +394,7 @@ // \x83t\x83@\x83C\x83\x8B\x91\x97\x90M\x8AJ\x8En\x91O\x82ɁA"rb \x83t\x83@\x83C\x83\x8B\x96\xBC"\x82\xF0\x8E\xA9\x93\xAE\x93I\x82ɌĂяo\x82\xB7\x81B(2007.12.20 yutaka) //strcpy(ts->YModemRcvCommand, "rb"); if (ts->YModemRcvCommand[0] != '\0') { + char inistr[MAX_PATH + 10]; _snprintf_s(inistr, sizeof(inistr), _TRUNCATE, "%s\015", ts->YModemRcvCommand); YWrite(fv,yv,cv, inistr , strlen(inistr)); @@ -431,7 +429,7 @@ yv->YMode = 0; // quit } -void YTimeOutProc(PFileVarProto fv, PComVar cv) +static void YTimeOutProc(PFileVarProto fv, PComVar cv) { PYVar yv = fv->data; switch (yv->YMode) { @@ -456,7 +454,7 @@ // // return TRUE: \x83t\x83@\x83C\x83\x8B\x8E\xF3\x90M\x92\x86 // FALSE: \x8E\xF3\x90M\x8A\xAE\x97\xB9 -BOOL YReadPacket(PFileVarProto fv, PYVar yv, PComVar cv) +static BOOL YReadPacket(PFileVarProto fv, PYVar yv, PComVar cv) { BYTE b, d; int i, c, nak; @@ -623,9 +621,9 @@ memset(p, 0, yv->__DataLen + 1); memcpy(p, &(yv->PktIn[3]), yv->__DataLen); name = p; - strncpy_s(&(fv->FullName[fv->DirLen]), - sizeof(fv->FullName) - fv->DirLen, name, - _TRUNCATE); + + strncpy_s(fv->FullName, _countof(fv->FullName), fv->RecievePath, _TRUNCATE); + strncat_s(fv->FullName, _countof(fv->FullName), name, _TRUNCATE); if (!FTCreateFile(fv)) { free(p); return FALSE; @@ -692,7 +690,7 @@ } // \x83t\x83@\x83C\x83\x8B\x91\x97\x90M(local-to-remote)\x8E\x9E\x82ɁAYMODEM\x83T\x81[\x83o\x82\xA9\x82\xE7\x83f\x81[\x83^\x82\xAA\x91\x97\x82\xE7\x82\xEA\x82Ă\xAB\x82\xBD\x82Ƃ\xAB\x82ɌĂяo\x82\xB3\x82\xEA\x82\xE9\x81B -BOOL YSendPacket(PFileVarProto fv, PYVar yv, PComVar cv) +static BOOL YSendPacket(PFileVarProto fv, PYVar yv, PComVar cv) { // If current buffer is empty. if (0 == yv->PktBufCount) @@ -906,6 +904,7 @@ size_t idx; // TODO: remove magic number. BYTE buf[1024 + 10]; + int FnPos; // 128 bytes for the first packet. current_packet_size = SOH_DATALEN; @@ -915,8 +914,9 @@ // Timestamp. fv->FileMtime = GetFMtime(fv->FullName); - ret = _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%s", - &(fv->FullName[fv->DirLen])); + GetFileNamePos(fv->FullName, NULL, &FnPos); + ret = _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%s", &(fv->FullName[FnPos])); + // NULL-terminated string. buf[ret] = 0x00; total = ret + 1; @@ -1084,7 +1084,7 @@ return TRUE; } -BOOL YParse(PFileVarProto fv, PComVar cv) +static BOOL YParse(PFileVarProto fv, PComVar cv) { PYVar pv = fv->data; switch (pv->YMode) { @@ -1109,7 +1109,7 @@ return 0; } case YMODEM_OPT: { - WORD Opt1 = va_arg(ap, WORD); + WORD Opt1 = va_arg(ap, int); pv->YOpt = Opt1; return 0; }