示例#1
0
int main( void ) {
	char *input = NULL;
	size_t read_count = 0;
	token_t *tokens;
	command_t *commands;
	int num_commands;

	/*Prompt user until interrupt, error or quit*/
	while(1) {
		num_commands = 0;

		printf("> ");
		getline(&input, &read_count, stdin);
		input[strlen(input) - 1] = '\0'; /*Strip newline char*/

		if(feof(stdin)) {
			exit_with_sig(0, NULL);
		}

		tokens = build_tokens(input);
		commands = build_commands(tokens, &num_commands);

		execute_comm_list(commands, num_commands);
		destroy_commands(commands);
	}
}
示例#2
0
/*****************************************************************************
 * int bsdl_process_elements( jtag_ctrl_t *jc, const char *idcode )
 *
 * If enabled, runs through the list of vhdl elements in jtag ctrl and parser
 * them as BSDL statements.
 * If enabled, compares idcode versus jc->idcode.
 * If enabled, prints or executes the resulting jtag commands.
 *
 * Parameters
 *   jc     : jtag_ctrl structure
 *   idcode : idcode string
 *
 * Returns
 *   < 0 : Error occured, parse/syntax problems or out of memory
 *   = 0 : No errors, idcode not checked or mismatching
 *   > 0 : No errors, idcode checked and matched
 *
 ****************************************************************************/
int bsdl_process_elements( jtag_ctrl_t *jc, const char *idcode )
{
  bsdl_parser_priv_t *priv;
  vhdl_elem_t *el = jc->vhdl_elem_first;
  int result = BSDL_MODE_SYN_CHECK;

  if ((priv = bsdl_parser_init( jc )) == NULL)
    return -1;

  if (jc->proc_mode & BSDL_MODE_SYN_CHECK)
  {
    while (el && (result & BSDL_MODE_SYN_CHECK))
    {
      result = parse_vhdl_elem( priv, el );

      el = el->next;
    }

    if (!(result & BSDL_MODE_SYN_CHECK))
    {
      bsdl_msg( jc->proc_mode,
                BSDL_MSG_ERR, _("BSDL stage reported errors, aborting.\n") );
      bsdl_parser_deinit( priv );
      return -1;
    }
  }

  if (jc->idcode)
    bsdl_msg( jc->proc_mode,
              BSDL_MSG_NOTE, _("Got IDCODE: %s\n"), jc->idcode );

  if (jc->proc_mode & BSDL_MODE_IDCODE_CHECK)
    result |= compare_idcode( jc, idcode );

  if (jc->proc_mode & (BSDL_MODE_INSTR_EXEC | BSDL_MODE_INSTR_PRINT))
    /* IDCODE check positive if requested? */
    if ( ((jc->proc_mode & BSDL_MODE_IDCODE_CHECK) &&
          (result & BSDL_MODE_IDCODE_CHECK))
         || (!(jc->proc_mode & BSDL_MODE_IDCODE_CHECK)) )
      result |= build_commands( priv );

  if ((result & jc->proc_mode) == (jc->proc_mode & BSDL_MODE_ACTION_ALL))
    if (jc->proc_mode & BSDL_MODE_IDCODE_CHECK)
      result = 1;
    else
      result = 0;
  else
    result = -1;

  bsdl_parser_deinit( priv );

  return result;
}