Use xdg configuration path ~/.config/radare2/

This commit is contained in:
pancake 2013-06-27 19:15:59 +02:00
parent 4aa2867486
commit 8377c98458
12 changed files with 34 additions and 30 deletions

View File

@ -100,6 +100,7 @@ static int main_help(int line) {
if (line==2)
printf (
"Files:\n"
" RHOMEDIR ~/.config/radare2\n"
" RCFILE ~/.radare2rc (user preferences, batch script)\n"
" MAGICPATH "R_MAGIC_PATH"\n"
"Environment:\n"
@ -192,7 +193,7 @@ int main(int argc, char **argv) {
if (argc<2)
return main_help (1);
if (argc==2 && !strcmp (argv[1], "-p")) {
char *path = r_str_home (".radare2/rdb/");
char *path = r_str_home (R2_HOMEDIR"/rdb/");
DIR *d = r_sandbox_opendir (path);
if (d) {
for (;;) {
@ -243,7 +244,7 @@ int main(int argc, char **argv) {
// TODO: handle error when removing project
char *path, repath[128];
snprintf (repath, sizeof (repath),
".radare2/rdb/%s.d", optarg+1);
R2_HOMEDIR"/rdb/%s.d", optarg+1);
path = r_str_home (repath);
if (r_file_exists (path)) {
r_file_rmrf (path);

View File

@ -6,7 +6,7 @@
#define DB anal->sdb_xrefs
R_API void r_anal_xrefs_load(RAnal *anal, const char *prjfile) {
char *path, *db = r_str_dup_printf ("/.radare2/rdb/%s.d/xrefs", prjfile);
char *path, *db = r_str_dup_printf (R2_HOMEDIR"/rdb/%s.d/xrefs", prjfile);
path = r_str_home (db);
//eprintf ("Open (%s)\n", path);
sdb_free (DB);

View File

@ -256,7 +256,7 @@ static int cmd_quit(void *data, const char *input) {
case '\0':
// TODO
default:
r_line_hist_save (".radare2_history");
r_line_hist_save (R2_HOMEDIR"/history");
if (*input)
r_num_math (core->num, input);
else core->num->value = 0LL;

View File

@ -14,7 +14,7 @@ static int cmd_project(void *data, const char *input) {
" Po [file] open project\n"
" Ps [file] save project\n"
" Pi [file] info\n"
"NOTE: project files are stored in ~/.radare2/rdb\n");
"NOTE: project files are stored in ~/.config/radare2/rdb\n");
break;
}
free (str);

View File

@ -629,7 +629,7 @@ r_config_set (cfg, "asm.arch", R_SYS_ARCH);
r_config_set_i (cfg, "diff.to", 0);
r_config_desc (cfg, "diff.to", "set destination diffing address for px (uses cc command)");
/* dir */
r_config_set (cfg, "dir.projects", "~/.radare2/rdb");
r_config_set (cfg, "dir.projects", R2_HOMEDIR"/rdb");
r_config_set (cfg, "dir.types", "/usr/include");
r_config_desc (cfg, "dir.types", "Default path to look for cparse type files");
r_config_set (cfg, "dir.source", "");

View File

@ -499,7 +499,7 @@ R_API int r_core_init(RCore *core) {
line->user = core;
core->cons->user_fgets = (void *)myfgets;
//r_line_singleton()->user = (void *)core;
r_line_hist_load (".radare2_history");
r_line_hist_load (R2_HOMEDIR"/history");
singleton = R_FALSE;
}
core->print->cons = core->cons;

View File

@ -46,7 +46,7 @@ R_API int r_core_loadlibs_init(struct r_core_t *core) {
R_API int r_core_loadlibs(struct r_core_t *core) {
/* TODO: all those default plugin paths should be defined in r_lib */
char *homeplugindir = r_str_home (".radare2/plugins");
char *homeplugindir = r_str_home (R2_HOMEDIR"/plugins");
core->lib = r_lib_new ("radare_plugin");
r_core_loadlibs_init (core);
r_lib_opendir (core->lib, r_config_get (core->config, "dir.plugins"));

View File

@ -24,7 +24,7 @@ static ut64 marks[UT8_MAX+1];
static int r_core_visual_hud(RCore *core) {
const char *f = R2_LIBDIR"/radare2/"R2_VERSION"/hud/main";
char *homehud = r_str_home("/.radare2/hud");
char *homehud = r_str_home(R2_HOMEDIR"/hud");
char *res = NULL;
char *p = 0;

View File

@ -86,6 +86,25 @@ typedef struct r_bin_info_t {
RBinHash sum[2];
} RBinInfo;
typedef struct r_bin_object_t {
ut64 baddr;
int size;
RList/*<RBinSection>*/ *sections;
RList/*<RBinImport>*/ *imports;
RList/*<RBinSymbol>*/ *symbols;
RList/*<??>*/ *entries;
RList/*<??>*/ *fields;
RList/*<??>*/ *libs;
RList/*<??>*/ *relocs;
RList/*<??>*/ *strings;
RList/*<RBinClass>*/ *classes;
RList/*<RBinDwarfRow>*/ *lines;
RBinInfo *info;
RBinAddr *binsym[R_BIN_SYM_LAST];
int referenced;
int lang;
} RBinObject;
// XXX: this is a copy of RBinObject
// TODO: rename RBinArch to RBinFile
typedef struct r_bin_arch_t {
@ -94,7 +113,7 @@ typedef struct r_bin_arch_t {
int size;
int rawstr;
ut64 offset;
struct r_bin_object_t *o;
RBinObject *o;
void *bin_obj; // internal pointer used by formats
struct r_bin_plugin_t *curplugin;
} RBinArch;
@ -235,25 +254,6 @@ typedef struct r_bin_write_t {
int (*rpath_del)(RBinArch *arch);
} RBinWrite;
typedef struct r_bin_object_t {
ut64 baddr;
int size;
RList/*<RBinSection>*/ *sections;
RList/*<RBinImport>*/ *imports;
RList/*<RBinSymbol>*/ *symbols;
RList/*<??>*/ *entries;
RList/*<??>*/ *fields;
RList/*<??>*/ *libs;
RList/*<??>*/ *relocs;
RList/*<??>*/ *strings;
RList/*<RBinClass>*/ *classes;
RList/*<RBinDwarfRow>*/ *lines;
RBinInfo *info;
RBinAddr *binsym[R_BIN_SYM_LAST];
int referenced;
int lang;
} RBinObject;
// TODO: deprecate r_bin_is_big_endian
// TODO: has_dbg_syms... maybe flags?

View File

@ -76,6 +76,8 @@ const char *x##_version() { return ""GIT_TAP; }
#define R_SYS_HOME "HOME"
#endif
#define R2_HOMEDIR ".config/radare2"
#ifndef __packed
#define __packed __attribute__((__packed__))
#endif

View File

@ -54,7 +54,7 @@ Load given plugin file
.It Fl L
List supported IO plugins.
.It Fl n
Do not load user settings/projects from ~/.radare2rc and ~/.radare2/.
Do not load user settings/projects from ~/.radare2rc and ~/.config/radare2/.
.It Fl N
Do not perform any analysis (r_bin). Just load the raw file.
.It Fl q

View File

@ -15,6 +15,7 @@ run command ?i cmd;`?y`;?ik
seek to entrypoint s entry0
seek to main s main
set breakpoint db;?i new breakpoint address;db `?y`
remove breakpoint ?i delete breakpoint at given address;db-`?y`
show backtrace dbt;?ik
show bytes in disassembly e asm.bytes=1
show debugger register values dr;?ik