Rizin
unix-like reverse engineering framework and cli tools
rz-bb.c File Reference
#include <rz_util.h>

Go to the source code of this file.

Classes

struct  BbCommands
 

Typedefs

typedef char *(* CommandCallback) (const char *args)
 

Functions

static int run (int i, const char *arg)
 
int main (int argc, char **argv)
 

Variables

static BbCommands bbcmds []
 

Typedef Documentation

◆ CommandCallback

typedef char*(* CommandCallback) (const char *args)

Definition at line 6 of file rz-bb.c.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 29 of file rz-bb.c.

29  {
30  int i;
31  for (i = 0; bbcmds[i].cmd; i++) {
32  if (!strcmp(bbcmds[i].cmd, argv[0])) {
33  const char *arg = argc > 1 ? argv[1] : NULL;
34  return run(i, arg);
35  }
36  }
37  if (argc > 1) {
38  for (i = 0; bbcmds[i].cmd; i++) {
39  if (!strcmp(bbcmds[i].cmd, argv[1])) {
40  const char *arg = argc > 2 ? argv[2] : NULL;
41  return run(i, arg);
42  }
43  }
44  }
45  for (i = 0; bbcmds[i].cmd; i++) {
46  printf("%s\n", bbcmds[i].cmd);
47  }
48  return 1;
49 }
lzma_index ** i
Definition: index.h:629
#define NULL
Definition: cris-opc.c:27
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
Definition: cs_driver.c:93
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
Definition: sflib.h:79
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
static BbCommands bbcmds[]
Definition: rz-bb.c:13
static int run(int i, const char *arg)
Definition: rz-bb.c:19
const char * cmd
Definition: rz-bb.c:9

References argv, bbcmds, BbCommands::cmd, cmd, i, NULL, printf(), and run().

◆ run()

static int run ( int  i,
const char *  arg 
)
static

Definition at line 19 of file rz-bb.c.

19  {
20  char *res = bbcmds[i].cb(arg);
21  if (res) {
22  printf("%s", res);
23  free(res);
24  return 0;
25  }
26  return 1;
27 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
CommandCallback cb
Definition: rz-bb.c:10

References bbcmds, BbCommands::cb, free(), i, and printf().

Referenced by chmd_extract(), copy_fh(), hash_context_run(), main(), noned_decompress(), rip(), rz_bin_dmp64_init_memory_runs(), and zip_read_lens().

Variable Documentation

◆ bbcmds

BbCommands bbcmds[]
static
Initial value:
= {
{ "cat", rz_syscmd_cat },
{ "ls", rz_syscmd_ls },
}
RZ_API RZ_OWN char * rz_syscmd_cat(RZ_NONNULL const char *file)
Definition: syscmd.c:442
RZ_API RZ_OWN char * rz_syscmd_ls(RZ_NONNULL const char *input)
Definition: syscmd.c:121

Definition at line 13 of file rz-bb.c.

Referenced by main(), and run().