void command_print(command_context_t *context, char *format, ...)
{
- va_list ap;
char *buffer = NULL;
int n, size = 0;
char *p;
- va_start(ap, format);
-
/* process format string */
- /* TODO: possible bug. va_list is undefined after the first call to vsnprintf */
- while (!buffer || (n = vsnprintf(buffer, size, format, ap)) >= size)
- {
- /* increase buffer until it fits the whole string */
- if (!(p = realloc(buffer, size += 4096)))
+ for (;;)
+ {
+ va_list ap;
+ va_start(ap, format);
+ if (!buffer || (n = vsnprintf(buffer, size, format, ap)) >= size)
{
- /* gotta free up */
- if (buffer)
- free(buffer);
- return;
+ /* increase buffer until it fits the whole string */
+ if (!(p = realloc(buffer, size += 4096)))
+ {
+ /* gotta free up */
+ if (buffer)
+ free(buffer);
+ return;
+ }
+
+ buffer = p;
+
+ va_end(ap);
+ continue;
}
-
- buffer = p;
+ va_end(ap);
+ break;
}
/* vsnprintf failed */
if (buffer)
free(buffer);
-
- va_end(ap);
}
int find_and_run_command(command_context_t *context, command_t *commands, char *words[], int num_words, int start_word)
if (strncasecmp(c->name, words[start_word], strlen(words[start_word])))
continue;
- if ((c->mode == context->mode) || (c->mode == COMMAND_ANY))
+ if ((context->mode == COMMAND_CONFIG) || (c->mode == COMMAND_ANY) || (c->mode == context->mode) )
{
if (!c->children)
{
}
indents[i*2] = 0;
- if ((command->mode == COMMAND_EXEC) || (command->mode == COMMAND_ANY))
- {
- if (command->help)
- help = command->help;
+ if (command->help)
+ help = command->help;
- snprintf(name_buf, 64, command->name);
- strncat(name_buf, indents, 64);
- command_print(context, "%20s\t%s", name_buf, help);
- }
+ snprintf(name_buf, 64, command->name);
+ strncat(name_buf, indents, 64);
+ command_print(context, "%20s\t%s", name_buf, help);
if (command->children)
{
free(captured_char);
free(in_check_value_char);
+
+ retval = ERROR_JTAG_QUEUE_FAILED;
}
}
register_command(cmd_ctx, NULL, "jtag_speed", handle_jtag_speed_command,
COMMAND_ANY, "set jtag speed (if supported) <speed>");
register_command(cmd_ctx, NULL, "jtag_device", handle_jtag_device_command,
- COMMAND_CONFIG, NULL);
+ COMMAND_CONFIG, "jtag_device <ir_length> <ir_expected> <ir_mask>");
register_command(cmd_ctx, NULL, "reset_config", handle_reset_config_command,
COMMAND_CONFIG, NULL);
register_command(cmd_ctx, NULL, "jtag_nsrst_delay", handle_jtag_nsrst_delay_command,