static int __system(RIO *io, RIODesc *fd, const char *command) { int code, rlen; char *out; int ret = 0; char *url = r_str_newf ("%s/%s", rURL(fd), command); out = r_socket_http_get (url, &code, &rlen); if (out && rlen>0) { io->cb_printf ("%s", out); } free (out); free (url); return ret; }
static int __write(RIO *io, RIODesc *fd, const ut8 *buf, int count) { int code, rlen; char *out, *url, *hexbuf; if (fd == NULL || fd->data == NULL) return -1; hexbuf = malloc (count * 3); hexbuf[0] = 0; r_hex_bin2str (buf, count, hexbuf); url = r_str_newf ("%s/wx%%20%s@%"PFMT64d, rURL(fd), hexbuf, io->off); out = r_socket_http_get (url, &code, &rlen); free (out); free (url); free (hexbuf); return count; }
static int __read(RIO *io, RIODesc *fd, ut8 *buf, int count) { int code, rlen; char *out, *url; int ret = 0; if (fd == NULL || fd->data == NULL) return -1; url = r_str_newf ("%s/p8%%20%d@%"PFMT64d, rURL(fd), count, io->off); out = r_socket_http_get (url, &code, &rlen); if (out && rlen>0) { ut8 *tmp = malloc (rlen+1); ret = r_hex_str2bin (out, tmp); memcpy (buf, tmp, R_MIN (count, rlen)); free (tmp); if (ret<0) ret = -ret; } free (out); free (url); return ret; }