本文整理汇总了C++中sdb_get函数的典型用法代码示例。如果您正苦于以下问题:C++ sdb_get函数的具体用法?C++ sdb_get怎么用?C++ sdb_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sdb_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sdb_get
SDB_API char *sdb_array_pop(Sdb *s, const char *key, ut32 *cas) {
ut32 kas;
char *end, *str = sdb_get (s, key, &kas);
if (!str || !*str) {
free (str);
return NULL;
}
if (cas && *cas != kas)
*cas = kas;
#if PUSH_PREPENDS
end = strchr (str, SDB_RS);
if (end) {
*end = 0;
sdb_set (s, key, end+1, 0);
} else {
sdb_unset (s, key, 0);
}
return str;
#else
for (end = str+strlen (str)-1;
end>str && *end!=SDB_RS; end--);
if (*end==SDB_RS) *end++ = 0;
sdb_set_owned (s, key, str, 0);
// XXX: probably wrong
return strdup (end);
#endif
}
示例2: sdb_fmt
R_API char *r_type_link_at (Sdb *TDB, ut64 addr) {
char* res = NULL;
if (addr == UT64_MAX) {
return NULL;
}
char* query = sdb_fmt ("link.%08"PFMT64x, addr);
res = sdb_get (TDB, query, 0);
if (!res) { // resolve struct memb if possible for given addr
SdbKv *kv;
SdbListIter *sdb_iter;
SdbList *sdb_list = sdb_foreach_list (TDB, true);
ls_foreach (sdb_list, sdb_iter, kv) {
if (strncmp (kv->key, "link.", strlen ("link."))) {
continue;
}
const char *linkptr = sdb_fmt ("0x%s", kv->key + strlen ("link."));
ut64 baseaddr = r_num_math (NULL, linkptr);
int delta = (addr > baseaddr)? addr - baseaddr: -1;
res = r_type_get_struct_memb (TDB, kv->value, delta);
if (res) {
break;
}
}
ls_free (sdb_list);
}
示例3: runline
static void runline (Sdb *s, const char *cmd) {
ut64 n;
char *p, *eq;
switch (*cmd) {
case '+': // inc
n = sdb_inc (s, cmd, 1);
save = 1;
printf ("%"ULLFMT"d\n", n);
break;
case '-': // dec
n = sdb_inc (s, cmd, -1);
save = 1;
printf ("%"ULLFMT"d\n", n);
break;
default:
if ((eq = strchr (cmd, '='))) {
save = 1;
*eq = 0;
sdb_set (s, cmd, eq+1);
} else if ((p = sdb_get (s, cmd))) {
printf ("%s\n", p);
free (p);
}
}
}
示例4: sdb_array_delete
SDB_API int sdb_array_delete(Sdb *s, const char *key, int idx, ut32 cas) {
int i;
char *p, *n, *str = sdb_get (s, key, 0);
p = str;
if (!str || !*str) {
free (str);
return 0;
}
if (idx < 0) {
idx = sdb_alen (str);
if (idx) idx--;
}
for (i = 0; i < idx; i++) {
if ( (n = strchr (p, SDB_RS)) ) {
p = n + 1;
} else {
free (str);
return 0;
}
}
n = strchr (p, SDB_RS);
if (n) {
memmove (p, n + 1, strlen (n));
} else {
if (p != str)
p--; // remove tailing SDB_RS
*p = 0;
p[1] = 0;
}
sdb_set_owned (s, key, str, cas);
return 1;
}
示例5: r_anal_get_fcn_in
R_API RAnalVar *r_anal_var_get (RAnal *a, ut64 addr, char kind, int scope, int delta) {
RAnalVar *av;
struct VarType vt;
RAnalFunction *fcn = r_anal_get_fcn_in (a, addr, 0);
if (!fcn)
return NULL;
if (delta<0) {
kind = 'v';
delta = -delta;
}
char *vardef = sdb_get (DB,
sdb_fmt (0, "var.0x%"PFMT64x".%c.%d.%d",
fcn->addr, kind, scope, delta), 0);
if (!vardef)
return NULL;
sdb_fmt_tobin (vardef, SDB_VARTYPE_FMT, &vt);
av = R_NEW0 (RAnalVar);
av->addr = addr;
av->scope = scope;
av->delta = delta;
av->name = strdup (vt.name);
av->size = vt.size;
av->type = strdup (vt.type);
sdb_fmt_free (&vt, SDB_VARTYPE_FMT);
// TODO:
// get name from sdb
// get size from sdb
// get type from sdb
return av;
}
示例6: r_anal_xrefs_from
R_API int r_anal_xrefs_from (RAnal *anal, RList *list, const char *kind, const RAnalRefType type, ut64 addr) {
char *next, *s, *str, *ptr, key[256];
RAnalRef *ref = NULL;
if (addr == UT64_MAX) {
_type = type;
_list = list;
_kpfx = r_str_newf ("xref.%s", analref_toString (type));
sdb_foreach (DB, (SdbForeachCallback)xrefs_list_cb_any, anal);
free (_kpfx);
return true;
}
XREFKEY(key, sizeof (key), kind, type, addr);
str = sdb_get (DB, key, 0);
if (!str) {
return false;
}
for (next = ptr = str; next; ptr = next) {
s = sdb_anext (ptr, &next);
if (!(ref = r_anal_ref_new ())) {
return false;
}
ref->addr = r_num_get (NULL, s);
ref->at = addr;
ref->type = type;
r_list_append (list, ref);
}
free (str);
return true;
}
示例7: typelist
static int typelist (void *p, const char *k, const char *v) {
r_cons_printf ("tk %s = %s\n", k, v);
#if 0
if (!strcmp (v, "func")) {
const char *rv = sdb_const_get (DB,
sdb_fmt (0, "func.%s.ret", k), 0);
r_cons_printf ("# %s %s(", rv, k);
for (i = 0; i < 16; i++) {
char *av = sdb_get (DB,
sdb_fmt (0, "func.%s.arg.%d", k, i), 0);
if (!av) break;
r_str_replace_char (av, ',', ' ');
r_cons_printf ("%s%s", i? ", ": "", av);
free (av);
}
r_cons_printf (");\n");
// signature in pf for asf
r_cons_printf ("asf %s=", k);
// formats
for (i = 0; i < 16; i++) {
const char *fmt;
char *comma, *av = sdb_get (DB,
sdb_fmt (0, "func.%s.arg.%d", k, i), 0);
if (!av) break;
comma = strchr (av, ',');
if (comma) *comma = 0;
fmt = sdb_const_get (DB, sdb_fmt (0, "type.%s", av), 0);
r_cons_printf ("%s", fmt);
if (comma) *comma = ',';
free (av);
}
// names
for (i = 0; i < 16; i++) {
char *comma, *av = sdb_get (DB,
sdb_fmt (0, "func.%s.arg.%d", k, i), 0);
if (!av) break;
comma = strchr (av, ',');
if (comma) *comma++ = 0;
r_cons_printf (" %s", comma);
free (av);
}
r_cons_newline ();
}
#endif
return 1;
}
示例8: sdb_json_geti
SDB_API int sdb_json_geti (Sdb *s, const char *k, const char *p, ut32 *cas) {
char *v = sdb_get (s, k, cas);
if (v) {
Rangstr rs = json_get (v, p);
return rangstr_int (&rs);
}
return 0;
}
示例9: sdb_json_geti
SDB_VISIBLE int sdb_json_geti (Sdb *s, const char *k, const char *p) {
char *v = sdb_get (s, k, 0); // XXX cas
if (v) {
Rangstr rs = json_get (v, p);
return rangstr_int (&rs);
}
return 0;
}
示例10: print_meta_fileline
static int print_meta_fileline(RCore *core, const char *file_line) {
char *meta_info = sdb_get (core->bin->cur->sdb_addrinfo, file_line, 0);
if (meta_info) {
r_cons_printf ("Meta info %s\n", meta_info);
} else {
r_cons_printf ("No meta info for %s found\n", file_line);
}
return 0;
}
示例11: sdb_get
SDB_API char *sdb_json_get (Sdb *s, const char *k, const char *p, ut32 *cas) {
Rangstr rs;
char *u, *v = sdb_get (s, k, cas);
if (!v) return NULL;
rs = json_get (v, p);
u = rangstr_dup (&rs);
free (v);
return u;
}
示例12: getswi
R_API RSyscallItem *r_syscall_get(RSyscall *s, int num, int swi) {
char *ret, *ret2, foo[32];
RSyscallItem *si;
if (!s || !s->db)
return NULL;
swi = getswi (s->db, swi);
snprintf (foo, sizeof (foo), "0x%02x.%d", swi, num);
ret = sdb_get (s->db, foo, 0);
if (ret == NULL)
return NULL;
// TODO: optimize with sdb_const_get
ret2 = sdb_get (s->db, ret, 0);
if (ret2 == NULL)
return NULL;
si = r_syscall_item_new_from_string (ret, ret2);
free (ret);
free (ret2);
return si;
}
示例13: r_meta_del
R_API int r_meta_del(RAnal *a, int type, ut64 addr, ut64 size, const char *str) {
char key[100], *dtr, *s, *p, *next;
#if 0
char key2[100];
#endif
const char *ptr;
int i;
if (size == UT64_MAX) {
// FULL CLEANUP
// XXX: this thing ignores the type
if (type == R_META_TYPE_ANY) {
sdb_reset (DB);
} else {
snprintf (key, sizeof (key)-1, "meta.%c.count", type);
int last = (ut64)sdb_num_get (DB, key, NULL)/K;
for (i=0; i<last; i++) {
snprintf (key, sizeof (key)-1, "meta.%c.%d", type, i);
dtr = sdb_get (DB, key, 0);
for (p = dtr; p; p = next) {
s = sdb_anext (p, &next);
snprintf (key, sizeof (key)-1,
"meta.%c.0x%"PFMT64x,
type, sdb_atoi (s));
eprintf ("--> %s\n", key);
sdb_unset (DB, key, 0);
if (!next) break;
}
free (dtr);
}
}
return false;
}
meta_inrange_del (a, addr, size);
snprintf (key, sizeof (key)-1, type == R_META_TYPE_COMMENT ?
"meta.C.0x%"PFMT64x : "meta.0x%"PFMT64x, addr);
ptr = sdb_const_get (DB, key, 0);
if (ptr) {
sdb_unset (DB, key, 0);
#if 0
// This code is wrong, but i guess it's necessary in case type is ANY
for (i=0; ptr[i]; i++) {
if (ptr[i] != SDB_RS) {
snprintf (key2, sizeof (key2)-1,
"meta.%c.0x%"PFMT64x, ptr[i], addr);
printf ("UNSET (%s)\n", key2);
sdb_unset (DB, key2, 0);
}
}
#endif
}
sdb_unset (DB, key, 0);
return false;
}
示例14: r_str_newf
static RAnalVar *get_used_var(RAnal *anal, RAnalOp *op) {
char *inst_key = r_str_newf ("inst.0x%"PFMT64x".vars", op->addr);
char *var_def = sdb_get (anal->sdb_fcns, inst_key, 0);
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;
}
示例15: r_syscall_get_num
R_API int r_syscall_get_num(RSyscall *s, const char *str) {
char *o;
int i = -1;
// TODO: use sdb array api here
if (!s || !s->db)
return -1;
o = sdb_get (s->db, str, 0);
if (o && *o) {
r_str_split (o, ',');
i = r_num_get (NULL, r_str_word_get0 (o, 1));
}
free (o);
return i;
}