]> git.sur5r.net Git - openocd/commitdiff
- clean up target output strings a bit
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Fri, 29 Feb 2008 11:31:49 +0000 (11:31 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Fri, 29 Feb 2008 11:31:49 +0000 (11:31 +0000)
- open_file_from_path() now uses logging feature
- open_file_from_path() no longer uses paths for anything but "r" mode. Fixes
  bug  waiting to happen.

git-svn-id: svn://svn.berlios.de/openocd/trunk@389 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/helper/configuration.c
src/helper/configuration.h
src/helper/interpreter.c
src/helper/log.c
src/server/gdb_server.c
src/target/target.c

index abbcbfcb0bc9f5ae43d927fe1a25bbafa13a80f7..d72556060bb738935299539481d6b2b67b27276f 100644 (file)
@@ -54,8 +54,14 @@ void add_config_file_name (const char *cfg)
        config_file_names[num_config_files] = NULL;
 }
 
-FILE *open_file_from_path (command_context_t *cmd_ctx, char *file, char *mode)
+FILE *open_file_from_path (char *file, char *mode)
 {
+       if (mode[0]!='r')
+       {
+               return fopen(file, mode);
+       } else
+       {
+               
        FILE *fp = NULL;
        char **search_dirs = script_search_dirs;
        char *dir;
@@ -78,9 +84,10 @@ FILE *open_file_from_path (command_context_t *cmd_ctx, char *file, char *mode)
        }
 
        if (fp)
-               command_print(cmd_ctx, "opened %s", full_path);
+                       DEBUG("opened %s", full_path);
 
        return fp;
+       }
 }
 
 int parse_config_file(struct command_context_s *cmd_ctx)
index f4aa8c0a015eabbfa7a495ac10fe329c640bb5af..ff802758fcca0546aa1fbd03d8f85c387877156e 100644 (file)
@@ -28,6 +28,6 @@ extern int parse_config_file(struct command_context_s *cmd_ctx);
 extern void add_config_file_name (const char *cfg);
 extern void add_script_search_dir (const char *dir);
 extern int configuration_output_handler(struct command_context_s *context, char* line);
-extern FILE *open_file_from_path (command_context_t *cmd_ctx, char *file, char *mode);
+extern FILE *open_file_from_path (char *file, char *mode);
 
 #endif /* CONFIGURATION_H */
index abf7b0938762a1c32681571570d49fa87dca45fe..186d992e3cb48f1d38d46e9da3d4a40b00aac5be 100644 (file)
@@ -221,7 +221,7 @@ int handle_script_command(struct command_context_s *cmd_ctx, char *cmd, char **a
        if (argc != 1)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
-       script_file = open_file_from_path(cmd_ctx, args[0], "r");
+       script_file = open_file_from_path (args[0], "r");
 
        if (!script_file)
        {
index de74f9d05c5069b6315cce3bd15b23ed0d7be03f..85861988bc52a543732a312c1421eb19e345aa66 100644 (file)
@@ -74,7 +74,7 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch
        if (f != NULL)
                file = f + 1;
 
-       if (strchr(buffer, '\n')!=NULL)
+       if (strchr(string, '\n')!=NULL)
        {
                if (debug_level >= LOG_DEBUG)
                {
index 57ba2806276fa3780bbc43a3b5931e8e28ff3a30..9994b93b070c1bb23a6dc8919ee5b43b5498b870 100644 (file)
@@ -540,7 +540,7 @@ int gdb_program_handler(struct target_s *target, enum target_event event, void *
 
        if (target->gdb_program_script)
        {
-               script = open_file_from_path(cmd_ctx, target->gdb_program_script, "r");
+               script = open_file_from_path(target->gdb_program_script, "r");
                if (!script)
                {
                        ERROR("couldn't open script file %s", target->gdb_program_script);
index 61fac56b23ae336021800bf834eae9e53c1c85b7..feddc1c0fe7b726edffc85ba52b510fa4b7e245e 100644 (file)
@@ -229,7 +229,7 @@ int target_init_handler(struct target_s *target, enum target_event event, void *
        {
                target_unregister_event_callback(target_init_handler, priv);
 
-               script = open_file_from_path(cmd_ctx, target->reset_script, "r");
+               script = open_file_from_path(target->reset_script, "r");
                if (!script)
                {
                        ERROR("couldn't open script file %s", target->reset_script);
@@ -270,11 +270,11 @@ int target_process_reset(struct command_context_s *cmd_ctx)
                        switch (target->reset_mode)
                        {
                                case RESET_HALT:
-                                       command_print(cmd_ctx, "nSRST pulls nTRST, falling back to RESET_RUN_AND_HALT");
+                                       command_print(cmd_ctx, "nSRST pulls nTRST, falling back to \"reset run_and_halt\"");
                                        target->reset_mode = RESET_RUN_AND_HALT;
                                        break;
                                case RESET_INIT:
-                                       command_print(cmd_ctx, "nSRST pulls nTRST, falling back to RESET_RUN_AND_INIT");
+                                       command_print(cmd_ctx, "nSRST pulls nTRST, falling back to \"reset run_and_init\"");
                                        target->reset_mode = RESET_RUN_AND_INIT;
                                        break;
                                default:
@@ -1540,7 +1540,7 @@ static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum target_
 {
        int retval;
        struct timeval timeout, now;
-       
+       int once=1;
        gettimeofday(&timeout, NULL);
        timeval_add_time(&timeout, 0, ms * 1000);
        
@@ -1554,12 +1554,15 @@ static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum target_
                {
                        break;
                }
-               command_print(cmd_ctx, "waiting for target %s...", target_state_strings[state]);
+               if (once)
+               {
+                       once=0;
+                       command_print(cmd_ctx, "waiting for target %s...", target_state_strings[state]);
+               }
                
                gettimeofday(&now, NULL);
                if ((now.tv_sec > timeout.tv_sec) || ((now.tv_sec == timeout.tv_sec) && (now.tv_usec >= timeout.tv_usec)))
                {
-                       command_print(cmd_ctx, "timed out while waiting for target %s", target_state_strings[state]);
                        ERROR("timed out while waiting for target %s", target_state_strings[state]);
                        break;
                }
@@ -1915,7 +1918,6 @@ int handle_load_image_command(struct command_context_s *cmd_ctx, char *cmd, char
        
        if (image_open(&image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK)
        {
-               command_print(cmd_ctx, "load_image error: %s", image.error_str);
                return ERROR_OK;
        }
        
@@ -1985,7 +1987,6 @@ int handle_dump_image_command(struct command_context_s *cmd_ctx, char *cmd, char
        
        if (fileio_open(&fileio, args[0], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK)
        {
-               command_print(cmd_ctx, "dump_image error: %s", fileio.error_str);
                return ERROR_OK;
        }
        
@@ -2064,7 +2065,6 @@ int handle_verify_image_command(struct command_context_s *cmd_ctx, char *cmd, ch
 
        if (image_open(&image, args[0], (argc == 3) ? args[2] : NULL) != ERROR_OK)
        {
-               command_print(cmd_ctx, "verify_image error: %s", image.error_str);
                return ERROR_OK;
        }