Rizin
unix-like reverse engineering framework and cli tools
cmd_interpret.c File Reference
#include <rz_cmd.h>
#include <rz_core.h>
#include <cmd_descs.h>
#include "../core_private.h"

Go to the source code of this file.

Functions

RZ_IPI RzCmdStatus rz_interpret_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_interpret_output_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_repeat_forward_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_interpret_script_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_interpret_editor_2_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_interpret_pipe_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_interpret_macro_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_interpret_macro_multiple_handler (RzCore *core, int argc, const char **argv)
 

Function Documentation

◆ rz_interpret_editor_2_handler()

RZ_IPI RzCmdStatus rz_interpret_editor_2_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 58 of file cmd_interpret.c.

58  {
59  rz_core_run_script(core, "-");
60  return RZ_CMD_STATUS_OK;
61 }
RZ_API bool rz_core_run_script(RzCore *core, RZ_NONNULL const char *file)
Definition: cmd.c:457
@ RZ_CMD_STATUS_OK
command handler exited in the right way
Definition: rz_cmd.h:24

References RZ_CMD_STATUS_OK, and rz_core_run_script().

Referenced by rzshell_cmddescs_init().

◆ rz_interpret_handler()

RZ_IPI RzCmdStatus rz_interpret_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 9 of file cmd_interpret.c.

9  {
10  if (argc == 1) {
12  return RZ_CMD_STATUS_OK;
13  } else if (argc == 2) {
14  int tmp_html = rz_cons_singleton()->is_html;
16  char *cmd_output = rz_core_cmd_str(core, argv[1]);
17  rz_cons_singleton()->is_html = tmp_html;
18  if (!cmd_output) {
19  return RZ_CMD_STATUS_ERROR;
20  }
21  rz_core_cmd(core, cmd_output, 0);
22  free(cmd_output);
23  return RZ_CMD_STATUS_OK;
24  }
25  return RZ_CMD_STATUS_ERROR;
26 }
RZ_API int rz_core_cmd(RzCore *core, const char *cstr, int log)
Definition: cmd.c:5328
RZ_IPI bool rz_core_cmd_lastcmd_repeat(RzCore *core, bool next)
Definition: cmd.c:216
RZ_API char * rz_core_cmd_str(RzCore *core, const char *cmd)
Executes a rizin command and returns the stdout as a string.
Definition: cmd.c:5513
RZ_API RzCons * rz_cons_singleton(void)
Definition: cons.c:300
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
@ RZ_CMD_STATUS_ERROR
command handler had issues while running (e.g. allocation error, etc.)
Definition: rz_cmd.h:26
bool is_html
Definition: rz_cons.h:505

References argv, free(), rz_cons_t::is_html, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_singleton(), rz_core_cmd(), rz_core_cmd_lastcmd_repeat(), and rz_core_cmd_str().

Referenced by rzshell_cmddescs_init().

◆ rz_interpret_macro_handler()

RZ_IPI RzCmdStatus rz_interpret_macro_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 68 of file cmd_interpret.c.

68  {
69  rz_cmd_macro_call(&core->rcmd->macro, argv[1]);
70  return RZ_CMD_STATUS_OK;
71 }
RZ_API int rz_cmd_macro_call(RzCmdMacro *mac, const char *name)
Definition: cmd_api.c:1993
RzCmdMacro macro
Definition: rz_cmd.h:482
RzCmd * rcmd
Definition: rz_core.h:319

References argv, rz_cmd_t::macro, rz_core_t::rcmd, rz_cmd_macro_call(), and RZ_CMD_STATUS_OK.

Referenced by rzshell_cmddescs_init().

◆ rz_interpret_macro_multiple_handler()

RZ_IPI RzCmdStatus rz_interpret_macro_multiple_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 73 of file cmd_interpret.c.

73  {
75  return RZ_CMD_STATUS_OK;
76 }
RZ_API int rz_cmd_macro_call_multiple(RzCmdMacro *mac, const char *name)
Definition: cmd_api.c:1997

References argv, rz_cmd_t::macro, rz_core_t::rcmd, rz_cmd_macro_call_multiple(), and RZ_CMD_STATUS_OK.

Referenced by rzshell_cmddescs_init().

◆ rz_interpret_output_handler()

RZ_IPI RzCmdStatus rz_interpret_output_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 28 of file cmd_interpret.c.

28  {
29  char *str = rz_core_cmd_str_pipe(core, argv[1]);
30  if (!str) {
31  return RZ_CMD_STATUS_ERROR;
32  }
33  rz_core_cmd(core, str, 0);
34  free(str);
35  return RZ_CMD_STATUS_OK;
36 }
RZ_API char * rz_core_cmd_str_pipe(RzCore *core, const char *cmd)
Definition: cmd.c:5438

References argv, free(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_core_cmd(), rz_core_cmd_str_pipe(), and cmd_descs_generate::str.

Referenced by rzshell_cmddescs_init().

◆ rz_interpret_pipe_handler()

RZ_IPI RzCmdStatus rz_interpret_pipe_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 63 of file cmd_interpret.c.

63  {
64  rz_core_run_script(core, argv[1]);
65  return RZ_CMD_STATUS_OK;
66 }

References argv, RZ_CMD_STATUS_OK, and rz_core_run_script().

Referenced by rzshell_cmddescs_init().

◆ rz_interpret_script_handler()

RZ_IPI RzCmdStatus rz_interpret_script_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 43 of file cmd_interpret.c.

43  {
44  const char *script_file = argv[1];
45  if (*script_file == '$') {
46  rz_core_cmd0(core, script_file);
47  } else {
48  if (!rz_core_run_script(core, script_file)) {
49  eprintf("Cannot find script '%s'\n", script_file);
50  core->num->value = 1;
51  } else {
52  core->num->value = 0;
53  }
54  }
55  return RZ_CMD_STATUS_OK;
56 }
RZ_API int rz_core_cmd0(RzCore *core, const char *cmd)
Definition: cmd.c:5428
#define eprintf(x, y...)
Definition: rlcc.c:7
RzNum * num
Definition: rz_core.h:316
ut64 value
Definition: rz_num.h:63

References argv, eprintf, rz_core_t::num, RZ_CMD_STATUS_OK, rz_core_cmd0(), rz_core_run_script(), and rz_num_t::value.

Referenced by rzshell_cmddescs_init().

◆ rz_repeat_forward_handler()

RZ_IPI RzCmdStatus rz_repeat_forward_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 38 of file cmd_interpret.c.

38  {
40  return RZ_CMD_STATUS_OK;
41 }

References RZ_CMD_STATUS_OK, and rz_core_cmd_lastcmd_repeat().

Referenced by rzshell_cmddescs_init().