mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-28 15:41:38 +00:00
Implement {flag} to get flag size
This commit is contained in:
parent
cbeff990a1
commit
38d6dada8d
@ -157,6 +157,7 @@ static const char *help_msg_question_v[] = {
|
||||
"$w", "", "get word size, 4 if asm.bits=32, 8 if 64, ...",
|
||||
"${ev}", "", "get value of eval config variable",
|
||||
"$k{kv}", "", "get value of an sdb query value",
|
||||
"$s{flag}", "", "get size of flag",
|
||||
"RNum", "", "$variables usable in math expressions",
|
||||
NULL
|
||||
};
|
||||
|
@ -412,7 +412,7 @@ static const char *str_callback(RNum *user, ut64 off, int *ok) {
|
||||
static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
|
||||
RCore *core = (RCore *)userptr; // XXX ?
|
||||
RAnalFunction *fcn;
|
||||
char *ptr, *bptr, *out;
|
||||
char *ptr, *bptr, *out = NULL;
|
||||
RFlagItem *flag;
|
||||
RIOSection *s;
|
||||
RAnalOp op;
|
||||
@ -583,7 +583,22 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
|
||||
case 'l': return op.size;
|
||||
case 'b': return core->blocksize;
|
||||
case 's':
|
||||
if (core->file) {
|
||||
// flag size $s{}
|
||||
if (str[2] == '{') {
|
||||
bptr = strdup (str + 3);
|
||||
ptr = strchr (bptr, '}');
|
||||
if (!ptr) {
|
||||
// invalid json
|
||||
free (bptr);
|
||||
break;
|
||||
}
|
||||
*ptr = '\0';
|
||||
RFlagItem *flag = r_flag_get (core->flags, bptr);
|
||||
ret = flag? flag->size: 0LL; // flag
|
||||
free (bptr);
|
||||
free (out);
|
||||
return ret;
|
||||
} else if (core->file) {
|
||||
return r_io_fd_size (core->io, core->file->fd);
|
||||
}
|
||||
return 0LL;
|
||||
|
Loading…
Reference in New Issue
Block a user