Changeset 8806 for trunk/src/kernel32/hmstd.cpp
- Timestamp:
- Jun 30, 2002, 11:54:51 AM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/hmstd.cpp
r8795 r8806 1 /* $Id: hmstd.cpp,v 1.1 0 2002-06-27 12:35:56sandervl Exp $ */1 /* $Id: hmstd.cpp,v 1.11 2002-06-30 09:54:51 sandervl Exp $ */ 2 2 3 3 /* … … 23 23 #include <os2win.h> 24 24 #include <stdlib.h> 25 #include <stdio.h> 25 26 #include <string.h> 26 27 #include <unicode.h> 27 #include < misc.h>28 #include <dbglog.h> 28 29 29 30 #include "HandleManager.H" … … 71 72 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) 72 73 { 73 BOOL bRC; 74 DWORD bytesread; 75 76 dprintf2(("KERNEL32: HMDeviceStandardClass::ReadFile %s(%08x,%08x,%08x,%08x,%08x) - NOT IMPLEMENTED\n", 77 lpHMDeviceName, 78 pHMHandleData, 79 lpBuffer, 80 nNumberOfBytesToRead, 81 lpNumberOfBytesRead, 82 lpOverlapped)); 83 84 if(lpCompletionRoutine) { 85 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 86 } 87 88 if(lpNumberOfBytesRead == NULL) { 89 lpNumberOfBytesRead = &bytesread; 90 } 91 if(pHMHandleData->dwUserData != STD_INPUT_HANDLE) { 92 return FALSE; 93 } 94 return O32_ReadFile(pHMHandleData->hHMHandle, (LPVOID)lpBuffer, nNumberOfBytesToRead, 95 lpNumberOfBytesRead, lpOverlapped); 74 BOOL bRC; 75 DWORD bytesread; 76 77 dprintf2(("KERNEL32: HMDeviceStandardClass::ReadFile %s(%08x,%08x,%08x,%08x,%08x) - NOT IMPLEMENTED\n", 78 lpHMDeviceName, pHMHandleData, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped)); 79 80 if(lpCompletionRoutine) { 81 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 82 } 83 84 if(lpNumberOfBytesRead == NULL) { 85 lpNumberOfBytesRead = &bytesread; 86 } 87 if(pHMHandleData->dwUserData != STD_INPUT_HANDLE) { 88 return FALSE; 89 } 90 return O32_ReadFile(pHMHandleData->hHMHandle, (LPVOID)lpBuffer, nNumberOfBytesToRead, 91 lpNumberOfBytesRead, lpOverlapped); 96 92 } 97 93 … … 112 108 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 113 109 *****************************************************************************/ 110 #define CARRIAGE_RETURN 0xD 111 #define LINE_FEED 0xA 114 112 115 113 BOOL HMDeviceStandardClass::WriteFile(PHMHANDLEDATA pHMHandleData, … … 124 122 125 123 dprintf(("KERNEL32: HMDeviceStandardClass::WriteFile %s(%08x,%08x,%08x,%08x,%08x)", 126 lpHMDeviceName, 127 pHMHandleData, 128 lpBuffer, 129 nNumberOfBytesToWrite, 130 lpNumberOfBytesWritten, 124 lpHMDeviceName, pHMHandleData, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, 131 125 lpOverlapped)); 132 if (lpNumberOfBytesWritten == NULL) 126 127 if(lpNumberOfBytesWritten == NULL) 133 128 lpNumberOfBytesWritten = &byteswritten; 134 if (lpCompletionRoutine) 129 130 if(lpCompletionRoutine) 135 131 { 136 132 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 137 133 } 138 134 139 if (pHMHandleData->dwUserData == STD_INPUT_HANDLE) 140 return FALSE; 135 if(pHMHandleData->dwUserData == STD_INPUT_HANDLE) 136 return FALSE; 137 138 //count linefeed without carriage return occurances 139 char *src, *dest; 140 int i = 0; 141 int missingCR = 0; 142 char prevchar = 0; 143 144 src = (char *)lpBuffer; 145 while(i < nNumberOfBytesToWrite) { 146 if(src[i] == LINE_FEED && prevchar != CARRIAGE_RETURN) { 147 missingCR++; 148 } 149 prevchar = src[i]; 150 i++; 151 } 152 nNumberOfBytesToWrite += missingCR; 153 dprintf(("missingCR %d", missingCR)); 154 141 155 lpLowMemBuffer = alloca(nNumberOfBytesToWrite); 142 if 156 if(lpLowMemBuffer == NULL) 143 157 { 144 158 DebugInt3(); 145 159 return FALSE; 146 160 } 147 memcpy(lpLowMemBuffer, lpBuffer, nNumberOfBytesToWrite); 148 149 if ( WinExe 150 && !WinExe->isConsoleApp() 151 && O32_GetFileType(pHMHandleData->hHMHandle) == FILE_TYPE_UNKNOWN) /* kso */ 161 162 //convert linefeed without carriage return into LF+CR 163 i = 0; 164 missingCR = 0; 165 prevchar = 0; 166 src = (char *)lpBuffer; 167 dest = (char *)lpLowMemBuffer; 168 169 while(i < nNumberOfBytesToWrite) { 170 if(src[i] == LINE_FEED && prevchar != CARRIAGE_RETURN) { 171 dest[i+missingCR] = CARRIAGE_RETURN; 172 missingCR++; 173 dest[i+missingCR] = LINE_FEED; 174 } 175 else { 176 dest[i+missingCR] = src[i]; 177 } 178 prevchar = src[i]; 179 i++; 180 } 181 //memcpy(lpLowMemBuffer, lpBuffer, nNumberOfBytesToWrite); 182 183 if(WinExe && !WinExe->isConsoleApp() && O32_GetFileType(pHMHandleData->hHMHandle) == FILE_TYPE_UNKNOWN) /* kso */ 152 184 { 153 185 //DosWrite returns error 436 when PM apps try to write to std out … … 162 194 dprintf(("%s: %.*s", pHMHandleData->dwUserData == STD_ERROR_HANDLE ? "STDERR" : "STDOUT", 163 195 nNumberOfBytesToWrite, lpLowMemBuffer)); 164 if (!O32_WriteFile(pHMHandleData->hHMHandle, lpLowMemBuffer, nNumberOfBytesToWrite, 165 lpNumberOfBytesWritten, lpOverlapped)) 166 { 167 /* Open32 wasn't made for console apps... */ 196 197 198 if(!O32_WriteFile(pHMHandleData->hHMHandle, lpLowMemBuffer, nNumberOfBytesToWrite, 199 lpNumberOfBytesWritten, lpOverlapped)) 200 { 168 201 dprintf(("STD*: failed with lasterror=%d\n", GetLastError())); 169 202 return FALSE;
Note:
See TracChangeset
for help on using the changeset viewer.