本文整理汇总了C++中r_sys_getenv函数的典型用法代码示例。如果您正苦于以下问题:C++ r_sys_getenv函数的具体用法?C++ r_sys_getenv怎么用?C++ r_sys_getenv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r_sys_getenv函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: R_NEW0
R_API R2Pipe *r2p_open(const char *cmd) {
R2Pipe *r2p = R_NEW0 (R2Pipe);
r2p->magic = R2P_MAGIC;
if (cmd == NULL) {
r2p->child = -1;
#if __UNIX__
{
char *out = r_sys_getenv ("R2PIPE_IN");
char *in = r_sys_getenv ("R2PIPE_OUT");
int done = R_FALSE;
if (in && out) {
int i_in = atoi (in);
int i_out = atoi (out);
if (i_in>=0 && i_out>=0) {
r2p->input[0] = r2p->input[1] = i_in;
r2p->output[0] = r2p->output[1] = i_out;
done = R_TRUE;
}
}
if (!done) {
eprintf ("Cannot find R2PIPE_IN or R2PIPE_OUT environment\n");
R_FREE (r2p);
}
free (in);
free (out);
}
return r2p;
#else
eprintf ("r2p_open(NULL) not supported on windows\n");
return NULL;
#endif
}
#if __WINDOWS__
w32_createPipe (r2p, cmd);
r2p->child = (int)(r2p->pipe);
#else
pipe (r2p->input);
pipe (r2p->output);
r2p->child = fork ();
if (r2p->child == -1) {
r2p_close (r2p);
return NULL;
}
env ("R2PIPE_IN", r2p->input[0]);
env ("R2PIPE_OUT", r2p->output[1]);
if (r2p->child) {
eprintf ("Child is %d\n", r2p->child);
} else {
int rc;
if (cmd && *cmd) {
rc = r_sandbox_system (cmd, 1);
} else rc = 0;
r2p_close (r2p);
exit (0);
return NULL;
}
#endif
return r2p;
}
开发者ID:sparkhom,项目名称:radare2,代码行数:60,代码来源:r2pipe.c
示例2: r2pipe_open_spawn
static R2Pipe* r2pipe_open_spawn(R2Pipe* r2pipe) {
#if __UNIX__ || defined(__CYGWIN__)
char *out = r_sys_getenv ("R2PIPE_IN");
char *in = r_sys_getenv ("R2PIPE_OUT");
int done = false;
if (in && out) {
int i_in = atoi (in);
int i_out = atoi (out);
if (i_in >= 0 && i_out >= 0) {
r2pipe->input[0] = r2pipe->input[1] = i_in;
r2pipe->output[0] = r2pipe->output[1] = i_out;
done = true;
}
}
if (!done) {
eprintf ("Cannot find R2PIPE_IN or R2PIPE_OUT environment\n");
R_FREE (r2pipe);
}
free (in);
free (out);
return r2pipe;
#else
eprintf ("r2pipe_open(NULL) not supported on windows\n");
return NULL;
#endif
}
开发者ID:csarn,项目名称:radare2,代码行数:26,代码来源:r2pipe.c
示例3: r_egg_lang_include_path
R_API void r_egg_lang_include_path (REgg *egg, const char *path) {
char *env = r_sys_getenv (R_EGG_INCDIR_ENV);
if (!env || !*env) {
r_egg_lang_include_init (egg);
env = r_sys_getenv (R_EGG_INCDIR_ENV);
}
env = r_str_concatf (NULL, "%s:%s", path, env);
r_sys_setenv (R_EGG_INCDIR_ENV, env);
free (env);
}
开发者ID:bigos,项目名称:radare2,代码行数:10,代码来源:lang.c
示例4: R_NEW0
R_API RIO *r_io_new() {
RIO *io = R_NEW0 (RIO);
if (!io) {
return NULL;
}
io->buffer = r_cache_new (); // RCache is a list of ranged buffers. maybe rename?
io->write_mask_fd = -1;
io->cb_printf = (void *)printf;
io->bits = (sizeof (void *) == 8)? 64: 32;
io->ff = true;
io->Oxff = 0xff;
io->aslr = 0;
io->pava = false;
io->raised = -1;
io->autofd = true;
r_io_map_init (io);
r_io_desc_init (io);
r_io_undo_init (io);
r_io_cache_init (io);
r_io_plugin_init (io);
r_io_section_init (io);
{
char *env = r_sys_getenv ("R_IO_MAX_ALLOC");
if (env) {
io->maxalloc = r_num_get (NULL, env);
free (env);
}
}
return io;
}
开发者ID:m403,项目名称:radare2,代码行数:30,代码来源:io.c
示例5: parseline
static void parseline (char *b) {
char *e = strchr (b, '=');
if (!e) return;
if (*b=='#') return;
*e++ = 0;
if (*e=='$') e = r_sys_getenv (e);
if (e == NULL) return;
if (!strcmp (b, "program")) _args[0] = _program = strdup (e);
else if (!strcmp (b, "connect")) _connect = strdup (e);
else if (!strcmp (b, "listen")) _listen = strdup (e);
else if (!strcmp (b, "stdout")) _stdout = strdup (e);
else if (!strcmp (b, "stdin")) _stdin = strdup (e);
else if (!strcmp (b, "input")) _input = strdup (e);
else if (!strcmp (b, "chdir")) _chgdir = strdup (e);
else if (!strcmp (b, "chroot")) _chroot = strdup (e);
else if (!strcmp (b, "preload")) _preload = strdup (e);
else if (!strcmp (b, "setuid")) _setuid = strdup (e);
else if (!strcmp (b, "seteuid")) _seteuid = strdup (e);
else if (!strcmp (b, "setgid")) _setgid = strdup (e);
else if (!strcmp (b, "setegid")) _setegid = strdup (e);
else if (!memcmp (b, "arg", 3)) {
int n = atoi (b+3);
if (n>=0 && n<NARGS) {
_args[n] = strdup (e);
r_str_escape (_args[n]);
} else eprintf ("Out of bounds args index: %d\n", n);
} else if (!strcmp (b, "timeout")) _timeout = atoi (e);
else if (!strcmp (b, "setenv")) {
char *v = strchr (e, '=');
if (v) {
*v++ = 0;
r_sys_setenv (e, v);
}
}
}
开发者ID:Missuniverse110,项目名称:radare2,代码行数:35,代码来源:rarun2.c
示例6: r_cons_get_size
R_API int r_cons_get_size(int *rows) {
#if __UNIX__
struct winsize win;
if (ioctl (1, TIOCGWINSZ, &win) == 0) {
I.columns = win.ws_col;
I.rows = win.ws_row-1;
} else {
I.columns = 80;
I.rows = 23;
}
#else
char *str = r_sys_getenv ("COLUMNS");
if (str != NULL) {
I.columns = atoi (str);
I.rows = 23; // XXX. windows must get console size
free (str);
} else {
I.columns = 80;
I.rows = 23;
}
#endif
if (rows)
*rows = I.rows;
return I.columns;
}
开发者ID:jevinskie,项目名称:radare2,代码行数:25,代码来源:cons.c
示例7: r_sys_getenv
static char *find_include(const char *prefix, const char *file) {
char *pfx = NULL, *ret = NULL, *env = r_sys_getenv (R_EGG_INCDIR_ENV);
//eprintf ("find_include (%s,%s)\n", prefix, file);
if (!prefix) prefix = "";
if (*prefix=='$') {
char *out = r_sys_getenv (prefix+1);
pfx = out? out: strdup ("");
} else {
pfx = strdup (prefix);
if (!pfx) {
free (env);
return NULL;
}
}
if (env) {
char *str, *ptr = strchr (env, ':');
// eprintf ("MUST FIND IN PATH (%s)\n", env);
str = env;
while (str) {
if (ptr)
*ptr = 0;
free (ret);
ret = r_str_concatf (NULL, "%s/%s", pfx, file);
{
char *filepath = r_str_concatf (NULL, "%s/%s/%s", str, pfx, file);
// eprintf ("try (%s)\n", filepath);
if (r_file_exists (filepath)) {
free (env);
free (pfx);
free (ret);
return filepath;
}
free (filepath);
}
if (!ptr) break;
str = ptr+1;
ptr = strchr (str, ':');
}
free (env);
} else ret = r_str_concatf (NULL, "%s/%s", pfx, file);
free (pfx);
return ret;
}
开发者ID:EliaGeretto,项目名称:radare2,代码行数:44,代码来源:egg_lang.c
示例8: r_assert_log
/*
* It prints a message to the log and it provides a single point of entrance in
* case of debugging. All r_return_* functions call this.
*/
R_API void r_assert_log(RLogLevel level, const char *fmt, ...) {
va_list args;
va_start (args, fmt);
print_message (level, fmt, args);
va_end (args);
char *env = r_sys_getenv ("R_DEBUG_ASSERT");
if (env) {
if (*env && atoi (env)) {
r_sys_breakpoint ();
}
free (env);
}
}
开发者ID:aronsky,项目名称:radare2,代码行数:17,代码来源:assert.c
示例9: strdup
R_API RLine *r_line_new() {
I.hist_up = NULL;
I.hist_down = NULL;
I.prompt = strdup ("> ");
I.contents = NULL;
#if __WINDOWS__
I.ansicon = r_sys_getenv ("ANSICON");
#endif
if (!r_line_dietline_init ()) {
eprintf ("error: r_line_dietline_init\n");
}
r_line_completion_init (&I.completion, 4096);
return &I;
}
开发者ID:radare,项目名称:radare2,代码行数:14,代码来源:line.c
示例10: lang_c_file
static int lang_c_file(RLang *lang, const char *file) {
void *lib;
char *cc, *p, name[512], buf[512];
const char *libpath, *libname;
if (strlen (file) > (sizeof(name)-10))
return R_FALSE;
if (!strstr (file, ".c"))
sprintf (name, "%s.c", file);
else strcpy (name, file);
if (!r_file_exists (name)) {
eprintf ("file not found (%s)\n", name);
return R_FALSE;
}
{
char *a = (char*)r_str_lchr (name, '/');
if (a) {
*a = 0;
libpath = name;
libname = a+1;
} else {
libpath = ".";
libname = name;
}
}
p = strstr (name, ".c");
if (p) *p=0;
cc = r_sys_getenv ("CC");
if (!cc || !*cc)
cc = strdup ("gcc");
snprintf (buf, sizeof (buf), "%s -fPIC -shared %s -o %s/lib%s."R_LIB_EXT
" $(pkg-config --cflags --libs r_core)", cc, file, libpath, libname);
free (cc);
if (r_sandbox_system (buf, 1) != 0)
return R_FALSE;
snprintf (buf, sizeof (buf), "%s/lib%s."R_LIB_EXT, libpath, libname);
lib = r_lib_dl_open (buf);
if (lib!= NULL) {
void (*fcn)(RCore *);
fcn = r_lib_dl_sym (lib, "entry");
if (fcn) fcn (lang->user);
else eprintf ("Cannot find 'entry' symbol in library\n");
r_lib_dl_close (lib);
} else eprintf ("Cannot open library\n");
r_file_rm (buf); // remove lib
return 0;
}
开发者ID:libcrack,项目名称:radare2,代码行数:49,代码来源:c.c
示例11: radare2_rc
static void radare2_rc(RCore *r) {
char* env_debug = r_sys_getenv ("R_DEBUG");
bool has_debug = false;
if (env_debug) {
has_debug = true;
R_FREE (env_debug);
}
char *homerc = r_str_home (".radare2rc");
if (homerc && r_file_is_regular (homerc)) {
if (has_debug) {
eprintf ("USER CONFIG loaded from %s\n", homerc);
}
r_core_cmd_file (r, homerc);
}
free (homerc);
homerc = r_str_home (".config/radare2/radare2rc");
if (homerc && r_file_is_regular (homerc)) {
if (has_debug) {
eprintf ("USER CONFIG loaded from %s\n", homerc);
}
r_core_cmd_file (r, homerc);
}
free (homerc);
homerc = r_str_home (".config/radare2/radare2rc.d");
if (homerc) {
if (r_file_is_directory (homerc)) {
char *file;
RListIter *iter;
RList *files = r_sys_dir (homerc);
r_list_foreach (files, iter, file) {
if (*file != '.') {
char *path = r_str_newf ("%s/%s", homerc, file);
if (r_file_is_regular (path)) {
if (has_debug) {
eprintf ("USER CONFIG loaded from %s\n", homerc);
}
r_core_cmd_file (r, path);
}
free (path);
}
}
r_list_free (files);
}
free (homerc);
}
}
开发者ID:P4N74,项目名称:radare2,代码行数:47,代码来源:radare2.c
示例12: r_sys_getenv
R_API char *r_str_home(const char *str) {
int lhome, lstr;
char *dst;
char *home = r_sys_getenv (R_SYS_HOME);
if (home == NULL)
return NULL;
lhome = strlen (home);
lstr = strlen (str);
dst = (char *)malloc (lhome + lstr + 2);
memcpy (dst, home, lhome+1);
if (str && *str) {
memcpy (dst+lhome, R_SYS_DIR, strlen (R_SYS_DIR));
memcpy (dst+lhome+strlen (R_SYS_DIR), str, lstr+1);
}
free (home);
return dst;
}
开发者ID:pixilla,项目名称:radare2,代码行数:17,代码来源:str.c
示例13: _libwrap_init
static void _libwrap_init() {
char *web;
signal (SIGUSR1, sigusr1);
signal (SIGUSR2, sigusr2);
printf ("libr2 initialized. send SIGUSR1 to %d in order to reach the r2 prompt\n", getpid ());
printf ("kill -USR1 %d\n", getpid ());
fflush (stdout);
web = r_sys_getenv ("RARUN2_WEB");
core = r_core_new ();
r_core_loadlibs (core, R_CORE_LOADLIBS_ALL, NULL);
if (web) {
r_core_cmd0 (core, "=H&");
r_sys_setenv ("RARUN2_WEB", NULL);
free (web);
}
// TODO: maybe reopen every time a signal is spawned to reload memory regions information
// TODO: open io_self
}
开发者ID:aronsky,项目名称:radare2,代码行数:18,代码来源:libr2.c
示例14: r_vala_file
static int r_vala_file(RLang *lang, const char *file) {
void *lib;
char *p, name[512], buf[512];
char *vapidir;
if (!strstr (file, ".vala"))
sprintf (name, "%s.vala", file);
else strcpy (name, file);
if (!r_file_exists (name)) {
eprintf ("file not found (%s)\n", name);
return R_FALSE;
}
vapidir = r_sys_getenv ("VAPIDIR");
if (vapidir) {
if (*vapidir) {
snprintf (buf, sizeof (buf), "valac --vapidir=%s --pkg r_core -C %s",
vapidir, name);
}
free (vapidir);
} else sprintf (buf, "valac --pkg r_core -C %s", name);
if (system (buf) != 0)
return R_FALSE;
p = strstr (name, ".vala"); if (p) *p=0;
p = strstr (name, ".gs"); if (p) *p=0;
snprintf (buf, sizeof (buf), "gcc -fPIC -shared %s.c -o lib%s."R_LIB_EXT
" $(pkg-config --cflags --libs r_core gobject-2.0)", name, name);
if (system (buf) != 0)
return R_FALSE;
snprintf (buf, sizeof (buf), "./lib%s."R_LIB_EXT, name);
lib = r_lib_dl_open (buf);
if (lib!= NULL) {
void (*fcn)(RCore *);
fcn = r_lib_dl_sym (lib, "entry");
if (fcn) fcn (lang->user);
else eprintf ("Cannot find 'entry' symbol in library\n");
r_lib_dl_close (lib);
} else eprintf ("Cannot open library\n");
r_file_rm (buf); // remove lib
sprintf (buf, "%s.c", name); // remove .c
r_file_rm (buf);
return 0;
}
开发者ID:BatchDrake,项目名称:radare2,代码行数:44,代码来源:vala.c
示例15: r_cons_get_size
R_API int r_cons_get_size(int *rows) {
#if EMSCRIPTEN
I.columns = 80;
I.rows = 23;
#elif __UNIX__
struct winsize win;
if (isatty (1) && ioctl (1, TIOCGWINSZ, &win) == 0) {
if (win.ws_col==0) {
int fd = open ("/dev/tty", O_RDONLY);
if (fd != -1) {
if (ioctl (fd, TIOCGWINSZ, &win) != 0) {
I.columns = 80;
I.rows = 23;
}
close (fd);
}
}
I.columns = win.ws_col;
I.rows = win.ws_row-1;
if (I.heightfix)
I.rows--;
} else {
I.columns = 80;
I.rows = 23;
}
#else
char *str = r_sys_getenv ("COLUMNS");
if (str != NULL) {
I.columns = atoi (str);
I.rows = 23; // XXX. windows must get console size
free (str);
} else {
I.columns = 80;
I.rows = 23;
}
#endif
if (rows)
*rows = I.rows;
if (I.widthfix) I.columns--;
if (I.force_columns) I.columns = I.force_columns;
if (I.force_rows) I.rows = I.force_rows;
return I.columns;
}
开发者ID:sstjohn,项目名称:radare2,代码行数:44,代码来源:cons.c
示例16: lang_cpipe_file
static int lang_cpipe_file(RLang *lang, const char *file) {
char *a, *cc, *p, name[512];
const char *libpath, *libname;
if (strlen (file) > (sizeof (name)-10))
return false;
if (!strstr (file, ".c"))
sprintf (name, "%s.c", file);
else strcpy (name, file);
if (!r_file_exists (name)) {
eprintf ("file not found (%s)\n", name);
return false;
}
a = (char*)r_str_lchr (name, '/');
if (a) {
*a = 0;
libpath = name;
libname = a + 1;
} else {
libpath = ".";
libname = name;
}
r_sys_setenv ("PKG_CONFIG_PATH", R2_LIBDIR"/pkgconfig");
p = strstr (name, ".c");
if (p) *p = 0;
cc = r_sys_getenv ("CC");
if (!cc || !*cc) {
free (cc);
cc = strdup ("gcc");
}
char *buf = r_str_newf ("%s %s -o %s/bin%s"
" $(pkg-config --cflags --libs r_socket)",
cc, file, libpath, libname);
free (cc);
if (r_sandbox_system (buf, 1) == 0) {
char *binfile = r_str_newf ("%s/bin%s", libpath, libname);
lang_pipe_run (lang, binfile, -1);
r_file_rm (binfile);
free (binfile);
}
free (buf);
return 0;
}
开发者ID:aronsky,项目名称:radare2,代码行数:44,代码来源:cpipe.c
示例17: 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
示例18: r_sys_getenv
R_API char *r_str_home(const char *str) {
char *dst, *home = r_sys_getenv (R_SYS_HOME);
size_t length;
if (home == NULL)
return NULL;
length = strlen (home) + 1;
if (str)
length += strlen (R_SYS_DIR) + strlen (str);
dst = (char *)malloc (length);
if (dst == NULL)
goto fail;
strcpy (dst, home);
if (str) {
strcat (dst, R_SYS_DIR);
strcat (dst, str);
}
fail:
free (home);
return dst;
}
开发者ID:bigendiansmalls,项目名称:radare2,代码行数:20,代码来源:str.c
示例19: r_egg_Cfile_getCompiler
static char* r_egg_Cfile_getCompiler(void) {
size_t i;
const char *compilers[] = {"llvm-gcc", "clang", "gcc"};
char *output = r_sys_getenv ("CC");
if (output) {
return output;
}
for (i = 0; i < 3; i++) {
output = r_file_path (compilers[i]);
if (strcmp (output, compilers[i])) {
free (output);
return strdup (compilers[i]);
}
free (output);
}
eprintf ("Couldn't find a compiler ! Please, set CC.\n");
return NULL;
}
开发者ID:agatti,项目名称:radare2,代码行数:21,代码来源:egg_Cfile.c
示例20: 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
注:本文中的r_sys_getenv函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论