mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-11 06:55:01 +00:00
2487fa20a4
* Many fixes related to the argument parsing and help messages
36 lines
744 B
C
36 lines
744 B
C
static char *mnemonics(RAsm *a, int id, bool json) {
|
|
int i;
|
|
a->cur->disassemble (a, NULL, NULL, -1);
|
|
if (id != -1) {
|
|
const char *name = cs_insn_name (cd, id);
|
|
if (json) {
|
|
return name? r_str_newf ("[\"%s\"]\n", name): NULL;
|
|
}
|
|
return name? strdup (name): NULL;
|
|
}
|
|
RStrBuf *buf = r_strbuf_new ("");
|
|
if (json) {
|
|
r_strbuf_append (buf, "[");
|
|
}
|
|
for (i = 1; ; i++) {
|
|
const char *op = cs_insn_name (cd, i);
|
|
if (!op) {
|
|
break;
|
|
}
|
|
if (json) {
|
|
r_strbuf_append (buf, "\"");
|
|
}
|
|
r_strbuf_append (buf, op);
|
|
if (json) {
|
|
if (cs_insn_name (cd, i + 1)) {
|
|
r_strbuf_append (buf, "\",");
|
|
} else {
|
|
r_strbuf_append (buf, "\"]\n");
|
|
}
|
|
} else {
|
|
r_strbuf_append (buf, "\n");
|
|
}
|
|
}
|
|
return r_strbuf_drain (buf);
|
|
}
|