Example #1
0
static int jtag_readline_multiple_commands_support(chain_t *chain, char * line) /* multiple commands should be separated with '::' */
{
  int 	r;
  char	*nextcmd = line;

  if (!line || !(strlen( line ) > 0))
		return 1;

  do {
  line = nextcmd;

  nextcmd = strstr(nextcmd, "::"); /* :: to not confuse ms-dos users ;-) */
  
  if (nextcmd) {  
    *nextcmd++ = 0;
     ++nextcmd;
     while (*line == ':') ++line;
  } 
  
  r = jtag_parse_line( chain, line );

  chain_flush( chain );
  
  } while (nextcmd && r);

  return r;
}
Example #2
0
static int
jtag_parse_stream( FILE *f )
{
    int go = 1;
    char *line = NULL;
    int n = 0;

    while (go && (getline( &line, &n, f ) != -1))
        if ((strlen(line) > 0) && (line[0] != '#'))
            go = jtag_parse_line(line);

    free(line);

    return go;
}
Example #3
0
static void
jtag_readline_loop( const char *prompt )
{
    char *line = NULL;

    /* Iterate */
    while (jtag_parse_line( line )) {
        free( line );

        /* Read a line from the terminal */
        line = readline( prompt );

        /* Check if we actually got something */
        if (line && (strlen( line ) > 0))
            add_history( line );
    }
    free( line );
}