2014-05-27 23:07:02 +00:00
|
|
|
/* radare - LGPL - Copyright 2009-2014 - pancake */
|
2016-05-03 02:52:41 +00:00
|
|
|
#include "r_core.h"
|
2014-05-27 23:07:02 +00:00
|
|
|
|
|
|
|
static int cmd_quit(void *data, const char *input) {
|
|
|
|
RCore *core = (RCore *)data;
|
2014-06-20 09:10:27 +00:00
|
|
|
const char* help_msg[] = {
|
2015-01-17 18:32:19 +00:00
|
|
|
"Usage:", "q[!][!] [retval]", "",
|
2014-06-20 09:10:27 +00:00
|
|
|
"q","","quit program",
|
|
|
|
"q!","","force quit (no questions)",
|
2015-01-17 18:32:19 +00:00
|
|
|
"q!!","","force quit without saving history",
|
2014-06-20 09:10:27 +00:00
|
|
|
"q"," 1","quit with return value 1",
|
|
|
|
"q"," a-b","quit with return value a-b",
|
2016-07-10 14:29:20 +00:00
|
|
|
"q[y/n][y/n]","","quit, chose to kill process, chose to save project ",
|
2014-06-20 09:10:27 +00:00
|
|
|
NULL};
|
2014-05-27 23:07:02 +00:00
|
|
|
if (input)
|
|
|
|
switch (*input) {
|
|
|
|
case '?':
|
2014-06-20 09:10:27 +00:00
|
|
|
r_core_cmd_help (core, help_msg);
|
2014-05-27 23:07:02 +00:00
|
|
|
break;
|
|
|
|
case '!':
|
2016-07-10 14:29:20 +00:00
|
|
|
if (input[1] == '!') {
|
2015-01-17 18:32:19 +00:00
|
|
|
r_config_set (core->config, "scr.histsave", "false");
|
2016-07-10 14:29:20 +00:00
|
|
|
}
|
2014-11-08 12:15:45 +00:00
|
|
|
core->num->value = -1;
|
|
|
|
return -2;
|
2014-05-27 23:07:02 +00:00
|
|
|
case '\0':
|
2014-11-09 17:28:10 +00:00
|
|
|
core->num->value = 0LL;
|
|
|
|
return -2;
|
2014-05-27 23:07:02 +00:00
|
|
|
default:
|
2016-07-10 14:29:20 +00:00
|
|
|
while (*input == ' ') {
|
2014-11-09 17:28:10 +00:00
|
|
|
input++;
|
2016-07-10 14:29:20 +00:00
|
|
|
}
|
|
|
|
if (*input) {
|
2014-05-27 23:07:02 +00:00
|
|
|
r_num_math (core->num, input);
|
2016-07-10 14:29:20 +00:00
|
|
|
} else {
|
|
|
|
core->num->value = 0LL;
|
|
|
|
}
|
2016-07-25 08:37:51 +00:00
|
|
|
|
2016-07-10 14:29:20 +00:00
|
|
|
if (*input == 'y') {
|
|
|
|
core->num->value = 5;
|
|
|
|
} else if (*input == 'n') {
|
|
|
|
core->num->value = 1;
|
|
|
|
}
|
2016-07-25 08:37:51 +00:00
|
|
|
|
2016-07-10 14:29:20 +00:00
|
|
|
if (input[1] == 'y') {
|
|
|
|
core->num->value += 10;
|
|
|
|
} else if (input[1] == 'n') {
|
|
|
|
core->num->value += 2;
|
|
|
|
}
|
2014-05-27 23:07:02 +00:00
|
|
|
//exit (*input?r_num_math (core->num, input+1):0);
|
2016-07-12 20:15:19 +00:00
|
|
|
//if (core->http_up) return false; // cancel quit when http is running
|
2014-05-27 23:07:02 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2016-07-12 20:15:19 +00:00
|
|
|
return false;
|
2014-05-27 23:07:02 +00:00
|
|
|
}
|