--- mstools/samples/comm/tty.c 2018/08/09 18:20:59 1.1.1.1 +++ mstools/samples/comm/tty.c 2018/08/09 18:22:16 1.1.1.2 @@ -1481,12 +1481,11 @@ BOOL NEAR CloseConnection( HWND hWnd ) int NEAR ReadCommBlock( HWND hWnd, LPSTR lpszBlock, int nMaxLength ) { #ifdef WIN32 - DWORD nLength ; BOOL fReadStat ; COMSTAT ComStat ; - DWORD dwErrorFlags ; + DWORD dwErrorFlags, dwLength ; #else - int nLength, nError ; + int nError, nLength ; #endif char szError[ 10 ] ; @@ -1502,35 +1501,34 @@ int NEAR ReadCommBlock( HWND hWnd, LPSTR wsprintf( szError, "", dwErrorFlags ) ; WriteTTYBlock( hWnd, szError, lstrlen( szError ) ) ; } - nLength = min( (DWORD) nMaxLength, ComStat.cbInQue ) ; - if (nLength > 0) + dwLength = min( (DWORD) nMaxLength, ComStat.cbInQue ) ; + if (dwLength > 0) { fReadStat = ReadFile( COMDEV( npTTYInfo ), lpszBlock, - nLength, &nLength, &READ_OS( npTTYInfo ) ) ; + dwLength, &dwLength, &READ_OS( npTTYInfo ) ) ; if (!fReadStat) { if (GetLastError() == ERROR_IO_PENDING) { - OutputDebugString( "ReadCommBlock: I/O Pending.\r\n" ) ; - // wait for a second for this transmission to complete if (WaitForSingleObject( READ_OS( npTTYInfo ).hEvent, 1000 )) - nLength = 0 ; + dwLength = 0 ; else { GetOverlappedResult( COMDEV( npTTYInfo ), &READ_OS( npTTYInfo ), - &nLength, FALSE ) ; - READ_OS( npTTYInfo ).Offset += nLength ; + &dwLength, FALSE ) ; + READ_OS( npTTYInfo ).Offset += dwLength ; } } else // some other error occurred - nLength = 0 ; + dwLength = 0 ; } } + return ( dwLength ) ; #else nLength = ReadComm( COMDEV( npTTYInfo ), lpszBlock, nMaxLength ) ; @@ -1546,9 +1544,9 @@ int NEAR ReadCommBlock( HWND hWnd, LPSTR } } } + return ( nLength ) ; #endif - return ( nLength ) ; } // end of ReadCommBlock() @@ -1591,8 +1589,6 @@ BOOL NEAR WriteCommByte( HWND hWnd, BYTE &dwBytesWritten, &WRITE_OS( npTTYInfo ) ) ; if (!fWriteStat && (GetLastError() == ERROR_IO_PENDING)) { - OutputDebugString( "WriteCommByte: I/O Pending.\r\n" ) ; - // wait for a second for this transmission to complete if (WaitForSingleObject( WRITE_OS( npTTYInfo ).hEvent, 1000 )) @@ -1763,7 +1759,6 @@ BOOL FAR PASCAL AboutDlgProc( HWND hDlg, { #ifdef WIN32 char szBuffer[ MAXLEN_TEMPSTR ], szTemp[ MAXLEN_TEMPSTR ]; - DWORD dwFreeMemory ; WORD wRevision, wVersion ; #else int idModeString ; @@ -1819,6 +1814,7 @@ BOOL FAR PASCAL AboutDlgProc( HWND hDlg, SetDlgItemText( hDlg, IDD_WINDOWSMODE, "NT Mode" ) ; #endif +#ifndef WIN32 // get free memory information dwFreeMemory = GetFreeSpace( 0 ) / 1024L ; @@ -1826,7 +1822,6 @@ BOOL FAR PASCAL AboutDlgProc( HWND hDlg, wsprintf( szBuffer, szTemp, dwFreeMemory ) ; SetDlgItemText( hDlg, IDD_FREEMEM, (LPSTR) szBuffer ) ; -#ifndef WIN32 // get free resources information wFreeResources = GetFreeSystemResources( 0 ) ; @@ -2315,8 +2310,7 @@ BOOL FAR PASCAL SettingsDlgProc( HWND hD DWORD FAR PASCAL CommWatchProc( LPSTR lpData ) { - DWORD cbTransfer ; - DWORD dwEvtMask ; + DWORD dwTransfer, dwEvtMask ; NPTTYINFO npTTYInfo = (NPTTYINFO) lpData ; OVERLAPPED os ; @@ -2346,8 +2340,8 @@ DWORD FAR PASCAL CommWatchProc( LPSTR lp { if (ERROR_IO_PENDING == GetLastError()) { - GetOverlappedResult( COMDEV( npTTYInfo ), &os, &cbTransfer, TRUE ) ; - os.Offset += cbTransfer ; + GetOverlappedResult( COMDEV( npTTYInfo ), &os, &dwTransfer, TRUE ) ; + os.Offset += dwTransfer ; } }