本文整理汇总了C++中set_env函数的典型用法代码示例。如果您正苦于以下问题:C++ set_env函数的具体用法?C++ set_env怎么用?C++ set_env使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_env函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int
main(int argc, char** argv)
{
set_env();
environ = NULL;
test_env();
set_env();
environ[0] = NULL;
test_env();
static char* emptyEnv[1] = {NULL};
set_env();
environ = emptyEnv;
test_env();
set_env();
environ = (char**)calloc(1, sizeof(*environ));
test_env();
// clearenv() is not part of the POSIX specs
#if 1
set_env();
clearenv();
test_env();
#endif
return 0;
}
示例2: add_environment
static ret_t
add_environment (cherokee_handler_cgi_t *cgi,
cherokee_connection_t *conn)
{
ret_t ret;
cherokee_handler_cgi_base_t *cgi_base = HDL_CGI_BASE(cgi);
cherokee_buffer_t *tmp = THREAD_TMP_BUF2(CONN_THREAD(conn));
ret = cherokee_handler_cgi_base_build_envp (HDL_CGI_BASE(cgi), conn);
if (unlikely (ret != ret_ok))
return ret;
/* CONTENT_LENGTH
*/
if (http_method_with_input (conn->header.method)) {
cherokee_buffer_clean (tmp);
cherokee_buffer_add_ullong10 (tmp, conn->post.len);
set_env (cgi_base, "CONTENT_LENGTH", tmp->buf, tmp->len);
}
/* SCRIPT_FILENAME
*/
if (cgi_base->executable.len <= 0)
return ret_error;
set_env (cgi_base, "SCRIPT_FILENAME",
cgi_base->executable.buf,
cgi_base->executable.len);
return ret_ok;
}
示例3: handle_exit_status
void handle_exit_status(char ***env, int child_status,
char **cmds, int i)
{
char buf[25];
char *tmp;
if (WIFEXITED(child_status) == 1)
{
set_env(env, "?", tmp = ft_itoa(WEXITSTATUS(child_status)));
ft_strdel(&tmp);
}
else if (WIFSIGNALED(child_status) == 1)
{
set_env(env, "?", tmp = ft_itoa(child_status));
ft_strdel(&tmp);
set_message(buf, WTERMSIG(child_status));
if (buf[0] != '\0')
{
ft_putstr_fd(singleton_state()->shell_name, 2);
ft_putstr_fd(": ", 2);
ft_putstr_fd(buf, 2);
ft_putstr_fd(": ", 2);
ft_putendl_fd(ft_remove_blank_begin_end(cmds[i]), 2);
}
}
}
示例4: setenv_from_config
void
setenv_from_config(void)
{
int i, lim = sizeof(envname) / sizeof(char *);
STRBUF *sb = strbuf_open(0);
for (i = 0; i < lim; i++) {
if (getenv(envname[i]) == NULL) {
strbuf_reset(sb);
if (getconfs(envname[i], sb))
set_env(envname[i], strbuf_value(sb));
else if (getconfb(envname[i]))
set_env(envname[i], "");
}
}
/*
* For upper compatibility.
* htags_options is deprecated.
*/
if (getenv("HTAGS_OPTIONS") == NULL) {
strbuf_reset(sb);
if (getconfs("htags_options", sb))
set_env("HTAGS_OPTIONS", strbuf_value(sb));
}
strbuf_close(sb);
}
示例5: stdenv
bool stdenv(lisp_env *env)
{
/* Arithmetic, logical */
set_env(env, "+", (lisp_obj*) &lisp_add);
set_env(env, "-", (lisp_obj*) &lisp_sub);
set_env(env, "*", (lisp_obj*) &lisp_mul);
set_env(env, "<", (lisp_obj*) &lisp_lt);
set_env(env, "real", (lisp_obj*) &lisp_real);
/* Repl, i/o */
set_env(env, "display", (lisp_obj*) &lisp_display);
set_env(env, "exit", (lisp_obj*) &lisp_exit);
/* Debug, internal */
set_env(env, "refcount", (lisp_obj*) &lisp_refcount);
set_env(env, "dmp", (lisp_obj*) &lisp_dump_env);
/* Lisp plumbery */
lisp_obj *res = NULL;
for (size_t i=0; i<sizeof(lisp_stubs)/sizeof(lisp_stubs[0]); i++){
res = eval(lisp_stubs[i], env, NULL);
if (res != NIL){
return false;
}
}
return true;
}
示例6: set_rd_prompt
static void set_rd_prompt(char **pt, int lap)
{
if (lap == 0)
{
*pt = my_strdup(get_env("PS1"));
set_env("PS1", "> ");
return ;
}
set_env("PS1", *pt);
free(*pt);
}
示例7: add_env
int add_env( char * name, char * value ) {
int res = 0 ;
char * npst = getenv( name ), * vpst = NULL ;
if( npst==NULL ) { res = set_env( name, value ) ; }
else {
vpst = (char*) malloc( strlen(npst)+strlen(value)+20 ) ;
sprintf( vpst, "%s=%s;%s", name, npst, value ) ;
res = set_env( name, vpst ) ;
free( vpst ) ;
}
return res ;
}
示例8: start_win_emulator
int
start_win_emulator(char* emu, char *start_prog, char** argv, int start_detached)
{
int result;
windowed = 1;
if (start_detached) {
char *buff;
close(0);
close(1);
close(2);
set_env("ERL_CONSOLE_MODE", "detached");
set_env(DLL_ENV, emu);
argv[0] = start_prog;
argv = fnuttify_argv(argv);
result = spawnv(_P_DETACH, start_prog, argv);
free_fnuttified(argv);
} else {
int argc = 0;
#ifdef LOAD_BEAM_DYNAMICALLY
HMODULE beam_module = load_win_beam_dll(emu);
#endif
set_env("ERL_CONSOLE_MODE", "window");
while (argv[argc] != NULL) {
++argc;
}
#ifdef ARGS_HARDDEBUG
{
char sbuf[2048] = "";
int i;
for (i = 0; i < argc; ++i) {
strcat(sbuf,"|");
strcat(sbuf, argv[i]);
strcat(sbuf,"| ");
}
MessageBox(NULL, sbuf, "Werl", MB_OK|MB_ICONERROR);
}
#endif
#ifdef LOAD_BEAM_DYNAMICALLY
(*sys_primitive_init_p)(beam_module);
(*erl_start_p)(argc,argv);
#else
erl_start(argc, argv);
#endif
result = 0;
}
if (result == -1) {
error("Failed to execute %s: %s", emu, win32_errorstr(_doserrno));
}
return 0;
}
示例9: ft_setenv
void ft_setenv(char **env, char *name, char *value)
{
int i;
int j;
int g;
char *e_title;
i = 0;
g = 0;
while (env[i])
{
j = 0;
while (env[i][j] != '\0' && env[i][j] != '=')
j++;
if (env[i][j] != '\0')
{
e_title = ft_strsub(env[i], 0, j);
if (ft_strcmp(e_title, name) == 0)
{
set_env(env, i, j, value);
g++;
}
ft_memdel((void **)&e_title);
}
i++;
}
if (g == 0)
add_env(env, i, name, value);
}
示例10: set_env_keyval
void set_env_keyval(t_env **env, char *keyval)
{
char **split;
if (!keyval)
return ;
split = ft_strsplit(keyval, '=');
if (split[0] == NULL)
{
set_env(env, "", ft_strdup(""));
}
else
set_env(env, split[0], split[1]);
free(split[0]);
free(split);
}
示例11: w_exec_avp
inline static int w_exec_avp(struct sip_msg* msg, char* cmd, char* avpl)
{
environment_t *backup;
int ret;
str command;
if(msg==0 || cmd==0)
return -1;
backup=0;
if (setvars) {
backup=set_env(msg);
if (!backup) {
LM_ERR("no env created\n");
return -1;
}
}
if(fixup_get_svalue(msg, (gparam_p)cmd, &command)!=0)
{
LM_ERR("invalid command parameter");
return -1;
}
LM_DBG("executing [%s]\n", command.s);
ret=exec_avp(msg, command.s, (pvname_list_p)avpl);
if (setvars) {
unset_env(backup);
}
return ret;
}
示例12: print_pipe_error_then_exit
void print_pipe_error_then_exit(t_state *state)
{
ft_putstr_fd(state->shell_name, 2);
ft_putendl_fd(": pipe() error", 2);
set_env(&state->env, "?", "1");
exit(1);
}
示例13: print_command_not_found
void print_command_not_found(t_state *state, char *cmd, char *s)
{
ft_putstr_fd(cmd, 2);
ft_putstr_fd(": command not found: ", 2);
ft_putendl_fd(s, 2);
set_env(&state->env, "?", "127");
}
示例14: ft_isbuiltin
int ft_isbuiltin(t_env *env, char *line)
{
char **line2;
int i;
t_main w;
i = 0;
line2 = ft_strsplit(line, ' ');
if (ft_strcmp(line2[0], "echo") == 0 && (i = 1))
{
line = ft_strfcut(line, 5);
ft_echo(line);
}
else if (ft_strncmp(line, "cd", 2) == 0 && (i = 1))
ft_cd(line);
else if (ft_strncmp(line, "unsetenv", 7) == 0 && (i = 1))
env = ft_unsetenv(env);
else if (ft_strncmp(line, "env", 2) == 0 && (i = 1))
print_env(env);
else if (ft_strncmp(line, "setenv", 5) == 0 && (i = 1))
{
line = ft_strrw(line);
line2 = ft_strsplit(line, ' ');
env = set_env(line2, env);
}
if (i == 1)
ft_doublecoms(env, &w, 0);
return (1);
}
示例15: load_default_env
static void load_default_env(void)
{
int i;
char *tmp;
int mum = 1;
char load_buf[20]={0};
printk("[%s]load default env\n",MODULE_NAME);
tmp = get_env(DATA_FREE_SIZE_TH_NAME);
if(tmp == NULL){
printk("[%s]can not find %s,set the default value\n",MODULE_NAME,DATA_FREE_SIZE_TH_NAME);
sprintf(load_buf,"%d",DATA_FREE_SIZE_TH_DEFAULT);
set_env(DATA_FREE_SIZE_TH_NAME,load_buf);
return;
}
for(i=0;i<strlen(tmp);i++){
if(tmp[i] == 'M' || tmp[i] == 'm'){
mum = 1024*1024;
break;
}else if(tmp[i] == 'K' || tmp[i] == 'k'){
mum = 1024;
break;
}else{
load_buf[i] = tmp[i];
}
}
data_free_size_th =(long long)simple_strtol(load_buf,NULL,10)*mum;
printk("[%s]find %s = %llx\n",MODULE_NAME,DATA_FREE_SIZE_TH_NAME,data_free_size_th);
}