Changeset 4862 for trunk/src/kernel32/hmcomm.cpp
- Timestamp:
- Dec 31, 2000, 1:28:54 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/hmcomm.cpp
r4588 r4862 1 /* $Id: hmcomm.cpp,v 1. 6 2000-11-14 14:26:59sandervl Exp $ */1 /* $Id: hmcomm.cpp,v 1.7 2000-12-31 12:28:53 sandervl Exp $ */ 2 2 3 3 /* … … 250 250 if((NULL==pDevData) || (pDevData->ulMagic != MAGIC_COM) ) 251 251 { 252 O32_SetLastError(ERROR_INVALID_HANDLE);252 SetLastError(ERROR_INVALID_HANDLE); 253 253 return FALSE; 254 254 } … … 649 649 } 650 650 651 /***************************************************************************** 652 * Name : BOOL HMDeviceCommClass::WriteFile 653 * Purpose : write data to handle / device 654 * Parameters: PHMHANDLEDATA pHMHandleData, 655 * LPCVOID lpBuffer, 656 * DWORD nNumberOfBytesToWrite, 657 * LPDWORD lpNumberOfBytesWritten, 658 * LPOVERLAPPED lpOverlapped 659 * Variables : 660 * Result : Boolean 661 * Remark : 662 * Status : 663 * 664 * Author : SvL 665 *****************************************************************************/ 666 667 BOOL HMDeviceCommClass::WriteFile(PHMHANDLEDATA pHMHandleData, 668 LPCVOID lpBuffer, 669 DWORD nNumberOfBytesToWrite, 670 LPDWORD lpNumberOfBytesWritten, 671 LPOVERLAPPED lpOverlapped) 672 { 673 dprintf(("KERNEL32:HMDeviceCommClass::WriteFile %s(%08x,%08x,%08x,%08x,%08x)", 674 lpHMDeviceName, 675 pHMHandleData->hHMHandle, 676 lpBuffer, 677 nNumberOfBytesToWrite, 678 lpNumberOfBytesWritten, 679 lpOverlapped)); 680 681 APIRET rc; 682 ULONG ulBytesWritten; 683 684 if((pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && !lpOverlapped) { 685 dprintf(("FILE_FLAG_OVERLAPPED flag set, but lpOverlapped NULL!!")); 686 SetLastError(ERROR_INVALID_PARAMETER); 687 return FALSE; 688 } 689 if(!(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && lpOverlapped) { 690 dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation")); 691 } 692 693 rc = OSLibDosWrite(pHMHandleData->hHMHandle, (LPVOID)lpBuffer, nNumberOfBytesToWrite, 694 &ulBytesWritten); 695 696 if(lpNumberOfBytesWritten) { 697 *lpNumberOfBytesWritten = (rc) ? 0 : ulBytesWritten; 698 } 699 return(rc==0); 700 } 701 702 /***************************************************************************** 703 * Name : BOOL WriteFileEx 704 * Purpose : The WriteFileEx function writes data to a file. It is designed 705 * solely for asynchronous operation, unlike WriteFile, which is 706 * designed for both synchronous and asynchronous operation. 707 * WriteFileEx reports its completion status asynchronously, 708 * calling a specified completion routine when writing is completed 709 * and the calling thread is in an alertable wait state. 710 * Parameters: HANDLE hFile handle of file to write 711 * LPVOID lpBuffer address of buffer 712 * DWORD nNumberOfBytesToRead number of bytes to write 713 * LPOVERLAPPED lpOverlapped address of offset 714 * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine 715 * Variables : 716 * Result : TRUE / FALSE 717 * Remark : 718 * Status : UNTESTED STUB 719 * 720 * Author : Patrick Haller [Mon, 1998/06/15 08:00] 721 *****************************************************************************/ 722 723 BOOL HMDeviceCommClass::WriteFileEx(PHMHANDLEDATA pHMHandleData, 724 LPVOID lpBuffer, 725 DWORD nNumberOfBytesToWrite, 726 LPOVERLAPPED lpOverlapped, 727 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) 728 { 729 dprintf(("ERROR: WriteFileEx %s (%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", 730 lpHMDeviceName, 731 pHMHandleData->hHMHandle, 732 lpBuffer, 733 nNumberOfBytesToWrite, 734 lpOverlapped, 735 lpCompletionRoutine)); 736 737 SetLastError(ERROR_INVALID_FUNCTION); 738 return FALSE; 739 } 740 741 /***************************************************************************** 742 * Name : BOOL HMDeviceCommClass::ReadFile 743 * Purpose : read data from handle / device 744 * Parameters: PHMHANDLEDATA pHMHandleData, 745 * LPCVOID lpBuffer, 746 * DWORD nNumberOfBytesToRead, 747 * LPDWORD lpNumberOfBytesRead, 748 * LPOVERLAPPED lpOverlapped 749 * Variables : 750 * Result : Boolean 751 * Remark : 752 * Status : 753 * 754 * Author : SvL 755 *****************************************************************************/ 756 757 BOOL HMDeviceCommClass::ReadFile(PHMHANDLEDATA pHMHandleData, 758 LPCVOID lpBuffer, 759 DWORD nNumberOfBytesToRead, 760 LPDWORD lpNumberOfBytesRead, 761 LPOVERLAPPED lpOverlapped) 762 { 763 dprintf(("KERNEL32:HMDeviceCommClass::ReadFile %s(%08x,%08x,%08x,%08x,%08x)", 764 lpHMDeviceName, 765 pHMHandleData->hHMHandle, 766 lpBuffer, 767 nNumberOfBytesToRead, 768 lpNumberOfBytesRead, 769 lpOverlapped)); 770 771 APIRET rc; 772 ULONG ulBytesRead; 773 774 if((pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && !lpOverlapped) { 775 dprintf(("FILE_FLAG_OVERLAPPED flag set, but lpOverlapped NULL!!")); 776 SetLastError(ERROR_INVALID_PARAMETER); 777 return FALSE; 778 } 779 if(!(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && lpOverlapped) { 780 dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation")); 781 } 782 783 rc = OSLibDosRead(pHMHandleData->hHMHandle, (LPVOID)lpBuffer, nNumberOfBytesToRead, 784 &ulBytesRead); 785 786 if(lpNumberOfBytesRead) { 787 *lpNumberOfBytesRead = (rc) ? 0 : ulBytesRead; 788 } 789 return(rc==0); 790 } 791 792 /***************************************************************************** 793 * Name : BOOL ReadFileEx 794 * Purpose : The ReadFileEx function reads data from a file asynchronously. 795 * It is designed solely for asynchronous operation, unlike the 796 * ReadFile function, which is designed for both synchronous and 797 * asynchronous operation. ReadFileEx lets an application perform 798 * other processing during a file read operation. 799 * The ReadFileEx function reports its completion status asynchronously, 800 * calling a specified completion routine when reading is completed 801 * and the calling thread is in an alertable wait state. 802 * Parameters: HANDLE hFile handle of file to read 803 * LPVOID lpBuffer address of buffer 804 * DWORD nNumberOfBytesToRead number of bytes to read 805 * LPOVERLAPPED lpOverlapped address of offset 806 * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine 807 * Variables : 808 * Result : TRUE / FALSE 809 * Remark : 810 * Status : UNTESTED STUB 811 * 812 * Author : Patrick Haller [Mon, 1998/06/15 08:00] 813 *****************************************************************************/ 814 BOOL HMDeviceCommClass::ReadFileEx(PHMHANDLEDATA pHMHandleData, 815 LPVOID lpBuffer, 816 DWORD nNumberOfBytesToRead, 817 LPOVERLAPPED lpOverlapped, 818 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) 819 { 820 dprintf(("ERROR: ReadFileEx %s (%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", 821 lpHMDeviceName, 822 pHMHandleData->hHMHandle, 823 lpBuffer, 824 nNumberOfBytesToRead, 825 lpOverlapped, 826 lpCompletionRoutine)); 827 828 SetLastError(ERROR_INVALID_FUNCTION); 829 return FALSE; 830 } 831 651 832 BOOL HMDeviceCommClass::SetCommBreak( PHMHANDLEDATA pHMHandleData ) 652 833 { … … 706 887 *lpdwSize< sizeof(COMMCONFIG) ) 707 888 { 708 O32_SetLastError(ERROR_INSUFFICIENT_BUFFER);889 SetLastError(ERROR_INSUFFICIENT_BUFFER); 709 890 *lpdwSize= sizeof(COMMCONFIG); 710 891 return FALSE; … … 713 894 if((NULL==pDevData) || (pDevData->ulMagic != MAGIC_COM) ) 714 895 { 715 O32_SetLastError(ERROR_INVALID_HANDLE);896 SetLastError(ERROR_INVALID_HANDLE); 716 897 return FALSE; 717 898 } … … 790 971 break; 791 972 default: 792 O32_SetLastError(ERROR_INVALID_PARAMETER);973 SetLastError(ERROR_INVALID_PARAMETER); 793 974 return(FALSE); 794 975 } … … 804 985 if((NULL==pDevData) || (pDevData->ulMagic != MAGIC_COM) ) 805 986 { 806 O32_SetLastError(ERROR_INVALID_HANDLE);987 SetLastError(ERROR_INVALID_HANDLE); 807 988 return FALSE; 808 989 } … … 821 1002 *lpdwSize< sizeof(COMMCONFIG) ) 822 1003 { 823 O32_SetLastError(ERROR_INSUFFICIENT_BUFFER);1004 SetLastError(ERROR_INSUFFICIENT_BUFFER); 824 1005 *lpdwSize= sizeof(COMMCONFIG); 825 1006 return FALSE; … … 828 1009 if((NULL==pDevData) || (pDevData->ulMagic != MAGIC_COM) ) 829 1010 { 830 O32_SetLastError(ERROR_INVALID_HANDLE);1011 SetLastError(ERROR_INVALID_HANDLE); 831 1012 return FALSE; 832 1013 }
Note:
See TracChangeset
for help on using the changeset viewer.