]> 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 7e88263b7fa2c88b159d606b64247cd2acc7f8cf..186d992e3cb48f1d38d46e9da3d4a40b00aac5be 100644 (file)
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "interpreter.h"
+#include "configuration.h"
 
 #include "binarybuffer.h"
 #include <stdlib.h>
@@ -88,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);
@@ -122,7 +127,7 @@ int handle_var_command(struct command_context_s *cmd_ctx, char *cmd, char **args
                        last_var_p = &((*last_var_p)->next);
                }
 
-               if ((args[0][0] >= 0) && (args[0][0] <= 9))
+               if ((args[0][0] >= '0') && (args[0][0] <= '9'))
                {
                        command_print(cmd_ctx, "invalid name specified (first character may not be a number)");
                        return ERROR_OK;
@@ -179,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)
        {
@@ -212,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);