summaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/gdb_server.c13
-rw-r--r--src/server/telnet_server.c35
2 files changed, 27 insertions, 21 deletions
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index 335a4cd2..6c9936ee 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -511,16 +511,14 @@ int gdb_output_con(connection_t *connection, char* line)
bin_size = strlen(line);
- hex_buffer = malloc(bin_size*2 + 4);
+ hex_buffer = malloc(bin_size*2 + 2);
hex_buffer[0] = 'O';
for (i=0; i<bin_size; i++)
snprintf(hex_buffer + 1 + i*2, 3, "%2.2x", line[i]);
- hex_buffer[bin_size*2+1] = '0';
- hex_buffer[bin_size*2+2] = 'a';
- hex_buffer[bin_size*2+3] = 0x0;
+ hex_buffer[bin_size*2+1] = 0;
- gdb_put_packet(connection, hex_buffer, bin_size*2 + 3);
+ gdb_put_packet(connection, hex_buffer, bin_size*2 + 1);
free(hex_buffer);
return ERROR_OK;
@@ -529,7 +527,7 @@ int gdb_output_con(connection_t *connection, char* line)
int gdb_output(struct command_context_s *context, char* line)
{
/* this will be dumped to the log and also sent as an O packet if possible */
- USER(line);
+ USER_SAMELINE(line);
return ERROR_OK;
}
@@ -605,7 +603,8 @@ int gdb_target_callback_event_handler(struct target_s *target, enum target_event
return ERROR_OK;
}
-
+
+
int gdb_new_connection(connection_t *connection)
{
gdb_connection_t *gdb_connection = malloc(sizeof(gdb_connection_t));
diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c
index 5cfb0ab4..ea5ec575 100644
--- a/src/server/telnet_server.c
+++ b/src/server/telnet_server.c
@@ -77,8 +77,26 @@ int telnet_prompt(connection_t *connection)
int telnet_outputline(connection_t *connection, char* line)
{
- telnet_write(connection, line, strlen(line));
- return telnet_write(connection, "\r\n\0", 3);
+
+ /* process lines in buffer */
+ char *p=line;
+ do {
+ char *next = strchr(p, '\n');
+
+ if (next)
+ *next++ = 0;
+
+
+ telnet_write(connection, p, strlen(p));
+ if (next)
+ {
+ telnet_write(connection, "\r\n\0", 3);
+ }
+
+ p = next;
+ } while (p);
+
+ return ERROR_OK;
}
int telnet_output(struct command_context_s *cmd_ctx, char* line)
@@ -93,20 +111,9 @@ void telnet_log_callback(void *priv, const char *file, int line,
{
connection_t *connection = priv;
char *t = alloc_printf(format, args);
- char *t2;
if (t == NULL)
return;
- t2=t;
- char *endline;
- do
- {
- if ((endline=strchr(t2, '\n'))!=NULL)
- {
- *endline=0;
- }
- telnet_outputline(connection, t2);
- t2=endline+1;
- } while (endline);
+ telnet_outputline(connection, t);
free(t);
}