Changeset 701
- Timestamp:
- Mar 18, 2010, 3:54:07 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/tools/assistant/tools/assistant/remotecontrol.cpp ¶
r651 r701 79 79 { 80 80 char chBuf[4096]; 81 size_t pos = 0; 81 82 ULONG ulRead; 82 83 … … 86 87 87 88 while (arc == NO_ERROR) { 88 arc = DosRead(hStdinDup, chBuf, sizeof(chBuf), &ulRead); 89 if (arc == NO_ERROR && ulRead != 0) 90 emit receivedCommand(QString::fromLocal8Bit(chBuf)); 89 arc = DosRead(hStdinDup, chBuf + pos, sizeof(chBuf) - pos, &ulRead); 90 if (arc == NO_ERROR && ulRead != 0) { 91 size_t totalRead = pos + ulRead; 92 size_t len = ulRead; 93 char *start = chBuf, *zero = chBuf + pos; 94 // send all complete commands 95 while (len && (zero = static_cast<char *>(memchr(zero, '\0', len)))) { 96 emit receivedCommand(QString::fromLocal8Bit(start)); 97 start = ++zero; 98 len = totalRead - (start - chBuf); 99 } 100 if (start != chBuf) { 101 // move the incomplete portion to the beginning 102 memcpy(chBuf, start, len); 103 pos = len; 104 } else { 105 pos = totalRead; 106 if (pos == sizeof(chBuf)) { 107 // buffer full, emit the command anyway and start over 108 QByteArray cmd(chBuf, sizeof(chBuf)); 109 emit receivedCommand(QString::fromLocal8Bit(cmd)); 110 pos = 0; 111 } 112 } 113 } 91 114 } 92 115 … … 118 141 hStdinDup = stdin; 119 142 #endif 143 144 // ### do the same as in the OS/2 version above 120 145 121 146 while (ok) {
Note:
See TracChangeset
for help on using the changeset viewer.