]> git.sur5r.net Git - openocd/blobdiff - src/helper/interpreter.c
- command_run_line will only search once for the command, and execute if found
[openocd] / src / helper / interpreter.c
index 7b0432abc097a68191b142a8ab88ed734370eada..186d992e3cb48f1d38d46e9da3d4a40b00aac5be 100644 (file)
@@ -22,6 +22,7 @@
 #endif
 
 #include "interpreter.h"
+#include "configuration.h"
 
 #include "binarybuffer.h"
 #include <stdlib.h>
@@ -92,7 +93,7 @@ var_t* get_var_by_namenum(char *namenum)
        
 }
 
-int field_le_to_host(u8 *buffer, void *priv)
+int field_le_to_host(u8 *buffer, void *priv, struct scan_field_s *dummy)
 {
        var_field_t *field = priv;
        field->value = buf_get_u32(buffer, 0, field->num_bits);
@@ -183,7 +184,7 @@ int handle_field_command(struct command_context_s *cmd_ctx, char *cmd, char **ar
 {
 
        if (argc < 2)
-               command_print(cmd_ctx, "usage: field <var> <field> [value|'flip']");
+               return ERROR_COMMAND_SYNTAX_ERROR;
 
        if (argc >= 2)
        {
@@ -216,24 +217,19 @@ int handle_field_command(struct command_context_s *cmd_ctx, char *cmd, char **ar
 int handle_script_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
        FILE *script_file;
-       int echo;
 
        if (argc != 1)
-               command_print(cmd_ctx, "usage: script <file>");
+               return ERROR_COMMAND_SYNTAX_ERROR;
+
+       script_file = open_file_from_path (args[0], "r");
 
-       script_file = fopen(args[0], "r");
        if (!script_file)
        {
                command_print(cmd_ctx, "couldn't open script file %s", args[0]);
                return ERROR_OK;
        }
-
-       echo = cmd_ctx->echo;
-       cmd_ctx->echo = 1;
-       
-       command_run_file(cmd_ctx, script_file, COMMAND_EXEC);
        
-       cmd_ctx->echo = echo;
+       command_run_file(cmd_ctx, script_file, cmd_ctx->mode);
        
        fclose(script_file);