diff --git a/librz/core/cfile.c b/librz/core/cfile.c index c40644a1c1c..6d0ee2fa298 100644 --- a/librz/core/cfile.c +++ b/librz/core/cfile.c @@ -1285,7 +1285,7 @@ RZ_API RzCoreFile *rz_core_file_get_by_fd(RzCore *core, int fd) { return NULL; } -RZ_API int rz_core_file_list(RzCore *core, int mode) { +RZ_API int rz_core_file_print(RzCore *core, RzOutputMode mode) { int count = 0; RzCoreFile *f; RzIODesc *desc; @@ -1294,7 +1294,7 @@ RZ_API int rz_core_file_list(RzCore *core, int mode) { RzBinFile *bf; RzListIter *iter; PJ *pj = NULL; - if (mode == 'j') { + if (mode == RZ_OUTPUT_MODE_JSON) { pj = pj_new(); if (!pj) { return 0; @@ -1309,7 +1309,7 @@ RZ_API int rz_core_file_list(RzCore *core, int mode) { } from = 0LL; switch (mode) { - case 'j': { // "oij" + case RZ_OUTPUT_MODE_JSON: { // "oij" pj_o(pj); pj_kb(pj, "raised", core->io->desc->fd == f->fd); pj_ki(pj, "fd", f->fd); @@ -1320,8 +1320,7 @@ RZ_API int rz_core_file_list(RzCore *core, int mode) { pj_end(pj); break; } - case '*': - case 'r': + case RZ_OUTPUT_MODE_RIZIN: // TODO: use a getter { bool fileHaveBin = false; @@ -1338,7 +1337,7 @@ RZ_API int rz_core_file_list(RzCore *core, int mode) { free(absfile); } break; - case 'n': { + case RZ_OUTPUT_MODE_LONG: { bool header_loaded = false; rz_list_foreach (core->bin->binfiles, it, bf) { if (bf->fd == f->fd) { @@ -1378,7 +1377,7 @@ RZ_API int rz_core_file_list(RzCore *core, int mode) { } count++; } - if (mode == 'j') { + if (mode == RZ_OUTPUT_MODE_JSON) { pj_end(pj); rz_cons_println(pj_string(pj)); pj_free(pj); diff --git a/librz/core/cmd_open.c b/librz/core/cmd_open.c index 5750c34424d..718e94cb335 100644 --- a/librz/core/cmd_open.c +++ b/librz/core/cmd_open.c @@ -1134,7 +1134,7 @@ RZ_IPI int rz_cmd_open(void *data, const char *input) { } case 'n': // "on" if (input[1] == '*') { - rz_core_file_list(core, 'n'); + rz_core_file_print(core, RZ_OUTPUT_MODE_LONG); return 0; } if (input[1] == '+') { // "on+" @@ -1289,7 +1289,7 @@ RZ_IPI int rz_cmd_open(void *data, const char *input) { rz_core_cmd_help(core, help_msg_o_star); break; } - rz_core_file_list(core, (int)(*input)); + rz_core_file_print(core, RZ_OUTPUT_MODE_RIZIN); break; case 'j': // "oj" if ('?' == input[1]) { @@ -1352,10 +1352,14 @@ RZ_IPI int rz_cmd_open(void *data, const char *input) { } } break; case 'j': // "oij" + rz_core_file_print(core, RZ_OUTPUT_MODE_JSON); + break; case '*': // "oi*" + rz_core_file_print(core, RZ_OUTPUT_MODE_RIZIN); + break; case 0: // "oi" - rz_core_file_list(core, input[1]); break; + rz_core_file_print(core, RZ_OUTPUT_MODE_STANDARD); } break; case 'u': { // "ou" diff --git a/librz/include/rz_core.h b/librz/include/rz_core.h index 32faf6dfb92..7c109f97e83 100644 --- a/librz/include/rz_core.h +++ b/librz/include/rz_core.h @@ -564,7 +564,7 @@ RZ_API RzCoreFile *rz_core_file_get_by_fd(RzCore *core, int fd); RZ_API void rz_core_file_close(RzCoreFile *fh); RZ_API bool rz_core_file_close_fd(RzCore *core, int fd); RZ_API bool rz_core_file_close_all_but(RzCore *core); -RZ_API int rz_core_file_list(RzCore *core, int mode); +RZ_API int rz_core_file_print(RzCore *core, RzOutputMode mode); RZ_API int rz_core_file_binlist(RzCore *core); RZ_API bool rz_core_file_bin_raise(RzCore *core, ut32 num); RZ_API bool rz_core_extend_at(RzCore *core, ut64 addr, int size);