rizin/librz/core/clang.c
Theofilos Pechlivanis 07b937e235 Print the rizin plugin info in json ##print ##json
* Implement `aLj` in cmd_analysis.c ##print ##json
* Replace `,` with a `:` in `Loj` json ##test
* Replace `L` and `Lj` with `Ll` and `Llj` ##test
* Add tests for rz plugin json cmds ##print ##json
* List BinLdrPlugins for `Lij` ##print ##json
* Add spaces to represent no authors for `Li` ##test
* Convert `L` and `Ll` to newshell
* Convert `La` and `Laj` to newshell
* Move `Ll` handler to `clang.c`, rename `La` handler ##print ##json
* Convert `Lc` to newshell ##print ##json
* Convert `Ld` cmd to newshell ##print ##json
* Add `Laq` cmd test ##test
* Convert `Lh` to newshell and fix `La` check ##print ##json
* Fix `Lh` and convert `Li` cmd to newshell ##print ##json
* Convert `Lo` to newshell and modify `Lh` ##print ##json ##test
* Convert `Lp` to newshell ##print ##json ##test
* Use newshell cmd for `aL` ##print ##json
* Fix `Li`, lowercase json properties, add tests ##print ##json ##test
* Fix `Ld` and add `Lds` to set dbg backend ##print ##json ##test
* Revert `oL` and `aL` and replace `Lds` with `Ld` ##print ##json
* Use newshell for `obL`
* Replace `lang->cb_printf` with `rz_cons_printf`
* Replace `bin->cb_printf` with `rz_cons_printf` ##print
* Use `rz_lang_list()` instead of cmd0 ##print
* Set `Lo` and `Loj` tests as broken ##test
2021-05-17 13:38:11 +08:00

49 lines
1.2 KiB
C

// SPDX-FileCopyrightText: 2021 theopechli <theofilos.pechlivanis@gmail.com>
// SPDX-License-Identifier: LGPL-3.0-only
#include <rz_core.h>
RZ_API RzCmdStatus rz_core_lang_plugin_print(RzLangPlugin *lp, RzCmdStateOutput *state) {
const char *license = lp->license
? lp->license
: "???";
PJ *pj = state->d.pj;
switch (state->mode) {
case RZ_OUTPUT_MODE_JSON: {
pj_o(pj);
pj_ks(pj, "name", lp->name);
pj_ks(pj, "description", lp->desc);
pj_ks(pj, "license", license);
pj_end(pj);
break;
}
case RZ_OUTPUT_MODE_STANDARD: {
rz_cons_printf("%s: %s (%s)\n",
lp->name, lp->desc, license);
break;
}
default: {
rz_warn_if_reached();
return RZ_CMD_STATUS_NONEXISTINGCMD;
}
}
return RZ_CMD_STATUS_OK;
}
RZ_API RzCmdStatus rz_core_lang_plugins_print(RzLang *lang, RzCmdStateOutput *state) {
RzListIter *iter;
RzLangPlugin *lp;
RzCmdStatus status;
if (!lang) {
return RZ_CMD_STATUS_ERROR;
}
rz_cmd_state_output_array_start(state);
rz_list_foreach (lang->langs, iter, lp) {
status = rz_core_lang_plugin_print(lp, state);
if (status != RZ_CMD_STATUS_OK) {
return status;
}
}
rz_cmd_state_output_array_end(state);
return RZ_CMD_STATUS_OK;
}