]> git.sur5r.net Git - openocd/commitdiff
- added "version" command (patch from John Hartman, thanks)
authordrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Sun, 25 Jun 2006 11:14:44 +0000 (11:14 +0000)
committerdrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Sun, 25 Jun 2006 11:14:44 +0000 (11:14 +0000)
- fixed bug in telnet history handling (patch from John Hartman, thanks)
- OpenOCD version has been changed from SVN revision number to date/time

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

src/jtag/jtag.h
src/openocd.c
src/server/telnet_server.c

index a2cc01b0fbb3a46a20c32e742cf201d5ecf8a79d..124150ce7f4a3bb16024702e62d2aacc767e29fe 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "command.h"
 
-#if 
+#if 0
 #define _DEBUG_JTAG_IO_
 #endif
 
index b0d0a844e92937654bbf54622fab2a319b0adda5..229fd916e081478fe7165161a6786159cf33cee4 100644 (file)
@@ -18,6 +18,8 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
+#define OPENOCD_VERSION "Open On-Chip Debugger (2006-06-25 13:15 CEST)"
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 #include <unistd.h>
 #include <errno.h>
 
+/* Give TELNET a way to find out what version this is */
+int handle_version_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+       command_print(cmd_ctx, OPENOCD_VERSION);
+
+       return ERROR_OK;
+}
+
 int main(int argc, char *argv[])
 {
        /* initialize commandline interface */
        command_context_t *cmd_ctx, *cfg_cmd_ctx;
        cmd_ctx = command_init();
+
+       register_command(cmd_ctx, NULL, "version", handle_version_command,
+                                        COMMAND_EXEC, "show OpenOCD version");
        
        /* register subsystem commands */
        server_register_commands(cmd_ctx);
@@ -70,7 +83,7 @@ int main(int argc, char *argv[])
                return EXIT_FAILURE;
        DEBUG("log init complete");
        
-       INFO("Open On-Chip Debugger (Revision 65)");
+       INFO( OPENOCD_VERSION );
 
        cfg_cmd_ctx = copy_command_context(cmd_ctx);
        cfg_cmd_ctx->mode = COMMAND_CONFIG;
index 3ff3456a3d47d204140c647e4472caf39b089638..a2704e9cc00d05bff96457ca4ca07372d3911275 100644 (file)
@@ -254,28 +254,31 @@ int telnet_input(connection_t *connection)
                                                                        return ERROR_SERVER_REMOTE_CLOSED;
                                                                }
                                                        }
-                                                       
-                                                       /* if the history slot is already taken, free it */
-                                                       if (t_con->history[t_con->next_history])
+
+                                                       /* Save only non-blank lines in the history */
+                                                       if (t_con->line_size > 0)
                                                        {
-                                                               free(t_con->history[t_con->next_history]);
-                                                       }
-                                                       
-                                                       /* add line to history */
-                                                       t_con->history[t_con->next_history++] = strdup(t_con->line);
+                                                               /* if the history slot is already taken, free it */
+                                                               if (t_con->history[t_con->next_history])
+                                                               {
+                                                                       free(t_con->history[t_con->next_history]);
+                                                               }
+               
+                                                               /* add line to history */
+                                                               t_con->history[t_con->next_history] = strdup(t_con->line);
+
+                                                               /* wrap history at TELNET_LINE_HISTORY_SIZE */
+                                                               t_con->next_history = (t_con->next_history + 1) % TELNET_LINE_HISTORY_SIZE;
                                                        
-                                                       /* current history line starts at the new entry */
-                                                       t_con->current_history = t_con->next_history;
+                                                               /* current history line starts at the new entry */
+                                                               t_con->current_history = t_con->next_history;
                                                        
-                                                       if (t_con->history[t_con->current_history])
-                                                       {
-                                                               free(t_con->history[t_con->current_history]);
+                                                               if (t_con->history[t_con->current_history])
+                                                               {
+                                                                       free(t_con->history[t_con->current_history]);
+                                                               }
+                                                               t_con->history[t_con->current_history] = strdup("");
                                                        }
-                                                       t_con->history[t_con->current_history] = strdup("");
-                                                       
-                                                       /* wrap history at TELNET_LINE_HISTORY_SIZE */
-                                                       if (t_con->next_history > TELNET_LINE_HISTORY_SIZE - 1)
-                                                               t_con->next_history = 0;
                                                        
                                                        if (!t_con->suppress_prompt)
                                                        {
@@ -394,7 +397,7 @@ int telnet_input(connection_t *connection)
                                        }
                                        else if (*buf_p == 'A') /* cursor up */
                                        {
-                                               int last_history = (t_con->current_history - 1 >= 0) ? t_con->current_history - 1 : 127;
+                                               int last_history = (t_con->current_history > 0) ? t_con->current_history - 1 : TELNET_LINE_HISTORY_SIZE-1;
                                                if (t_con->history[last_history])
                                                {
                                                        telnet_clear_line(connection, t_con);
@@ -408,7 +411,7 @@ int telnet_input(connection_t *connection)
                                        }
                                        else if (*buf_p == 'B') /* cursor down */
                                        {
-                                               int next_history = (t_con->current_history + 1 < 128) ? t_con->current_history + 1 : 0;
+                                               int next_history = (t_con->current_history + 1) % TELNET_LINE_HISTORY_SIZE;
                                                if (t_con->history[next_history])
                                                {
                                                        telnet_clear_line(connection, t_con);