Rizin
unix-like reverse engineering framework and cli tools
cmd_hash.c File Reference
#include <stddef.h>
#include <rz_core.h>

Go to the source code of this file.

Classes

struct  MsgDigestCaller
 

Typedefs

typedef void(* DigestHandler) (const char *name, const ut8 *block, int len)
 

Functions

RZ_IPI RzCmdDescDetailrz_hash_bang_details_cb (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_hash_bang_handler (RzCore *core, int argc, const char **argv)
 

Typedef Documentation

◆ DigestHandler

typedef void(* DigestHandler) (const char *name, const ut8 *block, int len)

Definition at line 8 of file cmd_hash.c.

Function Documentation

◆ rz_hash_bang_details_cb()

RZ_IPI RzCmdDescDetail* rz_hash_bang_details_cb ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 16 of file cmd_hash.c.

16  {
18  RzLangPlugin *lp;
20  if (!details) {
21  return NULL;
22  }
23  details[0].name = (const char *)strdup("Available interpreters");
24  if (!details->name) {
25  goto err;
26  }
28  details[0].entries = (const RzCmdDescDetailEntry *)entries;
29  if (!entries) {
30  goto err;
31  }
32  int i = 0;
33  rz_list_foreach (core->lang->langs, iter, lp) {
34  entries[i].text = (char *)strdup("#!");
35  entries[i].arg_str = (char *)strdup(lp->name);
36  entries[i].comment = (char *)rz_str_newf("%s (%s)", lp->desc, lp->license);
37  if (!entries[i].text || !entries[i].arg_str || !entries[i].comment) {
38  goto err;
39  }
40  i++;
41  }
42  details->entries = (const RzCmdDescDetailEntry *)entries;
43  return details;
44 err:
45  rz_cmd_desc_details_free(details);
46  return NULL;
47 }
lzma_index ** i
Definition: index.h:629
static bool err
Definition: armass.c:435
RzList * entries(RzBinFile *bf)
Definition: bin_ne.c:98
RZ_API void rz_cmd_desc_details_free(RzCmdDescDetail *details)
Free an array of RzCmdDescDetail sections.
Definition: cmd_api.c:2698
#define NULL
Definition: cris-opc.c:27
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
Definition: list.c:109
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
#define RZ_NEWS0(x, y)
Definition: rz_types.h:282
A detailed entry that can be used to show additional info about a command entry.
Definition: rz_cmd.h:172
const char * name
Definition: rz_cmd.h:197
const RzCmdDescDetailEntry * entries
Definition: rz_cmd.h:201
RzLang * lang
Definition: rz_core.h:328
const char * desc
Definition: rz_lang.h:30
const char * license
Definition: rz_lang.h:31
const char * name
Definition: rz_lang.h:28
RzList * langs
Definition: rz_lang.h:21

References rz_lang_plugin_t::desc, entries(), rz_cmd_desc_detail_t::entries, err, i, rz_core_t::lang, rz_lang_t::langs, rz_lang_plugin_t::license, rz_cmd_desc_detail_t::name, rz_lang_plugin_t::name, NULL, rz_cmd_desc_details_free(), rz_list_length(), RZ_NEWS0, rz_str_newf(), strdup(), and create_tags_rz::text.

◆ rz_hash_bang_handler()

RZ_IPI RzCmdStatus rz_hash_bang_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 49 of file cmd_hash.c.

49  {
51  if (!p) {
52  RZ_LOG_ERROR("No interpreter with name '%s'\n", argv[1]);
53  return RZ_CMD_STATUS_ERROR;
54  }
55  core->lang->cur = p;
56  if (argc > 2) {
57  if (rz_lang_set_argv(core->lang, argc - 2, (char **)&argv[2])) {
58  rz_lang_run_file(core->lang, argv[2]);
59  } else {
60  char *run_str = rz_str_array_join(argv + 2, argc - 2, " ");
61  rz_lang_run_file(core->lang, run_str);
62  free(run_str);
63  }
64  } else {
65  if (rz_cons_is_interactive()) {
66  rz_lang_prompt(core->lang);
67  } else {
68  RZ_LOG_ERROR("scr.interactive required to run the rlang prompt\n");
69  return RZ_CMD_STATUS_ERROR;
70  }
71  }
72  return RZ_CMD_STATUS_OK;
73 }
RZ_API bool rz_cons_is_interactive(void)
Definition: cons.c:365
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
RZ_API int rz_lang_prompt(RzLang *lang)
Definition: lang.c:205
RZ_API RzLangPlugin * rz_lang_get_by_name(RzLang *lang, const char *name)
Definition: lang.c:141
RZ_API int rz_lang_run_file(RzLang *lang, const char *file)
Definition: lang.c:183
RZ_API bool rz_lang_set_argv(RzLang *lang, int argc, char **argv)
Definition: lang.c:165
void * p
Definition: libc.cpp:67
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
@ RZ_CMD_STATUS_OK
command handler exited in the right way
Definition: rz_cmd.h:24
@ RZ_CMD_STATUS_ERROR
command handler had issues while running (e.g. allocation error, etc.)
Definition: rz_cmd.h:26
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
RZ_API char * rz_str_array_join(const char **a, size_t n, const char *sep)
Definition: str.c:3861
struct rz_lang_plugin_t * cur
Definition: rz_lang.h:18

References argv, rz_lang_t::cur, free(), rz_core_t::lang, p, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_is_interactive(), rz_lang_get_by_name(), rz_lang_prompt(), rz_lang_run_file(), rz_lang_set_argv(), RZ_LOG_ERROR, and rz_str_array_join().

Referenced by rzshell_cmddescs_init().