• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sdb_const_get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sdb_const_get函数的典型用法代码示例。如果您正苦于以下问题:C++ sdb_const_get函数的具体用法?C++ sdb_const_get怎么用?C++ sdb_const_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sdb_const_get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: eprintf

R_API RAnalMetaItem *r_meta_find(RAnal *a, ut64 at, int type, int where) {
	const char *infos, *metas;
	char key[100];
	Sdb *s = a->sdb_meta;
	static RAnalMetaItem mi = {0};
	// XXX: return allocated item? wtf
	if (where != R_META_WHERE_HERE) {
		eprintf ("THIS WAS NOT SUPOSED TO HAPPEN\n");
		return NULL;
	}

	snprintf (key, sizeof (key), "meta.0x%" PFMT64x, at);
	infos = sdb_const_get (s, key, 0);
	if (!infos) {
		return NULL;
	}
	for (; *infos; infos++) {
		if (*infos == ',') {
			continue;
		}
		if (type != R_META_TYPE_ANY && type != *infos) {
			continue;
		}
		snprintf (key, sizeof (key), "meta.%c.0x%" PFMT64x, *infos, at);
		metas = sdb_const_get (s, key, 0);
		if (metas) {
			if (!r_meta_deserialize_val (&mi, *infos, at, metas)) {
				continue;
			}
			return &mi;
		}
	}
	return NULL;
}
开发者ID:skuater,项目名称:radare2,代码行数:34,代码来源:meta.c


示例2: dbdiff

static int dbdiff (const char *a, const char *b) {
	int n = 0;
	char *k, *v;
	const char *v2;
	Sdb *A = sdb_new (NULL, a, 0);
	Sdb *B = sdb_new (NULL, b, 0);
	sdb_dump_begin (A);
	while (sdb_dump_dupnext (A, &k, &v)) {
		v2 = sdb_const_get (B, k, 0);
		if (!v2) {
			printf ("%s=\n", k);
			n = 1;
		}
	}
	sdb_dump_begin (B);
	while (sdb_dump_dupnext (B, &k, &v)) {
		if (!v || !*v) continue;
		v2 = sdb_const_get (A, k, 0);
		if (!v2 || strcmp (v, v2)) {
			printf ("%s=%s\n", k, v2);
			n = 1;
		}
	}
	return n;
}
开发者ID:johansenj,项目名称:radare2,代码行数:25,代码来源:main.c


示例3: eprintf

R_API RSyscallItem *r_syscall_get(RSyscall *s, int num, int swi) {
	const char *ret, *ret2, *key;
	if (!s || !s->db) {
		eprintf ("Syscall database not loaded\n");
		return NULL;
	}
	swi = getswi (s, swi);
	if (swi < 16) {
		key = sdb_fmt (0, "%d.%d", swi, num);
	} else {
		key = sdb_fmt (0, "0x%02x.%d", swi, num);
	}
	ret = sdb_const_get (s->db, key, 0);
	if (!ret) {
		key = sdb_fmt (0, "0x%02x.0x%02x", swi, num); // Workaround until Syscall SDB is fixed 
		ret = sdb_const_get (s->db, key, 0);
		if (!ret) {
			return NULL;
		}	
	}
	ret2 = sdb_const_get (s->db, ret, 0);
	if (!ret2) {
		return NULL;
	}
	return r_syscall_item_new_from_string (ret, ret2);
}
开发者ID:dtrecherel,项目名称:radare2,代码行数:26,代码来源:syscall.c


示例4: dbdiff

static int dbdiff (const char *a, const char *b) {
	int n = 0;
	char *v;
	char k[SDB_MAX_KEY] = {0};
	const char *v2;
	Sdb *A = sdb_new (NULL, a, 0);
	Sdb *B = sdb_new (NULL, b, 0);
	sdb_dump_begin (A);
	while (sdb_dump_dupnext (A, k, &v, NULL)) {
		v2 = sdb_const_get (B, k, 0);
		if (!v2) {
			printf ("%s=\n", k);
			n = 1;
		}
	}
	sdb_dump_begin (B);
	while (sdb_dump_dupnext (B, k, &v, NULL)) {
		if (!v || !*v) {
			continue;
		}
		v2 = sdb_const_get (A, k, 0);
		if (!v2 || strcmp (v, v2)) {
			printf ("%s=%s\n", k, v2);
			n = 1;
		}
	}
	sdb_free (A);
	sdb_free (B);
	free (v);
	return n;
}
开发者ID:lionaneesh,项目名称:radare2,代码行数:31,代码来源:main.c


示例5: r_anal_esil_trace_show

R_API void r_anal_esil_trace_show(RAnalEsil *esil, int idx) {
	PrintfCallback p = esil->anal->printf;
	const char *str2;
	const char *str;
	int trace_idx = esil->trace_idx;
	esil->trace_idx = idx;

	str2 = sdb_const_get (DB, KEY ("addr"), 0);
	if (!str2) {
		return;
	}
	p ("dr pc = %s\n", str2);
	/* registers */
	str = sdb_const_get (DB, KEY ("reg.read"), 0);
	if (str) {
		char regname[32];
		const char *next, *ptr = str;
		if (ptr && *ptr) {
			do {
				const char *ztr = sdb_const_anext (ptr, &next);
				int len = next? (int)(size_t)(next-ztr)-1 : strlen (ztr);
				if (len <sizeof(regname)) {
					memcpy (regname, ztr, len);
					regname[len] = 0;
					str2 = sdb_const_get (DB, KEYREG ("reg.read", regname), 0);
					p ("dr %s = %s\n", regname, str2);
				} else {
					eprintf ("Invalid entry in reg.read\n");
				}
				ptr = next;
			} while (next);
		}
	}
	/* memory */
	str = sdb_const_get (DB, KEY ("mem.read"), 0);
	if (str) {
		char addr[64];
		const char *next, *ptr = str;
		if (ptr && *ptr) {
			do {
				const char *ztr = sdb_const_anext (ptr, &next);
				int len = next? (int)(size_t)(next-ztr)-1 : strlen (ztr);
				if (len <sizeof(addr)) {
					memcpy (addr, ztr, len);
					addr[len] = 0;
					str2 = sdb_const_get (DB, KEYAT ("mem.read.data",
						r_num_get (NULL, addr)), 0);
					p ("wx %s @ %s\n", str2, addr);
				} else {
					eprintf ("Invalid entry in reg.read\n");
				}
				ptr = next;
			} while (next);
		}
	}

	esil->trace_idx = trace_idx;
}
开发者ID:AnwarMohamed,项目名称:radare2,代码行数:58,代码来源:esil_trace.c


示例6: main

int main() {
    const char *v;
    Sdb *s = sdb_new0 ();
    sdb_set (s, "key", "foo", 0);
    v = sdb_const_get(s, "key", 0);
    printf ("%p %p (assert != 0)\n", s, v);
    if (!v) return 1;

    sdb_drain (s, sdb_new0());
    v = sdb_const_get(s, "key", 0);
    printf ("%p %p (assert == 0)\n", s, v);
    sdb_free (s);
    return (v==0)?0:1;
}
开发者ID:neuschaefer,项目名称:sdb,代码行数:14,代码来源:drain.c


示例7: r_str_appendf

R_API char *r_type_enum_getbitfield(Sdb *TDB, const char *name, ut64 val) {
	char *q, *ret = NULL;
	const char *res;
	int i;

	if (r_type_kind (TDB, name) != R_TYPE_ENUM) {
		return NULL;
	}
	bool isFirst = true;
	ret = r_str_appendf (ret, "0x%08"PFMT64x" : ", val);
	for (i = 0; i < 32; i++) {
		if (!(val & (1 << i))) {
			continue;
		}
		q = sdb_fmt ("enum.%s.0x%x", name, (1<<i));
                res = sdb_const_get (TDB, q, 0);
                if (isFirst) {
			isFirst = false;
                } else {
			ret = r_str_append (ret, " | ");
                }
                if (res) {
			ret = r_str_append (ret, res);
                } else {
			ret = r_str_appendf (ret, "0x%x", (1<<i));
                }
	}
	return ret;
}
开发者ID:skuater,项目名称:radare2,代码行数:29,代码来源:ctype.c


示例8: snprintf

R_API char *r_meta_get_string(RAnal *a, int type, ut64 addr) {
	char key[100];
	const char *k, *p, *p2, *p3;
	snprintf (key, sizeof (key)-1, "meta.%c.0x%"PFMT64x, type, addr);
	k = sdb_const_get (DB, key, NULL);
	if (!k) {
		return NULL;
	}
	p = strchr (k, SDB_RS);
	if (!p) {
		return NULL;
	}
	k = p + 1;
	p2 = strchr (k, SDB_RS);
	if (!p2) {
		return (char *)sdb_decode (k, NULL);
	}
	k = p2 + 1;
	if (type == R_META_TYPE_STRING) {
		p3 = strchr (k, SDB_RS);
		if (p3) {
			return (char *)sdb_decode (p3 + 1, NULL);
		}
	}
	return (char *)sdb_decode (k, NULL);
}
开发者ID:skuater,项目名称:radare2,代码行数:26,代码来源:meta.c


示例9: r_syscall_sysreg

R_API const char* r_syscall_sysreg(RSyscall *s, const char *type, ut64 num) {
	if (!s || !s->db) {
		return NULL;
	}
	const char *key = sdb_fmt (0, "%s,%"PFMT64d, type, num);
	return sdb_const_get (s->db, key, 0);
}
开发者ID:dtrecherel,项目名称:radare2,代码行数:7,代码来源:syscall.c


示例10: sdb_const_get

SDB_API char *sdb_array_get(Sdb *s, const char *key, int idx, ut32 *cas) {
	const char *str = sdb_const_get (s, key, cas);
	const char *p = str;
	char *o, *n;
	int i, len;
	if (!str || !*str) return NULL;
	if (idx<0) {
		int len = sdb_alen (str);
		idx = -idx;
		if (idx>len)
			return NULL;
		idx = (len-idx);
	}
	if (idx==0) {
		n = strchr (str, SDB_RS);
		if (!n) return strdup (str);
		len = n-str;
		o = malloc (len+1);
		memcpy (o, str, len);
		o[len] = 0;
		return o;
	}
	for (i=0; i<idx; i++) {
		n = strchr (p, SDB_RS);
		if (!n) return NULL;
		p = n+1;
	}
	n = strchr (p, SDB_RS);
	if (!n) return strdup (p);
	len = n-p;
	o = malloc (len+1);
	memcpy (o, p, len);
	o[len] = 0;
	return o;
}
开发者ID:haoa193,项目名称:radare2,代码行数:35,代码来源:array.c


示例11: getswi

R_API const char *r_syscall_get_i(RSyscall *s, int num, int swi) {
	char foo[32];
	if (!s || !s->db)
		return NULL;
	swi = getswi (s->db, swi);
	snprintf (foo, sizeof (foo), "0x%x.%d", swi, num);
	return sdb_const_get (s->db, foo, 0);
}
开发者ID:CodingFree,项目名称:radare2,代码行数:8,代码来源:syscall.c


示例12: eprintf

R_API RAnalMetaItem *r_meta_find(RAnal *a, ut64 at, int type, int where) {
	const char *infos, *metas;
	char key[100];
	Sdb *s = a->sdb_meta;
	static RAnalMetaItem mi = {0};
	// XXX: return allocated item? wtf
	if (where != R_META_WHERE_HERE) {
		eprintf ("THIS WAS NOT SUPOSED TO HAPPEN\n");
		return NULL;
	}

	snprintf (key, sizeof (key)-1, "meta.0x%"PFMT64x, at);
	infos = sdb_const_get (s, key, 0);
	if (!infos)
		return NULL;
	for (; *infos; infos++) {
		/* XXX wtf, must use anal.meta.deserialize() */
		char *p, *q;
		if (*infos==',')
			continue;
		snprintf (key, sizeof (key) - 1, "meta.%c.0x%"PFMT64x, *infos, at);
		metas = sdb_const_get (s, key, 0);
		mi.size = sdb_array_get_num (s, key, 0, 0);
		mi.type = *infos;
		mi.from = at;
		mi.to = at + mi.size;
		if (type != R_META_TYPE_ANY && type != mi.type) {
			continue;
		}
		if (metas) {
			p = strchr (metas, ',');
			if (!p) {
				continue;
			}
			mi.space = atoi (p + 1);
			q = strchr (p + 1, ',');
			if (!q) {
				continue;
			}
			free (mi.str);
			mi.str = (char*)sdb_decode (q + 1, 0);
			return &mi;
		} else mi.str = NULL;
	}
	return NULL;
}
开发者ID:ghostbar,项目名称:radare2.deb,代码行数:46,代码来源:meta.c


示例13: 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;
}
开发者ID:HKingz,项目名称:radare2,代码行数:46,代码来源:cmd_type.c


示例14: setf

R_API RAnalHint *r_anal_hint_get(RAnal *a, ut64 addr) {
	char key[64];
	setf (key, "hint.0x%08"PFMT64x, addr);
	const char *s = sdb_const_get (DB, key, 0);
	if (!s) {
		return NULL;
	}
	return r_anal_hint_from_string (a, addr, s);
}
开发者ID:xarkes,项目名称:radare2,代码行数:9,代码来源:hint.c


示例15: r_anal_type_set

R_API int r_anal_type_set(RAnal *anal, ut64 at, const char *field, ut64 val) {
	Sdb *DB = anal->sdb_types;
	const char *kind;
	char var[128];
	sprintf (var, "link.%08"PFMT64x, at);
	kind = sdb_const_get (DB, var, NULL);
	if (kind) {
		const char *p = sdb_const_get (DB, kind, NULL);
		if (p) {
			snprintf (var, sizeof (var), "%s.%s.%s", p, kind, field);
			int off = sdb_array_get_num (DB, var, 1, NULL);
			//int siz = sdb_array_get_num (DB, var, 2, NULL);
			eprintf ("wv 0x%08"PFMT64x" @ 0x%08"PFMT64x, val, at+off);
			return true;
		} else eprintf ("Invalid kind of type\n");
	}
	return false;
}
开发者ID:zerolugithub,项目名称:radare2,代码行数:18,代码来源:types.c


示例16: test_sdb_array_add_remove

bool test_sdb_array_add_remove(void) {
	Sdb *db = sdb_new (NULL, NULL, false);
	sdb_array_add (db, "foo", "foo", 0);
	sdb_array_add (db, "foo", "bar", 0);
	sdb_array_add (db, "foo", "cow", 0);

	mu_assert_streq (sdb_const_get (db, "foo", 0), "foo,bar,cow", "Not all items found");

	sdb_array_remove (db, "foo", "bar", 0);
	mu_assert_streq (sdb_const_get (db, "foo", 0), "foo,cow", "bar was not deleted");
	sdb_array_remove (db, "foo", "nothing", 0);
	mu_assert_streq (sdb_const_get (db, "foo", 0), "foo,cow", "nothing should be deleted");
	sdb_array_remove (db, "foo", "cow", 0);
	sdb_array_remove (db, "foo", "foo", 0);
	mu_assert_eq ((int)(size_t)sdb_const_get (db, "foo", 0), (int)(size_t)NULL, "all elements should be deleted");

	sdb_free (db);
	mu_end;
}
开发者ID:ret2libc,项目名称:sdb,代码行数:19,代码来源:test_array.c


示例17: main

int main(int argc, char **argv) {
	int i, N;
	if (argc>1)
		N = atoi (argv[1]);
	else N = 1000;
	Sdb *s = sdb_new (NULL, NULL, 0);
	for (i=0;i<N;i++)
		sdb_array_push (s, "key", "foo", 0);
#if 1
	if (N != sdb_alen (sdb_const_get (s, "key", 0))) {
		printf ("FAIL IN VERY PUSH\n");
		return 1;
	}
	eprintf ("--%d\n", (int)strlen (sdb_const_get (s, "key", 0)));
#endif
	for (i=0;i<N;i++)
		free (sdb_array_pop (s, "key", 0));
	sdb_free (s);
	return 0;
}
开发者ID:XVilka,项目名称:sdb,代码行数:20,代码来源:verypush.c


示例18: snprintf

R_API char *r_meta_get_string(RAnal *a, int type, ut64 addr) {
	char key[100];
	const char *k, *p;
	snprintf (key, sizeof (key)-1, "meta.%c.0x%"PFMT64x, 'C', addr);
	k = sdb_const_get (DB, key, NULL);
	if (!k) return NULL;
	p = strchr (k, SDB_RS);
	if (!p) return NULL;
	k = p+1;
// TODO : comment append has been deprecated
	return (char *)sdb_decode (k, NULL);
}
开发者ID:KarjamP,项目名称:radare2,代码行数:12,代码来源:meta.c


示例19: 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;
}
开发者ID:ghostbar,项目名称:radare2.deb,代码行数:53,代码来源:meta.c


示例20: sdb_fmt

static RAnalVar *get_used_var(RAnal *anal, RAnalOp *op) {
	char *inst_key = sdb_fmt (0, "inst.0x%"PFMT64x".vars", op->addr);
	const char *var_def = sdb_const_get (anal->sdb_fcns, inst_key, 0);
	struct VarUsedType vut;
	RAnalVar *res;

	if (sdb_fmt_tobin (var_def, SDB_VARUSED_FMT, &vut) != 4) {
		return NULL;
	}
	res = r_anal_var_get (anal, vut.fcn_addr, vut.type[0], vut.scope, vut.delta);
	sdb_fmt_free (&vut, SDB_VARUSED_FMT);
	return res;
}
开发者ID:m-emerson,项目名称:radare2,代码行数:13,代码来源:op.c



注:本文中的sdb_const_get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sdb_fmt函数代码示例发布时间:2022-05-30
下一篇:
C++ sd_strerror函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap