|
From: Zachary T W. <zw...@su...> - 2009-11-17 18:40:16
|
Removes external linkage from helper module, making the startup
code a parameter to a new command context's initialization routine.
Signed-off-by: Zachary T Welch <zw...@su...>
---
src/Makefile.am | 2 +-
src/helper/command.c | 3 +--
src/helper/command.h | 5 ++++-
src/openocd.c | 3 ++-
src/openocd.h | 3 +++
5 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 7a88681..8f96b05 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -116,7 +116,7 @@ BIN2C = $(builddir)/helper/bin2char$(EXEEXT_FOR_BUILD)
# Convert .tcl to cfile
startup_tcl.c: startup.tcl $(BIN2C)
- $(BIN2C) startup_tcl < $< > $@ || rm -f $@
+ $(BIN2C) openocd_startup_tcl < $< > $@ || rm -f $@
# add startup_tcl.c to make clean list
CLEANFILES = startup.tcl startup_tcl.c
diff --git a/src/helper/command.c b/src/helper/command.c
index 7edd585..053f027 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -764,10 +764,9 @@ COMMAND_HANDLER(handle_fast_command)
}
-struct command_context* command_init()
+struct command_context* command_init(const char *startup_tcl)
{
struct command_context* context = malloc(sizeof(struct command_context));
- extern const char startup_tcl[];
const char *HostOs;
context->mode = COMMAND_EXEC;
diff --git a/src/helper/command.h b/src/helper/command.h
index 79e57f5..fb1ff04 100644
--- a/src/helper/command.h
+++ b/src/helper/command.h
@@ -165,7 +165,10 @@ struct command_context* copy_command_context(struct command_context* context);
int command_context_mode(struct command_context *context, enum command_mode mode);
-struct command_context* command_init(void);
+/**
+ * Creates a new command context using the startup TCL provided.
+ */
+struct command_context* command_init(const char *startup_tcl);
int command_done(struct command_context *context);
void command_print(struct command_context *context, const char *format, ...)
diff --git a/src/openocd.c b/src/openocd.c
index 4c07511..da98c92 100644
--- a/src/openocd.c
+++ b/src/openocd.c
@@ -28,6 +28,7 @@
#include "config.h"
#endif
+#include "openocd.h"
#include "jtag.h"
#include "configuration.h"
#include "xsvf.h"
@@ -168,7 +169,7 @@ struct command_context *setup_command_handler(void)
{
struct command_context *cmd_ctx;
- global_cmd_ctx = cmd_ctx = command_init();
+ global_cmd_ctx = cmd_ctx = command_init(openocd_startup_tcl);
register_command(cmd_ctx, NULL, "version", handle_version_command,
COMMAND_EXEC, "show OpenOCD version");
diff --git a/src/openocd.h b/src/openocd.h
index 1bf6b7e..70e3ee0 100644
--- a/src/openocd.h
+++ b/src/openocd.h
@@ -36,4 +36,7 @@ void openocd_sleep_prelude(void);
/// used by the server_loop() function in src/server/server.c
void openocd_sleep_postlude(void);
+/// provides a hard-coded command environment setup
+extern const char *openocd_startup_tcl;
+
#endif
--
1.6.4.4
|