本文整理汇总了C++中r_config_get函数的典型用法代码示例。如果您正苦于以下问题:C++ r_config_get函数的具体用法?C++ r_config_get怎么用?C++ r_config_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r_config_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: config_asmbits_callback
static int config_asmbits_callback(void *user, void *data) {
const char *asmos, *asmarch;
RCore *core = (RCore *) user;
RConfigNode *node = (RConfigNode *) data;
int ret = r_asm_set_bits (core->assembler, node->i_value);
if (ret == R_FALSE) {
RAsmPlugin *h = core->assembler->cur;
if (h) {
eprintf ("Cannot set bits %"PFMT64d" to '%s'\n",
node->i_value, h->name);
} else {
eprintf ("e asm.bits: Cannot set value, no plugins defined yet\n");
ret = R_TRUE;
}
}
if (!r_anal_set_bits (core->anal, node->i_value))
eprintf ("asm.arch: Cannot setup '%i' bits analysis engine\n", (int)node->i_value);
if (core->dbg && core->anal && core->anal->cur)
r_debug_set_arch (core->dbg, core->anal->cur->arch, node->i_value);
asmos = r_config_get (core->config, "asm.os");
asmarch = r_config_get (core->config, "asm.arch");
if (core && core->anal)
if (!r_syscall_setup (core->anal->syscall, asmarch,
asmos, node->i_value)) {
//eprintf ("asm.arch: Cannot setup syscall '%s/%s' from '%s'\n",
// node->value, asmos, R2_LIBDIR"/radare2/"R2_VERSION"/syscall");
}
return ret;
}
示例2: r_core_setup_debugger
R_API int r_core_setup_debugger (RCore *r, const char *debugbackend, bool attach) {
int pid, *p = NULL;
bool is_gdb = !strcmp (debugbackend, "gdb");
RIODesc * fd = r->file ? r_io_desc_get (r->io, r->file->fd) : NULL;
const char *prompt = NULL;
p = fd ? fd->data : NULL;
r_config_set_i (r->config, "cfg.debug", 1);
if (!p) {
eprintf ("Invalid debug io\n");
return false;
}
r_config_set (r->config, "io.ff", "true");
r_core_cmdf (r, "dL %s", debugbackend);
if (!is_gdb) {
pid = r_io_desc_get_pid (fd);
r_core_cmdf (r, "dp=%d", pid);
if (attach) {
r_core_cmdf (r, "dpa %d", pid);
}
}
//this makes to attach twice showing warnings in the output
//we get "resource busy" so it seems isn't an issue
r_core_cmd (r, ".dr*", 0);
/* honor dbg.bep */
{
const char *bep = r_config_get (r->config, "dbg.bep");
if (bep) {
if (!strcmp (bep, "loader")) {
/* do nothing here */
} else if (!strcmp (bep, "entry")) {
r_core_cmd (r, "dcu entry0", 0);
} else {
r_core_cmdf (r, "dcu %s", bep);
}
}
}
r_core_cmd (r, "sr PC", 0);
/* set the prompt if it's not been set already by the callbacks */
prompt = r_config_get (r->config, "cmd.prompt");
if (prompt && !strcmp (prompt, "")) {
if (r_config_get_i (r->config, "dbg.status")) {
r_config_set (r->config, "cmd.prompt", ".dr*;drd;sr PC;pi 1;s-");
} else {
r_config_set (r->config, "cmd.prompt", ".dr*");
}
}
r_config_set (r->config, "cmd.vprompt", ".dr*");
return true;
}
示例3: textlog_chat
static int textlog_chat(RCore *core) {
char prompt[64];
char buf[1024];
int lastmsg = 0;
const char *me = r_config_get (core->config, "cfg.user");
char msg[1024];
eprintf ("Type '/help' for commands:\n");
snprintf (prompt, sizeof (prompt) - 1, "[%s]> ", me);
r_line_set_prompt (prompt);
for (;;) {
r_core_log_list (core, lastmsg, 0, 0);
lastmsg = core->log->last;
if (r_cons_fgets (buf, sizeof (buf) - 1, 0, NULL) < 0) {
return 1;
}
if (!*buf) {
continue;
}
if (!strcmp (buf, "/help")) {
eprintf ("/quit quit the chat (same as ^D)\n");
eprintf ("/name <nick> set cfg.user name\n");
eprintf ("/log show full log\n");
eprintf ("/clear clear text log messages\n");
} else if (!strncmp (buf, "/name ", 6)) {
snprintf (msg, sizeof (msg) - 1, "* '%s' is now known as '%s'", me, buf + 6);
r_core_log_add (core, msg);
r_config_set (core->config, "cfg.user", buf + 6);
me = r_config_get (core->config, "cfg.user");
snprintf (prompt, sizeof (prompt) - 1, "[%s]> ", me);
r_line_set_prompt (prompt);
return 0;
} else if (!strcmp (buf, "/log")) {
r_core_log_list (core, 0, 0, 0);
return 0;
} else if (!strcmp (buf, "/clear")) {
// r_core_log_del (core, 0);
r_core_cmd0 (core, "T-");
return 0;
} else if (!strcmp (buf, "/quit")) {
return 0;
} else if (*buf == '/') {
eprintf ("Unknown command: %s\n", buf);
} else {
snprintf (msg, sizeof (msg) - 1, "[%s] %s", me, buf);
r_core_log_add (core, msg);
}
}
return 1;
}
示例4: readline_callback
static int readline_callback(void *_a, const char *str) {
RCoreVisualAsm *a = _a;
int xlen;
r_cons_clear00 ();
r_cons_printf ("Write your favourite %s-%d opcode...\n\n",
r_config_get (a->core->config, "asm.arch"),
r_config_get_i (a->core->config, "asm.bits"));
if (*str == '?') {
r_cons_printf ("0> ?\n\n"
"Visual assembler help:\n\n"
" assemble input while typing using asm.arch, asm.bits and cfg.bigendian\n"
" press enter to quit (prompt if there are bytes to be written)\n"
" this assembler supports various directives like .hex ...\n"
);
} else {
r_asm_code_free (a->acode);
a->acode = r_asm_massemble (a->core->assembler, str);
r_cons_printf ("%d> %s\n", a->acode? a->acode->len: 0, str);
if (a->acode && a->acode->len)
r_cons_printf ("* %s\n\n", a->acode->buf_hex);
else r_cons_printf ("\n\n");
if (a->acode) {
xlen = strlen (a->acode->buf_hex);
strcpy (a->codebuf, a->blockbuf);
memcpy (a->codebuf, a->acode->buf_hex, xlen);
}
r_core_cmdf (a->core, "pd [email protected]:%s @0x%"PFMT64x, a->codebuf, a->off);
}
r_cons_flush ();
return 1;
}
示例5: r_core_project_list
R_API int r_core_project_list(RCore *core, int mode) {
RListIter *iter;
RList *list;
int isfirst = 1;
char *foo, *path = r_file_abspath (r_config_get (core->config, "dir.projects"));
if (!path)
return 0;
list = r_sys_dir (path);
switch (mode) {
case 'j':
r_cons_printf ("[");
r_list_foreach (list, iter, foo) {
// todo. escape string
if (r_core_is_project (core, foo)) {
r_cons_printf ("%s\"%s\"",
isfirst?"":",", foo);
isfirst = 0;
}
}
r_cons_printf ("]\n");
break;
default:
r_list_foreach (list, iter, foo) {
if (r_core_is_project (core, foo))
r_cons_println (foo);
}
break;
}
r_list_free (list);
free (path);
return 0;
}
示例6: cmd_project
static int cmd_project(void *data, const char *input) {
RCore *core = (RCore *)data;
const char *file, *arg = input+1;
char *str = strdup (r_config_get (core->config, "file.project"));
if (*arg==' ') arg++;
file = input[1]?arg:str;
switch (input[0]) {
case 'o':
// if (r_file_is_regular (file))
r_core_project_open (core, file);
break;
case 's':
r_core_project_save (core, file);
r_config_set (core->config, "file.project", file);
break;
case 'i':
// if (r_file_is_regular (file))
free (r_core_project_info (core, file));
break;
default:
r_cons_printf (
"|Usage: P[?osi] [file]\n"
"| Po [file] open project\n"
"| Ps [file] save project\n"
"| Pi [file] show project information\n"
"|NOTE: See 'e file.project'\n"
"|NOTE: project files are stored in ~/.config/radare2/rdb\n");
break;
}
free (str);
return R_TRUE;
}
示例7: r_core_hack
R_API int r_core_hack(RCore *core, const char *op) {
bool (*hack)(RCore *core, const char *op, const RAnalOp *analop) = NULL;
const char *asmarch = r_config_get (core->config, "asm.arch");
const int asmbits = core->assembler->bits;
if (!asmarch) {
return false;
}
if (strstr (asmarch, "x86")) {
hack = r_core_hack_x86;
} else if (strstr (asmarch, "arm")) {
if (asmbits == 64) {
hack = r_core_hack_arm64;
} else {
hack = r_core_hack_arm;
}
} else {
eprintf ("TODO: write hacks are only for x86\n");
}
if (hack) {
RAnalOp analop;
if (!r_anal_op (core->anal, &analop, core->offset, core->block, core->blocksize, R_ANAL_OP_MASK_ALL)) {
eprintf ("anal op fail\n");
return false;
}
return hack (core, op, &analop);
}
return false;
}
示例8: r_anal_hint_free
R_API RAnalHint *r_core_hint_begin (RCore *core, RAnalHint* hint, ut64 at) {
// XXX not here
static char *hint_arch = NULL;
static int hint_bits = 0;
if (hint) {
r_anal_hint_free (hint);
hint = NULL;
}
hint = r_anal_hint_get (core->anal, at);
if (hint_arch) {
r_config_set (core->config, "asm.arch", hint_arch);
hint_arch = NULL;
}
if (hint_bits) {
r_config_set_i (core->config, "asm.bits", hint_bits);
hint_bits = 0;
}
if (hint) {
/* arch */
if (hint->arch) {
if (!hint_arch) hint_arch = strdup (
r_config_get (core->config, "asm.arch"));
r_config_set (core->config, "asm.arch", hint->arch);
}
/* bits */
if (hint->bits) {
if (!hint_bits) hint_bits =
r_config_get_i (core->config, "asm.bits");
r_config_set_i (core->config, "asm.bits", hint->bits);
}
}
return hint;
}
示例9: strdup
static char *projectScriptPath(RCore *core, const char *file) {
const char *magic = "# r2 rdb project file";
char *data, *prjfile;
if (r_file_is_abspath (file)) {
prjfile = strdup (file);
} else {
if (!is_valid_project_name (file)) {
return NULL;
}
prjfile = r_file_abspath (r_config_get (core->config, "dir.projects"));
prjfile = r_str_append (prjfile, R_SYS_DIR);
prjfile = r_str_append (prjfile, file);
if (!r_file_exists (prjfile) || r_file_is_directory (prjfile)) {
prjfile = r_str_append (prjfile, R_SYS_DIR "rc");
}
}
data = r_file_slurp (prjfile, NULL);
if (data) {
if (strncmp (data, magic, strlen (magic))) {
R_FREE (prjfile);
}
}
free (data);
return prjfile;
}
示例10: visual_repeat
static void visual_repeat(RCore *core) {
int atport = r_config_get_i (core->config, "scr.atport");
if (atport) {
#if __UNIX__ && !__APPLE__
int port = r_config_get_i (core->config, "http.port");
if (!r_core_rtr_http (core, '&', NULL)) {
const char *xterm = r_config_get (core->config, "cmd.xterm");
// TODO: this must be configurable
r_sys_cmdf ("%s 'r2 -C http://localhost:%d/cmd/V;sleep 1' &", xterm, port);
//xterm -bg black -fg gray -e 'r2 -C http://localhost:%d/cmd/;sleep 1' &", port);
} else {
r_cons_any_key (NULL);
}
#else
eprintf ("Unsupported on this platform\n");
r_cons_any_key (NULL);
#endif
} else {
RThread *th = r_th_new (visual_repeat_thread, core, 0);
r_th_start (th, 1);
r_cons_break (NULL, NULL);
r_cons_any_key (NULL);
eprintf ("^C \n");
core->cons->breaked = true;
r_th_wait (th);
r_cons_break_end ();
}
}
示例11: r_core_visual_hud
R_API int r_core_visual_hud(RCore *core) {
const char *c = r_config_get (core->config, "hud.path");
const char *f = R2_LIBDIR"/radare2/"R2_VERSION"/hud/main";
char *homehud = r_str_home (R2_HOMEDIR"/hud");
char *res = NULL;
char *p = 0;
showcursor (core, true);
if (c && *c && r_file_exists (c))
res = r_cons_hud_file (c);
if (!res && homehud)
res = r_cons_hud_file (homehud);
if (!res && r_file_exists (f))
res = r_cons_hud_file (f);
if (!res)
r_cons_message ("Cannot find hud file");
r_cons_clear ();
if (res) {
p = strchr (res, '\t');
r_cons_printf ("%s\n", res);
r_cons_flush ();
if (p) r_core_cmd0 (core, p+1);
free (res);
}
showcursor (core, false);
r_cons_flush ();
free (homehud);
return (int)(size_t)p;
}
示例12: cmd_project
/* radare - LGPL - Copyright 2009-2012 // pancake<nopcode.org> */
static int cmd_project(void *data, const char *input) {
RCore *core = (RCore *)data;
const char *arg = input+1;
char *str = strdup (r_config_get (core->config, "file.project"));
if (*arg==' ') arg++;
switch (input[0]) {
case 'o':
r_core_project_open (core, input[1]?arg:str);
break;
case 's':
r_core_project_save (core, input[1]?arg:str);
break;
case 'i':
free (r_core_project_info (core, input[1]?arg:str));
break;
default:
r_cons_printf (
"Usage: P[?osi] [file]\n"
" Po [file] open project\n"
" Ps [file] save project\n"
" Pi [file] info\n"
"NOTE: project files are stored in ~/.radare2/rdb\n");
break;
}
free (str);
return R_TRUE;
}
示例13: r_core_project_init
static int r_core_project_init(RCore *core) {
char *prjdir = r_file_abspath (r_config_get (
core->config, "dir.projects"));
int ret = r_sys_rmkdir (prjdir);
if (!ret) eprintf ("Cannot mkdir dir.projects\n");
free (prjdir);
return ret;
}
示例14: config_asmos_callback
static int config_asmos_callback(void *user, void *data) {
RCore *core = (RCore*) user;
RConfigNode *node = (RConfigNode*) data;
r_syscall_setup (core->anal->syscall,
r_config_get (core->config, "asm.arch"),
node->value, core->anal->bits);
//if (!ret) eprintf ("asm.os: Cannot setup syscall os/arch for '%s'\n", node->value);
return R_TRUE;
}
示例15: objc_analyze
static void objc_analyze(RCore *core) {
eprintf ("[+] Analyzing searching references to selref\n");
r_core_cmd0 (core, "aar");
if (!strcmp ("arm", r_config_get (core->config, "asm.arch"))) {
bool emu_lazy = r_config_get_i (core->config, "emu.lazy");
r_config_set_i (core->config, "emu.lazy", true);
r_core_cmd0 (core, "aae");
r_config_set_i (core->config, "emu.lazy", emu_lazy);
}
}