示例#1
0
文件: hud.c 项目: Darredevil/radare2
// Display a buffer in the hud (splitting it line-by-line and ignoring 
// the lines starting with # )
R_API char *r_cons_hud_string(const char *s, const bool usecolor) {
	char *os, *track, *ret, *o = strdup (s);
	if (!o) return NULL;
	RList *fl = r_list_new ();
	int i;
	if (!fl) {
		free (o);
		return NULL;
	}
	fl->free = free;
	for (os = o, i = 0; o[i]; i++) {
		if (o[i] == '\n') {
			o[i] = 0;
			if (*os && *os != '#') {
				track = strdup (os);
				if (!r_list_append (fl, track)) {
					free (track);
					break;
				}
			}
			os = o + i + 1;
		}
	}
	ret = r_cons_hud (fl, NULL, usecolor);
	free (o);
	r_list_free (fl);
	return ret;
}
示例#2
0
文件: hud.c 项目: commiebstrd/radare2
R_API char *r_cons_hud_path(const char *path, int dir) {
	char *tmp = NULL, *ret = NULL;
	RList *files;
	if (path){
		while (*path==' ')
			path++;
		tmp = (*path)? strdup(path): strdup ("./");
	} else
		tmp = strdup ("./");

	files = r_sys_dir (tmp);
	if (files) {
		ret = r_cons_hud (files, tmp);
		if (ret) {
			tmp = r_str_concat (tmp, "/");
			tmp = r_str_concat (tmp, ret);
			ret = r_file_abspath (tmp);
			free (tmp);
			tmp = ret;
			if (r_file_is_directory (tmp)) {
				ret = r_cons_hud_path (tmp, dir);
				free (tmp);
				tmp = ret;
			}
		}
		r_list_free (files);
	} else eprintf ("No files found\n");
	if (!ret) {
		free (tmp);
		return NULL;
	}
	return tmp;
}
示例#3
0
文件: hud.c 项目: aronsky/radare2
// Display a buffer in the hud (splitting it line-by-line and ignoring
// the lines starting with # )
R_API char *r_cons_hud_string(const char *s) {
	char *os, *track, *ret, *o = strdup (s);
	if (!o) {
		return NULL;
	}
	r_str_replace_ch (o, '\r', 0, true);
	r_str_replace_ch (o, '\t', 0, true);
	RList *fl = r_list_new ();
	int i;
	if (!fl) {
		free (o);
		return NULL;
	}
	fl->free = free;
	for (os = o, i = 0; o[i]; i++) {
		if (o[i] == '\n') {
			o[i] = 0;
			if (*os && *os != '#') {
				track = strdup (os);
				if (!r_list_append (fl, track)) {
					free (track);
					break;
				}
			}
			os = o + i + 1;
		}
	}
	ret = r_cons_hud (fl, NULL);
	free (o);
	r_list_free (fl);
	return ret;
}
示例#4
0
文件: hud.c 项目: commiebstrd/radare2
main() {
	char *res;
	RFList fl = r_flist_new (3);
	r_flist_set (fl, 0, "foo is pure cow");
	r_flist_set (fl, 1, "bla is kinda crazy");
	r_flist_set (fl, 2, "funny to see you here");
	
	r_cons_new ();
	res = r_cons_hud (fl, NULL);
	r_cons_clear ();
	if (res) {
		r_cons_printf ("%s\n", res);
		free (res);
	}
	r_cons_flush ();
	r_cons_free ();
}
示例#5
0
文件: hud.c 项目: commiebstrd/radare2
R_API char *r_cons_hud_string(const char *s) {
	int i;
	char *os, *ret, *o = strdup (s);
	RList *fl = r_list_new ();
	if (!fl) {
		free (o);
		return NULL;
	}
	fl->free = free;
	for (os=o, i=0; o[i]; i++) {
		if (o[i]=='\n') {
			o[i] = 0;
			if (*os && *os != '#')
				r_list_append (fl, strdup (os));
			os = o + i + 1;
		}
	}
	ret = r_cons_hud (fl, NULL);
	free (o);
	r_list_free (fl);
	return ret;
}