| 314 | } |
| 315 | |
| 316 | void TelnetDebugger::checkDebugRecv() |
| 317 | { |
| 318 | for (;;) |
| 319 | { |
| 320 | // Process all the complete commands in the buffer. |
| 321 | while ( mCurPos > 0 ) |
| 322 | { |
| 323 | // Remove leading whitespace. |
| 324 | while ( mCurPos > 0 && ( mLineBuffer[0] == 0 || mLineBuffer[0] == '\r' || mLineBuffer[0] == '\n' ) ) |
| 325 | { |
| 326 | mCurPos--; |
| 327 | dMemmove(mLineBuffer, mLineBuffer + 1, mCurPos); |
| 328 | } |
| 329 | |
| 330 | // Look for a complete command. |
| 331 | bool gotCmd = false; |
| 332 | for(S32 i = 0; i < mCurPos; i++) |
| 333 | { |
| 334 | if( mLineBuffer[i] == 0 ) |
| 335 | mLineBuffer[i] = '_'; |
| 336 | |
| 337 | else if ( mLineBuffer[i] == '\r' || mLineBuffer[i] == '\n' ) |
| 338 | { |
| 339 | // Send this command to be processed. |
| 340 | mLineBuffer[i] = '\n'; |
| 341 | processLineBuffer(i+1); |
| 342 | |
| 343 | // Remove the command from the buffer. |
| 344 | mCurPos -= i + 1; |
| 345 | dMemmove(mLineBuffer, mLineBuffer + i + 1, mCurPos); |
| 346 | |
| 347 | gotCmd = true; |
| 348 | break; |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | // If we didn't find a command in this pass |
| 353 | // then we have an incomplete buffer. |
| 354 | if ( !gotCmd ) |
| 355 | break; |
| 356 | } |
| 357 | |
| 358 | // found no <CR> or <LF> |
| 359 | if(mCurPos == MaxCommandSize) // this shouldn't happen |
| 360 | { |
| 361 | disconnect(); |
| 362 | return; |
| 363 | } |
| 364 | |
| 365 | S32 numBytes; |
| 366 | Net::Error err = Net::recv(mDebugSocket, (unsigned char*)(mLineBuffer + mCurPos), MaxCommandSize - mCurPos, &numBytes); |
| 367 | |
| 368 | if((err != Net::NoError && err != Net::WouldBlock) || numBytes == 0) |
| 369 | { |
| 370 | disconnect(); |
| 371 | return; |
| 372 | } |
| 373 | if(err == Net::WouldBlock) |
nothing calls this directly
no test coverage detected