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

C++ r_file_slurp函数代码示例

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

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



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

示例1: free

R_API char *r_cons_editor (const char *file) {
	char *line;
	_n = 0;
	free (path);
	if (file) {
		path = strdup (file);
		lines = r_file_slurp (file, &bytes);
		nlines = r_str_split (lines, '\n');
		eprintf ("Loaded %d lines on %d bytes\n", nlines-1, bytes);
	} else path = NULL;
	r_cons_new ();
	I->line->hist_up = up;
	I->line->hist_down = down;
	I->line->contents = I->line->buffer.data;
	for (;;) {
		setnewline (_n);
		snprintf (prompt, sizeof (prompt), "%d: ", _n);
		r_line_set_prompt (prompt);
		line = r_line_readline ();
		saveline (_n, line);
		_n++;
		if (!line) break;
	}
	filesave ();
	return NULL;
}
开发者ID:silky,项目名称:radare2,代码行数:26,代码来源:editor.c


示例2: r_egg_Cfile_parseCompiled

static bool r_egg_Cfile_parseCompiled(const char *file) {
	char *fileExt = r_str_newf ("%s.tmp", file);
	char *buffer = r_file_slurp (fileExt, NULL);

	buffer = r_str_replace (buffer, "rdata", "text", false);
	buffer = r_str_replace (buffer, "rodata", "text", false);
	buffer = r_str_replace (buffer, "get_pc_thunk.bx", "__getesp__", true);

	const char *words[] = {".cstring", "size", "___main", "section", "__alloca", "zero", "cfi"};
	size_t i;
	for (i = 0; i < 7; i++) {
		r_str_stripLine (buffer, words[i]);
	}

	free (fileExt);
	fileExt = r_str_newf ("%s.s", file);
	if (!r_file_dump (fileExt, (const ut8*) buffer, strlen (buffer), true)) {
		eprintf ("Error while opening %s.s\n", file);
		goto fail;
	}

	free (buffer);
	free (fileExt);
	return true;

fail:
	free (buffer);
	free (fileExt);
	return false;
}
开发者ID:agatti,项目名称:radare2,代码行数:30,代码来源:egg_Cfile.c


示例3: R_NEW0

static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
	char *out;
	int rlen;
	if (__plugin_open (io, pathname, 0)) {
		RIOBind iob;
		RIOBfdbg *mal = R_NEW0 (RIOBfdbg);
		r_io_bind (io, &iob);
		mal->fd = getmalfd (mal);
		mal->bfvm = bfvm_new (&iob);
		out = r_file_slurp (pathname+8, &rlen);
		if (!out || rlen < 1) {
			free (mal);
			free (out);
			return NULL;
		}
		mal->size = rlen;
		mal->buf = malloc (mal->size+1);
		if (mal->buf != NULL) {
			memcpy (mal->buf, out, rlen);
			free (out);
			return r_io_desc_new (&r_io_plugin_bfdbg,
				mal->fd, pathname, rw, mode, mal);
		}
		eprintf ("Cannot allocate (%s) %d bytes\n",
			pathname+9, mal->size);
		free (mal);
		free (out);
	}
	return NULL;
}
开发者ID:8500616886,项目名称:radare2,代码行数:30,代码来源:io_bfdbg.c


示例4: 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;
}
开发者ID:csarn,项目名称:radare2,代码行数:25,代码来源:project.c


示例5: r_io_open

static ut8 *slurp(RCore **c, const char *file, int *sz) {
	RIODesc *d;
	RIO *io;
	if (c && file && strstr (file, "://")) {
		ut8 *data = NULL;
		ut64 size;
		if (!*c) {
			*c = opencore (NULL);
		}
		io = (*c)->io;
		d = r_io_open (io, file, 0, 0);
		if (!d) {
			return NULL;
		}
		size = r_io_size (io);
		if (size > 0 || size < ST32_MAX) {
			data = calloc (1, size);
			if (r_io_read_at (io, 0, data, size) == size) {
				if (sz) {
					*sz = size;
				}
			} else {
				eprintf ("slurp: read error\n");
				R_FREE (data);
			}
		} else {
			eprintf ("slurp: File is too big\n");
		}
		r_io_close (io, d);
		return data;
	}
	return (ut8*)r_file_slurp (file, sz);
}
开发者ID:ninjahacker,项目名称:radare2,代码行数:33,代码来源:radiff2.c


示例6: r_buf_new

R_API RBuffer *r_buf_file (const char *file) {
	RBuffer *b = r_buf_new ();
	if (!b) return NULL;
	b->buf = (ut8*)r_file_slurp (file, &b->length);
	if (b->buf) return b;
	r_buf_free (b);
	return NULL; /* we just freed b, don't return it */
}
开发者ID:dialeth,项目名称:radare2,代码行数:8,代码来源:buf.c


示例7: r_file_temp

static char *r_debug_rap_reg_profile(RDebug *dbg) {
	char *out, *tf = r_file_temp ("/tmp/rap.XXXXXX");
	int fd = r_cons_pipe_open (tf, 1, 0);
	r_io_system (dbg->iob.io, "drp");
	r_cons_pipe_close (fd);
	out = r_file_slurp (tf, NULL);
	r_file_rm (tf);
	return out;
}
开发者ID:17twenty,项目名称:radare2,代码行数:9,代码来源:debug_rap.c


示例8: r_file_slurp

// Display the content of a file in the hud
R_API char *r_cons_hud_file(const char *f) {
	char *s = r_file_slurp (f, NULL);
	if (s) {
		char *ret = r_cons_hud_string (s);
		free (s);
		return ret;
	}
	return NULL;
}
开发者ID:Maijin,项目名称:radare2,代码行数:10,代码来源:hud.c


示例9: r_run_parsefile

R_API int r_run_parsefile(RRunProfile *p, const char *b) {
	char *s = r_file_slurp (b, NULL);
	if (s) {
		int ret = r_run_parse (p, s);
		free (s);
		return ret;
	}
	return 0;
}
开发者ID:f0829,项目名称:radare2,代码行数:9,代码来源:run.c


示例10: r_file_slurp

// Display the content of a file in the hud
R_API char *r_cons_hud_file(const char *f, const bool usecolor) {
	char *s = r_file_slurp (f, NULL);
	if (s) {
		char *ret = r_cons_hud_string (s, usecolor);
		free (s);
		if (!ret)
			ret = strdup ("");
		return ret;
	}
	return NULL;
}
开发者ID:Darredevil,项目名称:radare2,代码行数:12,代码来源:hud.c


示例11: r_reg_set_profile

R_API int r_reg_set_profile(RReg *reg, const char *profile) {
	int ret;
	char *base, *file;
	char *str = r_file_slurp (profile, NULL);
	if (!str) {
		base = r_sys_getenv (R_LIB_ENV);
		if (base) {
			file = r_str_append (base, profile);
			str = r_file_slurp (file, NULL);
			free (file);
		}
	}
	if (!str) {
		eprintf ("r_reg_set_profile: Cannot find '%s'\n", profile);
		return false;
	}
	ret = r_reg_set_profile_string (reg, str);
	free (str);
	return ret;
}
开发者ID:Maijin,项目名称:radare2,代码行数:20,代码来源:profile.c


示例12: r_buf_new

// TODO: rename to new_from_file ?
R_API RBuffer *r_buf_new_slurp(const char *file) {
	int len;
	RBuffer *b = r_buf_new ();
	if (!b) return NULL;
	b->buf = (ut8*)r_file_slurp (file, &len);
	b->length = len;
	if (b->buf) {
		return b;
	}
	r_buf_free (b);
	return NULL; /* we just freed b, don't return it */
}
开发者ID:P4N74,项目名称:radare2,代码行数:13,代码来源:buf.c


示例13: switch

static char *getstr(const char *src) {
	int len;
	char *ret = NULL;

	switch (*src) {
	case '\'':
		ret = strdup (src+1);
		if (ret) {
			len = strlen (ret);
			if (len>0) {
				len--;
				if (ret[len]=='\'') {
					ret[len] = 0;
					return ret;
				} else eprintf ("Missing \"\n");
			}
			free (ret);
		}
		return NULL;
	case '"':
		ret = strdup (src+1);
		if (ret) {
			len = strlen (ret);
			if (len>0) {
				len--;
				if (ret[len]=='"') {
					ret[len] = 0;
					r_str_unescape (ret);
					return ret;
				} else eprintf ("Missing \"\n");
			}
			free (ret);
		}
		return NULL;
	case '@':
		// slurp file
		return r_file_slurp (src+1, NULL);
	case ':':
		// hexpairs
		ret = strdup (src);
		len = r_hex_str2bin (src+1, (ut8*)ret);
		if (len>0) {
			ret[len] = 0;
			return ret;
		} else {
			eprintf ("Invalid hexpair string\n");
			free (ret);
			return NULL;
		}
	}
	r_str_unescape ((ret = strdup (src)));
	return ret;
}
开发者ID:LucaBongiorni,项目名称:radare2,代码行数:53,代码来源:rarun2.c


示例14: r_core_project_cat

R_API int r_core_project_cat(RCore *core, const char *name) {
	char *path = r_core_project_file (core, name);
	if (path) {
		char *data = r_file_slurp (path, NULL);
		if (data) {
			r_cons_println (data);
			free (data);
		}
	}
	free (path);
	return 0;
}
开发者ID:AmesianX,项目名称:radare2,代码行数:12,代码来源:project.c


示例15: r_reg_set_profile

R_API int r_reg_set_profile(RReg *reg, const char *profile) {
	int ret;
	char *base, *file;
	char *str = r_file_slurp (profile, NULL);
	if (!str) {
		// XXX we must define this varname in r_lib.h /compiletime/
		base = r_sys_getenv ("LIBR_PLUGINS");
		if (base) {
			file = r_str_concat (base, profile);
			str = r_file_slurp (file, NULL);
			free (file);
		}
	}

	if (!str) {
		eprintf ("r_reg_set_profile: Cannot find '%s'\n", profile);
		return false;
	}
	
	ret = r_reg_set_profile_string (reg, str);
	free (str);
	return ret;
}
开发者ID:johnjohnsp1,项目名称:radare2,代码行数:23,代码来源:profile.c


示例16: r_bin_java_new

RBinJavaObj* r_bin_java_new(const char* file) {
	ut8 *buf;
	RBinJavaObj *bin = R_NEW0 (RBinJavaObj);
	bin->file = file;
	if (!(buf = (ut8*)r_file_slurp (file, &bin->size))) 
		return r_bin_java_free (bin);
	bin->b = r_buf_new ();
	if (!r_buf_set_bytes (bin->b, buf, bin->size))
		return r_bin_java_free (bin);
	free (buf);
	if (!javasm_init (bin))
		return r_bin_java_free (bin);
	return bin;
}
开发者ID:pixilla,项目名称:radare2,代码行数:14,代码来源:java.c


示例17: r_bin_te_new

struct r_bin_te_obj_t* r_bin_te_new(const char* file) {
	ut8 *buf;
	struct r_bin_te_obj_t *bin = R_NEW0 (struct r_bin_te_obj_t);
	if (!bin) return NULL;
	bin->file = file;
	if (!(buf = (ut8*)r_file_slurp(file, &bin->size)))
		return r_bin_te_free(bin);
	bin->b = r_buf_new ();
	if (!r_buf_set_bytes (bin->b, buf, bin->size))
		return r_bin_te_free(bin);
	free (buf);
	if (!r_bin_te_init(bin))
		return r_bin_te_free(bin);
	return bin;
}
开发者ID:BatchDrake,项目名称:radare2,代码行数:15,代码来源:te.c


示例18: cmd_wff

static bool cmd_wff(RCore *core, const char *input) {
	ut8 *buf;
	int size;
	// XXX: file names cannot contain spaces
	const char *arg = input + ((input[1] == ' ') ? 2 : 1);
	int wseek = r_config_get_i (core->config, "cfg.wseek");
	char *p, *a = r_str_trim (strdup (arg));
	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));
			r_core_block_read (core);
			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_fd (core->io, core->file->fd);
		r_io_write_at (core->io, core->offset, buf + u_offset, u_size);
		WSEEK (core, size);
		free (buf);
		r_core_block_read (core);
	} else {
		eprintf ("Cannot open file '%s'\n", arg);
	}
	return true;
}
开发者ID:agatti,项目名称:radare2,代码行数:48,代码来源:cmd_write.c


示例19: r_bin_dyldcache_new

struct r_bin_dyldcache_obj_t* r_bin_dyldcache_new(const char* file) {
	struct r_bin_dyldcache_obj_t *bin;
	ut8 *buf;
	if (!(bin = malloc (sizeof (struct r_bin_dyldcache_obj_t))))
		return NULL;
	memset (bin, 0, sizeof (struct r_bin_dyldcache_obj_t));
	bin->file = file;
	if (!(buf = (ut8*)r_file_slurp(file, &bin->size))) 
		return r_bin_dyldcache_free(bin);
	bin->b = r_buf_new();
	if (!r_buf_set_bytes(bin->b, buf, bin->size))
		return r_bin_dyldcache_free(bin);
	free (buf);
	if (!r_bin_dyldcache_init(bin))
		return r_bin_dyldcache_free(bin);
	return bin;
}
开发者ID:17twenty,项目名称:radare2,代码行数:17,代码来源:dyldcache.c


示例20: lang_duktape_file

static int lang_duktape_file(RLang *lang, const char *file) {
	int ret = -1;
	char *code = r_file_slurp (file, NULL); 
	if (code) {
		register_helpers (lang);
		duk_push_lstring (ctx, code, strlen (code));
		duk_push_string (ctx,file);
		free (code);
		ret = duk_safe_call (ctx, wrapped_compile_execute, 2, 1);
		if (ret != DUK_EXEC_SUCCESS) {
			print_error(ctx, stderr);
			eprintf ("duktape error");
		} else {
			duk_pop (ctx);
		}
	}
	return ret;
}
开发者ID:pleonex,项目名称:radare2-bindings,代码行数:18,代码来源:duktape.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ r_has_type函数代码示例发布时间:2022-05-30
下一篇:
C++ r_egg_printf函数代码示例发布时间: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