server/telnet: support 'CTRL+C'
[fw/openocd] / src / server / telnet_server.c
index 253591ec948823e71424883b94fe8ebbca926a56..f7b3f6449bbfda33c3daa894a1ad963f7ccdb052 100644 (file)
@@ -718,6 +718,13 @@ static int telnet_input(struct connection *connection)
                                                                t_con->line_cursor--;
                                                        }
                                                        t_con->state = TELNET_STATE_DATA;
+                                               } else if (*buf_p == CTRL('C')) {       /* interrupt */
+                                                       /* print '^C' at line end, and display a new command prompt */
+                                                       telnet_move_cursor(connection, t_con->line_size);
+                                                       telnet_write(connection, "^C\n\r", 4);
+                                                       t_con->line_cursor = 0;
+                                                       t_con->line_size = 0;
+                                                       telnet_prompt(connection);
                                                } else if (*buf_p == CTRL('F')) {       /* cursor right */
                                                        if (t_con->line_cursor < t_con->line_size)
                                                                telnet_write(connection, t_con->line + t_con->line_cursor++, 1);