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

Go to the source code of this file.

Functions

RZ_API int rz_main_rz_run (int argc, const char **argv)
 

Function Documentation

◆ rz_main_rz_run()

RZ_API int rz_main_rz_run ( int  argc,
const char **  argv 
)

Definition at line 25 of file rz-run.c.

25  {
26  RzRunProfile *p;
27  int i, ret;
28  if (argc == 1 || !strcmp(argv[1], "-h")) {
29  printf("Usage: rz-run -v|-t|script.rr2 [directive ..]\n");
30  printf("%s", rz_run_help());
31  return 1;
32  }
33  if (!strcmp(argv[1], "-v")) {
34  return rz_main_version_print("rz-run");
35  }
36  const char *file = argv[1];
37  if (!strcmp(file, "-t")) {
38 #if __UNIX__
39  rz_run_tty();
40  return 0;
41 #else
42  eprintf("Not supported\n");
43  return 1;
44 #endif
45  }
46  if (*file && !strchr(file, '=')) {
47  p = rz_run_new(file);
48  } else {
49  bool noMoreDirectives = false;
50  int directiveIndex = 0;
51  p = rz_run_new(NULL);
52  for (i = *file ? 1 : 2; i < argc; i++) {
53  if (!strcmp(argv[i], "--")) {
54  noMoreDirectives = true;
55  continue;
56  }
57  if (noMoreDirectives) {
58  const char *word = argv[i];
59  char *line = directiveIndex
60  ? rz_str_newf("arg%d=%s", directiveIndex, word)
61  : rz_str_newf("program=%s", word);
63  directiveIndex++;
64  free(line);
65  } else {
67  }
68  }
69  }
70  if (!p) {
71  return 1;
72  }
73  ret = rz_run_config_env(p);
74  if (ret) {
75  printf("error while configuring the environment.\n");
76  rz_run_free(p);
77  return 1;
78  }
79  ret = rz_run_start(p);
80  rz_run_free(p);
81  return ret;
82 }
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
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
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
line
Definition: setup.py:34
#define eprintf(x, y...)
Definition: rlcc.c:7
RZ_API int rz_main_version_print(const char *program)
Definition: main.c:49
RZ_API void rz_run_free(RzRunProfile *r)
Definition: run.c:122
RZ_API RzRunProfile * rz_run_new(const char *str)
Definition: run.c:86
RZ_API const char * rz_run_help(void)
Definition: run.c:630
RZ_API bool rz_run_parseline(RzRunProfile *p, const char *b)
Definition: run.c:479
RZ_API int rz_run_start(RzRunProfile *p)
Definition: run.c:1081
RZ_API int rz_run_config_env(RzRunProfile *p)
Definition: run.c:809
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
Definition: gzappend.c:170

References argv, eprintf, free(), i, setup::line, NULL, p, printf(), rz_main_version_print(), rz_run_config_env(), rz_run_free(), rz_run_help(), rz_run_new(), rz_run_parseline(), rz_run_start(), and rz_str_newf().

Referenced by MAIN_NAME().