lib/src/BoxTools/VisItPythonConnection.cpp
// ****************************************************************************
//  Method:  WaitForPrompt
//
//  Purpose:
//    Internal method to read output from the CLI until we get a prompt.
//
//  Programmer:  Jeremy Meredith
//  Creation:    June 12, 2007
//
// ****************************************************************************
WaitForPrompt
Purpose:
Internal method to read output from the CLI until we get a prompt.

Jeremy Meredith
Creation:    June 12, 2007
WaitForPrompt Purpose : Internal method to read output from the CLI until we get a prompt . Jeremy Meredith Creation : June 12 2007
bool VisItPythonConnection::WaitForPrompt()
{
    char *pbuf = readbuffer;
    int   len  = 0;
    while (true)
    {
        int nread = read(from_cli, pbuf, readbufferlen - len);
        if (nread <= 0)
        {
            error = "read from CLI failed";
            return false;
        }
        len  += nread;
        pbuf += nread;
        *pbuf = '\0';
        if (strstr(readbuffer, ">>> "))
        {
            return true;
        }
        if (readbuffer[len-1] != '>')
        {
            pbuf = readbuffer;
            len  = 0;
        }
    }
}
bool VisItPythonConnection :: WaitForPrompt ( ) { char * pbuf = readbuffer ; int len = 0 ; while ( true ) { int nread = read ( from_cli , pbuf , readbufferlen - len ) ; if ( nread <= 0 ) { error = " " ; return false ; } len += nread ; pbuf += nread ; * pbuf = ' \0 ' ; if ( strstr ( readbuffer , " " ) ) { return true ; } if ( readbuffer [ len - 1 ] != ' ' ) { pbuf = readbuffer ; len = 0 ; } } }
Method:  WaitForPrompt
Purpose:
Internal method to read output from the CLI until we get a prompt.
Method : WaitForPrompt Purpose : Internal method to read output from the CLI until we get a prompt .
// Read some text // Enable for debugging //write(fileno(stderr), pbuf, nread); // Advance pbuf and keep track of the total length read // Check for the prompt string.  We could probably just check the // last four characters, not search the whole string, but this is // easy and might be more robust. // To avoid buffer overruns and speed up searches for the prompt, // cycle around.  Avoid the situation where the prompt is partially // printed at the end of the read buffer.