Example #1
0
void read_input(char *str, int str_size)
{
    char ch;

    if (NULL == str)
    {
        run_error ("Buffer is null in read_string");
        return;
    }
    if (str_size < 0)
    {
        run_error ("Buffer size is null in read_string");
        return;
    }

    // We assume that get_console_char will "do the right thing" wrt the msg
    // pump, etc.
    while ((1 < str_size) && (!force_break))
    {
        ch = get_console_char();
        *str = ch;
        ++str;
        --str_size;
        put_console_char(ch);

        // Read just one line.
        if (ch == '\n')
            break;
    }

    if (0 < str_size)
        *str = '\0';
}
/*
 * display_debug_string() - Dump string to debug console
 *
 * INPUT
 *     - str: string to write to debug console
 * OUTPUT
 *     none
 */
static void display_debug_string(char *str)
{
    do
    {
        put_console_char(*str);
    }
    while(*(str++));
}