Make system.h private by including it from config.h autoheader.
[openocd.git] / src / helper / command.c
index 23d0004115535a147e0af90f978ff4f0b7580487..cb576bb39d461961c49d05a7cd8bcc154279d94c 100644 (file)
 #include "config.h"
 #endif
 
-#include "replacements.h"
+// @todo the inclusion of target.h here is a layering violation
 #include "target.h"
 #include "command.h"
 #include "configuration.h"
-
 #include "log.h"
 #include "time_support.h"
 #include "jim-eventloop.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
 
 int fast_and_dangerous = 0;
 Jim_Interp *interp = NULL;
@@ -290,9 +282,9 @@ int unregister_command(command_context_t *context, char *name)
 
        /* find command */
        c = context->commands;
-       
+
        while(NULL != c)
-       {               
+       {
                if (strcmp(name, c->name) == 0)
                {
                        /* unlink command */
@@ -305,7 +297,7 @@ int unregister_command(command_context_t *context, char *name)
                                /* first element in command list */
                                context->commands = c->next;
                        }
-                       
+
                        /* unregister children */
                        while(NULL != c->children)
                        {
@@ -316,7 +308,7 @@ int unregister_command(command_context_t *context, char *name)
                                free(c2);
                                c2 = NULL;
                        }
-                       
+
                        /* delete command */
                        free(c->name);
                        c->name = NULL;
@@ -324,7 +316,7 @@ int unregister_command(command_context_t *context, char *name)
                        c = NULL;
                        return ERROR_OK;
                }
-               
+
                /* remember the last command for unlinking */
                p = c;
                c = c->next;
@@ -479,7 +471,8 @@ int command_run_line(command_context_t *context, char *line)
                int reslen;
 
                result = Jim_GetString(Jim_GetResult(interp), &reslen);
-               if (reslen) {
+               if (reslen>0)
+               {
                        int i;
                        char buff[256+1];
                        for (i = 0; i < reslen; i += 256)
@@ -494,6 +487,7 @@ int command_run_line(command_context_t *context, char *line)
                        }
                        LOG_USER_N("%s", "\n");
                }
+               retval=ERROR_OK;
        }
        return retval;
 }
@@ -673,6 +667,7 @@ command_context_t* command_init()
 {
        command_context_t* context = malloc(sizeof(command_context_t));
        extern const char startup_tcl[];
+       const char *HostOs;
 
        context->mode = COMMAND_EXEC;
        context->commands = NULL;
@@ -688,6 +683,28 @@ command_context_t* command_init()
        Jim_RegisterCoreCommands(interp);
 #endif
 
+#if defined( _MSC_VER )
+       /* WinXX - is generic, the forward
+        * looking problem is this:
+        *
+        *   "win32" or "win64"
+        *
+        * "winxx" is generic.
+        */
+       HostOs = "winxx";
+#elif defined( __LINUX__)
+       HostOs = "linux";
+#elif defined( __DARWIN__ )
+       HostOs = "darwin";
+#elif defined( __CYGWIN__ )
+       HostOs = "cygwin";
+#elif defined( __MINGW32__ )
+       HostOs = "mingw32";
+#else
+       HostOs = "other";
+#endif
+       Jim_SetGlobalVariableStr( interp, "ocd_HOSTOS", Jim_NewStringObj( interp, HostOs , strlen(HostOs)) );
+
        Jim_CreateCommand(interp, "ocd_find", jim_find, NULL, NULL);
        Jim_CreateCommand(interp, "echo", jim_echo, NULL, NULL);
        Jim_CreateCommand(interp, "capture", jim_capture, NULL, NULL);
@@ -761,7 +778,7 @@ int handle_sleep_command(struct command_context_s *cmd_ctx, char *cmd, char **ar
        } else
        {
                long long then=timeval_ms();
-               while ((timeval_ms()-then)<duration)
+               while ((timeval_ms()-then)<(long long)duration)
                {
                        target_call_timer_callbacks_now();
                        usleep(1000);

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)