mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-05 04:56:10 +00:00
Move const char help_msg_*[] arrays to top (#8250)
This commit is contained in:
parent
11b744f188
commit
a635b34c77
@ -971,20 +971,20 @@ static int cmd_bsize(void *data, const char *input) {
|
||||
RFlagItem *flag;
|
||||
RCore *core = (RCore *)data;
|
||||
switch (input[0]) {
|
||||
case 'm':
|
||||
case 'm': // "bm"
|
||||
n = r_num_math (core->num, input + 1);
|
||||
if (n > 1) core->blocksize_max = n;
|
||||
else r_cons_printf ("0x%x\n", (ut32)core->blocksize_max);
|
||||
break;
|
||||
case '+':
|
||||
case '+': // "b+"
|
||||
n = r_num_math (core->num, input + 1);
|
||||
r_core_block_size (core, core->blocksize + n);
|
||||
break;
|
||||
case '-':
|
||||
case '-': // "b-"
|
||||
n = r_num_math (core->num, input + 1);
|
||||
r_core_block_size (core, core->blocksize - n);
|
||||
break;
|
||||
case 'f':
|
||||
case 'f': // "bf"
|
||||
if (input[1] == ' ') {
|
||||
flag = r_flag_get (core->flags, input + 2);
|
||||
if (flag) {
|
||||
@ -996,10 +996,10 @@ static int cmd_bsize(void *data, const char *input) {
|
||||
eprintf ("Usage: bf [flagname]\n");
|
||||
}
|
||||
break;
|
||||
case '\0':
|
||||
case '\0': // "b"
|
||||
r_cons_printf ("0x%x\n", core->blocksize);
|
||||
break;
|
||||
case '?':
|
||||
case '?': // "b?"
|
||||
r_core_cmd_help (core, help_msg_b);
|
||||
break;
|
||||
default:
|
||||
@ -1020,28 +1020,28 @@ static int cmd_resize(void *data, const char *input) {
|
||||
oldsize = r_io_desc_size (core->file->desc);
|
||||
else oldsize = 0;
|
||||
switch (*input) {
|
||||
case '2':
|
||||
case '2': // "r2"
|
||||
// TODO: use argv[0] instead of 'radare2'
|
||||
r_sys_cmdf ("radare%s", input);
|
||||
return true;
|
||||
case 'm':
|
||||
case 'm': // "rm"
|
||||
if (input[1] == ' ')
|
||||
r_file_rm (input + 2);
|
||||
else eprintf ("Usage: rm [file] # removes a file\n");
|
||||
return true;
|
||||
case '\0':
|
||||
case '\0': // "r"
|
||||
if (core->file && core->file->desc) {
|
||||
if (oldsize != -1) {
|
||||
r_cons_printf ("%"PFMT64d"\n", oldsize);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case '+':
|
||||
case '-':
|
||||
case '+': // "r+"
|
||||
case '-': // "r-"
|
||||
delta = (st64)r_num_math (core->num, input);
|
||||
newsize = oldsize + delta;
|
||||
break;
|
||||
case ' ':
|
||||
case ' ': // "r "
|
||||
newsize = r_num_math (core->num, input + 1);
|
||||
if (newsize == 0) {
|
||||
if (input[1] == '0')
|
||||
@ -1049,8 +1049,8 @@ static int cmd_resize(void *data, const char *input) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case '?': // "r?"
|
||||
default:
|
||||
case '?':
|
||||
r_core_cmd_help (core, help_msg_r);
|
||||
return true;
|
||||
}
|
||||
@ -3292,7 +3292,7 @@ R_API void r_core_cmd_init(RCore *core) {
|
||||
{"$", "alias", cmd_alias},
|
||||
{"%", "short version of 'env' command", cmd_env},
|
||||
{"&", "threading capabilities", cmd_thread},
|
||||
{"(", "macro", cmd_macro},
|
||||
{"(", "macro", cmd_macro, cmd_macro_init},
|
||||
{"*", "pointer read/write", cmd_pointer},
|
||||
{"-", "open cfg.editor and run script", cmd_stdin},
|
||||
{".", "interpret", cmd_interpret},
|
||||
@ -3303,7 +3303,7 @@ R_API void r_core_cmd_init(RCore *core) {
|
||||
{"0x", "alias for s 0x", cmd_ox},
|
||||
{"analysis", "analysis", cmd_anal, cmd_anal_init},
|
||||
{"bsize", "change block size", cmd_bsize},
|
||||
{"cmp", "compare memory", cmd_cmp},
|
||||
{"cmp", "compare memory", cmd_cmp, cmd_cmp_init},
|
||||
{"Code", "code metadata", cmd_meta, cmd_meta_init},
|
||||
{"debug", "debugger operations", cmd_debug, cmd_debug_init},
|
||||
{"eval", "evaluate configuration variable", cmd_eval, cmd_eval_init},
|
||||
|
@ -2,33 +2,35 @@
|
||||
|
||||
#include "r_core.h"
|
||||
|
||||
static void showhelp(RCore *core) {
|
||||
const char *help_msg[] = {
|
||||
"Usage:", "c[?dfx] [argument]", " # Compare",
|
||||
"c", " [string]", "Compare a plain with escaped chars string",
|
||||
"c*", " [string]", "Compare a plain with escaped chars string (output r2 commands)",
|
||||
"c4", " [value]", "Compare a doubleword from a math expression",
|
||||
"c8", " [value]", "Compare a quadword from a math expression",
|
||||
"cat", " [file]", "Show contents of file (see pwd, ls)",
|
||||
"cc", " [at] [(at)]", "Compares in two hexdump columns of block size",
|
||||
"ccc", " [at] [(at)]", "Same as above, but only showing different lines",
|
||||
"ccd", " [at] [(at)]", "Compares in two disasm columns of block size",
|
||||
// "cc", " [offset]", "code bindiff current block against offset"
|
||||
// "cD", " [file]", "like above, but using radiff -b",
|
||||
"cf", " [file]", "Compare contents of file at current seek",
|
||||
"cg", "[?] [o] [file]", "Graphdiff current file and [file]",
|
||||
"cl|cls|clear", "", "Clear screen, (clear0 to goto 0, 0 only)",
|
||||
"cu", "[?] [addr] @at", "Compare memory hexdumps of $$ and dst in unified diff",
|
||||
"cud", " [addr] @at", "Unified diff disasm from $$ and given address",
|
||||
"cv", "[1248] [addr] @at", "Compare 1,2,4,8-byte value",
|
||||
"cw", "[?] [us?] [...]", "Compare memory watchers",
|
||||
"cx", " [hexpair]", "Compare hexpair string (use '.' as nibble wildcard)",
|
||||
"cx*", " [hexpair]", "Compare hexpair string (output r2 commands)",
|
||||
"cX", " [addr]", "Like 'cc' but using hexdiff output",
|
||||
NULL
|
||||
};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
static const char *help_msg_c[] = {
|
||||
"Usage:", "c[?dfx] [argument]", " # Compare",
|
||||
"c", " [string]", "Compare a plain with escaped chars string",
|
||||
"c*", " [string]", "Compare a plain with escaped chars string (output r2 commands)",
|
||||
"c4", " [value]", "Compare a doubleword from a math expression",
|
||||
"c8", " [value]", "Compare a quadword from a math expression",
|
||||
"cat", " [file]", "Show contents of file (see pwd, ls)",
|
||||
"cc", " [at] [(at)]", "Compares in two hexdump columns of block size",
|
||||
"ccc", " [at] [(at)]", "Same as above, but only showing different lines",
|
||||
"ccd", " [at] [(at)]", "Compares in two disasm columns of block size",
|
||||
// "cc", " [offset]", "code bindiff current block against offset"
|
||||
// "cD", " [file]", "like above, but using radiff -b",
|
||||
"cf", " [file]", "Compare contents of file at current seek",
|
||||
"cg", "[?] [o] [file]", "Graphdiff current file and [file]",
|
||||
"cl|cls|clear", "", "Clear screen, (clear0 to goto 0, 0 only)",
|
||||
"cu", "[?] [addr] @at", "Compare memory hexdumps of $$ and dst in unified diff",
|
||||
"cud", " [addr] @at", "Unified diff disasm from $$ and given address",
|
||||
"cv", "[1248] [addr] @at", "Compare 1,2,4,8-byte value",
|
||||
"cw", "[?] [us?] [...]", "Compare memory watchers",
|
||||
"cx", " [hexpair]", "Compare hexpair string (use '.' as nibble wildcard)",
|
||||
"cx*", " [hexpair]", "Compare hexpair string (output r2 commands)",
|
||||
"cX", " [addr]", "Like 'cc' but using hexdiff output",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void cmd_cmp_init(RCore *core) {
|
||||
DEFINE_CMD_DESCRIPTOR (core, c);
|
||||
}
|
||||
|
||||
R_API void r_core_cmpwatch_free(RCoreCmpWatcher *w) {
|
||||
free (w->ndata);
|
||||
free (w->odata);
|
||||
@ -684,7 +686,7 @@ static int cmd_cmp(void *data, const char *input) {
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
showhelp (core);
|
||||
r_core_cmd_help (core, help_msg_c);
|
||||
break;
|
||||
case 'v': // "cv"
|
||||
{
|
||||
@ -760,11 +762,10 @@ static int cmd_cmp(void *data, const char *input) {
|
||||
// r_cons_flush ();
|
||||
break;
|
||||
default:
|
||||
showhelp (core);
|
||||
r_core_cmd_help (core, help_msg_c);
|
||||
}
|
||||
if (val != UT64_MAX) {
|
||||
core->num->value = val;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,32 @@
|
||||
#include "r_cmd.h"
|
||||
#include "r_core.h"
|
||||
|
||||
static const char *help_msg_lparen[] = {
|
||||
"Usage:", "(foo args,cmd1,cmd2,..)", "Aliases",
|
||||
"(foo args,..,..)", "", "define a macro",
|
||||
"(foo args,..,..)()", "", "define and call a macro",
|
||||
"(-foo)", "", "remove a macro",
|
||||
".(foo)", "", "to call it",
|
||||
"()", "", "break inside macro",
|
||||
"(*", "", "list all defined macros",
|
||||
"", "Argument support:", "",
|
||||
"(foo x y, $0 @ $1)", "", "define fun with args (x - $0, y - $1)",
|
||||
".(foo 128 0x804800)", "", "call it with args",
|
||||
"", "Iterations:", "",
|
||||
".(foo,() $@)", "", "define iterator returning iter index",
|
||||
"x @@ .(foo)", "", "iterate over them",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void cmd_macro_init(RCore *core) {
|
||||
RCmdDescriptor *d = R_NEW0 (RCmdDescriptor);
|
||||
if (d) {
|
||||
d->cmd = "(";
|
||||
d->help_msg = help_msg_lparen;
|
||||
r_list_append (core->cmd_descriptors, d);
|
||||
}
|
||||
}
|
||||
|
||||
static int cmd_macro(void *data, const char *input) {
|
||||
char *buf = NULL;
|
||||
RCore *core = (RCore*)data;
|
||||
@ -12,24 +38,8 @@ static int cmd_macro(void *data, const char *input) {
|
||||
case '*': r_cmd_macro_meta (&core->rcmd->macro); break;
|
||||
case '\0': r_cmd_macro_list (&core->rcmd->macro); break;
|
||||
case '(':
|
||||
case '?': {
|
||||
const char* help_msg[] = {
|
||||
"Usage:", "(foo args,cmd1,cmd2,..)", "Aliases",
|
||||
"(foo args,..,..)", "", "define a macro",
|
||||
"(foo args,..,..)()", "", "define and call a macro",
|
||||
"(-foo)", "", "remove a macro",
|
||||
".(foo)", "", "to call it",
|
||||
"()", "", "break inside macro",
|
||||
"(*", "", "list all defined macros",
|
||||
"", "Argument support:", "",
|
||||
"(foo x y, $0 @ $1)", "", "define fun with args (x - $0, y - $1)",
|
||||
".(foo 128 0x804800)", "", "call it with args",
|
||||
"", "Iterations:", "",
|
||||
".(foo,() $@)", "", "define iterator returning iter index",
|
||||
"x @@ .(foo)", "", "iterate over them",
|
||||
NULL};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
}
|
||||
case '?':
|
||||
r_core_cmd_help (core, help_msg_lparen);
|
||||
break;
|
||||
default: {
|
||||
// XXX: stop at first ')'. if next is '(' and last
|
||||
|
@ -32,7 +32,7 @@ static const char *help_msg_slash[] = {
|
||||
"/o", " [n]", "show offset of n instructions backward",
|
||||
"/p", " patternsize", "search for pattern of given size",
|
||||
"/P", " patternsize", "search similar blocks",
|
||||
"/r[e]", " sym.printf", "analyze opcode reference an offset (/re for esil)",
|
||||
"/r[e]", "[?] sym.printf", "analyze opcode reference an offset (/re for esil)",
|
||||
"/R", " [grepopcode]", "search for matching ROP gadgets, semicolon-separated",
|
||||
"/v", "[1248] value", "look for an `cfg.bigendian` 32bit value",
|
||||
"/V", "[1248] min max", "look for an `cfg.bigendian` 32bit value in range",
|
||||
@ -73,6 +73,15 @@ static const char *help_msg_slash_C[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static const char *help_msg_slash_r[] = {
|
||||
"Usage:", "/r[e] [address]", " search references to this specific address",
|
||||
"/r", " [addr]", "search references to this specific address",
|
||||
"/re", " [addr]", "search references using esil",
|
||||
"/rc", "", "search for call references",
|
||||
"/ra", "", "search all references",
|
||||
NULL
|
||||
};
|
||||
|
||||
static const char *help_msg_slash_R[] = {
|
||||
"Usage: /R", "", "Search for ROP gadgets",
|
||||
"/R", " [filter-by-string]", "Show gadgets",
|
||||
@ -134,6 +143,7 @@ static void cmd_search_init(RCore *core) {
|
||||
DEFINE_CMD_DESCRIPTOR_SPECIAL (core, /, slash);
|
||||
DEFINE_CMD_DESCRIPTOR_SPECIAL (core, /c, slash_c);
|
||||
DEFINE_CMD_DESCRIPTOR_SPECIAL (core, /C, slash_C);
|
||||
DEFINE_CMD_DESCRIPTOR_SPECIAL (core, /r, slash_r);
|
||||
DEFINE_CMD_DESCRIPTOR_SPECIAL (core, /R, slash_R);
|
||||
DEFINE_CMD_DESCRIPTOR_SPECIAL (core, /Rk, slash_Rk);
|
||||
DEFINE_CMD_DESCRIPTOR_SPECIAL (core, /x, slash_x);
|
||||
@ -2473,19 +2483,15 @@ reread:
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
eprintf ("Usage /r[e] [address] - search references to this specific address\n"
|
||||
" /r [addr] - search references to this specific address\n"
|
||||
" /re [addr] - search references using esil\n"
|
||||
" /rc - search for call references\n"
|
||||
" /ra - search all references\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'A':
|
||||
case 'A': // "/A"
|
||||
do_anal_search (core, ¶m, input + 1);
|
||||
dosearch = false;
|
||||
break;
|
||||
case 'a': if (input[1]) {
|
||||
case 'a': // "/a"
|
||||
if (input[1]) {
|
||||
char *kwd = r_core_asm_search (core, input + param_offset,
|
||||
param.from, param.to);
|
||||
if (kwd) {
|
||||
@ -2503,7 +2509,7 @@ reread:
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'C': {
|
||||
case 'C': { // "/C"
|
||||
dosearch = true;
|
||||
param.crypto_search = true;
|
||||
switch (input[1]) {
|
||||
@ -2563,7 +2569,7 @@ reread:
|
||||
case 'P': // "/P"
|
||||
search_similar_pattern (core, atoi (input + 1));
|
||||
break;
|
||||
case 'V':
|
||||
case 'V': // "/V"
|
||||
// TODO: add support for json
|
||||
{
|
||||
int err = 1, vsize = atoi (input + 1);
|
||||
@ -2652,7 +2658,7 @@ reread:
|
||||
r_search_begin (core->search);
|
||||
dosearch = true;
|
||||
break;
|
||||
case 'w': /* search wide string, includes ignorecase search functionality (/wi cmd)! */
|
||||
case 'w': // "/w" search wide string, includes ignorecase search functionality (/wi cmd)!
|
||||
if (input[1]) {
|
||||
if (input[2]) {
|
||||
if (input[1] == 'j' || input[2] == 'j') {
|
||||
@ -2696,19 +2702,19 @@ reread:
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
case 'i': // "/i"
|
||||
if (input[param_offset - 1] != ' ') {
|
||||
eprintf ("Missing ' ' after /i\n");
|
||||
ret = false;
|
||||
goto beach;
|
||||
}
|
||||
ignorecase = true;
|
||||
case 'j':
|
||||
case 'j': // "/j"
|
||||
if (input[0] == 'j') {
|
||||
json = true;
|
||||
}
|
||||
/* pass-thru */
|
||||
case ' ': /* search string */
|
||||
case ' ': // "/ " search string
|
||||
inp = strdup (input + 1 + ignorecase + json);
|
||||
len = r_str_unescape (inp);
|
||||
if (!json) {
|
||||
@ -2738,7 +2744,7 @@ reread:
|
||||
r_search_begin (core->search);
|
||||
dosearch = true;
|
||||
break;
|
||||
case 'e': /* match regexp */
|
||||
case 'e': // "/e" match regexp
|
||||
if (input[1]) {
|
||||
RSearchKeyword *kw;
|
||||
kw = r_search_keyword_new_regexp (input + param_offset, NULL);
|
||||
@ -2756,13 +2762,13 @@ reread:
|
||||
eprintf ("Missing regex\n");
|
||||
}
|
||||
break;
|
||||
case 'E':
|
||||
case 'E': // "/E"
|
||||
if (core->io && core->io->debug) {
|
||||
r_debug_map_sync (core->dbg);
|
||||
}
|
||||
do_esil_search (core, ¶m, input);
|
||||
goto beach;
|
||||
case 'd': /* search delta key */
|
||||
case 'd': // "/d" search delta key
|
||||
if (input[1]) {
|
||||
r_search_reset (core->search, R_SEARCH_DELTAKEY);
|
||||
r_search_kw_add (core->search,
|
||||
@ -2773,7 +2779,7 @@ reread:
|
||||
eprintf ("Missing delta\n");
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
case 'h': // "/h"
|
||||
{
|
||||
char *p, *arg = r_str_chop (strdup (input + 1));
|
||||
p = strchr (arg, ' ');
|
||||
@ -2845,7 +2851,7 @@ reread:
|
||||
eprintf ("Usage: /f [file] ([offset] ([size]))\n");
|
||||
}
|
||||
break;
|
||||
case 'x': /* search hex */
|
||||
case 'x': // "/x" search hex
|
||||
if (input[1] == '?') {
|
||||
r_core_cmd_help (core, help_msg_slash_x);
|
||||
} else {
|
||||
@ -2871,14 +2877,14 @@ reread:
|
||||
free (p);
|
||||
}
|
||||
break;
|
||||
case 'c': /* search asm */
|
||||
case 'c': // "/c" search asm
|
||||
if (input[1] == '?') {
|
||||
r_core_cmd_help (core, help_msg_slash_c);
|
||||
}
|
||||
do_asm_search (core, ¶m, input);
|
||||
dosearch = 0;
|
||||
break;
|
||||
case '+':
|
||||
case '+': // "/+"
|
||||
if (input[1] == ' ') {
|
||||
// TODO: support /+j
|
||||
char *buf = malloc (strlen (input) * 2);
|
||||
@ -2916,7 +2922,7 @@ again:
|
||||
eprintf ("Usage: /+ [string]\n");
|
||||
}
|
||||
break;
|
||||
case 'z': /* search strings of min-max range*/
|
||||
case 'z': // "/z" search strings of min-max range
|
||||
{
|
||||
char *p;
|
||||
ut32 min, max;
|
||||
@ -2948,7 +2954,7 @@ again:
|
||||
dosearch = true;
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
case '?': // "/?"
|
||||
r_core_cmd_help (core, help_msg_slash);
|
||||
break;
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user