Fix output of 'i'. fix rap:// connect
This commit is contained in:
parent
eaefe56897
commit
16581dde3f
|
@ -155,7 +155,8 @@ static int cmd_info(void *data, const char *input) {
|
|||
if (mode == R_CORE_BIN_JSON)
|
||||
r_cons_printf ("{\"bin\":");
|
||||
r_core_bin_info (core, R_CORE_BIN_ACC_INFO, mode, va, NULL, offset);
|
||||
r_cons_printf (",\"core\":");
|
||||
if (mode == R_CORE_BIN_JSON)
|
||||
r_cons_printf (",\"core\":");
|
||||
r_core_file_info (core, mode);
|
||||
if (mode == R_CORE_BIN_JSON)
|
||||
r_cons_printf ("}\n");
|
||||
|
|
|
@ -63,7 +63,7 @@ static void r_core_visual_mark_seek(RCore *core, ut8 ch) {
|
|||
static void r_core_visual_mark(RCore *core, ut8 ch) {
|
||||
if (!marks_init) {
|
||||
int i;
|
||||
for (i=0;i<UT8_MAX;i++)
|
||||
for (i=0; i<UT8_MAX; i++)
|
||||
marks[i] = 0;
|
||||
marks_init = 1;
|
||||
}
|
||||
|
|
|
@ -195,8 +195,10 @@ static RIODesc *rap__open(struct r_io_t *io, const char *pathname, int rw, int m
|
|||
r_socket_flush (rap_fd);
|
||||
// read
|
||||
eprintf ("waiting... ");
|
||||
buf[0] = 0;
|
||||
r_socket_read_block (rap_fd, (ut8*)buf, 5);
|
||||
if (buf[0] != (char)(RMT_OPEN|RMT_REPLY)) {
|
||||
eprintf ("rap: Expecting OPEN|REPLY packet. got %02x\n", buf[0]);
|
||||
r_socket_free (rap_fd);
|
||||
free (rior);
|
||||
return NULL;
|
||||
|
@ -204,6 +206,7 @@ static RIODesc *rap__open(struct r_io_t *io, const char *pathname, int rw, int m
|
|||
r_mem_copyendian ((ut8 *)&i, (ut8*)buf+1, 4, ENDIAN);
|
||||
if (i>0) eprintf ("ok\n");
|
||||
|
||||
#if 0
|
||||
/* Read meta info */
|
||||
r_socket_read (rap_fd, (ut8 *)&buf, 4);
|
||||
r_mem_copyendian ((ut8 *)&i, (ut8*)buf, 4, ENDIAN);
|
||||
|
@ -217,11 +220,12 @@ static RIODesc *rap__open(struct r_io_t *io, const char *pathname, int rw, int m
|
|||
r_mem_copyendian ((ut8 *)&i, (ut8*)buf, 4, ENDIAN);
|
||||
i -= n;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
r_socket_free (rap_fd);
|
||||
return NULL;
|
||||
}
|
||||
r_socket_free (rap_fd);
|
||||
//r_socket_free (rap_fd);
|
||||
return r_io_desc_new (&r_io_plugin_rap, rior->fd->fd,
|
||||
pathname, rw, mode, rior);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* radare - LGPL - Copyright 2009-2012 pancake<nopcode.org> */
|
||||
/* radare - LGPL - Copyright 2009-2012 - pancake */
|
||||
|
||||
#include <r_lang.h>
|
||||
#include <r_util.h>
|
||||
|
|
|
@ -160,8 +160,13 @@ R_API int r_socket_connect (RSocket *s, const char *host, const char *port, int
|
|||
r_socket_block_time (s, 1, timeout);
|
||||
//fcntl (s->fd, F_SETFL, O_NONBLOCK, 1);
|
||||
ret = connect (s->fd, rp->ai_addr, rp->ai_addrlen);
|
||||
if (timeout<1 && ret != -1)
|
||||
break;
|
||||
if (timeout<1) {
|
||||
if (ret == -1) {
|
||||
close (s->fd);
|
||||
return R_FALSE;
|
||||
}
|
||||
return R_TRUE;
|
||||
}
|
||||
if (timeout>0) {
|
||||
struct timeval tv;
|
||||
fd_set fdset;
|
||||
|
@ -172,21 +177,24 @@ R_API int r_socket_connect (RSocket *s, const char *host, const char *port, int
|
|||
if (select (s->fd + 1, NULL, &fdset, NULL, &tv) == 1) {
|
||||
int so_error;
|
||||
socklen_t len = sizeof so_error;
|
||||
ret = getsockopt (s->fd, SOL_SOCKET, SO_ERROR, &so_error, &len);
|
||||
ret = getsockopt (s->fd, SOL_SOCKET,
|
||||
SO_ERROR, &so_error, &len);
|
||||
// fcntl (s->fd, F_SETFL, O_NONBLOCK, 0);
|
||||
r_socket_block_time (s, 0, 0);
|
||||
// r_socket_block_time (s, 0, 0);
|
||||
freeaddrinfo (res);
|
||||
return R_TRUE;
|
||||
} else {
|
||||
freeaddrinfo (res);
|
||||
close (s->fd);
|
||||
return R_FALSE;
|
||||
}
|
||||
}
|
||||
//rp = NULL;
|
||||
close (s->fd);
|
||||
s->fd = -1;
|
||||
}
|
||||
freeaddrinfo (res);
|
||||
if (rp == NULL) {
|
||||
//eprintf ("Could not connect\n");
|
||||
eprintf ("Could not resolve address\n");
|
||||
return R_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -336,11 +344,9 @@ R_API int r_socket_block_time (RSocket *s, int block, int sec) {
|
|||
#if __UNIX__
|
||||
{
|
||||
int flags = fcntl (s->fd, F_GETFL, 0);
|
||||
if (block) {
|
||||
fcntl (s->fd, F_SETFL, flags & ~O_NONBLOCK);
|
||||
} else {
|
||||
fcntl (s->fd, F_SETFL, flags | O_NONBLOCK);
|
||||
}
|
||||
fcntl (s->fd, F_SETFL, block?
|
||||
(flags & ~O_NONBLOCK):
|
||||
(flags | O_NONBLOCK));
|
||||
}
|
||||
#elif __WINDOWS__
|
||||
ioctlsocket (s->fd, FIONBIO, (u_long FAR*)&block);
|
||||
|
|
Loading…
Reference in New Issue