Rizin
unix-like reverse engineering framework and cli tools
cmd_quit.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2016 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include "rz_core.h"
5 
6 #define RZ_QUIT_VALUE_KILL 5
7 #define RZ_QUIT_VALUE_NOKILL 1
8 #define RZ_QUIT_VALUE_SAVE 10
9 #define RZ_QUIT_VALUE_NOSAVE 2
10 
11 RZ_IPI RzCmdStatus rz_cmd_quit_handler(RzCore *core, int argc, const char **argv) {
12  core->num->value = 0LL;
13  return RZ_CMD_STATUS_EXIT;
14 }
15 
16 RZ_IPI RzCmdStatus rz_quit_kill_save_handler(RzCore *core, int argc, const char **argv) {
17  core->num->value = RZ_QUIT_VALUE_KILL;
18  core->num->value += RZ_QUIT_VALUE_SAVE;
19  return RZ_CMD_STATUS_EXIT;
20 }
21 RZ_IPI RzCmdStatus rz_quit_kill_nosave_handler(RzCore *core, int argc, const char **argv) {
22  core->num->value = RZ_QUIT_VALUE_KILL;
23  core->num->value += RZ_QUIT_VALUE_NOSAVE;
24  return RZ_CMD_STATUS_EXIT;
25 }
28  core->num->value += RZ_QUIT_VALUE_NOSAVE;
29  return RZ_CMD_STATUS_EXIT;
30 }
31 RZ_IPI RzCmdStatus rz_quit_nokill_save_handler(RzCore *core, int argc, const char **argv) {
33  core->num->value += RZ_QUIT_VALUE_SAVE;
34  return RZ_CMD_STATUS_EXIT;
35 }
36 
37 static int cmd_Quit(void *data, const char *input) {
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 }
53 
54 RZ_IPI RzCmdStatus rz_cmd_force_quit_handler(RzCore *core, int argc, const char **argv) {
55  cmd_Quit(core, argv[0] + 1);
56  return RZ_CMD_STATUS_EXIT;
57 }
58 
60  cmd_Quit(core, argv[0] + 1);
61  return RZ_CMD_STATUS_EXIT;
62 }
#define RZ_IPI
Definition: analysis_wasm.c:11
RZ_IPI RzCmdStatus rz_quit_kill_nosave_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_quit.c:21
#define RZ_QUIT_VALUE_NOSAVE
Definition: cmd_quit.c:9
#define RZ_QUIT_VALUE_NOKILL
Definition: cmd_quit.c:7
RZ_IPI RzCmdStatus rz_quit_nokill_nosave_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_quit.c:26
static int cmd_Quit(void *data, const char *input)
Definition: cmd_quit.c:37
#define RZ_QUIT_VALUE_SAVE
Definition: cmd_quit.c:8
RZ_IPI RzCmdStatus rz_cmd_force_quit_without_history_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_quit.c:59
#define RZ_QUIT_VALUE_KILL
Definition: cmd_quit.c:6
RZ_IPI RzCmdStatus rz_cmd_quit_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_quit.c:11
RZ_IPI RzCmdStatus rz_quit_nokill_save_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_quit.c:31
RZ_IPI RzCmdStatus rz_quit_kill_save_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_quit.c:16
RZ_IPI RzCmdStatus rz_cmd_force_quit_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_quit.c:54
RZ_API RzConfigNode * rz_config_set(RzConfig *cfg, RZ_NONNULL const char *name, const char *value)
Definition: config.c:267
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
enum rz_cmd_status_t RzCmdStatus
@ RZ_CMD_STATUS_EXIT
command handler asks to exit the prompt loop
Definition: rz_cmd.h:29
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)