summaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/Makefile.am2
-rw-r--r--src/helper/command.c24
-rw-r--r--src/helper/configuration.c5
3 files changed, 25 insertions, 6 deletions
diff --git a/src/helper/Makefile.am b/src/helper/Makefile.am
index 1f3d76b6..8a2d472e 100644
--- a/src/helper/Makefile.am
+++ b/src/helper/Makefile.am
@@ -1,4 +1,4 @@
-INCLUDES = $(all_includes)
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
METASOURCES = AUTO
AM_CPPFLAGS = -DPKGDATADIR=\"$(pkgdatadir)\" -DPKGLIBDIR=\"$(pkglibdir)\" @CPPFLAGS@
noinst_LIBRARIES = libhelper.a
diff --git a/src/helper/command.c b/src/helper/command.c
index d2abb0c2..e536cca5 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -38,6 +38,8 @@
#include <stdio.h>
#include <unistd.h>
+#include <openocd_tcl.h>
+
int fast_and_dangerous = 0;
void command_print_help_line(command_context_t* context, struct command_s *command, int indent);
@@ -65,10 +67,9 @@ command_t* register_command(command_context_t *context, command_t *parent, char
c->children = NULL;
c->handler = handler;
c->mode = mode;
- if (help)
- c->help = strdup(help);
- else
- c->help = NULL;
+ if (!help)
+ help="";
+ c->help = strdup(help);
c->next = NULL;
/* place command in tree */
@@ -100,7 +101,22 @@ command_t* register_command(command_context_t *context, command_t *parent, char
context->commands = c;
}
}
+ /* accumulate help text in Tcl helptext list. */
+ Jim_Obj *helptext=Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG);
+ Jim_Obj *cmd_entry=Jim_NewListObj(interp, NULL, 0);
+
+ Jim_Obj *cmd_list=Jim_NewListObj(interp, NULL, 0);
+
+ /* maximum of two levels :-) */
+ if (c->parent!=NULL)
+ {
+ Jim_ListAppendElement(interp, cmd_list, Jim_NewStringObj(interp, c->parent->name, -1));
+ }
+ Jim_ListAppendElement(interp, cmd_list, Jim_NewStringObj(interp, c->name, -1));
+ Jim_ListAppendElement(interp, cmd_entry, cmd_list);
+ Jim_ListAppendElement(interp, cmd_entry, Jim_NewStringObj(interp, c->help, -1));
+ Jim_ListAppendElement(interp, helptext, cmd_entry);
return c;
}
diff --git a/src/helper/configuration.c b/src/helper/configuration.c
index ff8b0272..e9a13ead 100644
--- a/src/helper/configuration.c
+++ b/src/helper/configuration.c
@@ -106,6 +106,7 @@ FILE *open_file_from_path (char *file, char *mode)
int parse_config_file(struct command_context_s *cmd_ctx)
{
+ int retval;
char **cfg;
if (!config_file_names)
@@ -115,7 +116,9 @@ int parse_config_file(struct command_context_s *cmd_ctx)
while (*cfg)
{
- command_run_line(cmd_ctx, *cfg);
+ retval=command_run_line(cmd_ctx, *cfg);
+ if (retval!=ERROR_OK)
+ return retval;
cfg++;
}