Implement R2_ARGS as it was done for rabin2 and rarun2

* TODO: Unify all this logic into a single function
This commit is contained in:
pancake 2023-08-18 14:14:36 +02:00
parent 7dda1e97d9
commit 5b0b9d09a9
6 changed files with 18 additions and 3 deletions

View File

@ -1,7 +1,17 @@
/* radare - LGPL - Copyright 2009-2022 - pancake */
/* radare - LGPL - Copyright 2009-2023 - pancake */
#include <r_main.h>
int main(int argc, const char **argv) {
char *ea = r_sys_getenv ("RABIN2_ARGS");
if (R_STR_ISNOTEMPTY (ea)) {
char **argv = r_str_argv (ea, &argc);
r_sys_setenv ("RABIN2_ARGS", NULL);
int res = r_main_rabin2 (argc, (const char **)argv);
free (ea);
free (argv);
return res;
}
free (ea);
return r_main_rabin2 (argc, argv);
}

View File

@ -75,6 +75,7 @@ static int rabin_show_help(int v) {
if (v) {
printf ("Environment:\n"
" R2_NOPLUGINS: 1|0| # do not load shared plugins (speedup loading)\n"
" RABIN2_ARGS: # ignore cli and use these program arguments\n"
" RABIN2_CHARSET: e cfg.charset # set default value charset for -z strings\n"
" RABIN2_DEBASE64: e bin.str.debase64 # try to debase64 all strings\n"
" RABIN2_DEMANGLE=0:e bin.demangle # do not demangle symbols\n"

View File

@ -171,6 +171,7 @@ static int main_help(int line) {
" R2_USER_ZIGNS ${XDG_DATA_DIR:=~/.local/share/radare2}/zigns\n"
"Environment:\n"
" R2_COLOR sets the initial value for 'scr.color'. set to 0 for no color\n"
" R2_ARGS ignore cli arguments and use these ones instead\n"
" R2_DEBUG if defined, show error messages and crash signal.\n"
" R2_DEBUG_NOPAPI do not load r2papi in the -j qjs shell\n"
" R2_DEBUG_ASSERT set a breakpoint when hitting an assert.\n"

View File

@ -1,4 +1,4 @@
/* radare2 - Copyleft 2011-2022 - pancake */
/* radare2 - Copyleft 2011-2023 - pancake */
#define R_LOG_ORIGIN "rarun2"

View File

@ -139,6 +139,8 @@ Dump raw strings to stdout (for huge files)
.El
.Sh ENVIRONMENT
.Pp
RABIN2_ARGS ignore cli and use these arguments instead
.Pp
RABIN2_LANG same as r2 -e bin.lang for rabin2
.Pp
RABIN2_DEMANGLE demangle symbols

View File

@ -1,4 +1,5 @@
const lines = r2.cmd('cat mem.log').split(/\n/);
const logfile = 'a.txt';
const lines = r2.cmd('cat '+logfile).split(/\n/);
let total = 0;
let leaked = 0;
var track = {};