Skip to content

Commit

Permalink
Swap = & - R (rizinorg#615)&(rizinorg#616)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanachao committed Apr 18, 2021
1 parent 18e224e commit 7e7ca05
Show file tree
Hide file tree
Showing 202 changed files with 1,550 additions and 1,529 deletions.
2 changes: 1 addition & 1 deletion binrz/rz-test/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ RZ_API RzSubprocessOutput *rz_test_run_cmd_test(RzTestRunConfig *config, RzCmdTe
} else {
files->free = NULL;
}
rz_list_push(files, "-");
rz_list_push(files, "=");
}
ut64 timeout_ms = test->timeout.set ? test->timeout.value * 1000 : config->timeout_ms;
RzSubprocessOutput *out = run_rz_test(config, timeout_ms, test->cmds.value, files, extra_args, test->load_plugins, runner, user);
Expand Down
2 changes: 1 addition & 1 deletion librz/core/cdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,5 +581,5 @@ RZ_IPI void rz_core_debug_attach(RzCore *core, int pid) {
}
rz_debug_select(core->dbg, core->dbg->pid, core->dbg->tid);
rz_config_set_i(core->config, "dbg.swstep", (core->dbg->h && !core->dbg->h->canstep));
rz_core_cmdf(core, "=! \"pid %d\"", core->dbg->pid);
rz_core_cmdf(core, "R! \"pid %d\"", core->dbg->pid);
}
4 changes: 2 additions & 2 deletions librz/core/cfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ RZ_API RzCoreFile *rz_core_file_open(RzCore *r, const char *file, int flags, ut6
const bool openmany = rz_config_get_i(r->config, "file.openmany");
RzCoreFile *fh = NULL;

if (!strcmp(file, "-")) {
if (!strcmp(file, "=")) {
file = "malloc://512";
}
//if not flags was passed open it with -r--
Expand Down Expand Up @@ -1186,7 +1186,7 @@ RZ_API RzCoreFile *rz_core_file_open(RzCore *r, const char *file, int flags, ut6
if (loadaddr != UT64_MAX) {
rz_config_set_i(r->config, "bin.laddr", loadaddr);
}
rz_core_cmd0(r, "=!");
rz_core_cmd0(r, "R!");
beach:
r->times->file_open_time = rz_time_now_mono() - prev;
return fh;
Expand Down
2 changes: 1 addition & 1 deletion librz/core/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -6625,7 +6625,7 @@ RZ_API void rz_core_cmd_init(RzCore *core) {
{ "-", "open cfg.editor and run script", rz_cmd_stdin },
{ ".", "interpret", rz_cmd_interpret },
{ "/", "search kw, pattern aes", rz_cmd_search },
{ "=", "io pipe", rz_cmd_remote },
{ "R", "io pipe", rz_cmd_remote },
{ "?", "help message", rz_cmd_help },
{ "<", "pipe into RzCons.readChar", rz_cmd_pipein },
{ "0", "alias for s 0x", rz_cmd_ox },
Expand Down
2 changes: 1 addition & 1 deletion librz/core/cmd_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ RZ_API int rz_cmd_call(RzCmd *cmd, const char *input) {
rz_cons_strcat(ji + 1);
return true;
} else {
nstr = rz_str_newf("=! %s", input);
nstr = rz_str_newf("R! %s", input);
input = nstr;
}
}
Expand Down
32 changes: 16 additions & 16 deletions librz/core/cmd_descs/cmd_descs.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ static const RzCmdDescHelp cmd_search_help = {
.summary = "Search for bytes, regexps, patterns, ..",
};

static const RzCmdDescHelp equal__help = {
static const RzCmdDescHelp R_help = {
.summary = "Connect with other instances of rizin",
};
static const RzCmdDescArg remote_args[] = {
Expand Down Expand Up @@ -3971,45 +3971,45 @@ RZ_IPI void newshell_cmddescs_init(RzCore *core) {
RzCmdDesc *cmd_search_cd = rz_cmd_desc_oldinput_new(core->rcmd, root_cd, "/", rz_cmd_search, &cmd_search_help);
rz_warn_if_fail(cmd_search_cd);

RzCmdDesc *equal__cd = rz_cmd_desc_group_new(core->rcmd, root_cd, "=", rz_remote_handler, &remote_help, &equal__help);
rz_warn_if_fail(equal__cd);
RzCmdDesc *remote_send_cd = rz_cmd_desc_argv_new(core->rcmd, equal__cd, "=<", rz_remote_send_handler, &remote_send_help);
RzCmdDesc *R_cd = rz_cmd_desc_group_new(core->rcmd, root_cd, "R", rz_remote_handler, &remote_help, &R_help);
rz_warn_if_fail(R_cd);
RzCmdDesc *remote_send_cd = rz_cmd_desc_argv_new(core->rcmd, R_cd, "R<", rz_remote_send_handler, &remote_send_help);
rz_warn_if_fail(remote_send_cd);

RzCmdDesc *io_system_run_oldhandler_cd = rz_cmd_desc_oldinput_new(core->rcmd, equal__cd, "=!", rz_io_system_run_oldhandler, &io_system_run_oldhandler_help);
RzCmdDesc *io_system_run_oldhandler_cd = rz_cmd_desc_oldinput_new(core->rcmd, R_cd, "R!", rz_io_system_run_oldhandler, &io_system_run_oldhandler_help);
rz_warn_if_fail(io_system_run_oldhandler_cd);

RzCmdDesc *remote_add_cd = rz_cmd_desc_argv_new(core->rcmd, equal__cd, "=+", rz_remote_add_handler, &remote_add_help);
RzCmdDesc *remote_add_cd = rz_cmd_desc_argv_new(core->rcmd, R_cd, "R+", rz_remote_add_handler, &remote_add_help);
rz_warn_if_fail(remote_add_cd);

RzCmdDesc *remote_del_cd = rz_cmd_desc_argv_new(core->rcmd, equal__cd, "=-", rz_remote_del_handler, &remote_del_help);
RzCmdDesc *remote_del_cd = rz_cmd_desc_argv_new(core->rcmd, R_cd, "R-", rz_remote_del_handler, &remote_del_help);
rz_warn_if_fail(remote_del_cd);

RzCmdDesc *remote_open_cd = rz_cmd_desc_argv_new(core->rcmd, equal__cd, "==", rz_remote_open_handler, &remote_open_help);
RzCmdDesc *remote_open_cd = rz_cmd_desc_argv_new(core->rcmd, R_cd, "R=", rz_remote_open_handler, &remote_open_help);
rz_warn_if_fail(remote_open_cd);

RzCmdDesc *remote_mode_enable_cd = rz_cmd_desc_argv_new(core->rcmd, equal__cd, "=!=", rz_remote_mode_enable_handler, &remote_mode_enable_help);
RzCmdDesc *remote_mode_enable_cd = rz_cmd_desc_argv_new(core->rcmd, R_cd, "R!=", rz_remote_mode_enable_handler, &remote_mode_enable_help);
rz_warn_if_fail(remote_mode_enable_cd);

RzCmdDesc *remote_mode_disable_cd = rz_cmd_desc_argv_new(core->rcmd, equal__cd, "!=!", rz_remote_mode_disable_handler, &remote_mode_disable_help);
RzCmdDesc *remote_mode_disable_cd = rz_cmd_desc_argv_new(core->rcmd, R_cd, "R=!", rz_remote_mode_disable_handler, &remote_mode_disable_help);
rz_warn_if_fail(remote_mode_disable_cd);

RzCmdDesc *remote_rap_cd = rz_cmd_desc_argv_new(core->rcmd, equal__cd, "=r", rz_remote_rap_handler, &remote_rap_help);
RzCmdDesc *remote_rap_cd = rz_cmd_desc_argv_new(core->rcmd, R_cd, "Rr", rz_remote_rap_handler, &remote_rap_help);
rz_warn_if_fail(remote_rap_cd);

RzCmdDesc *equal_g_handler_old_cd = rz_cmd_desc_oldinput_new(core->rcmd, equal__cd, "=g", rz_equal_g_handler_old, &equal_g_handler_old_help);
RzCmdDesc *equal_g_handler_old_cd = rz_cmd_desc_oldinput_new(core->rcmd, R_cd, "Rg", rz_equal_g_handler_old, &equal_g_handler_old_help);
rz_warn_if_fail(equal_g_handler_old_cd);

RzCmdDesc *equal_h_handler_old_cd = rz_cmd_desc_oldinput_new(core->rcmd, equal__cd, "=h", rz_equal_h_handler_old, &equal_h_handler_old_help);
RzCmdDesc *equal_h_handler_old_cd = rz_cmd_desc_oldinput_new(core->rcmd, R_cd, "Rh", rz_equal_h_handler_old, &equal_h_handler_old_help);
rz_warn_if_fail(equal_h_handler_old_cd);

RzCmdDesc *equal_H_handler_old_cd = rz_cmd_desc_oldinput_new(core->rcmd, equal__cd, "=H", rz_equal_H_handler_old, &equal_H_handler_old_help);
RzCmdDesc *equal_H_handler_old_cd = rz_cmd_desc_oldinput_new(core->rcmd, R_cd, "RH", rz_equal_H_handler_old, &equal_H_handler_old_help);
rz_warn_if_fail(equal_H_handler_old_cd);

RzCmdDesc *remote_tcp_cd = rz_cmd_desc_argv_new(core->rcmd, equal__cd, "=t", rz_remote_tcp_handler, &remote_tcp_help);
RzCmdDesc *remote_tcp_cd = rz_cmd_desc_argv_new(core->rcmd, R_cd, "Rt", rz_remote_tcp_handler, &remote_tcp_help);
rz_warn_if_fail(remote_tcp_cd);

RzCmdDesc *remote_rap_bg_cd = rz_cmd_desc_argv_new(core->rcmd, equal__cd, "=&r", rz_remote_rap_bg_handler, &remote_rap_bg_help);
RzCmdDesc *remote_rap_bg_cd = rz_cmd_desc_argv_new(core->rcmd, R_cd, "R&r", rz_remote_rap_bg_handler, &remote_rap_bg_help);
rz_warn_if_fail(remote_rap_bg_cd);

RzCmdDesc *cmd_help_search_cd = rz_cmd_desc_argv_modes_new(core->rcmd, root_cd, "?*", RZ_OUTPUT_MODE_STANDARD | RZ_OUTPUT_MODE_JSON, rz_cmd_help_search_handler, &cmd_help_search_help);
Expand Down
2 changes: 1 addition & 1 deletion librz/core/cmd_descs/cmd_descs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ commands:
cname: cmd_search
summary: Search for bytes, regexps, patterns, ..
type: RZ_CMD_DESC_TYPE_OLDINPUT
- name: "="
- name: "R"
summary: Connect with other instances of rizin
subcommands: cmd_remote
- name: "?*"
Expand Down
28 changes: 14 additions & 14 deletions librz/core/cmd_descs/cmd_remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
---
name: cmd_remote
commands:
- name: "="
- name: "R"
cname: remote
summary: List all open connections / Exec <cmd> at remote <fd>
args_str: " [[<fd>] <cmd>]"
Expand All @@ -13,7 +13,7 @@ commands:
optional: true
- name: cmd
type: RZ_CMD_ARG_TYPE_CMD
- name: =<
- name: R<
cname: remote_send
summary: Send output of local <cmd> to remote <fd>
args:
Expand All @@ -22,43 +22,43 @@ commands:
optional: true
- name: cmd
type: RZ_CMD_ARG_TYPE_CMD
- name: =!
- name: R!
cname: io_system_run_oldhandler
summary: Run <cmd> via rz_io_system
type: RZ_CMD_DESC_TYPE_OLDINPUT
args_str: "[<cmd>]"
options: ""
- name: =+
- name: R+
cname: remote_add
summary: Connect to remote host:port
args:
- name: "[proto://]host:port"
type: RZ_CMD_ARG_TYPE_STRING
- name: =-
- name: R-
cname: remote_del
summary: remove all hosts or host 'fd'
args:
- name: fd
type: RZ_CMD_ARG_TYPE_NUM
optional: true
- name: ==
- name: R=
cname: remote_open
summary: Open remote session with host 'fd', 'q' to quit
args:
- name: fd
type: RZ_CMD_ARG_TYPE_NUM
- name: =!=
- name: R!=
cname: remote_mode_enable
summary: Enable remote cmd mode, sending commands to remote <fd> server
args:
- name: fd
type: RZ_CMD_ARG_TYPE_NUM
default_value: "0"
- name: "!=!"
- name: "R=!"
cname: remote_mode_disable
summary: Disable remote cmd mode
args: []
- name: "=r"
- name: "Rr"
cname: remote_rap
summary: Start the rap server (o rap://9999) / Execute <cmd> on rap server
args:
Expand All @@ -67,19 +67,19 @@ commands:
- name: cmd
type: RZ_CMD_ARG_TYPE_CMD
optional: true
- name: =g
- name: Rg
cname: equal_g_handler_old
summary: Start the gdbserver
type: RZ_CMD_DESC_TYPE_OLDINPUT
- name: =h
- name: Rh
cname: equal_h_handler_old
summary: Start the http webserver
type: RZ_CMD_DESC_TYPE_OLDINPUT
- name: =H
- name: RH
cname: equal_H_handler_old
summary: Start the http webserver (and launch the web browser)
type: RZ_CMD_DESC_TYPE_OLDINPUT
- name: =t
- name: Rt
cname: remote_tcp
summary: Start the tcp server
args:
Expand All @@ -88,7 +88,7 @@ commands:
- name: cmd
type: RZ_CMD_ARG_TYPE_CMD
optional: true
- name: "=&r"
- name: "R&r"
cname: remote_rap_bg
summary: Start rap server in background (same as '&_=h')
args:
Expand Down
83 changes: 41 additions & 42 deletions librz/core/cmd_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,52 @@
#include "rz_core.h"

static const char *help_msg_equal[] = {
"Usage:", " =[:!+-=ghH] [...]", " # connect with other instances of rizin",
"Usage:", " R[:!+-=ghH] [...]", " # connect with other instances of rizin",
"\nremote commands:", "", "",
"=", "", "list all open connections",
"=<", "[fd] cmd", "send output of local command to remote fd", // XXX may not be a special char
"=", "[fd] cmd", "exec cmd at remote 'fd' (last open is default one)",
"=!", " cmd", "run command via rz_io_system",
"=+", " [proto://]host:port", "connect to remote host:port (*rap://, raps://, tcp://, udp://, http://)",
"=-", "[fd]", "remove all hosts or host 'fd'",
"==", "[fd]", "open remote session with host 'fd', 'q' to quit",
"=!=", "", "disable remote cmd mode",
"!=!", "", "enable remote cmd mode",
"R", "", "list all open connections",
"R<", "[fd] cmd", "send output of local command to remote fd", // XXX may not be a special char
"R", "[fd] cmd", "exec cmd at remote 'fd' (last open is default one)",
"R!", " cmd", "run command via rz_io_system",
"R+", " [proto://]host:port", "connect to remote host:port (*rap://, raps://, tcp://, udp://, http://)",
"R-", "[fd]", "remove all hosts or host 'fd'",
"R=", "[fd]", "open remote session with host 'fd', 'q' to quit",
"R!=", "", "disable remote cmd mode",
"R=!", "", "enable remote cmd mode",
"\nservers:", "", "",
".:", "9000", "start the tcp server (echo x|nc ::1 9090 or curl ::1:9090/cmd/x)",
"=:", "port", "start the rap server (o rap://9999)",
"=g", "[?]", "start the gdbserver",
"=h", "[?]", "start the http webserver",
"=H", "[?]", "start the http webserver (and launch the web browser)",
"R:", "port", "start the rap server (o rap://9999)",
"Rg", "[?]", "start the gdbserver",
"Rh", "[?]", "start the http webserver",
"RH", "[?]", "start the http webserver (and launch the web browser)",
"\nother:", "", "",
"=&", ":port", "start rap server in background (same as '&_=h')",
"=", ":host:port cmd", "run 'cmd' command on remote server",
"R&", ":port", "start rap server in background (same as '&_=h')",
"R", ":host:port cmd", "run 'cmd' command on remote server",
"\nexamples:", "", "",
"=+", "tcp://localhost:9090/", "connect to: rizin -c.:9090 ./bin",
// "=+", "udp://localhost:9090/", "connect to: rizin -c.:9090 ./bin",
"=+", "rap://localhost:9090/", "connect to: rizin rap://:9090",
"=+", "http://localhost:9090/cmd/", "connect to: rizin -c'=h 9090' bin",
"R+", "tcp://localhost:9090/", "connect to: rizin -c.:9090 ./bin",
"R+", "rap://localhost:9090/", "connect to: rizin rap://:9090",
"R+", "http://localhost:9090/cmd/", "connect to: rizin -c'=h 9090' bin",
"o ", "rap://:9090/", "start the rap server on tcp port 9090",
NULL
};

static const char *help_msg_equalh[] = {
"Usage:", " =[hH] [...]", " # http server",
"Usage:", " R[hH] [...]", " # http server",
"http server:", "", "",
"=h", " port", "listen for http connections (rizin -qc=H /bin/ls)",
"=h-", "", "stop background webserver",
"=h--", "", "stop foreground webserver",
"=h*", "", "restart current webserver",
"=h&", " port", "start http server in background",
"=H", " port", "launch browser and listen for http",
"=H&", " port", "launch browser and listen for http in background",
"Rh", " port", "listen for http connections (rizin -qc=H /bin/ls)",
"Rh-", "", "stop background webserver",
"Rh--", "", "stop foreground webserver",
"Rh*", "", "restart current webserver",
"Rh&", " port", "start http server in background",
"RH", " port", "launch browser and listen for http",
"RH&", " port", "launch browser and listen for http in background",
NULL
};

static const char *help_msg_equalg[] = {
"Usage:", " =[g] [...]", " # gdb server",
"Usage:", " R[g] [...]", " # gdb server",
"gdbserver:", "", "",
"=g", " port file [args]", "listen on 'port' debugging 'file' using gdbserver",
"=g!", " port file [args]", "same as above, but debug protocol messages (like gdbserver --remote-debug)",
"Rg", " port file [args]", "listen on 'port' debugging 'file' using gdbserver",
"Rg!", " port file [args]", "same as above, but debug protocol messages (like gdbserver --remote-debug)",
NULL
};

Expand Down Expand Up @@ -100,13 +99,13 @@ RZ_IPI int rz_equal_H_handler_old(void *data, const char *input) {
RZ_IPI int rz_cmd_remote(void *data, const char *input) {
RzCore *core = (RzCore *)data;
switch (*input) {
case '\0': // "="
case '\0': // "R"
rz_core_rtr_list(core);
break;
case 'j': // "=j"
case 'j': // "Rj"
eprintf("TODO: list connections in json\n");
break;
case '!': // "=!"
case '!': // "R!"
if (input[1] == 'q') {
RZ_FREE(core->cmdremote);
} else if (input[1] == '=') { // =!=0 or =!= for iosystem
Expand All @@ -120,29 +119,29 @@ RZ_IPI int rz_cmd_remote(void *data, const char *input) {
}
}
break;
case '+': // "=+"
case '+': // "R+"
rz_core_rtr_add(core, input + 1);
break;
case '-': // "=-"
case '-': // "R-"
rz_core_rtr_remove(core, input + 1);
break;
//case ':': rz_core_rtr_cmds (core, input + 1); break;
case '<': // "=<"
case '<': // "R<"
rz_core_rtr_pushout(core, input + 1);
break;
case '=': // "=="
case '=': // "R="
rz_core_rtr_session(core, input + 1);
break;
case 'g': // "=g"
case 'g': // "Rg"
rz_equal_g_handler_old(core, input + 1);
break;
case 'h': // "=h"
case 'h': // "Rh"
rz_equal_h_handler_old(core, input + 1);
break;
case 'H': // "=H"
case 'H': // "RH"
rz_equal_H_handler_old(core, input + 1);
break;
case '?': // "=?"
case '?': // "R?"
rz_core_cmd_help(core, help_msg_equal);
break;
default:
Expand Down
4 changes: 2 additions & 2 deletions librz/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ static const char *rizin_argv[] = {
"*?", "*", "$",
"(", "(*", "(-", "()", ".?", ".", "..", "...", ".:", ".--", ".-", ".!", ".(", "./", ".*",
"_?", "_",
"=?", "=", "=<", "=!", "=+", "=-", "==", "=!=", "!=!", "=:", "=&:",
"R?", "R", "R<", "R!", "R+", "R-", "R=", "R!=", "R=!", "R:", "R&:",
"=g?", "=g", "=g!", "=h?", "=h", "=h-", "=h--", "=h*", "=h&", "=H?", "=H", "=H&",
"<",
"/?", "/", "/j", "/j!", "/j!x", "/+", "//", "/a", "/a1", "/ab", "/ad", "/aa", "/as", "/asl", "/at", "/atl", "/af", "/afl", "/ae", "/aej", "/ai", "/aij",
Expand Down Expand Up @@ -2733,7 +2733,7 @@ static void set_prompt(RzCore *r) {
char *s = rz_core_cmd_str(r, "s");
r->offset = rz_num_math(NULL, s);
free(s);
remote = "=!";
remote = "R!";
}

if (rz_config_get_i(r->config, "scr.color")) {
Expand Down
Loading

0 comments on commit 7e7ca05

Please sign in to comment.