Rizin
unix-like reverse engineering framework and cli tools
main.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2012-2020 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <stdio.h>
5 #include <string.h>
6 #include <rz_main.h>
7 #include <rz_util.h>
8 
9 RZ_LIB_VERSION(rz_main);
10 
11 static RzMain foo[] = {
12  { "rz", rz_main_rizin },
13  { "rz-ax", rz_main_rz_ax },
14  { "rz-diff", rz_main_rz_diff },
15  { "rz-find", rz_main_rz_find },
16  { "rz-run", rz_main_rz_run },
17  { "rz-asm", rz_main_rz_asm },
18  { "rz-gg", rz_main_rz_gg },
19  { "rz-bin", rz_main_rz_bin },
20  { "rizin", rz_main_rizin },
21  { NULL, NULL }
22 };
23 
24 RZ_API RzMain *rz_main_new(const char *name) {
25  int i = 0;
26  while (foo[i].name) {
27  if (!strcmp(name, foo[i].name)) {
28  RzMain *m = RZ_NEW0(RzMain);
29  if (m) {
30  m->name = strdup(foo[i].name);
31  m->main = foo[i].main;
32  }
33  return m;
34  }
35  i++;
36  }
37  return NULL;
38 }
39 
41  free(m);
42 }
43 
44 RZ_API int rz_main_run(RzMain *m, int argc, const char **argv) {
45  rz_return_val_if_fail(m && m->main, -1);
46  return m->main(argc, argv);
47 }
48 
50  char *s = rz_str_version(progname);
51  printf("%s\n", s);
52  free(s);
53  return 0;
54 }
lzma_index ** i
Definition: index.h:629
#define RZ_API
#define NULL
Definition: cris-opc.c:27
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
Definition: cs_driver.c:93
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
RZ_API void rz_main_free(RzMain *m)
Definition: main.c:40
static RzMain foo[]
Definition: main.c:11
RZ_API int rz_main_run(RzMain *m, int argc, const char **argv)
Definition: main.c:44
RZ_LIB_VERSION(rz_main)
RZ_API RzMain * rz_main_new(const char *name)
Definition: main.c:24
RZ_API int rz_main_version_print(const char *progname)
Definition: main.c:49
static Sdb * s
Definition: main.c:15
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
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")
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
RZ_API int rz_main_rizin(int argc, const char **argv)
Definition: rizin.c:370
RZ_API int rz_main_rz_find(int argc, const char **argv)
Definition: rz-find.c:474
RZ_API int rz_main_rz_diff(int argc, const char **argv)
Definition: rz-diff.c:2254
RZ_API int rz_main_rz_ax(int argc, const char **argv)
Definition: rz-ax.c:721
RZ_API int rz_main_rz_asm(int argc, const char **argv)
RZ_API int rz_main_rz_run(int argc, const char **argv)
Definition: rz-run.c:25
RZ_API int rz_main_rz_gg(int argc, const char **argv)
Definition: rz-gg.c:116
RZ_API int rz_main_rz_bin(int argc, const char **argv)
Definition: rz-bin.c:681
RZ_API char * rz_str_version(const char *program)
Definition: str.c:4051
#define RZ_NEW0(x)
Definition: rz_types.h:284
Definition: z80asm.h:102
int(* main)(int argc, const char **argv)
Definition: rz_main.h:18
#define progname