Skip to content

Commit

Permalink
Use R_LOG messages in the r2k plugin ##io
Browse files Browse the repository at this point in the history
  • Loading branch information
radare authored and trufae committed Dec 2, 2024
1 parent f33843e commit 4fc4780
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 78 deletions.
18 changes: 8 additions & 10 deletions libr/io/p/io_r2k.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <r_io.h>
#include <r_lib.h>
#include <r_types.h>
#include <r_util.h>
#include <sys/types.h>

#if R2__WINDOWS__
Expand All @@ -28,11 +27,11 @@ int r2k__write(RIO *io, RIODesc *fd, const ut8 *buf, int count) {
case 2:
return WriteMemory (io, fd, IOCTL_WRITE_PHYSICAL_ADDR, r2k_struct.pid, io->off, buf, count);
default:
io->cb_printf ("ERROR: Undefined beid in r2k__write.\n");
R_LOG_ERROR ("Undefined beid in r2k__write");
return -1;
}
#else
io->cb_printf ("TODO: r2k not implemented for this plataform.\n");
R_LOG_TODO ("r2k not implemented for this plataform");
return -1;
#endif
}
Expand All @@ -49,12 +48,12 @@ static int r2k__read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
case 2:
return ReadMemory (io, fd, IOCTL_READ_PHYSICAL_ADDR, r2k_struct.pid, io->off, buf, count);
default:
io->cb_printf ("ERROR: Undefined beid in r2k__read.\n");
R_LOG_ERROR ("Undefined beid in r2k__read");
memset (buf, 0xff, count);
return count;
}
#else
io->cb_printf ("TODO: r2k not implemented for this plataform.\n");
R_LOG_TODO ("r2k not implemented for this plataform");
memset (buf, 0xff, count);
return count;
#endif
Expand Down Expand Up @@ -86,7 +85,7 @@ static bool r2k__plugin_open(RIO *io, const char *pathname, bool many) {
}

static char *r2k__system(RIO *io, RIODesc *fd, const char *cmd) {
if (!strcmp (cmd, "")) {
if (R_STR_ISEMPTY (cmd)) {
return NULL;
}
if (r_str_startswith (cmd, "mod")) {
Expand All @@ -96,9 +95,8 @@ static char *r2k__system(RIO *io, RIODesc *fd, const char *cmd) {
} else {
#if defined (__linux__) && !defined (__GNU__)
(void)run_ioctl_command (io, fd, cmd);
return NULL;
#else
eprintf ("Try: ':mod'\n '.:mod'\n");
R_LOG_WARN ("Try with: ':mod' or '.:mod'");
#endif
}
return NULL;
Expand All @@ -119,7 +117,7 @@ static RIODesc *r2k__open(RIO *io, const char *pathname, int rw, int mode) {
#elif defined (__linux__) && !defined (__GNU__)
int fd = open ("/dev/r2k", O_RDONLY);
if (fd == -1) {
io->cb_printf ("r2k__open: Error in opening /dev/r2k.");
R_LOG_ERROR ("r2k__open: Error in opening /dev/r2k");
return NULL;
}

Expand All @@ -128,7 +126,7 @@ static RIODesc *r2k__open(RIO *io, const char *pathname, int rw, int mode) {
r2k_struct.wp = 1;
return r_io_desc_new (io, &r_io_plugin_r2k, pathname, rw, mode, (void *)(size_t)fd);
#else
io->cb_printf ("Not supported on this platform\n");
R_LOG_ERROR ("Not supported on this platform");
#endif
}
return NULL;
Expand Down
Loading

0 comments on commit 4fc4780

Please sign in to comment.