MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / ReceiveCommand

Method ReceiveCommand

source/Debugger.cpp:2107–2139  ·  view source on GitHub ↗

Debugger::ReceiveCommand Receives a full command line into mCommandBuf. If part of the next command is received, it remains in the buffer until the next call to ReceiveCommand.

Source from the content-addressed store, hash-verified

2105// received, it remains in the buffer until the next call to ReceiveCommand.
2106//
2107int Debugger::ReceiveCommand(int *aCommandLength)
2108{
2109 ASSERT(mSocket != INVALID_SOCKET); // Shouldn't be at this point; will be caught by recv() anyway.
2110 ASSERT(!mCommandBuf.mFailed); // Should have been previously reset.
2111
2112 DWORD u = 0;
2113
2114 for(;;)
2115 {
2116 // Check data received in the previous iteration or by a previous call to ReceiveCommand().
2117 for ( ; u < mCommandBuf.mDataUsed; ++u)
2118 {
2119 if (mCommandBuf.mData[u] == '\0')
2120 {
2121 if (aCommandLength)
2122 *aCommandLength = u; // Does not include the null-terminator.
2123 return DEBUGGER_E_OK;
2124 }
2125 }
2126
2127 // Init or expand the buffer as necessary.
2128 if (mCommandBuf.mDataUsed == mCommandBuf.mDataSize && mCommandBuf.Expand() != DEBUGGER_E_OK)
2129 return FatalError(); // This also calls mCommandBuf.Clear() via Disconnect().
2130
2131 // Receive and append data.
2132 int bytes_received = recv(mSocket, mCommandBuf.mData + mCommandBuf.mDataUsed, (int)(mCommandBuf.mDataSize - mCommandBuf.mDataUsed), 0);
2133
2134 if (bytes_received == SOCKET_ERROR)
2135 return FatalError();
2136
2137 mCommandBuf.mDataUsed += bytes_received;
2138 }
2139}
2140
2141// Debugger::SendResponse
2142//

Callers

nothing calls this directly

Calls 1

ExpandMethod · 0.45

Tested by

no test coverage detected