- remove error message on shutdown
[openocd.git] / src / helper / command.c
index 7a7cbcbb61932fecb8c3741e87881f50480dacfb..3cf531b7e6f6240b3b6b6a020b6f39c64c3d2cec 100644 (file)
 #include <stdio.h>
 #include <unistd.h>
 
+int fast_and_dangerous = 0;
+
 void command_print_help_line(command_context_t* context, struct command_s *command, int indent);
 
 int handle_sleep_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
 int handle_time_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+int handle_fast_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
 
 int build_unique_lengths(command_context_t *context, command_t *commands)
 {
@@ -140,6 +143,45 @@ command_t* register_command(command_context_t *context, command_t *parent, char
        return c;
 }
 
+int unregister_all_commands(command_context_t *context)
+{
+       command_t *c, *c2;
+       
+       unique_length_dirty = 1;
+       
+       if (context == NULL)
+               return ERROR_OK;
+       
+       
+       while(NULL != context->commands)
+       {
+               c = context->commands;
+               
+               while(NULL != c->children)
+               {
+                       c2 = c->children;
+                       c->children = c->children->next;
+                       free(c2->name);
+                       c2->name = NULL;
+                       free(c2->help);
+                       c2->help = NULL;
+                       free(c2);
+                       c2 = NULL;
+               }
+               
+               context->commands = context->commands->next;
+               
+               free(c->name);
+               c->name = NULL;
+               free(c->help);
+               c->help = NULL;
+               free(c);
+               c = NULL;               
+       }
+       
+       return ERROR_OK;
+}
+
 int unregister_command(command_context_t *context, char *name)
 {
        command_t *c, *p = NULL, *c2;
@@ -332,7 +374,12 @@ int find_and_run_command(command_context_t *context, command_t *commands, char *
                                        {
                                                command_print(context, "Syntax error:");
                                                command_print_help_line(context, c, 0);
-                                       } else if (retval != ERROR_OK)
+                                       }
+                                       else if (retval == ERROR_COMMAND_CLOSE_CONNECTION)
+                                       {
+                                               /* just fall through for a shutdown request */
+                                       }
+                                       else if (retval != ERROR_OK)
                                        {
                                                /* we do not print out an error message because the command *should*
                                                 * have printed out an error
@@ -516,7 +563,6 @@ int command_print_help(command_context_t* context, char* name, char** args, int
     return command_print_help_match(context, context->commands, name, args, argc);
 }
 
-
 void command_set_output_handler(command_context_t* context, int (*output_handler)(struct command_context_s *context, char* line), void *priv)
 {
        context->output_handler = output_handler;
@@ -559,6 +605,9 @@ command_context_t* command_init()
        register_command(context, NULL, "time", handle_time_command,
                                         COMMAND_ANY, "time <cmd + args> - execute <cmd + args> and print time it took");
        
+       register_command(context, NULL, "fast", handle_fast_command,
+                                        COMMAND_ANY, "fast <enable/disable> - place at beginning of config files. Sets defaults to fast and dangerous.");
+       
        return context;
 }
 
@@ -578,6 +627,17 @@ int handle_sleep_command(struct command_context_s *cmd_ctx, char *cmd, char **ar
        return ERROR_OK;
 }
 
+int handle_fast_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+       if (argc!=1)
+               return ERROR_COMMAND_SYNTAX_ERROR;
+       
+       fast_and_dangerous = strcmp("enable", args[0])==0;
+       
+       return ERROR_OK;
+}
+
+
 int handle_time_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
        duration_t duration;

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)