Revision: 9003 https://osdn.net/projects/ttssh2/scm/svn/commits/9003 Author: zmatsuo Date: 2020-11-02 00:37:07 +0900 (Mon, 02 Nov 2020) Log Message: ----------- TFileVarProto から DirLen を削除 Modified Paths: -------------- branches/proto_unicode/teraterm/common/ttlib.c branches/proto_unicode/teraterm/common/ttlib.h branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp branches/proto_unicode/teraterm/teraterm/filesys_proto.h branches/proto_unicode/teraterm/ttpfile/bplus.c branches/proto_unicode/teraterm/ttpfile/ftlib.c branches/proto_unicode/teraterm/ttpfile/quickvan.c branches/proto_unicode/teraterm/ttpfile/zmodem.c -------------- next part -------------- Modified: branches/proto_unicode/teraterm/common/ttlib.c =================================================================== --- branches/proto_unicode/teraterm/common/ttlib.c 2020-11-01 15:36:51 UTC (rev 9002) +++ branches/proto_unicode/teraterm/common/ttlib.c 2020-11-01 15:37:07 UTC (rev 9003) @@ -215,7 +215,19 @@ return len; } -BOOL GetFileNamePos(const char *PathName, int far *DirLen, int far *FNPos) +/** + * \x83t\x83@\x83C\x83\x8B\x96\xBC(\x83p\x83X\x96\xBC)\x82\xF0\x89\xF0\x90͂\xB7\x82\xE9 + * _splitpath\x82̃p\x83X\x82ƃt\x83@\x83C\x83\x8B\x96\xBC\x82\xBE\x82\xAF\x94\xC5 + * + * @param[in] PathName \x83t\x83@\x83C\x83\x8B\x96\xBC\x81A\x83t\x83\x8B\x83p\x83X + * @param[out] DirLen \x96\x96\x94\xF6\x82̃X\x83\x89\x83b\x83V\x83\x85\x82\xF0\x8A܂ރf\x83B\x83\x8C\x83N\x83g\x83\x8A\x83p\x83X\x92\xB7 + * NULL\x82̂Ƃ\xAB\x92l\x82\xF0\x95Ԃ\xB3\x82Ȃ\xA2 + * @param[out] FNPos \x83t\x83@\x83C\x83\x8B\x96\xBC\x82ւ\xCCindex + * &PathName[FNPos] \x82\xAA\x83t\x83@\x83C\x83\x8B\x96\xBC + * NULL\x82̂Ƃ\xAB\x92l\x82\xF0\x95Ԃ\xB3\x82Ȃ\xA2 + * @retval FALSE PathName\x82\xAA\x95s\x90\xB3 + */ +BOOL GetFileNamePos(const char *PathName, int *DirLen, int *FNPos) { BYTE b; const char *Ptr; @@ -223,8 +235,9 @@ const char *FNPtr; const char *PtrOld; - *DirLen = 0; - *FNPos = 0; + if (DirLen != NULL) *DirLen = 0; + if (FNPos != NULL) *FNPos = 0; + if (PathName==NULL) return FALSE; @@ -251,8 +264,8 @@ break; } } - *DirLen = DirPtr-PathName; - *FNPos = FNPtr-PathName; + if (DirLen != NULL) *DirLen = DirPtr-PathName; + if (FNPos != NULL) *FNPos = FNPtr-PathName; return TRUE; } Modified: branches/proto_unicode/teraterm/common/ttlib.h =================================================================== --- branches/proto_unicode/teraterm/common/ttlib.h 2020-11-01 15:36:51 UTC (rev 9002) +++ branches/proto_unicode/teraterm/common/ttlib.h 2020-11-01 15:37:07 UTC (rev 9003) @@ -41,7 +41,7 @@ #define DllExport __declspec(dllexport) #endif -BOOL GetFileNamePos(const char *PathName, int far *DirLen, int far *FNPos); +BOOL GetFileNamePos(const char *PathName, int *DirLen, int *FNPos); DllExport BOOL ExtractFileName(PCHAR PathName, PCHAR FileName, int destlen); DllExport BOOL ExtractDirName(PCHAR PathName, PCHAR DirName); void FitFileName(PCHAR FileName, int destlen, const char *DefExt); Modified: branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp =================================================================== --- branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp 2020-11-01 15:36:51 UTC (rev 9002) +++ branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp 2020-11-01 15:37:07 UTC (rev 9003) @@ -136,7 +136,7 @@ // \x8E\xF3\x90M\x83t\x83H\x83\x8B\x83_\x82\xF0 fv->FullName \x82ɐݒ肵\x82Ă\xA8\x82\xAD // fv->FullName[fv->DirLen] \x82\xA9\x82\xE7\x83t\x83@\x83C\x83\x8B\x96\xBC\x82\xF0\x90ݒ肷\x82\xE9\x82ƃt\x83\x8B\x83p\x83X\x82ɂȂ\xE9 strncpy_s(fv->FullName, sizeof(fv->FullName), FileDirExpanded, _TRUNCATE); - fv->DirLen = strlen(fv->FullName); + // fv->DirLen = strlen(fv->FullName); fv->FileOpen = FALSE; fv->OverWrite = ((ts.FTFlag & FT_RENAME) == 0); @@ -920,6 +920,7 @@ return ret; } +#if 0 static void _SetFileVar(PFileVarProto fv) { int i; @@ -929,6 +930,7 @@ c = fv->FullName[fv->DirLen]; if (c=='\\'||c=='/') fv->DirLen++; } +#endif static void KermitStart(int mode) { @@ -1010,10 +1012,10 @@ } } else { - FileVar->DirLen = 0; strncpy_s(FileVar->FullName, sizeof(FileVar->FullName),filename, _TRUNCATE); FileVar->NoMsg = TRUE; - _SetFileVar(FileVar); +// FileVar->DirLen = 0; +// _SetFileVar(FileVar); } KermitStart(IdKmtGet); @@ -1278,7 +1280,7 @@ // \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); +// _SetFileVar(FileVar); TalkStatus = IdTalkQuiet; @@ -1656,9 +1658,9 @@ } } else { - FileVar->DirLen = 0; strncpy_s(FileVar->FullName, sizeof(FileVar->FullName),filename, _TRUNCATE); FileVar->NoMsg = TRUE; +// FileVar->DirLen = 0; } TalkStatus = IdTalkQuiet; Modified: branches/proto_unicode/teraterm/teraterm/filesys_proto.h =================================================================== --- branches/proto_unicode/teraterm/teraterm/filesys_proto.h 2020-11-01 15:36:51 UTC (rev 9002) +++ branches/proto_unicode/teraterm/teraterm/filesys_proto.h 2020-11-01 15:37:07 UTC (rev 9003) @@ -36,7 +36,7 @@ // \x91\x97\x8E\xF3\x90M\x8E\x9E\x83\x8F\x81[\x83N char FullName[MAX_PATH]; // read/write\x82\xB7\x82\xE9\x83t\x83@\x83C\x83\x8B\x96\xBC(\x8Ae\x83v\x83\x8D\x83g\x83R\x83\x8B\x93\xE0\x82ŏ\x91\x82\xAB\x8A\xB7\x82\xA6\x82\xB7\x82邱\x82Ƃ\xA0\x82\xE8) - int DirLen; +// int DirLen; // \x91\x97\x90M\x83t\x83@\x83C\x83\x8B\x96\xBC\x94z\x97\xF1 // \x83t\x83\x8B\x83p\x83X\x82̃t\x83@\x83C\x83\x8B\x96\xBC\x94z\x97\xF1(\x88\xEA\x94ԍŌ\xE3\x82\xCDNULL) Modified: branches/proto_unicode/teraterm/ttpfile/bplus.c =================================================================== --- branches/proto_unicode/teraterm/ttpfile/bplus.c 2020-11-01 15:36:51 UTC (rev 9002) +++ branches/proto_unicode/teraterm/ttpfile/bplus.c 2020-11-01 15:37:07 UTC (rev 9003) @@ -104,12 +104,12 @@ BOOL r; if (fv->FileOpen) return TRUE; - if (strlen(&(fv->FullName[fv->DirLen]))==0) return FALSE; + if (fv->FullName[0]==0) return FALSE; r = fv->OpenRead(fv, fv->FullName); fv->FileOpen = r; if (r == TRUE) { - SetDlgItemText(fv->HWin, IDC_PROTOFNAME, &(fv->FullName[fv->DirLen])); + fv->SetDlgProtoFileName(fv, fv->FullName); fv->FileSize = fv->GetFSize(fv, fv->FullName); } return fv->FileOpen; @@ -577,6 +577,7 @@ BYTE b; // char Temp[HostNameMaxLength + 1]; // 81(yutaka) char Temp[81]; // 81(yutaka) + int FnPos; switch (bv->PktIn[2]) { case 'C': /* Close */ @@ -612,8 +613,9 @@ } Temp[j] = 0; - GetFileNamePos(Temp,&i,&j); - strncpy_s(&(fv->FullName[fv->DirLen]),sizeof(fv->FullName) - fv->DirLen,&(Temp[j]),_TRUNCATE); + strncpy_s(fv->FullName, _countof(fv->FullName), fv->RecievePath, _TRUNCATE); + GetFileNamePos(Temp,NULL,&FnPos); + strncat_s(fv->FullName, _countof(fv->FullName), &(Temp[FnPos]), _TRUNCATE); /* file open */ if (! FTCreateFile(fv)) { @@ -658,16 +660,20 @@ } Temp[j] = 0; - GetFileNamePos(Temp,&i,&j); - FitFileName(&(Temp[j]),sizeof(Temp) - j,NULL); - strncpy_s(&(fv->FullName[fv->DirLen]),sizeof(fv->FullName) - fv->DirLen, - &(Temp[j]),_TRUNCATE); + GetFileNamePos(Temp,NULL,&FnPos); + FitFileName(&(Temp[FnPos]),sizeof(Temp) - FnPos,NULL); + strncpy_s(fv->FullName, _countof(fv->FullName), fv->RecievePath, _TRUNCATE); + strncat_s(fv->FullName, _countof(fv->FullName), &(Temp[FnPos]), _TRUNCATE); /* file open */ if (! BPOpenFileToBeSent(fv)) { /* if file not found, ask user new file name */ - fv->FullName[fv->DirLen] = 0; + fv->FullName[0] = 0; + + // \x83_\x83C\x83A\x83\x8D\x83O\x82\xF0\x8AJ\x82\xA2\x82ăt\x83@\x83C\x83\x8B\x96\xBC\x82\xF0\x83\x86\x81[\x83U\x81[\x82Ɏw\x92肵\x82Ă\xE0\x82炤 + // \x82\xB1\x82̈ʒu\x82ōs\x82\xA4\x82͓̂K\x90łȂ\xA2\x82Ǝv\x82\xED\x82\xEA\x82邽\x82\xDF + // [cancel]\x82\xF0\x89\x9F\x82\xB5\x82\xBD\x82Ƃ\xAB\x82Ɠ\xAF\x97l\x82̓\xAE\x8D\xEC\x82Ƃ\xB5\x82\xBD //if (! GetTransFname(fv, NULL, GTF_BP, (PLONG)&i)) if (FALSE) { Modified: branches/proto_unicode/teraterm/ttpfile/ftlib.c =================================================================== --- branches/proto_unicode/teraterm/ttpfile/ftlib.c 2020-11-01 15:36:51 UTC (rev 9002) +++ branches/proto_unicode/teraterm/ttpfile/ftlib.c 2020-11-01 15:37:07 UTC (rev 9003) @@ -63,8 +63,8 @@ fv->FNCount++; strncpy_s(fv->FullName, sizeof(fv->FullName), f, _TRUNCATE); - GetFileNamePos(fv->FullName, &(fv->DirLen), &i); - fv->DirLen++; // \x88\xEA\x94ԍŌ\xE3\x82\xCC '\\' \x82\xF0\x8Ew\x82\xB5\x82Ă\xA2\x82\xE9\x82̂\xC5 +1 \x82\xB5\x82Ă\xA8\x82\xAD +// GetFileNamePos(fv->FullName, &(fv->DirLen), &i); +// fv->DirLen++; // \x88\xEA\x94ԍŌ\xE3\x82\xCC '\\' \x82\xF0\x8Ew\x82\xB5\x82Ă\xA2\x82\xE9\x82̂\xC5 +1 \x82\xB5\x82Ă\xA8\x82\xAD return TRUE; } @@ -102,7 +102,7 @@ SetTimer(fv->HMainWin, IdProtoTimer, T*1000, NULL); } -void AddNum(PCHAR FName, int n) +static void AddNum(PCHAR FName, int n) { char Num[11]; int i, j, k, dLen; @@ -125,14 +125,18 @@ { int i; char Temp[MAX_PATH]; + int DirLen; - replaceInvalidFileNameChar(&(fv->FullName[fv->DirLen]), '_'); + GetFileNamePos(fv->FullName, &DirLen, &i); + DirLen++; // \x88\xEA\x94ԍŌ\xE3\x82\xCC '\\' \x82\xF0\x8Ew\x82\xB5\x82Ă\xA2\x82\xE9\x82̂\xC5 +1 \x82\xB5\x82Ă\xA8\x82\xAD - if (fv->FullName[fv->DirLen] == 0) { - strncpy_s(&(fv->FullName[fv->DirLen]), sizeof(fv->FullName) - fv->DirLen, "noname", _TRUNCATE); + replaceInvalidFileNameChar(&(fv->FullName[DirLen]), '_'); + + if (fv->FullName[DirLen] == 0) { + strncpy_s(&(fv->FullName[DirLen]), sizeof(fv->FullName) - DirLen, "noname", _TRUNCATE); } - FitFileName(&(fv->FullName[fv->DirLen]),sizeof(fv->FullName) - fv->DirLen,NULL); + FitFileName(&(fv->FullName[DirLen]),sizeof(fv->FullName) - DirLen,NULL); if (! fv->OverWrite) { i = 0; @@ -149,7 +153,7 @@ if (! fv->FileOpen && ! fv->NoMsg) MessageBox(fv->HMainWin,"Cannot create file", "Tera Term: Error",MB_ICONEXCLAMATION); - SetDlgItemText(fv->HWin, IDC_PROTOFNAME,&(fv->FullName[fv->DirLen])); + fv->SetDlgProtoFileName(fv, fv->FullName); fv->ByteCount = 0; fv->FileSize = 0; Modified: branches/proto_unicode/teraterm/ttpfile/quickvan.c =================================================================== --- branches/proto_unicode/teraterm/ttpfile/quickvan.c 2020-11-01 15:36:51 UTC (rev 9002) +++ branches/proto_unicode/teraterm/ttpfile/quickvan.c 2020-11-01 15:37:07 UTC (rev 9003) @@ -158,7 +158,6 @@ static BOOL QVInit(PFileVarProto fv, PComVar cv, PTTSet ts) { - char uimsg[MAX_UIMSG]; PQVVar qv = fv->data; qv->WinSize = ts->QVWinSize; @@ -429,7 +428,8 @@ /* file name */ GetFileNamePos(&(qv->PktIn[5]),&i,&j); - strncpy_s(&(fv->FullName[fv->DirLen]),sizeof(fv->FullName) - fv->DirLen,&(qv->PktIn[5+j]),_TRUNCATE); + strncpy_s(fv->FullName, _countof(fv->FullName), fv->RecievePath, _TRUNCATE); + strncat_s(fv->FullName, _countof(fv->FullName), &(qv->PktIn[5+j]), _TRUNCATE); /* file open */ if (! FTCreateFile(fv)) return FALSE; /* file size */ @@ -828,6 +828,7 @@ struct tm tmbuf; char fullname_upper[MAX_PATH]; BOOL r; + int FnPos; if (! GetNextFname(fv)) { @@ -863,11 +864,12 @@ i = 3; QVPutNum2(qv,qv->FileNum,&i); /* file name */ - SetDlgItemText(fv->HWin, IDC_PROTOFNAME, &(fv->FullName[fv->DirLen])); - strncpy_s(fullname_upper, sizeof(fullname_upper), &(fv->FullName[fv->DirLen]), _TRUNCATE); + fv->SetDlgProtoFileName(fv, fv->FullName); + GetFileNamePos(fv->FullName, NULL, &FnPos); + strncpy_s(fullname_upper, _countof(fullname_upper), &(fv->FullName[FnPos]), _TRUNCATE); _strupr_s(fullname_upper, sizeof(fullname_upper)); + FTConvFName(fullname_upper); // replace ' ' by '_' in FName strncpy_s(&(qv->PktOut[i]),sizeof(qv->PktOut)-i,fullname_upper,_TRUNCATE); - FTConvFName(&(qv->PktOut[i])); // replace ' ' by '_' in FName i = strlen(&(qv->PktOut[i])) + i; qv->PktOut[i] = 0; i++; Modified: branches/proto_unicode/teraterm/ttpfile/zmodem.c =================================================================== --- branches/proto_unicode/teraterm/ttpfile/zmodem.c 2020-11-01 15:36:51 UTC (rev 9002) +++ branches/proto_unicode/teraterm/ttpfile/zmodem.c 2020-11-01 15:37:07 UTC (rev 9003) @@ -560,16 +560,17 @@ static void ZSendFileDat(PFileVarProto fv, PZVar zv) { int i, j; + int FNPos; if (!fv->FileOpen) { ZSendCancel(zv); return; } - SetDlgItemText(fv->HWin, IDC_PROTOFNAME, &(fv->FullName[fv->DirLen])); + SetDlgItemText(fv->HWin, IDC_PROTOFNAME, fv->FullName); /* file name */ - strncpy_s(zv->PktOut, sizeof(zv->PktOut), &(fv->FullName[fv->DirLen]), - _TRUNCATE); + GetFileNamePos(fv->FullName, NULL, &FNPos); + strncpy_s(zv->PktOut, sizeof(zv->PktOut), &(fv->FullName[FNPos]), _TRUNCATE); FTConvFName(zv->PktOut); // replace ' ' by '_' in FName zv->PktOutCount = strlen(zv->PktOut); zv->CRC = 0; @@ -620,7 +621,7 @@ add_sendbuf("%s: ZFILE: ZF0=%x ZF1=%x ZF2=%x file=%s size=%lu", __FUNCTION__, zv->TxHdr[ZF0], zv->TxHdr[ZF1],zv->TxHdr[ZF2], - &(fv->FullName[fv->DirLen]), fv->FileSize); + &(fv->FullName[FNPos]), fv->FileSize); } static void ZSendDataHdr(PZVar zv) @@ -691,8 +692,6 @@ static BOOL ZInit(PFileVarProto fv, PComVar cv, PTTSet ts) { int Max; - char uimsg[MAX_UIMSG]; - const char *UILanguageFile = ts->UILanguageFile; PZVar zv = fv->data; zv->CtlEsc = ((ts->FTFlag & FT_ZESCCTL) != 0); @@ -714,24 +713,6 @@ CommInsert1Byte(cv, ZPAD); } - strncpy_s(fv->DlgCaption, sizeof(fv->DlgCaption), "Tera Term: ", - _TRUNCATE); - switch (zv->ZMode) { - case IdZSend: - get_lang_msg("FILEDLG_TRANS_TITLE_ZSEND", uimsg, sizeof(uimsg), - TitZSend, UILanguageFile); - strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, - _TRUNCATE); - break; - case IdZReceive: - get_lang_msg("FILEDLG_TRANS_TITLE_ZRCV", uimsg, sizeof(uimsg), - TitZRcv, UILanguageFile); - strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, - _TRUNCATE); - break; - } - - SetWindowText(fv->HWin, fv->DlgCaption); SetDlgItemText(fv->HWin, IDC_PROTOPROT, "ZMODEM"); InitDlgProgress(fv->HWin, IDC_PROTOPROGRESS, &fv->ProgStat); @@ -1056,11 +1037,12 @@ static BOOL ZParseFile(PFileVarProto fv, PZVar zv) { BYTE b; - int i, j; + int i; char *p; long modtime; int mode; int ret; + int FnPos; if ((zv->ZState != Z_RecvInit) && (zv->ZState != Z_RecvInit2)) return FALSE; @@ -1071,10 +1053,9 @@ /* file name */ zv->PktIn[zv->PktInPtr] = 0; /* for safety */ - GetFileNamePos(zv->PktIn, &i, &j); - strncpy_s(&(fv->FullName[fv->DirLen]), - sizeof(fv->FullName) - fv->DirLen, &(zv->PktIn[j]), - _TRUNCATE); + GetFileNamePos(zv->PktIn, NULL, &FnPos); + strncpy_s(fv->FullName, _countof(fv->FullName), fv->RecievePath, _TRUNCATE); + strncat_s(fv->FullName, _countof(fv->FullName), &(zv->PktIn[FnPos]), _TRUNCATE); /* file open */ if (!FTCreateFile(fv)) return FALSE;