Rizin
unix-like reverse engineering framework and cli tools
cmd_quit.c File Reference
#include "rz_core.h"

Go to the source code of this file.

Macros

#define RZ_QUIT_VALUE_KILL   5
 
#define RZ_QUIT_VALUE_NOKILL   1
 
#define RZ_QUIT_VALUE_SAVE   10
 
#define RZ_QUIT_VALUE_NOSAVE   2
 

Functions

RZ_IPI RzCmdStatus rz_cmd_quit_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_quit_kill_save_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_quit_kill_nosave_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_quit_nokill_nosave_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_quit_nokill_save_handler (RzCore *core, int argc, const char **argv)
 
static int cmd_Quit (void *data, const char *input)
 
RZ_IPI RzCmdStatus rz_cmd_force_quit_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_cmd_force_quit_without_history_handler (RzCore *core, int argc, const char **argv)
 

Macro Definition Documentation

◆ RZ_QUIT_VALUE_KILL

#define RZ_QUIT_VALUE_KILL   5

Definition at line 6 of file cmd_quit.c.

◆ RZ_QUIT_VALUE_NOKILL

#define RZ_QUIT_VALUE_NOKILL   1

Definition at line 7 of file cmd_quit.c.

◆ RZ_QUIT_VALUE_NOSAVE

#define RZ_QUIT_VALUE_NOSAVE   2

Definition at line 9 of file cmd_quit.c.

◆ RZ_QUIT_VALUE_SAVE

#define RZ_QUIT_VALUE_SAVE   10

Definition at line 8 of file cmd_quit.c.

Function Documentation

◆ cmd_Quit()

static int cmd_Quit ( void *  data,
const char *  input 
)
static

Definition at line 37 of file cmd_quit.c.

37  {
38  RzCore *core = (RzCore *)data;
39  if (input[0] == '!') {
40  if (input[1] == '!') {
41  exit(0);
42  return -2;
43  }
44  rz_config_set(core->config, "scr.histsave", "false");
45  }
46  if (IS_DIGIT(input[0]) || input[0] == ' ') {
47  core->num->value = rz_num_math(core->num, input);
48  } else {
49  core->num->value = -1;
50  }
51  return -2;
52 }
RZ_API RzConfigNode * rz_config_set(RzConfig *cfg, RZ_NONNULL const char *name, const char *value)
Definition: config.c:267
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
Definition: unum.c:456
#define IS_DIGIT(x)
Definition: rz_str_util.h:11
RzNum * num
Definition: rz_core.h:316
RzConfig * config
Definition: rz_core.h:300
ut64 value
Definition: rz_num.h:63
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)

References rz_core_t::config, test-lz4-list::exit, input(), IS_DIGIT, rz_core_t::num, rz_config_set(), rz_num_math(), and rz_num_t::value.

Referenced by rz_cmd_force_quit_handler(), and rz_cmd_force_quit_without_history_handler().

◆ rz_cmd_force_quit_handler()

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

Definition at line 54 of file cmd_quit.c.

54  {
55  cmd_Quit(core, argv[0] + 1);
56  return RZ_CMD_STATUS_EXIT;
57 }
static int cmd_Quit(void *data, const char *input)
Definition: cmd_quit.c:37
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_EXIT
command handler asks to exit the prompt loop
Definition: rz_cmd.h:29

References argv, cmd_Quit(), and RZ_CMD_STATUS_EXIT.

Referenced by rzshell_cmddescs_init().

◆ rz_cmd_force_quit_without_history_handler()

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

Definition at line 59 of file cmd_quit.c.

59  {
60  cmd_Quit(core, argv[0] + 1);
61  return RZ_CMD_STATUS_EXIT;
62 }

References argv, cmd_Quit(), and RZ_CMD_STATUS_EXIT.

Referenced by rzshell_cmddescs_init().

◆ rz_cmd_quit_handler()

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

Definition at line 11 of file cmd_quit.c.

11  {
12  core->num->value = 0LL;
13  return RZ_CMD_STATUS_EXIT;
14 }

References rz_core_t::num, RZ_CMD_STATUS_EXIT, and rz_num_t::value.

Referenced by rzshell_cmddescs_init().

◆ rz_quit_kill_nosave_handler()

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

Definition at line 21 of file cmd_quit.c.

21  {
22  core->num->value = RZ_QUIT_VALUE_KILL;
23  core->num->value += RZ_QUIT_VALUE_NOSAVE;
24  return RZ_CMD_STATUS_EXIT;
25 }
#define RZ_QUIT_VALUE_NOSAVE
Definition: cmd_quit.c:9
#define RZ_QUIT_VALUE_KILL
Definition: cmd_quit.c:6

References rz_core_t::num, RZ_CMD_STATUS_EXIT, RZ_QUIT_VALUE_KILL, RZ_QUIT_VALUE_NOSAVE, and rz_num_t::value.

Referenced by rzshell_cmddescs_init().

◆ rz_quit_kill_save_handler()

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

Definition at line 16 of file cmd_quit.c.

16  {
17  core->num->value = RZ_QUIT_VALUE_KILL;
18  core->num->value += RZ_QUIT_VALUE_SAVE;
19  return RZ_CMD_STATUS_EXIT;
20 }
#define RZ_QUIT_VALUE_SAVE
Definition: cmd_quit.c:8

References rz_core_t::num, RZ_CMD_STATUS_EXIT, RZ_QUIT_VALUE_KILL, RZ_QUIT_VALUE_SAVE, and rz_num_t::value.

Referenced by rzshell_cmddescs_init().

◆ rz_quit_nokill_nosave_handler()

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

Definition at line 26 of file cmd_quit.c.

26  {
28  core->num->value += RZ_QUIT_VALUE_NOSAVE;
29  return RZ_CMD_STATUS_EXIT;
30 }
#define RZ_QUIT_VALUE_NOKILL
Definition: cmd_quit.c:7

References rz_core_t::num, RZ_CMD_STATUS_EXIT, RZ_QUIT_VALUE_NOKILL, RZ_QUIT_VALUE_NOSAVE, and rz_num_t::value.

Referenced by rzshell_cmddescs_init().

◆ rz_quit_nokill_save_handler()

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

Definition at line 31 of file cmd_quit.c.

31  {
33  core->num->value += RZ_QUIT_VALUE_SAVE;
34  return RZ_CMD_STATUS_EXIT;
35 }

References rz_core_t::num, RZ_CMD_STATUS_EXIT, RZ_QUIT_VALUE_NOKILL, RZ_QUIT_VALUE_SAVE, and rz_num_t::value.

Referenced by rzshell_cmddescs_init().