本文整理汇总了C++中r_num_math函数的典型用法代码示例。如果您正苦于以下问题:C++ r_num_math函数的具体用法?C++ r_num_math怎么用?C++ r_num_math使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r_num_math函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_num
int test_num(RNum *num, const char *str, ut64 okvalue) {
ut64 ret;
printf(" %"PFMT64d" == ", okvalue);
ret = r_num_math(num, str);
printf("%"PFMT64d" \t; %s", ret, str);
if (ret == okvalue) printf("\r ok\n");
else printf("\rFAIL\n");
}
示例2: cmd_meta
static int cmd_meta(void *data, const char *input) {
RCore *core = (RCore*)data;
int i;
RAnalFunction *f;
switch (*input) {
case 'j':
case '*':
r_meta_list (core->anal, R_META_TYPE_ANY, *input);
break;
case 'L':
cmd_meta_lineinfo (core, input + 1);
break;
case 'C':
cmd_meta_comment (core, input);
break;
case 'h': /* comment */
case 's': /* string */
case 'd': /* data */
case 'm': /* magic */
case 'f': /* formatted */
cmd_meta_hsdmf (core, input);
break;
case '-':
if (input[1]!='*') {
i = r_num_math (core->num, input+((input[1]==' ')?2:1));
r_meta_del (core->anal, R_META_TYPE_ANY, core->offset, i, "");
} else r_meta_cleanup (core->anal, 0LL, UT64_MAX);
break;
case '\0':
case '?':{
const char* help_msg[] = {
"Usage:", "C[-LCvsdfm?] [...]", " # Metadata management",
"C*", "", "list meta info in r2 commands",
"C-", " [len] [[@]addr]", "delete metadata at given address range",
"CL", "[-][*] [file:line] [addr]", "show or add 'code line' information (bininfo)",
"CC", "[-] [comment-text] [@addr]", "add/remove comment",
"CC!", " [@addr]", "edit comment with $EDITOR",
"CCa", "[-at]|[at] [text] [@addr]", "add/remove comment at given address",
"CCu", " [comment-text] [@addr]", "add unique comment",
"Cs", "[-] [size] [@addr]", "add string",
"Ch", "[-] [size] [@addr]", "hide data",
"Cd", "[-] [size] [@addr]", "hexdump data",
"Cf", "[-] [sz] [fmt..] [@addr]", "format memory (see pf?)",
"Cm", "[-] [sz] [fmt..] [@addr]", "magic parse (see pm?)",
NULL};
r_core_cmd_help (core, help_msg);
}
break;
case 'F':
f = r_anal_get_fcn_in (core->anal, core->offset,
R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM);
if (f) r_anal_str_to_fcn (core->anal, f, input+2);
else eprintf ("Cannot find function here\n");
break;
}
return R_TRUE;
}
示例3: cmd_wf
static bool cmd_wf(RCore *core, const char *input) {
ut8 *buf;
int size;
const char *arg = input + ((input[1] == ' ') ? 2 : 1);
int wseek = r_config_get_i (core->config, "cfg.wseek");
char *p, *a = r_str_chop (strdup (arg));
// XXX: file names cannot contain spaces
p = strchr (a, ' ');
if (p) *p++ = 0;
if (*arg =='?' || !*arg) {
eprintf ("Usage: wf [file] ([size] ([offset]))\n");
}
if (!strcmp (arg, "-")) {
char *out = r_core_editor (core, NULL, NULL);
if (out) {
r_io_write_at (core->io, core->offset,
(ut8*)out, strlen (out));
free (out);
}
}
if ((buf = (ut8*) r_file_slurp (a, &size))) {
int u_size = size;
int u_offset = 0;
u_size = r_num_math (core->num, p);
if (u_size < 1) u_size = size;
if (p) {
*p++ = 0;
u_offset = r_num_math (core->num, p);
if (u_offset > size) {
eprintf ("Invalid offset\n");
free (buf);
return false;
}
}
r_io_use_desc (core->io, core->file->desc);
r_io_write_at (core->io, core->offset, buf + u_offset, u_size);
WSEEK (core, size);
free (buf);
r_core_block_read (core, 0);
} else {
eprintf ("Cannot open file '%s'\n", arg);
}
return true;
}
示例4: cmd_meta
static int cmd_meta(void *data, const char *input) {
RCore *core = (RCore*)data;
int i;
char *t = 0;
RAnalFunction *f;
switch (*input) {
case 'j':
case '*':
r_meta_list (core->anal, R_META_TYPE_ANY, *input);
break;
case 'L':
cmd_meta_lineinfo (core, input + 1);
break;
case 'C':
cmd_meta_comment (core, input);
break;
case 'h': /* comment */
case 's': /* string */
case 'd': /* data */
case 'm': /* magic */
case 'f': /* formatted */
cmd_meta_hsdmf (core, input);
break;
case '-':
if (input[1]!='*') {
i = r_num_math (core->num, input+((input[1]==' ')?2:1));
r_meta_del (core->anal, R_META_TYPE_ANY, core->offset, i, "");
} else r_meta_cleanup (core->anal, 0LL, UT64_MAX);
break;
case '\0':
case '?':
r_cons_strcat (
"|Usage: C[-LCvsdfm?] [...]\n"
"| C* List meta info in r2 commands\n"
"| C- [len] [@][ addr] delete metadata at given address range\n"
"| CL[-][*] [file:line] [addr] show or add 'code line' information (bininfo)\n"
"| CC[-] [comment-text] add/remove comment. Use CC! to edit with $EDITOR\n"
"| CCa[-at]|[at] [text] add/remove comment at given address\n"
"| Cs[-] [size] [[addr]] add string\n"
"| Ch[-] [size] [@addr] hide data\n"
"| Cd[-] [size] hexdump data\n"
"| Cf[-] [sz] [fmt..] format memory (see pf?)\n"
"| Cm[-] [sz] [fmt..] magic parse (see pm?)\n");
break;
case 'F':
f = r_anal_fcn_find (core->anal, core->offset,
R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM);
if (f) r_anal_str_to_fcn (core->anal, f, input+2);
else eprintf ("Cannot find function here\n");
break;
}
if (t)
free (t);
return R_TRUE;
}
示例5: format_output
static int format_output (char mode, const char *s) {
ut64 n = r_num_math (num, s);
const char *str = (char*) &n;
char strbits[65];
if (flags & 2) {
/* swap endian */
ut32 n2 = (n>>32)? 8:4;
r_mem_copyendian ((ut8*) str, (ut8*) str, n2, 0);
}
示例6: r_reg_set_bvalue
R_API ut64 r_reg_set_bvalue(RReg *reg, RRegItem *item, const char *str) {
ut64 num;
if (!item->flags)
return UT64_MAX;
num = r_str_bits_from_string (str, item->flags);
if (num == UT64_MAX)
r_reg_set_value (reg, item, r_num_math (NULL, str));
else r_reg_set_value (reg, item, num);
return num;
}
示例7: rax
static int rax(const char *str) {
ut64 n;
if (*str=='q')
return 0;
n = r_num_math(NULL, str);
if (str[0]=='0'&&str[1]=='x')
printf("%"PFMT64d"\n", n);
else printf("0x%"PFMT64x"\n", n);
return 1;
}
示例8: r_reg_set_bvalue
R_API ut64 r_reg_set_bvalue(RReg *reg, RRegItem *item, const char *str) {
ut64 num = UT64_MAX;
if (item && item->flags && str) {
num = r_str_bits_from_string (str, item->flags);
if (num == UT64_MAX) {
num = r_num_math (NULL, str);
}
r_reg_set_value (reg, item, num);
}
return num;
}
示例9: __open
static RIODesc* __open(RIO* io, const char* pathname, int rw, int mode) {
RIONull* null;
if (__plugin_open (io, pathname,0)) {
if (!strncmp (pathname, "null://", 7) && strlen (pathname + 7)) {
null = R_NEW0 (RIONull);
null->size = r_num_math (NULL, pathname + 7) + 1; //???
null->offset = 0LL;
return r_io_desc_new (io, &r_io_plugin_null, pathname, rw, mode, null);
}
}
return NULL;
}
示例10: r_core_yank_file_ex
R_API int r_core_yank_file_ex (RCore *core, const char *input) {
ut64 len = 0, adv = 0, addr = 0;
int res = R_FALSE;
if (!input) return res;
// get the number of bytes to yank
adv = consume_chars (input, ' ');
len = r_num_math (core->num, input+adv);
if (len == 0) {
eprintf ("ERROR: Number of bytes read must be > 0\n");
return res;
}
// get the addr/offset from in the file we want to read
adv += find_next_char (input+adv, ' ');
if (adv == 0) {
eprintf ("ERROR: Address must be specified\n");
return res;
}
adv++;
IFDBG eprintf ("Handling the input: %s\n", input+adv);
// XXX - bug, will fail if address needs to be computed and has spaces
addr = r_num_math (core->num, input+adv);
adv += find_next_char (input+adv, ' ');
if (adv == 0) {
eprintf ("ERROR: File must be specified\n");
return res;
}
adv++;
IFDBG eprintf ("Filename: %s\n", input+adv);
// grab the current file descriptor, so we can reset core and io state
// after our io op is done
return perform_mapped_file_yank (core, addr, len, input+adv);
}
示例11: r_core_yank_to
R_API int r_core_yank_to(RCore *core, const char *_arg) {
ut64 src = core->offset;
ut64 len = 0;
ut64 pos = -1;
char *str, *arg;
ut8 *buf;
while (*_arg==' ') _arg++;
arg = strdup (_arg);
str = strchr (arg, ' ');
if (str) {
str[0]='\0';
len = r_num_math (core->num, arg);
pos = r_num_math (core->num, str+1);
str[0]=' ';
}
if ((str == NULL) || (pos == -1) || (len == 0)) {
eprintf ("Usage: yt [len] [dst-addr]\n");
free (arg);
return 1;
}
#if 0
if (!config_get("file.write")) {
eprintf("You are not in read-write mode.\n");
return 1;
}
#endif
buf = (ut8*)malloc (len);
r_core_read_at (core, src, buf, len);
r_core_write_at (core, pos, buf, len);
free (buf);
core->offset = src;
r_core_block_read (core, 0);
free (arg);
return 0;
}
示例12: meta_inrange_get
R_API RAnalMetaItem *r_meta_find_in(RAnal *a, ut64 at, int type, int where) {
char *res = meta_inrange_get (a, at, 1);
if (!res) {
return NULL;
}
RList *list = r_str_split_list (res, ",");
RListIter *iter;
const char *meta;
r_list_foreach (list, iter, meta) {
ut64 mia = r_num_math (NULL, meta);
RAnalMetaItem *mi = r_meta_find (a, mia, type, where);
if (mi && (at >= mi->from && at < mi->to)) {
free (res);
return mi;
}
}
示例13: sdb_fmt
R_API char *r_type_get_struct_memb(Sdb *TDB, const char *type, int offset) {
int i, typesize = 0;
char *res = NULL;
if (offset < 0) {
return NULL;
}
char* query = sdb_fmt ("struct.%s", type);
char *members = sdb_get (TDB, query, 0);
if (!members) {
//eprintf ("%s is not a struct\n", type);
return NULL;
}
int nargs = r_str_split (members, ',');
for (i = 0; i < nargs ; i++) {
const char *name = r_str_word_get0 (members, i);
if (!name) {
break;
}
query = sdb_fmt ("struct.%s.%s", type, name);
char *subtype = sdb_get (TDB, query, 0);
if (!subtype) {
break;
}
int len = r_str_split (subtype, ',');
if (len < 3) {
free (subtype);
break;
}
int val = r_num_math (NULL, r_str_word_get0 (subtype, len - 1));
int arrsz = val ? val : 1;
if ((typesize / 8) == offset) {
res = r_str_newf ("%s.%s", type, name);
free (subtype);
break;
}
typesize += r_type_get_bitsize (TDB, subtype) * arrsz;
free (subtype);
}
free (members);
return res;
}
示例14: r_core_rtr_remove
R_API void r_core_rtr_remove(RCore *core, const char *input) {
int fd, i;
if (input[0] >= '0' && input[0] <= '9') {
fd = r_num_math (core->num, input);
for (i = 0; i < RTR_MAX_HOSTS; i++)
if (rtr_host[i].fd->fd == fd) {
r_socket_free (rtr_host[i].fd);
rtr_host[i].fd = NULL;
if (rtr_n == i)
for (rtr_n = 0; !rtr_host[rtr_n].fd && rtr_n < RTR_MAX_HOSTS; rtr_n++);
break;
}
} else {
for (i = 0; i < RTR_MAX_HOSTS; i++)
if (rtr_host[i].fd)
r_socket_free (rtr_host[i].fd);
memset (rtr_host, '\0', RTR_MAX_HOSTS * sizeof(RCoreRtrHost));
rtr_n = 0;
}
}
示例15: sdb_fmt
R_API RAnalVar *get_link_var(RAnal *anal, ut64 faddr, RAnalVar *var) {
const char *var_local = sdb_fmt ("var.0x%"PFMT64x".%d.%d.%s",
faddr, 1, var->delta, "reads");
const char *xss = sdb_const_get (anal->sdb_fcns, var_local, 0);
ut64 addr = r_num_math (NULL, xss);
char *inst_key = r_str_newf ("inst.0x%"PFMT64x".lvar", addr);
char *var_def = sdb_get (anal->sdb_fcns, inst_key, 0);
if (!var_def) {
free (inst_key);
return NULL;
}
struct VarUsedType vut;
RAnalVar *res = NULL;
if (sdb_fmt_tobin (var_def, SDB_VARUSED_FMT, &vut) == 4) {
res = r_anal_var_get (anal, vut.fcn_addr, vut.type[0], vut.scope, vut.delta);
sdb_fmt_free (&vut, SDB_VARUSED_FMT);
}
free (inst_key);
free (var_def);
return res;
}