mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-13 16:18:33 +00:00
Implement RCore.cmdCallAt() + minor improve internal cmd calls ##api
* Use getb/setb for scr.html
This commit is contained in:
parent
6fb1e041d8
commit
466fa80d2c
@ -521,7 +521,7 @@ static bool lastcmd_repeat(RCore *core, int next) {
|
||||
case '$':
|
||||
if (!strncmp (core->lastcmd, "pd", 2)) {
|
||||
if (core->lastcmd[2]== ' ') {
|
||||
r_core_cmdf (core, "so %s", core->lastcmd + 3);
|
||||
r_core_cmd_callf (core, "so %s", r_str_trim_head_ro (core->lastcmd + 3));
|
||||
} else {
|
||||
r_core_cmd0 (core, "so `pi~?`");
|
||||
}
|
||||
@ -620,7 +620,7 @@ static int cmd_uniq(void *data, const char *input) { // "uniq"
|
||||
arg = "";
|
||||
}
|
||||
if (r_fs_check (core->fs, arg)) {
|
||||
r_core_cmdf (core, "md %s", arg);
|
||||
r_core_cmd_callf (core, "md %s", arg);
|
||||
} else {
|
||||
char *res = r_syscmd_uniq (arg);
|
||||
if (res) {
|
||||
@ -2975,25 +2975,17 @@ static int cmd_tasks(void *data, const char *input) {
|
||||
|
||||
static int cmd_pointer(void *data, const char *input) {
|
||||
RCore *core = (RCore*) data;
|
||||
int ret = true;
|
||||
char *str, *eq;
|
||||
int ret = 0;
|
||||
input = r_str_trim_head_ro (input);
|
||||
while (*input == ' ') {
|
||||
input++;
|
||||
}
|
||||
if (!*input || *input == '?') {
|
||||
r_core_cmd_help (core, help_msg_star);
|
||||
return ret;
|
||||
}
|
||||
str = strdup (input);
|
||||
eq = strchr (str, '=');
|
||||
char *str = strdup (input);
|
||||
char *eq = strchr (str, '=');
|
||||
if (eq) {
|
||||
*eq++ = 0;
|
||||
if (!strncmp (eq, "0x", 2)) {
|
||||
ret = r_core_cmdf (core, "wv %s@%s", eq, str);
|
||||
} else {
|
||||
ret = r_core_cmdf (core, "wx %s@%s", eq, str);
|
||||
}
|
||||
ret = r_core_cmdf (core, "wv %s@%s", eq, str);
|
||||
} else {
|
||||
ret = r_core_cmdf (core, "?v [%s]", input);
|
||||
}
|
||||
@ -3003,7 +2995,7 @@ static int cmd_pointer(void *data, const char *input) {
|
||||
|
||||
static int cmd_env(void *data, const char *input) {
|
||||
RCore *core = (RCore*)data;
|
||||
int ret = true;
|
||||
int ret = 1;
|
||||
switch (*input) {
|
||||
case '?':
|
||||
cmd_help_percent (core);
|
||||
@ -3439,7 +3431,7 @@ R_API int r_core_cmd_pipe(RCore *core, char *radare_cmd, char *shell_cmd) {
|
||||
}
|
||||
bool si = r_cons_is_interactive ();
|
||||
r_config_set_b (core->config, "scr.interactive", false);
|
||||
if (!r_config_get_i (core->config, "scr.color.pipe")) {
|
||||
if (!r_config_get_b (core->config, "scr.color.pipe")) {
|
||||
pipecolor = r_config_get_i (core->config, "scr.color");
|
||||
r_config_set_i (core->config, "scr.color", COLOR_MODE_DISABLED);
|
||||
}
|
||||
@ -4162,7 +4154,7 @@ escape_pipe:
|
||||
return true;
|
||||
}
|
||||
int fdn = 1;
|
||||
int pipecolor = r_config_get_i (core->config, "scr.color.pipe");
|
||||
bool pipecolor = r_config_get_b (core->config, "scr.color.pipe");
|
||||
int use_editor = false;
|
||||
int ocolor = r_config_get_i (core->config, "scr.color");
|
||||
*ptr = '\0';
|
||||
@ -4321,7 +4313,7 @@ next2:
|
||||
ret = r_core_cmd_subst (core, cmd);
|
||||
free (cmd);
|
||||
if (scr_html != -1) {
|
||||
r_config_set_i (core->config, "scr.html", scr_html);
|
||||
r_config_set_b (core->config, "scr.html", scr_html);
|
||||
}
|
||||
free (str);
|
||||
r_list_free (tmpenvs);
|
||||
@ -6069,6 +6061,21 @@ R_API char *r_core_cmd_strf(RCore *core, const char *fmt, ...) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if R2_590
|
||||
// R_API
|
||||
int r_core_cmd_call_at(RCore *core, const char *cmd, ut64 addr) {
|
||||
ut64 oaddr = core->offset;
|
||||
if (addr != core->offset) {
|
||||
r_core_seek (core, addr, 1);
|
||||
}
|
||||
int res = r_cmd_call (core->rcmd, cmd);
|
||||
if (addr != core->offset) {
|
||||
r_core_seek (core, oaddr, 1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
// run an r2 command without evaluating any special character
|
||||
R_API int r_core_cmd_call(RCore *core, const char *cmd) {
|
||||
return r_cmd_call (core->rcmd, cmd);
|
||||
@ -6160,7 +6167,13 @@ R_API int r_core_cmd_task_sync(RCore *core, const char *cmd, bool log) {
|
||||
}
|
||||
|
||||
static int cmd_ox(void *data, const char *input) {
|
||||
return r_core_cmdf ((RCore*)data, "s 0%s", input);
|
||||
// return r_core_cmdf ((RCore*)data, "s 0%s", input);
|
||||
RCore *core = (RCore*)data;
|
||||
char *s = r_str_newf ("0%s", input);
|
||||
ut64 at = r_num_get (NULL, s);
|
||||
int ret = r_core_seek (core, at, 1);
|
||||
free (s);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int core_cmd0_wrapper(void *core, const char *cmd) {
|
||||
|
@ -545,6 +545,7 @@ static int cmd_meta_comment(RCore *core, const char *input) {
|
||||
r_str_ansi_strip (out);
|
||||
//r_meta_set (core->anal->meta, R_META_TYPE_COMMENT, addr, 0, out);
|
||||
r_core_cmdf (core, "CC-@0x%08"PFMT64x, addr);
|
||||
// R2_590 - r_core_cmd_call_at (core, "CC-", addr);
|
||||
//r_meta_del (core->anal->meta, input[0], addr, addr+1);
|
||||
r_meta_set_string (core->anal,
|
||||
R_META_TYPE_COMMENT, addr, out);
|
||||
@ -799,6 +800,7 @@ static int cmd_meta_others(RCore *core, const char *input) {
|
||||
if (out) {
|
||||
//r_meta_set (core->anal->meta, R_META_TYPE_COMMENT, addr, 0, out);
|
||||
r_core_cmdf (core, "CC-@0x%08"PFMT64x, addr);
|
||||
// R2_590 - r_core_cmd_call_at (core, "CC-", addr);
|
||||
//r_meta_del (core->anal->meta, input[0], addr, addr+1);
|
||||
r_meta_set_string (core->anal, R_META_TYPE_COMMENT, addr, out);
|
||||
free (out);
|
||||
|
@ -2096,7 +2096,7 @@ static void annotated_hexdump(RCore *core, const char *str, int len) {
|
||||
const int col = core->print->col;
|
||||
RFlagItem *curflag = NULL;
|
||||
char **note;
|
||||
int html = r_config_get_i (core->config, "scr.html");
|
||||
bool html = r_config_get_b (core->config, "scr.html");
|
||||
int nb_cons_cols;
|
||||
bool compact = false;
|
||||
|
||||
@ -2189,7 +2189,7 @@ static void annotated_hexdump(RCore *core, const char *str, int len) {
|
||||
append (ebytes, s);
|
||||
free (s);
|
||||
}
|
||||
ebytes += sprintf (ebytes, "0x%08"PFMT64x, ea);
|
||||
ebytes += snprintf (ebytes, 20, "0x%08"PFMT64x, ea);
|
||||
if (usecolor) {
|
||||
append (ebytes, Color_RESET);
|
||||
}
|
||||
@ -3093,7 +3093,7 @@ static void disasm_strings(RCore *core, const char *input, RAnalFunction *fcn) {
|
||||
}
|
||||
r_cons_pop ();
|
||||
|
||||
r_config_set_i (core->config, "scr.html", scr_html);
|
||||
r_config_set_b (core->config, "scr.html", scr_html);
|
||||
r_config_set_i (core->config, "scr.color", use_color);
|
||||
r_config_set_i (core->config, "asm.cmt.right", asm_cmt_right);
|
||||
count = r_str_split (s, '\n');
|
||||
|
@ -69,10 +69,10 @@ static bool __core_patch_bracket(RCore *core, const char *str, ut64 *noff) {
|
||||
break;
|
||||
}
|
||||
if ((q = strstr (str, "${"))) {
|
||||
char *end = strchr (q+2,'}');
|
||||
char *end = strchr (q + 2,'}');
|
||||
if (end) {
|
||||
*q = *end = 0;
|
||||
*noff = r_num_math (core->num, q+2);
|
||||
*noff = r_num_math (core->num, q + 2);
|
||||
r_buf_append_bytes (b, (const ut8*)str, strlen (str));
|
||||
snprintf (tmp, sizeof (tmp), "0x%08"PFMT64x, *noff);
|
||||
r_buf_append_bytes (b, (const ut8*)tmp, strlen (tmp));
|
||||
|
Loading…
Reference in New Issue
Block a user