This commit is contained in:
Anton Kochkov 2014-04-23 02:12:03 +04:00
parent d05bbb4be2
commit 698fe42cfd

View File

@ -360,7 +360,7 @@ R_API void r_core_rtr_list(RCore *core) {
rtr_host[i].port, rtr_host[i].file); rtr_host[i].port, rtr_host[i].file);
} }
} }
R_API void r_core_rtr_add(RCore *core, const char *_input) { R_API void r_core_rtr_add(RCore *core, const char *_input) {
char *port, input[1024], *host = NULL, *file = NULL, *ptr = NULL, buf[1024]; char *port, input[1024], *host = NULL, *file = NULL, *ptr = NULL, buf[1024];
int proto, i, timeout, ret; int proto, i, timeout, ret;
@ -664,7 +664,7 @@ R_API char *r_core_rtr_cmds_query (RCore *core, const char *host, const char *po
} }
R_API int r_core_rtr_cmds (RCore *core, const char *port) { R_API int r_core_rtr_cmds (RCore *core, const char *port) {
unsigned char buf[4096]; unsigned char buf[4097];
RSocket *ch, *s; RSocket *ch, *s;
int i, ret; int i, ret;
char *str; char *str;
@ -680,14 +680,14 @@ R_API int r_core_rtr_cmds (RCore *core, const char *port) {
r_socket_free (s); r_socket_free (s);
return R_FALSE; return R_FALSE;
} }
eprintf ("Listening for commands on port %s\n", port); eprintf ("Listening for commands on port %s\n", port);
listenport = port; listenport = port;
for (;;) { for (;;) {
r_cons_break (http_break, core); r_cons_break (http_break, core);
ch = r_socket_accept (s); ch = r_socket_accept (s);
buf[0] = 0; buf[0] = 0;
ret = r_socket_read (ch, buf, sizeof (buf)); ret = r_socket_read (ch, buf, sizeof (buf) - 1);
if (ret>0) { if (ret>0) {
buf[ret] = 0; buf[ret] = 0;
for (i=0; buf[i]; i++) for (i=0; buf[i]; i++)
@ -699,7 +699,7 @@ R_API int r_core_rtr_cmds (RCore *core, const char *port) {
str = r_core_cmd_str (core, (const char *)buf); str = r_core_cmd_str (core, (const char *)buf);
if (str &&*str) { if (str &&*str) {
r_socket_write (ch, str, strlen (str)); r_socket_write (ch, str, strlen (str));
} else } else
r_socket_write (ch, "\n", 1); r_socket_write (ch, "\n", 1);
free (str); free (str);
} }