Rizin
unix-like reverse engineering framework and cli tools
cmd_project.c File Reference
#include <rz_project.h>

Go to the source code of this file.

Functions

RZ_API bool rz_core_project_load_for_cli (RzCore *core, const char *file, bool load_bin_io)
 
RZ_IPI RzCmdStatus rz_project_save_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_project_open_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_project_open_no_bin_io_handler (RzCore *core, int argc, const char **argv)
 

Function Documentation

◆ rz_core_project_load_for_cli()

RZ_API bool rz_core_project_load_for_cli ( RzCore core,
const char *  file,
bool  load_bin_io 
)

Definition at line 6 of file cmd_project.c.

6  {
8  RzProjectErr err = rz_project_load_file(core, file, load_bin_io, res);
10  eprintf("Failed to load project: %s\n", rz_project_err_message(err));
11  } else if (!rz_list_empty(res)) {
12  eprintf("Detailed project load info:\n");
13  }
14  RzListIter *it;
15  char *s;
16  rz_list_foreach (res, it, s) {
17  eprintf(" %s\n", s);
18  }
20  return err == RZ_PROJECT_ERR_SUCCESS;
21 }
static bool err
Definition: armass.c:435
RZ_API RZ_NONNULL const char * rz_project_err_message(RzProjectErr err)
Definition: project.c:11
RZ_API RzProjectErr rz_project_load_file(RzCore *core, const char *file, bool load_bin_io, RzSerializeResultInfo *res)
Definition: project.c:168
#define eprintf(x, y...)
Definition: rlcc.c:7
static RzSocket * s
Definition: rtr.c:28
@ RZ_PROJECT_ERR_SUCCESS
Definition: rz_project.h:20
enum rz_project_err RzProjectErr
static RzSerializeResultInfo * rz_serialize_result_info_new(void)
Definition: rz_serialize.h:18
static void rz_serialize_result_info_free(RzSerializeResultInfo *info)
Definition: rz_serialize.h:22
Definition: gzappend.c:170

References eprintf, err, rz_project_err_message(), RZ_PROJECT_ERR_SUCCESS, rz_project_load_file(), rz_serialize_result_info_free(), rz_serialize_result_info_new(), and s.

Referenced by rz_main_rizin(), rz_project_open_handler(), and rz_project_open_no_bin_io_handler().

◆ rz_project_open_handler()

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

Definition at line 43 of file cmd_project.c.

43  {
45 }
RZ_API bool rz_core_project_load_for_cli(RzCore *core, const char *file, bool load_bin_io)
Definition: cmd_project.c:6
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

References argv, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, and rz_core_project_load_for_cli().

Referenced by rzshell_cmddescs_init().

◆ rz_project_open_no_bin_io_handler()

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

Definition at line 47 of file cmd_project.c.

47  {
49 }

References argv, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, and rz_core_project_load_for_cli().

Referenced by rzshell_cmddescs_init().

◆ rz_project_save_handler()

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

Definition at line 23 of file cmd_project.c.

23  {
24  const char *file;
25  if (argc == 1) {
26  file = rz_config_get(core->config, "prj.file");
27  if (RZ_STR_ISEMPTY(file)) {
28  eprintf("There is no project file associated with the current session yet.\n"
29  "Specify the file explicitly as `Ps <file.rzdb>` or set it manually with `e prj.file=<project-path>`.\n");
30  return RZ_CMD_STATUS_ERROR;
31  }
32  } else { // argc == 2 checked by the shell
33  file = argv[1];
34  }
35  bool compress = rz_config_get_b(core->config, "prj.compress");
37  if (err != RZ_PROJECT_ERR_SUCCESS) {
38  eprintf("Failed to save project to file %s: %s\n", file, rz_project_err_message(err));
39  }
40  return RZ_CMD_STATUS_OK;
41 }
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
Definition: compress.c:68
RZ_API bool rz_config_get_b(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:142
RZ_API RZ_BORROW const char * rz_config_get(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:75
RZ_API RzProjectErr rz_project_save_file(RzCore *core, const char *file, bool compress)
Definition: project.c:42
#define RZ_STR_ISEMPTY(x)
Definition: rz_str.h:67
RzConfig * config
Definition: rz_core.h:300
static int file
Definition: z80asm.c:58

References argv, compress(), rz_core_t::config, eprintf, err, file, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_config_get(), rz_config_get_b(), rz_project_err_message(), RZ_PROJECT_ERR_SUCCESS, rz_project_save_file(), and RZ_STR_ISEMPTY.

Referenced by rzshell_cmddescs_init().