]> git.sur5r.net Git - openocd/commitdiff
pass startup_tcl to command_init
authorZachary T Welch <zw@superlucidity.net>
Tue, 17 Nov 2009 17:15:09 +0000 (09:15 -0800)
committerZachary T Welch <zw@superlucidity.net>
Wed, 18 Nov 2009 15:22:22 +0000 (07:22 -0800)
Removes external linkage from helper module, making the startup
code a parameter to a new command context's initialization routine.

src/Makefile.am
src/helper/command.c
src/helper/command.h
src/openocd.c
src/openocd.h

index 7a88681105f6862e32519331d27536f89d5a5fac..8f96b05380d3c9d40ff4f5b9e1c86c2a52eddf2f 100644 (file)
@@ -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
index ad09e3de27878f4dfb626e77e8bbc098b55b535d..708a8024f291927f227cab17103aec495d9a9b0b 100644 (file)
@@ -766,10 +766,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;
index 62231fc83440c0ca0e13623f9be5c1eaa6ba7469..05088b56f619c941c9d63b6597a9f47dabdf75ef 100644 (file)
@@ -190,7 +190,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, ...)
index 9edd611dd3787d814ffb54382eee03cb37528ed3..b7781a6b6d37332693838815f662347bdcfd80ca 100644 (file)
@@ -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");
index 1bf6b7e6f1a06e8634ed0485a87aa95fd6a85088..70e3ee0126f30e524bc1c935b3b4ac3af0ee0a08 100644 (file)
@@ -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