Changeset 1045 for trunk/tools/assistant
- Timestamp:
- Sep 2, 2011, 2:18:55 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/assistant/tools/assistant/remotecontrol.cpp
r846 r1045 86 86 TRACE_OBJ 87 87 char chBuf[4096]; 88 size_t pos = 0;89 88 ULONG ulRead; 89 90 90 91 91 HFILE hStdinDup = HFILE(~0); … … 94 94 95 95 while (arc == NO_ERROR) { 96 arc = DosRead(hStdinDup, chBuf + pos, sizeof(chBuf) - pos, &ulRead);96 arc = DosRead(hStdinDup, chBuf, &ulRead); 97 97 if (arc == NO_ERROR && ulRead != 0) { 98 size_t totalRead = pos + ulRead;99 size_t len = ulRead;100 char *start = chBuf, *zero = chBuf + pos;101 // send all complete commands102 while (len && (zero = static_cast<char *>(memchr(zero, '\0', len)))) {103 emit receivedCommand(QString::fromLocal8Bit(start));104 start = ++zero;105 len = totalRead - (start - chBuf);98 99 ; 100 ; 101 102 103 ; 104 105 ; 106 106 } 107 if (start != chBuf) { 108 // move the incomplete portion to the beginning 109 memcpy(chBuf, start, len); 110 pos = len; 111 } else { 112 pos = totalRead; 113 if (pos == sizeof(chBuf)) { 114 // buffer full, emit the command anyway and start over 115 QByteArray cmd(chBuf, sizeof(chBuf)); 116 emit receivedCommand(QString::fromLocal8Bit(cmd)); 117 pos = 0; 118 } 107 cmd.append(chBuf, i); 108 if (gotIt) { 109 emit receivedCommand(QString::fromLocal8Bit(cmd)); 110 cmd.clear(); 111 // get the remains if any 112 cmd.append(chBuf + i, ulRead - i); 119 113 } 120 114 } … … 149 143 hStdinDup = stdin; 150 144 #endif 151 152 // ### do the same as in the OS/2 version above153 145 154 146 while (ok) {
Note:
See TracChangeset
for help on using the changeset viewer.