Rizin
unix-like reverse engineering framework and cli tools
chash.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 theopechli <theofilos.pechlivanis@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_core.h>
5 
7  PJ *pj = state->d.pj;
8  switch (state->mode) {
10  rz_cons_printf("%s ", plugin->name);
11  break;
12  }
13  case RZ_OUTPUT_MODE_JSON: {
14  pj_o(pj);
15  pj_ks(pj, "name", plugin->name);
16  pj_ks(pj, "license", plugin->license);
17  pj_ks(pj, "author", plugin->author);
18  pj_end(pj);
19  break;
20  }
22  rz_cons_printf("%-14s %-10s %s\n", plugin->name, plugin->license, plugin->author);
23 
24  break;
25  }
26  default: {
29  }
30  }
31  return RZ_CMD_STATUS_OK;
32 }
33 
36 
37  const RzHashPlugin *plugin = NULL;
39  RzListIter *it;
41  if (state->mode == RZ_OUTPUT_MODE_STANDARD) {
42  rz_cons_println("algorithm license author");
43  }
44  rz_list_foreach (hash->plugins, it, plugin) {
46  if (status != RZ_CMD_STATUS_OK) {
47  return status;
48  }
49  }
50  if (state->mode == RZ_OUTPUT_MODE_QUIET) {
52  }
54  return RZ_CMD_STATUS_OK;
55 }
RZ_API RzCmdStatus rz_core_hash_plugins_print(RzHash *hash, RzCmdStateOutput *state)
Definition: chash.c:34
RZ_API RzCmdStatus rz_core_hash_plugin_print(RzCmdStateOutput *state, const RzHashPlugin *plugin)
Definition: chash.c:6
RZ_API void rz_cmd_state_output_array_start(RzCmdStateOutput *state)
Mark the start of an array of elements in the output.
Definition: cmd_api.c:2558
RZ_API void rz_cmd_state_output_array_end(RzCmdStateOutput *state)
Mark the end of an array of elements in the output.
Definition: cmd_api.c:2572
RZ_API void rz_cons_newline(void)
Definition: cons.c:1274
RZ_API int rz_cons_printf(const char *format,...)
Definition: cons.c:1202
RZ_API void rz_cons_println(const char *str)
Definition: cons.c:233
#define RZ_API
#define NULL
Definition: cris-opc.c:27
static const char struct stat static buf struct stat static buf static vhangup int status
Definition: sflib.h:145
#define rz_warn_if_reached()
Definition: rz_assert.h:29
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
enum rz_cmd_status_t RzCmdStatus
@ RZ_CMD_STATUS_OK
command handler exited in the right way
Definition: rz_cmd.h:24
@ RZ_CMD_STATUS_NONEXISTINGCMD
command does not exist
Definition: rz_cmd.h:28
@ RZ_CMD_STATUS_ERROR
command handler had issues while running (e.g. allocation error, etc.)
Definition: rz_cmd.h:26
RZ_API PJ * pj_end(PJ *j)
Definition: pj.c:87
RZ_API PJ * pj_o(PJ *j)
Definition: pj.c:75
RZ_API PJ * pj_ks(PJ *j, const char *k, const char *v)
Definition: pj.c:170
@ RZ_OUTPUT_MODE_JSON
Definition: rz_types.h:40
@ RZ_OUTPUT_MODE_QUIET
Definition: rz_types.h:42
@ RZ_OUTPUT_MODE_STANDARD
Definition: rz_types.h:39
Definition: rz_pj.h:12
Represent the output state of a command handler.
Definition: rz_cmd.h:91
const char * name
Definition: rz_hash.h:27
const char * author
Definition: rz_hash.h:29
const char * license
Definition: rz_hash.h:28
RzList * plugins
Definition: rz_hash.h:42
Definition: dis.h:43