Deprecate r_cons_eprintf and use R_LOG instead ##api

This commit is contained in:
pancake 2022-10-29 01:17:40 +02:00 committed by GitHub
parent 9cef5d68ee
commit e317a0666e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 154 deletions

View File

@ -115,9 +115,6 @@ static void cons_stack_load(RConsStack *data, bool free_current) {
static void cons_context_init(RConsContext *context, R_NULLABLE RConsContext *parent) { static void cons_context_init(RConsContext *context, R_NULLABLE RConsContext *parent) {
context->breaked = false; context->breaked = false;
context->cmd_depth = R_CONS_CMD_DEPTH + 1; context->cmd_depth = R_CONS_CMD_DEPTH + 1;
context->error = r_strbuf_new ("");
context->errmode = R_CONS_ERRMODE_ECHO;
context->buffer = NULL;
context->buffer_sz = 0; context->buffer_sz = 0;
context->lastEnabled = true; context->lastEnabled = true;
context->buffer_len = 0; context->buffer_len = 0;
@ -143,7 +140,6 @@ static void cons_context_init(RConsContext *context, R_NULLABLE RConsContext *pa
} }
static void cons_context_deinit(RConsContext *context) { static void cons_context_deinit(RConsContext *context) {
R_FREE (context->error);
r_stack_free (context->cons_stack); r_stack_free (context->cons_stack);
context->cons_stack = NULL; context->cons_stack = NULL;
r_stack_free (context->break_stack); r_stack_free (context->break_stack);
@ -986,14 +982,6 @@ R_API void r_cons_echo(const char *msg) {
} }
} }
R_API void r_cons_eflush(void) {
char *s = r_cons_errstr ();
if (s) {
eprintf ("%s", s);
free (s);
}
}
// TODO: must be called twice to remove all unnecessary reset codes. maybe adding the last two words would be faster // TODO: must be called twice to remove all unnecessary reset codes. maybe adding the last two words would be faster
// TODO remove all the strdup // TODO remove all the strdup
// TODO remove the slow memmove // TODO remove the slow memmove
@ -1060,9 +1048,6 @@ R_API void r_cons_flush(void) {
if (C->noflush) { if (C->noflush) {
return; return;
} }
if (C->errmode == R_CONS_ERRMODE_FLUSH) {
r_cons_eflush ();
}
if (I->null) { if (I->null) {
r_cons_reset (); r_cons_reset ();
return; return;
@ -1357,56 +1342,6 @@ R_API int r_cons_printf(const char *format, ...) {
return 0; return 0;
} }
R_API void r_cons_errmode(int mode) {
C->errmode = mode;
}
R_API void r_cons_errmodes(const char *mode) {
int m = -1;
if (!strcmp (mode, "echo")) {
m = R_CONS_ERRMODE_ECHO;
} else if (!strcmp (mode, "null")) {
m = R_CONS_ERRMODE_NULL;
} else if (!strcmp (mode, "buffer")) {
m = R_CONS_ERRMODE_BUFFER;
} else if (!strcmp (mode, "quiet")) {
m = R_CONS_ERRMODE_QUIET;
} else if (!strcmp (mode, "flush")) {
m = R_CONS_ERRMODE_FLUSH;
}
C->errmode = m;
}
R_API char *r_cons_errstr(void) {
char *s = r_strbuf_drain (C->error);
C->error = NULL;
return s;
}
// XXX overriden by RLOG apis imho
R_API int r_cons_eprintf(const char *format, ...) {
va_list ap;
r_return_val_if_fail (!R_STR_ISEMPTY (format), -1);
va_start (ap, format);
switch (C->errmode) {
case R_CONS_ERRMODE_NULL:
break;
case R_CONS_ERRMODE_ECHO:
vfprintf (stderr, format, ap);
break;
case R_CONS_ERRMODE_QUIET:
case R_CONS_ERRMODE_BUFFER:
case R_CONS_ERRMODE_FLUSH:
if (!C->error) {
C->error = r_strbuf_new ("");
}
r_strbuf_vappendf (C->error, format, ap);
break;
}
va_end (ap);
return C->error? r_strbuf_length (C->error): 0;
}
R_API int r_cons_get_column(void) { R_API int r_cons_get_column(void) {
char *line = strrchr (C->buffer, '\n'); char *line = strrchr (C->buffer, '\n');
if (!line) { if (!line) {

View File

@ -1652,17 +1652,6 @@ static bool cb_cmdrepeat(void *user, void *data) {
return true; return true;
} }
// R2_580 rename to log.sink=file:path log.sink=echo etc..
static bool cb_screrrmode(void *user, void *data) {
RConfigNode *node = (RConfigNode *) data;
if (*node->value == '?') {
r_cons_printf ("Valid values: null, echo, buffer, quiet, flush\n");
return false;
}
r_cons_errmodes (node->value);
return true;
}
static bool cb_scrnull(void *user, void *data) { static bool cb_scrnull(void *user, void *data) {
RCore *core = (RCore *) user; RCore *core = (RCore *) user;
RConfigNode *node = (RConfigNode *) data; RConfigNode *node = (RConfigNode *) data;
@ -3844,39 +3833,10 @@ R_API int r_core_config_init(RCore *core) {
SETI ("cfg.cpuaffinity", 0, "run on cpuid"); SETI ("cfg.cpuaffinity", 0, "run on cpuid");
/* log */ /* log */
// R2_LOGLEVEL / log.level SETICB ("log.level", R_LOGLVL_DEFAULT, cb_log_config_level, "Target log level/severity (0:FATAL 1:ERROR 2:INFO 3:WARN 4:TODO 5:DEBUG)");
#if 0
p = r_sys_getenv ("R2_LOGLEVEL");
SETICB ("log.level", p? atoi(p): R_DEFAULT_LOGLVL, cb_log_config_level, "target log level/severity"\
" (0:SILLY, 1:DEBUG, 2:VERBOSE, 3:INFO, 4:WARN, 5:ERROR, 6:FATAL)"
);
free (p);
// R2_LOGTRAP_LEVEL / log.traplevel
p = r_sys_getenv ("R2_LOGTRAPLEVEL");
SETICB ("log.traplevel", p ? atoi(p) : R_LOGLVL_FATAL, cb_log_config_traplevel, "log level for trapping R2 when hit"\
" (0:SILLY, 1:VERBOSE, 2:DEBUG, 3:INFO, 4:WARN, 5:ERROR, 6:FATAL)"
);
free (p);
// R2_LOGFILE / log.file
p = r_sys_getenv ("R2_LOGFILE");
SETCB ("log.file", r_str_get (p), cb_log_config_file, "logging output filename / path");
free (p);
// R2_LOGSRCINFO / log.srcinfo
p = r_sys_getenv ("R2_LOGSRCINFO");
SETCB ("log.srcinfo", r_str_get_fail (p, "false"), cb_log_config_srcinfo, "should the log output contain src info (filename:lineno)");
free (p);
// R2_LOGCOLORS / log.colors
p = r_sys_getenv ("R2_LOGCOLORS");
SETCB ("log.colors", r_str_get_fail (p, "false"), cb_log_config_colors, "should the log output use colors (TODO)");
free (p);
SETCB ("log.events", "false", &cb_log_events, "remote HTTP server to sync events with");
#endif
SETICB ("log.level", R_LOGLVL_DEFAULT, cb_log_config_level, "Target log level/severity (0:FATAL 1:ERROR 2:INFO 3:WARN 4:DEBUG)");
SETCB ("log.ts", "false", cb_log_config_ts, "Show timestamp in log messages"); SETCB ("log.ts", "false", cb_log_config_ts, "Show timestamp in log messages");
SETICB ("log.traplevel", 0, cb_log_config_traplevel, "Log level for trapping R2 when hit"); SETICB ("log.traplevel", 0, cb_log_config_traplevel, "Log level for trapping R2 when hit");
SETCB ("log.file", "", cb_log_config_file, "Save log messages to given filename"); // 580 -rename to file.log ?)
SETCB ("log.filter", "", cb_log_config_filter, "Filter only messages matching given origin"); SETCB ("log.filter", "", cb_log_config_filter, "Filter only messages matching given origin");
SETCB ("log.origin", "false", cb_log_origin, "Show [origin] in log messages"); SETCB ("log.origin", "false", cb_log_origin, "Show [origin] in log messages");
SETCB ("log.source", "false", cb_log_source, "Show source [file:line] in the log message"); SETCB ("log.source", "false", cb_log_source, "Show source [file:line] in the log message");
@ -4263,7 +4223,6 @@ R_API int r_core_config_init(RCore *core) {
SETBPREF ("scr.prompt.sect", "false", "show section name in the prompt"); SETBPREF ("scr.prompt.sect", "false", "show section name in the prompt");
SETBPREF ("scr.tts", "false", "use tts if available by a command (see ic)"); SETBPREF ("scr.tts", "false", "use tts if available by a command (see ic)");
SETCB ("scr.prompt", "true", &cb_scrprompt, "show user prompt (used by r2 -q)"); SETCB ("scr.prompt", "true", &cb_scrprompt, "show user prompt (used by r2 -q)");
SETCB ("scr.tee", "", &cb_teefile, "pipe output to file of this name");
SETICB ("scr.color", (core->print->flags&R_PRINT_FLAGS_COLOR)?COLOR_MODE_16:COLOR_MODE_DISABLED, &cb_color, "enable colors (0: none, 1: ansi, 2: 256 colors, 3: truecolor)"); SETICB ("scr.color", (core->print->flags&R_PRINT_FLAGS_COLOR)?COLOR_MODE_16:COLOR_MODE_DISABLED, &cb_color, "enable colors (0: none, 1: ansi, 2: 256 colors, 3: truecolor)");
r_config_set_getter (cfg, "scr.color", (RConfigCallback)cb_color_getter); r_config_set_getter (cfg, "scr.color", (RConfigCallback)cb_color_getter);
SETCB ("scr.color.grep", "false", &cb_scr_color_grep, "enable colors when using ~grep"); SETCB ("scr.color.grep", "false", &cb_scr_color_grep, "enable colors when using ~grep");
@ -4273,7 +4232,6 @@ R_API int r_core_config_init(RCore *core) {
SETBPREF ("scr.color.args", "true", "colorize arguments and variables of functions"); SETBPREF ("scr.color.args", "true", "colorize arguments and variables of functions");
SETBPREF ("scr.color.bytes", "true", "colorize bytes that represent the opcodes of the instruction"); SETBPREF ("scr.color.bytes", "true", "colorize bytes that represent the opcodes of the instruction");
SETCB ("scr.null", "false", &cb_scrnull, "show no output"); SETCB ("scr.null", "false", &cb_scrnull, "show no output");
SETCB ("scr.errmode", "echo", &cb_screrrmode, "error string handling");
SETCB ("scr.utf8", r_str_bool (r_cons_is_utf8()), &cb_utf8, "show UTF-8 characters instead of ANSI"); SETCB ("scr.utf8", r_str_bool (r_cons_is_utf8()), &cb_utf8, "show UTF-8 characters instead of ANSI");
SETCB ("scr.utf8.curvy", "false", &cb_utf8_curvy, "show curved UTF-8 corners (requires scr.utf8)"); SETCB ("scr.utf8.curvy", "false", &cb_utf8_curvy, "show curved UTF-8 corners (requires scr.utf8)");
SETCB ("scr.demo", "false", &cb_scr_demo, "use demoscene effects if available"); SETCB ("scr.demo", "false", &cb_scr_demo, "use demoscene effects if available");
@ -4348,6 +4306,13 @@ R_API int r_core_config_init(RCore *core) {
SETBPREF ("file.info", "true", "RBin info loaded"); SETBPREF ("file.info", "true", "RBin info loaded");
SETPREF ("file.type", "", "type of current file"); SETPREF ("file.type", "", "type of current file");
SETI ("file.loadalign", 1024, "alignment of load addresses"); SETI ("file.loadalign", 1024, "alignment of load addresses");
#if R2_580
SETCB ("file.log", "", cb_log_config_file, "Save log messages to given filename (log.file)");
SETCB ("file.output", "", &cb_teefile, "pipe output to file of this name (scr.tee)");
#else
SETCB ("log.file", "", cb_log_config_file, "Save log messages to given filename");
SETCB ("scr.tee", "", &cb_teefile, "pipe output to file of this name");
#endif
/* magic */ /* magic */
SETI ("magic.depth", 100, "recursivity depth in magic description strings"); SETI ("magic.depth", 100, "recursivity depth in magic description strings");

View File

@ -129,10 +129,10 @@ static int cmd_project(void *data, const char *input) {
} }
if (!R_STR_ISEMPTY (file)) { if (!R_STR_ISEMPTY (file)) {
if (!r_core_project_save (core, file)) { if (!r_core_project_save (core, file)) {
r_cons_eprintf ("Cannot save project.\n"); R_LOG_ERROR ("Cannot save project");
} }
} else { } else {
r_cons_eprintf ("Use: Ps [projectname]\n"); R_LOG_INFO ("Use: Ps [projectname]");
} }
break; break;
case '!': // "P!" case '!': // "P!"
@ -167,7 +167,7 @@ static int cmd_project(void *data, const char *input) {
} else if (input[1] == '*') { } else if (input[1] == '*') {
r_core_project_save_script (core, "/dev/stdout", R_CORE_PRJ_ALL); r_core_project_save_script (core, "/dev/stdout", R_CORE_PRJ_ALL);
} else { } else {
r_cons_eprintf ("Usage: PS[*] [projectname]\n"); eprintf ("Usage: PS[*] [projectname]\n");
} }
break; break;
case 'n': // "Pn" case 'n': // "Pn"

View File

@ -3572,12 +3572,12 @@ R_API int r_core_seek_size(RCore *core, ut64 addr, int bsize) {
if (r_sandbox_enable (0)) { if (r_sandbox_enable (0)) {
// TODO : restrict to filesize? // TODO : restrict to filesize?
if (bsize > 1024 * 32) { if (bsize > 1024 * 32) {
r_cons_eprintf ("Sandbox mode restricts blocksize bigger than 32k\n"); R_LOG_ERROR ("Sandbox mode restricts blocksize bigger than 32k");
return false; return false;
} }
} }
if (bsize > core->blocksize_max) { if (bsize > core->blocksize_max) {
r_cons_eprintf ("Block size %d is too big\n", bsize); R_LOG_ERROR ("Block size %d is too big", bsize);
return false; return false;
} }
R_CRITICAL_ENTER (core); R_CRITICAL_ENTER (core);
@ -3585,13 +3585,13 @@ R_API int r_core_seek_size(RCore *core, ut64 addr, int bsize) {
if (bsize < 1) { if (bsize < 1) {
bsize = 1; bsize = 1;
} else if (core->blocksize_max && bsize>core->blocksize_max) { } else if (core->blocksize_max && bsize>core->blocksize_max) {
r_cons_eprintf ("bsize is bigger than `bm`. dimmed to 0x%x > 0x%x\n", R_LOG_ERROR ("bsize is bigger than `bm`. dimmed to 0x%x > 0x%x",
bsize, core->blocksize_max); bsize, core->blocksize_max);
bsize = core->blocksize_max; bsize = core->blocksize_max;
} }
bump = realloc (core->block, bsize + 1); bump = realloc (core->block, bsize + 1);
if (!bump) { if (!bump) {
r_cons_eprintf ("Oops. cannot allocate that much (%u)\n", bsize); R_LOG_ERROR ("Oops. cannot allocate that much (%u)", bsize);
ret = false; ret = false;
} else { } else {
ret = true; ret = true;
@ -3674,12 +3674,12 @@ R_API bool r_core_serve(RCore *core, RIODesc *file) {
RIORap *rior = (RIORap *)file->data; RIORap *rior = (RIORap *)file->data;
if (!rior || !rior->fd) { if (!rior || !rior->fd) {
r_cons_eprintf ("rap: cannot listen.\n"); R_LOG_ERROR ("rap: cannot listen");
return false; return false;
} }
RSocket *fd = rior->fd; RSocket *fd = rior->fd;
r_cons_eprintf ("RAP Server started (rap.loop=%s)\n", const char *arg = r_config_get (core->config, "rap.loop");
r_config_get (core->config, "rap.loop")); R_LOG_INFO ("RAP Server started (rap.loop=%s)", arg);
r_cons_break_push (rap_break, rior); r_cons_break_push (rap_break, rior);
reaccept: reaccept:
while (!r_cons_is_breaked ()) { while (!r_cons_is_breaked ()) {
@ -3691,16 +3691,16 @@ reaccept:
goto out_of_function; goto out_of_function;
} }
if (!c) { if (!c) {
r_cons_eprintf ("rap: cannot accept\n"); R_LOG_ERROR ("rap: cannot accept");
r_socket_free (c); r_socket_free (c);
goto out_of_function; goto out_of_function;
} }
r_cons_eprintf ("rap: client connected\n"); R_LOG_INFO ("rap: client connected");
for (;!r_cons_is_breaked ();) { for (;!r_cons_is_breaked ();) {
if (!r_socket_read_block (c, &cmd, 1)) { if (!r_socket_read_block (c, &cmd, 1)) {
r_cons_eprintf ("rap: connection closed\n"); R_LOG_INFO ("rap: connection closed");
if (r_config_get_i (core->config, "rap.loop")) { if (r_config_get_i (core->config, "rap.loop")) {
r_cons_eprintf ("rap: waiting for new connection\n"); R_LOG_INFO ("rap: waiting for new connection");
r_socket_free (c); r_socket_free (c);
goto reaccept; goto reaccept;
} }
@ -3709,7 +3709,7 @@ reaccept:
switch (cmd) { switch (cmd) {
case RAP_PACKET_OPEN: case RAP_PACKET_OPEN:
r_socket_read_block (c, &flg, 1); // flags r_socket_read_block (c, &flg, 1); // flags
r_cons_eprintf ("open (%d): ", cmd); R_LOG_DEBUG ("open (%d)", cmd);
r_socket_read_block (c, &cmd, 1); // len r_socket_read_block (c, &cmd, 1); // len
pipefd = -1; pipefd = -1;
if (UT8_ADD_OVFCHK (cmd, 1)) { if (UT8_ADD_OVFCHK (cmd, 1)) {
@ -3717,7 +3717,7 @@ reaccept:
} }
ptr = malloc ((size_t)cmd + 1); ptr = malloc ((size_t)cmd + 1);
if (!ptr) { if (!ptr) {
r_cons_eprintf ("Cannot malloc in rmt-open len = %d\n", cmd); R_LOG_ERROR ("Cannot malloc in rmt-open len = %d", cmd);
} else { } else {
ut64 baddr = r_config_get_i (core->config, "bin.laddr"); ut64 baddr = r_config_get_i (core->config, "bin.laddr");
r_socket_read_block (c, ptr, cmd); r_socket_read_block (c, ptr, cmd);
@ -3735,14 +3735,13 @@ reaccept:
} else { } else {
pipefd = -1; pipefd = -1;
} }
r_cons_eprintf ("(flags: %d) len: %d filename: '%s'\n", R_LOG_ERROR ("(flags: %d) len: %d filename: '%s'", flg, cmd, ptr);
flg, cmd, ptr); //config.file);
} else { } else {
pipefd = -1; pipefd = -1;
r_cons_eprintf ("Cannot open file (%s)\n", ptr); R_LOG_ERROR ("Cannot open file (%s)", ptr);
r_socket_close (c); r_socket_close (c);
if (r_config_get_i (core->config, "rap.loop")) { if (r_config_get_i (core->config, "rap.loop")) {
r_cons_eprintf ("rap: waiting for new connection\n"); R_LOG_INFO ("rap: waiting for new connection");
r_socket_free (c); r_socket_free (c);
goto reaccept; goto reaccept;
} }
@ -3777,7 +3776,7 @@ reaccept:
r_socket_flush (c); r_socket_flush (c);
R_FREE (ptr); R_FREE (ptr);
} else { } else {
r_cons_eprintf ("Cannot read %d byte(s)\n", i); R_LOG_ERROR ("Cannot read %d byte(s)", i);
r_socket_free (c); r_socket_free (c);
// TODO: reply error here // TODO: reply error here
goto out_of_function; goto out_of_function;
@ -3803,10 +3802,10 @@ reaccept:
r_config_set_b (core->config, "scr.interactive", scr_interactive); r_config_set_b (core->config, "scr.interactive", scr_interactive);
free (cmd); free (cmd);
} else { } else {
r_cons_eprintf ("rap: cannot malloc\n"); R_LOG_ERROR ("rap: cannot malloc");
} }
} else { } else {
r_cons_eprintf ("rap: invalid length '%d'\n", i); R_LOG_INFO ("rap: invalid length '%d'", i);
} }
/* write */ /* write */
if (cmd_output) { if (cmd_output) {
@ -3832,11 +3831,11 @@ reaccept:
r_socket_read_block (c, b, 5); r_socket_read_block (c, b, 5);
if (b[0] == (RAP_PACKET_CMD | RAP_PACKET_REPLY)) { if (b[0] == (RAP_PACKET_CMD | RAP_PACKET_REPLY)) {
ut32 n = r_read_be32 (b + 1); ut32 n = r_read_be32 (b + 1);
r_cons_eprintf ("REPLY %d\n", n); R_LOG_DEBUG ("REPLY %d", n);
if (n > 0) { if (n > 0) {
ut8 *res = calloc (1, n); ut8 *res = calloc (1, n);
r_socket_read_block (c, res, n); r_socket_read_block (c, res, n);
r_cons_eprintf ("RESPONSE(%s)\n", (const char *)res); R_LOG_DEBUG ("RESPONSE(%s)", (const char *)res);
free (res); free (res);
} }
} }
@ -3928,19 +3927,19 @@ reaccept:
r_socket_close (c); r_socket_close (c);
} }
} else { } else {
r_cons_eprintf ("[rap] unknown command 0x%02x\n", cmd); R_LOG_ERROR ("[rap] unknown command 0x%02x", cmd);
r_socket_close (c); r_socket_close (c);
R_FREE (ptr); R_FREE (ptr);
} }
if (r_config_get_i (core->config, "rap.loop")) { if (r_config_get_i (core->config, "rap.loop")) {
r_cons_eprintf ("rap: waiting for new connection\n"); R_LOG_INFO ("rap: waiting for new connection");
r_socket_free (c); r_socket_free (c);
goto reaccept; goto reaccept;
} }
goto out_of_function; goto out_of_function;
} }
} }
r_cons_eprintf ("client: disconnected\n"); R_LOG_INFO ("client: disconnected");
r_socket_free (c); r_socket_free (c);
} }
out_of_function: out_of_function:
@ -3952,7 +3951,7 @@ R_API int r_core_search_cb(RCore *core, ut64 from, ut64 to, RCoreSearchCallback
int ret, len = core->blocksize; int ret, len = core->blocksize;
ut8 *buf = malloc (len); ut8 *buf = malloc (len);
if (!buf) { if (!buf) {
r_cons_eprintf ("Cannot allocate blocksize\n"); R_LOG_ERROR ("Cannot allocate blocksize");
return false; return false;
} }
while (from < to) { while (from < to) {
@ -3961,7 +3960,7 @@ R_API int r_core_search_cb(RCore *core, ut64 from, ut64 to, RCoreSearchCallback
len = (int)delta; len = (int)delta;
} }
if (!r_io_read_at (core->io, from, buf, len)) { if (!r_io_read_at (core->io, from, buf, len)) {
r_cons_eprintf ("Cannot read at 0x%"PFMT64x"\n", from); R_LOG_ERROR ("Cannot read at 0x%"PFMT64x, from);
break; break;
} }
for (ret = 0; ret < len;) { for (ret = 0; ret < len;) {
@ -4008,7 +4007,7 @@ R_API char *r_core_editor(const RCore *core, const char *file, const char *str)
return NULL; return NULL;
} }
if (readonly) { if (readonly) {
r_cons_eprintf ("Opening in read-only\n"); R_LOG_INFO ("Opening in read-only");
} else { } else {
if (str) { if (str) {
const size_t str_len = strlen (str); const size_t str_len = strlen (str);
@ -4080,7 +4079,7 @@ R_API RBuffer *r_core_syscall(RCore *core, const char *name, const char *args) {
//arch check //arch check
if (strcmp (core->anal->cur->arch, "x86")) { if (strcmp (core->anal->cur->arch, "x86")) {
r_cons_eprintf ("architecture not yet supported!\n"); R_LOG_ERROR ("architecture not yet supported!");
return 0; return 0;
} }
@ -4095,18 +4094,18 @@ R_API RBuffer *r_core_syscall(RCore *core, const char *name, const char *args) {
switch (core->rasm->config->bits) { switch (core->rasm->config->bits) {
case 32: case 32:
if (strcmp (name, "setup") && !num ) { if (strcmp (name, "setup") && !num ) {
r_cons_eprintf ("syscall not found!\n"); R_LOG_ERROR ("syscall not found!");
return 0; return 0;
} }
break; break;
case 64: case 64:
if (strcmp (name, "read") && !num ) { if (strcmp (name, "read") && !num ) {
r_cons_eprintf ("syscall not found!\n"); R_LOG_ERROR ("syscall not found!");
return 0; return 0;
} }
break; break;
default: default:
r_cons_eprintf ("syscall not found!\n"); R_LOG_ERROR ("syscall not found!");
return 0; return 0;
} }
@ -4120,10 +4119,10 @@ R_API RBuffer *r_core_syscall(RCore *core, const char *name, const char *args) {
r_egg_load (core->egg, code, 0); r_egg_load (core->egg, code, 0);
if (!r_egg_compile (core->egg)) { if (!r_egg_compile (core->egg)) {
r_cons_eprintf ("Cannot compile.\n"); R_LOG_ERROR ("Cannot compile");
} }
if (!r_egg_assemble (core->egg)) { if (!r_egg_assemble (core->egg)) {
r_cons_eprintf ("r_egg_assemble: invalid assembly\n"); R_LOG_ERROR ("r_egg_assemble: invalid assembly");
} }
if ((b = r_egg_get_bin (core->egg))) { if ((b = r_egg_get_bin (core->egg))) {
#if 0 #if 0
@ -4210,7 +4209,7 @@ R_API bool r_core_autocomplete_remove(RCoreAutocomplete *parent, const char* cmd
r_core_autocomplete_free (ac); r_core_autocomplete_free (ac);
RCoreAutocomplete **updated = realloc (parent->subcmds, (parent->n_subcmds - 1) * sizeof (RCoreAutocomplete*)); RCoreAutocomplete **updated = realloc (parent->subcmds, (parent->n_subcmds - 1) * sizeof (RCoreAutocomplete*));
if (!updated && (parent->n_subcmds - 1) > 0) { if (!updated && (parent->n_subcmds - 1) > 0) {
r_cons_eprintf ("Something really bad has happen.. this should never ever happen..\n"); R_LOG_INFO ("Something really bad has happen.. this should never ever happen");
return false; return false;
} }
parent->subcmds = updated; parent->subcmds = updated;

View File

@ -4497,7 +4497,7 @@ R_API void r_core_visual_disasm_down(RCore *core, RAsmOp *op, int *cols) {
size_t bufsize = maxopsize > -1? R_MAX (maxopsize, 32): 32; size_t bufsize = maxopsize > -1? R_MAX (maxopsize, 32): 32;
ut8 *buf = calloc (bufsize, sizeof (ut8)); ut8 *buf = calloc (bufsize, sizeof (ut8));
if (!buf) { if (!buf) {
r_cons_eprintf ("Cannot allocate %d byte(s)\n", (int)bufsize); R_LOG_ERROR ("Cannot allocate %d byte(s)", (int)bufsize);
return; return;
}; };
ut64 orig = core->offset; ut64 orig = core->offset;

View File

@ -392,8 +392,6 @@ typedef struct r_cons_context_t {
char *buffer; // TODO: replace with RStrBuf char *buffer; // TODO: replace with RStrBuf
size_t buffer_len; size_t buffer_len;
size_t buffer_sz; size_t buffer_sz;
RStrBuf *error; // r_cons_eprintf / r_cons_errstr / r_cons_errmode
int errmode;
bool breaked; bool breaked;
bool was_breaked; bool was_breaked;
bool unbreakable; bool unbreakable;
@ -850,11 +848,6 @@ R_API void r_cons_context_break_pop(RConsContext *context, bool sig);
R_API char *r_cons_editor(const char *file, const char *str); R_API char *r_cons_editor(const char *file, const char *str);
R_API void r_cons_reset(void); R_API void r_cons_reset(void);
R_API void r_cons_reset_colors(void); R_API void r_cons_reset_colors(void);
R_API char *r_cons_errstr(void);
R_API void r_cons_errmode(int mode);
R_API void r_cons_errmodes(const char *mode);
R_API int r_cons_eprintf(const char *format, ...);
R_API void r_cons_eflush(void);
R_API void r_cons_print_clear(void); R_API void r_cons_print_clear(void);
R_API void r_cons_echo(const char *msg); R_API void r_cons_echo(const char *msg);
R_API void r_cons_zero(void); R_API void r_cons_zero(void);