Rizin
unix-like reverse engineering framework and cli tools
cmd_project.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2020 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_project.h>
5 
6 RZ_API bool rz_core_project_load_for_cli(RzCore *core, const char *file, bool load_bin_io) {
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 }
22 
23 RZ_IPI RzCmdStatus rz_project_save_handler(RzCore *core, int argc, const char **argv) {
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 }
42 
43 RZ_IPI RzCmdStatus rz_project_open_handler(RzCore *core, int argc, const char **argv) {
45 }
46 
49 }
#define RZ_IPI
Definition: analysis_wasm.c:11
static bool err
Definition: armass.c:435
RZ_IPI RzCmdStatus rz_project_save_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_project.c:23
RZ_API bool rz_core_project_load_for_cli(RzCore *core, const char *file, bool load_bin_io)
Definition: cmd_project.c:6
RZ_IPI RzCmdStatus rz_project_open_no_bin_io_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_project.c:47
RZ_IPI RzCmdStatus rz_project_open_handler(RzCore *core, int argc, const char **argv)
Definition: cmd_project.c:43
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
#define RZ_API
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
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
RZ_API RzProjectErr rz_project_save_file(RzCore *core, const char *file, bool compress)
Definition: project.c:42
#define eprintf(x, y...)
Definition: rlcc.c:7
static RzSocket * s
Definition: rtr.c:28
enum rz_cmd_status_t RzCmdStatus
@ 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
@ 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
#define RZ_STR_ISEMPTY(x)
Definition: rz_str.h:67
Definition: gzappend.c:170
RzConfig * config
Definition: rz_core.h:300
static int file
Definition: z80asm.c:58