Revision: 9367 https://osdn.net/projects/ttssh2/scm/svn/commits/9367 Author: zmatsuo Date: 2021-08-15 22:14:09 +0900 (Sun, 15 Aug 2021) Log Message: ----------- ttl.cpp で win16api.c の関数を使用しないようにした - ttl.cpp に組み込んだ Modified Paths: -------------- trunk/teraterm/ttpmacro/CMakeLists.txt trunk/teraterm/ttpmacro/ttl.cpp trunk/teraterm/ttpmacro/ttpmacro.v16.vcxproj trunk/teraterm/ttpmacro/ttpmacro.v16.vcxproj.filters trunk/teraterm/ttpmacro/ttpmacro.v8.vcproj -------------- next part -------------- Modified: trunk/teraterm/ttpmacro/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpmacro/CMakeLists.txt 2021-08-15 13:13:58 UTC (rev 9366) +++ trunk/teraterm/ttpmacro/CMakeLists.txt 2021-08-15 13:14:09 UTC (rev 9367) @@ -74,7 +74,6 @@ ../common/ttlib.h ../common/tmfc.h ../common/compat_win.h - ../common/win16api.h ../common/codeconv.h ../common/dllutil.h ) Modified: trunk/teraterm/ttpmacro/ttl.cpp =================================================================== --- trunk/teraterm/ttpmacro/ttl.cpp 2021-08-15 13:13:58 UTC (rev 9366) +++ trunk/teraterm/ttpmacro/ttl.cpp 2021-08-15 13:14:09 UTC (rev 9367) @@ -60,7 +60,6 @@ #include <ws2tcpip.h> #include <iptypes.h> #include <iphlpapi.h> -#include "win16api.h" #include "ttl_gui.h" #include "codeconv.h" #include "dllutil.h" @@ -136,6 +135,50 @@ FHandle[fhi] = INVALID_HANDLE_VALUE; } +/** + * @retval \x93ǂݍ\x9E\x82݃o\x83C\x83g\x90\x94 + */ +static UINT win16_lread(HANDLE hFile, LPVOID lpBuffer, UINT uBytes) +{ + DWORD NumberOfBytesRead; + BOOL Result = ReadFile(hFile, lpBuffer, uBytes, &NumberOfBytesRead, NULL); + if (Result == FALSE) { + return 0; + } + return NumberOfBytesRead; +} + +/** + * @retval \x8F\x91\x82\xAB\x8D\x9E\x82݃o\x83C\x83g\x90\x94 + */ +static UINT win16_lwrite(HANDLE hFile, const char*buf, UINT length) +{ + DWORD NumberOfBytesWritten; + BOOL result = WriteFile(hFile, buf, length, &NumberOfBytesWritten, NULL); + if (result == FALSE) { + return 0; + } + return NumberOfBytesWritten; +} + +/* + * @param[in] iOrigin + * @arg 0(FILE_BEGIN) + * @arg 1(FILE_CURRENT) + * @arg 2(FILE_END) + * @retval \x83t\x83@\x83C\x83\x8B\x88ʒu + * @retval HFILE_ERROR((HFILE)-1) \x83G\x83\x89\x81[ + * @retval INVALID_SET_FILE_POINTER((DWORD)-1) \x83G\x83\x89\x81[ + */ +static LONG win16_llseek(HANDLE hFile, LONG lOffset, int iOrigin) +{ + DWORD pos = SetFilePointer(hFile, lOffset, NULL, iOrigin); + if (pos == INVALID_SET_FILE_POINTER) { + return HFILE_ERROR; + } + return pos; +} + BOOL InitTTL(HWND HWin) { int i; @@ -1169,7 +1212,7 @@ if ((Err==0) && (GetFirstChar()!=0)) Err = ErrSyntax; if (Err!=0) return Err; - _lclose(FH); + CloseHandle(FH); HandleFree(fhi); return Err; } @@ -1329,7 +1372,7 @@ fhi = HandlePut(FH); SetIntVal(VarId, fhi); if (fhi == -1) { - _lclose(FH); + CloseHandle(FH); } return Err; } @@ -1377,7 +1420,7 @@ if ((Err==0) && (GetFirstChar()!=0)) Err = ErrSyntax; if (Err!=0) return Err; - pos = _llseek(FH,0,1); /* mark current pos */ + pos = win16_llseek(FH,0,1); /* mark current pos */ if (pos == INVALID_SET_FILE_POINTER) { pos = 0; // ? } @@ -1533,14 +1576,14 @@ EndLine = FALSE; EndFile = TRUE; do { - c = _lread(FH, &b, 1); + c = win16_lread(FH, &b, 1); if (c>0) EndFile = FALSE; if (c==1) { switch (b) { case 0x0d: - c = _lread(FH, &b, 1); + c = win16_lread(FH, &b, 1); if ((c==1) && (b!=0x0a)) - _llseek(FH, -1, 1); + win16_llseek(FH, -1, 1); EndLine = TRUE; break; case 0x0a: EndLine = TRUE; break; @@ -1594,7 +1637,7 @@ EndFile = FALSE; for (i = 0 ; i < ReadByte ; i++) { - c = _lread(FH,&b,1); + c = win16_lread(FH,&b,1); if (c <= 0) { // EOF EndFile = TRUE; break; @@ -1693,7 +1736,7 @@ if ((Err==0) && (GetFirstChar()!=0)) Err = ErrSyntax; if (Err!=0) return Err; - _llseek(FH,i,j); + win16_llseek(FH,i,j); return Err; } @@ -1710,7 +1753,7 @@ Err = ErrSyntax; if (Err!=0) return Err; /* move back to the marked pos */ - _llseek(FH,FPointer[fhi],0); + win16_llseek(FH,FPointer[fhi],0); return Err; } @@ -1831,13 +1874,13 @@ ((strlen(Str)==0) || (GetFirstChar()!=0))) Err = ErrSyntax; if (Err!=0) return Err; - pos = _llseek(FH,0,1); + pos = win16_llseek(FH,0,1); if (pos == INVALID_SET_FILE_POINTER) return Err; Len = strlen(Str); i = 0; do { - c = _lread(FH,&b,1); + c = win16_lread(FH,&b,1); if (c==1) { if (b==(BYTE)Str[i]) @@ -1853,7 +1896,7 @@ SetResult(1); else { SetResult(0); - _llseek(FH,pos,0); + win16_llseek(FH,pos,0); } return Err; } @@ -1877,7 +1920,7 @@ ((strlen(Str)==0) || (GetFirstChar()!=0))) Err = ErrSyntax; if (Err!=0) return Err; - pos = _llseek(FH,0,1); + pos = win16_llseek(FH,0,1); if (pos == INVALID_SET_FILE_POINTER) return Err; Len = strlen(Str); @@ -1885,8 +1928,8 @@ pos2 = pos; do { Last = (pos2<=0); - c = _lread(FH,&b,1); - pos2 = _llseek(FH,-2,1); + c = win16_lread(FH,&b,1); + pos2 = win16_llseek(FH,-2,1); if (c==1) { if (b==(BYTE)Str[Len-1-i]) @@ -1903,11 +1946,11 @@ // INVALID_SET_FILE_POINTER \x82ɂȂ\xE9\x82̂ŁA // \x83[\x83\x8D\x83I\x83t\x83Z\x83b\x83g\x82ɂȂ\xE9\x82悤\x82ɒ\xB2\x90\xAE\x82\xB7\x82\xE9\x81B(2008.10.10 yutaka) if (pos2 == INVALID_SET_FILE_POINTER) - _llseek(FH, 0, 0); + win16_llseek(FH, 0, 0); SetResult(1); } else { SetResult(0); - _llseek(FH,pos,0); + win16_llseek(FH,pos,0); } return Err; } @@ -1987,7 +2030,7 @@ if (GetFirstChar()) return ErrSyntax; - _lwrite(FH, Str, strlen(Str)); + win16_lwrite(FH, Str, strlen(Str)); } else if (Err == ErrTypeMismatch) { Err = 0; @@ -1998,7 +2041,7 @@ return ErrSyntax; Str[0] = Val & 0xff; - _lwrite(FH, Str, 1); + win16_lwrite(FH, Str, 1); } else { return Err; @@ -2005,7 +2048,7 @@ } if (addCRLF) { - _lwrite(FH,"\015\012",2); + win16_lwrite(FH,"\015\012",2); } return 0; } Modified: trunk/teraterm/ttpmacro/ttpmacro.v16.vcxproj =================================================================== --- trunk/teraterm/ttpmacro/ttpmacro.v16.vcxproj 2021-08-15 13:13:58 UTC (rev 9366) +++ trunk/teraterm/ttpmacro/ttpmacro.v16.vcxproj 2021-08-15 13:14:09 UTC (rev 9367) @@ -155,7 +155,6 @@ <ClInclude Include="..\common\tmfc.h" /> <ClInclude Include="..\common\ttddecmnd.h" /> <ClInclude Include="..\common\ttlib.h" /> - <ClInclude Include="..\common\win16api.h" /> <ClInclude Include="ListDlg.h" /> <ClInclude Include="errdlg.h" /> <ClInclude Include="inpdlg.h" /> @@ -203,4 +202,4 @@ <UserProperties RESOURCE_FILE="ttpmacro.rc" /> </VisualStudio> </ProjectExtensions> -</Project> +</Project> \ No newline at end of file Modified: trunk/teraterm/ttpmacro/ttpmacro.v16.vcxproj.filters =================================================================== --- trunk/teraterm/ttpmacro/ttpmacro.v16.vcxproj.filters 2021-08-15 13:13:58 UTC (rev 9366) +++ trunk/teraterm/ttpmacro/ttpmacro.v16.vcxproj.filters 2021-08-15 13:14:09 UTC (rev 9367) @@ -126,9 +126,6 @@ <ClInclude Include="ttmparse.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="..\common\win16api.h"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="..\common\codeconv.h"> <Filter>Header Files</Filter> </ClInclude> @@ -167,4 +164,4 @@ <Filter>Source Files</Filter> </ResourceCompile> </ItemGroup> -</Project> +</Project> \ No newline at end of file Modified: trunk/teraterm/ttpmacro/ttpmacro.v8.vcproj =================================================================== --- trunk/teraterm/ttpmacro/ttpmacro.v8.vcproj 2021-08-15 13:13:58 UTC (rev 9366) +++ trunk/teraterm/ttpmacro/ttpmacro.v8.vcproj 2021-08-15 13:14:09 UTC (rev 9367) @@ -356,10 +356,6 @@ RelativePath="ttmparse.h" > </File> - <File - RelativePath="..\common\win16api.h" - > - </File> </Filter> <Filter Name="Resource Files"