Rizin
unix-like reverse engineering framework and cli tools
cmd_block.c File Reference
#include <rz_core.h>

Go to the source code of this file.

Functions

RZ_IPI RzCmdStatus rz_block_handler (RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_block_decrease_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_block_increase_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_block_flag_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_block_max_handler (RzCore *core, int argc, const char **argv)
 

Function Documentation

◆ rz_block_decrease_handler()

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

Definition at line 34 of file cmd_block.c.

34  {
35  ut64 n = rz_num_math(core->num, argv[1]);
36  rz_core_block_size(core, core->blocksize - n);
37  return RZ_CMD_STATUS_OK;
38 }
RZ_API bool rz_core_block_size(RzCore *core, ut32 bsize)
Definition: core.c:2842
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
int n
Definition: mipsasm.c:19
@ RZ_CMD_STATUS_OK
command handler exited in the right way
Definition: rz_cmd.h:24
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
Definition: unum.c:456
RzNum * num
Definition: rz_core.h:316
ut32 blocksize
Definition: rz_core.h:303
ut64(WINAPI *w32_GetEnabledXStateFeatures)()

References argv, rz_core_t::blocksize, n, rz_core_t::num, RZ_CMD_STATUS_OK, rz_core_block_size(), rz_num_math(), and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_block_flag_handler()

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

Definition at line 46 of file cmd_block.c.

46  {
47  RzFlagItem *flag = rz_flag_get(core->flags, argv[1]);
48  if (!flag) {
49  RZ_LOG_ERROR("Cannot find flag named \"%s\"", argv[1]);
50  return RZ_CMD_STATUS_ERROR;
51  }
52  rz_core_block_size(core, flag->size);
53  return RZ_CMD_STATUS_OK;
54 }
RZ_API RzFlagItem * rz_flag_get(RzFlag *f, const char *name)
Definition: flag.c:310
@ RZ_CMD_STATUS_ERROR
command handler had issues while running (e.g. allocation error, etc.)
Definition: rz_cmd.h:26
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
RzFlag * flags
Definition: rz_core.h:330

References argv, rz_core_t::flags, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_core_block_size(), rz_flag_get(), RZ_LOG_ERROR, and rz_flag_item_t::size.

Referenced by rzshell_cmddescs_init().

◆ rz_block_handler()

RZ_IPI RzCmdStatus rz_block_handler ( RzCore core,
int  argc,
const char **  argv,
RzCmdStateOutput state 
)

Definition at line 6 of file cmd_block.c.

6  {
7  if (argc > 1) {
8  ut64 newsize = rz_num_math(core->num, argv[1]);
9  rz_core_block_size(core, newsize);
10  } else {
11  switch (state->mode) {
12  case RZ_OUTPUT_MODE_JSON: {
13  PJ *pj = state->d.pj;
14  pj_o(pj);
15  pj_ki(pj, "blocksize", core->blocksize);
16  pj_ki(pj, "blocksize_limit", core->blocksize_max);
17  pj_end(pj);
18  break;
19  }
21  rz_cons_printf("b 0x%x\n", core->blocksize);
22  break;
24  rz_cons_printf("0x%x\n", core->blocksize);
25  break;
26  default:
28  break;
29  }
30  }
31  return RZ_CMD_STATUS_OK;
32 }
RZ_API int rz_cons_printf(const char *format,...)
Definition: cons.c:1202
#define rz_warn_if_reached()
Definition: rz_assert.h:29
RZ_API PJ * pj_ki(PJ *j, const char *k, int d)
Definition: pj.c:149
RZ_API PJ * pj_end(PJ *j)
Definition: pj.c:87
RZ_API PJ * pj_o(PJ *j)
Definition: pj.c:75
@ RZ_OUTPUT_MODE_JSON
Definition: rz_types.h:40
@ RZ_OUTPUT_MODE_RIZIN
Definition: rz_types.h:41
@ RZ_OUTPUT_MODE_STANDARD
Definition: rz_types.h:39
Definition: rz_pj.h:12
ut32 blocksize_max
Definition: rz_core.h:304
Definition: dis.h:43

References argv, rz_core_t::blocksize, rz_core_t::blocksize_max, rz_core_t::num, pj_end(), pj_ki(), pj_o(), RZ_CMD_STATUS_OK, rz_cons_printf(), rz_core_block_size(), rz_num_math(), RZ_OUTPUT_MODE_JSON, RZ_OUTPUT_MODE_RIZIN, RZ_OUTPUT_MODE_STANDARD, rz_warn_if_reached, and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_block_increase_handler()

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

Definition at line 40 of file cmd_block.c.

40  {
41  ut64 n = rz_num_math(core->num, argv[1]);
42  rz_core_block_size(core, core->blocksize + n);
43  return RZ_CMD_STATUS_OK;
44 }

References argv, rz_core_t::blocksize, n, rz_core_t::num, RZ_CMD_STATUS_OK, rz_core_block_size(), rz_num_math(), and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_block_max_handler()

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

Definition at line 56 of file cmd_block.c.

56  {
57  if (argc > 1) {
58  ut64 n = rz_num_math(core->num, argv[1]);
59  core->blocksize_max = n;
60  } else {
61  rz_cons_printf("0x%x\n", core->blocksize_max);
62  }
63  return RZ_CMD_STATUS_OK;
64 }

References argv, rz_core_t::blocksize_max, n, rz_core_t::num, RZ_CMD_STATUS_OK, rz_cons_printf(), rz_num_math(), and ut64().

Referenced by rzshell_cmddescs_init().