コード例 #1
0
ファイル: exec_mod.c プロジェクト: Gaoithe/openimscore_ims
inline static int w_exec_dset(struct sip_msg* msg, char* p1, char* foo)
{
        str cmd;
	str *uri;
	environment_t *backup;
	int ret;

	if (get_str_fparam(&cmd, msg, (fparam_t*)p1) < 0) {
	    ERR("Error while obtaining command name\n");
	    return -1;
	}

	backup=0;
	if (setvars) {
		backup=set_env(msg);
		if (!backup) {
			LOG(L_ERR, "ERROR: w_exec_msg: no env created\n");
			return -1;
		}
	}

	if (msg->new_uri.s && msg->new_uri.len)
		uri=&msg->new_uri;
	else
		uri=&msg->first_line.u.request.uri;

	ret=exec_str(msg, &cmd, uri->s, uri->len);
	if (setvars) {
		unset_env(backup);
	}
	return ret;
}
コード例 #2
0
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;
}
コード例 #3
0
ファイル: exec_mod.c プロジェクト: Gaoithe/openimscore_ims
inline static int w_exec_msg(struct sip_msg* msg, char* p1, char* foo)
{
        str cmd;
	environment_t *backup;
	int ret;

	if (get_str_fparam(&cmd, msg, (fparam_t*)p1) < 0) {
	    ERR("Error while obtaining command name\n");
	    return -1;
	}

	backup=0;
	if (setvars) {
		backup=set_env(msg);
		if (!backup) {
			LOG(L_ERR, "ERROR: w_exec_msg: no env created\n");
			return -1;
		}
	}
	ret=exec_msg(msg, &cmd);
	if (setvars) {
		unset_env(backup);
	}
	return ret;
}
コード例 #4
0
ファイル: bultins2.c プロジェクト: MRdotB/42sh
void	bc_unsetenv(t_cfg *cfg, char **path)
{
	if (path[1] == NULL)
		return (bc_error("unsetenv: Missing arg."));
	else if (path[2])
		return (bc_error("unsetenv: Too much args."));
	if (!(unset_env(&(cfg->env), path[1])))
		bc_error("unsetenv: Variable not found in env.");
}
コード例 #5
0
inline static int w_exec_dset(struct sip_msg* msg, char* cmd, char* foo)
{
	str *uri;
	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 (msg->new_uri.s && msg->new_uri.len)
		uri=&msg->new_uri;
	else
		uri=&msg->first_line.u.request.uri;
	
	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_str(msg, command.s, uri->s, uri->len);
	if (setvars) {
		unset_env(backup);
	}
	return ret;
}
コード例 #6
0
ファイル: builtins.c プロジェクト: jmontija/minishell
void	ft_unsetenv(t_group *grp)
{
	int		i;
	t_bool	error;

	i = 0;
	error = false;
	if (grp->cmd[1] == NULL)
	{
		ft_putendl("unsetenv: set argument(s) -> key");
		return ;
	}
	while (grp->cmd[++i] != NULL)
	{
		if (unset_env(grp, grp->cmd[i]) < 0)
		{
			ft_putstr("unsetenv: unfound key -> ");
			ft_putendl(grp->cmd[i]);
			error = true;
		}
	}
	error ? ft_putendl("unsetenv: synthax -> key") : 0;
}
コード例 #7
0
ファイル: env_builtin.c プロジェクト: Liliaze/Projets
int		handle_env_opt(t_node_cmd *node, int *it)
{
	if (ft_strequ("-i", node->cmd[*it]) && (*it)++)
		del_env(&node->env);
	else if (ft_strequ("-P", node->cmd[*it]) && node->cmd[*it + 1])
	{
		set_env(&node->env, "PATH", ft_strdup(node->cmd[*it + 1]));
		(*it) += 2;
	}
	else if (ft_strequ("-P", node->cmd[*it]))
		return (-1);
	else if (ft_strequ("-u", node->cmd[*it]) && node->cmd[*it + 1])
	{
		unset_env(&node->env, node->cmd[*it + 1]);
		(*it) += 2;
	}
	else if (ft_strequ("-u", node->cmd[*it]))
		return (-1);
	else if (ft_strchr(node->cmd[*it], '='))
	{
		set_env_keyval(&node->env, node->cmd[(*it)++]);
	}
	return (1);
}
コード例 #8
0
ファイル: builtins.c プロジェクト: jmontija/21sh
void	ft_unsetenv(t_group *grp)
{
	int		i;
	t_bool	error;

	i = 0;
	error = grp->cmd[1] != NULL ? false : true;
	while (grp->cmd[++i] != NULL)
	{
		if (!ft_strncmp(grp->cmd[i], "_", 1) ||
			!ft_strncmp(grp->cmd[i], "SHLVL", 5))
		{
			ft_putendl_fd("setenv: 'SHLVL', '_' can't be modify", 2);
			break ;
		}
		else if (unset_env(grp, grp->cmd[i]) < 0)
		{
			ft_putstr_fd("unsetenv: unfound key -> ", 2);
			ft_putendl_fd(grp->cmd[i], 2);
			error = true;
		}
	}
	error ? ft_putendl_fd("unsetenv: synthax -> key", 2) : 0;
}
コード例 #9
0
ファイル: env.c プロジェクト: ksherlock/gno
int main(int argc, char **argv) {

	unsigned i;
	int ch;
	const char *path;
	const char *search_path = 0;
	static unsigned zero = 0;


#ifdef __STACK_CHECK__
	_beginStackCheck();
	atexit(stackResults);
#endif


	// work around GNO/ME environment bug.
	PushVariablesGS(&zero);

	if (_toolErr) {
		errx(1, "PushVariablesGS: $%04x", _toolErr);
	}


	while ((ch = getopt(argc, argv, "-ivP:S:u:x:")) != -1) {
		switch(ch) {
			case 'v':
				_v++;
				break;

			case 'i':
			case '-':
				reset_env();
				break;

			case 'u':
				unset_env(optarg);
				break;

			case 'x':
				/* GNO-specific: set prefix */
				set_prefix(optarg);
				break;

			case 'P':
				search_path = optarg;
				break;

			case 'S':
				// not a posix flag.
				errx(1, "-S is not supported");
				break;

			case '?':
			default:
				usage();
		}
	}

	argc -= optind;
	argv += optind;

	for( ; argc; ++argv, --argc) {
		if (!set_env(*argv)) break;
	}

	if (!argc) {
		print_env();
		exit(0);
	}

	path = find_path(argv[0], search_path);
	if (_v) {
		fprintf(stderr, "#env executing:\t%s\n", path);
		for (i = 0; i < argc; ++i) 
			fprintf(stderr, "#env    arg[%d]= '%s'\n", i, argv[i]);
	}
	execv(path, argv);

	exit(errno == ENOENT ? 127 : 126);
	return 0;
}
コード例 #10
0
 inline void unset_env(const Ustring& name) {
     unset_env(to_wstring(name, Utf::replace));
 }
コード例 #11
0
ファイル: env.c プロジェクト: rashadkm/grass_cmake
/*!
  \brief Remove name from environment from specific place
  
  Updates .gisrc
  
  \param name variable name
  \param loc location (G_VAR_GISRC, G_VAR_MAPSET)
*/
void G_unsetenv2(const char *name, int loc)
{
    read_env(loc);
    unset_env(name, loc);
    write_env(loc);
}
コード例 #12
0
ファイル: env.c プロジェクト: rashadkm/grass_cmake
/*!
  \brief Remove name from environment
  
  Updates .gisrc
  
  \param name variable name
*/
void G_unsetenv(const char *name)
{
    read_env(G_VAR_GISRC);
    unset_env(name, G_VAR_GISRC);
    write_env(G_VAR_GISRC);
}
コード例 #13
0
ファイル: env.c プロジェクト: rashadkm/grass_cmake
static int set_env(const char *name, const char *value, int loc)
{
    int n;
    int empty;
    char *tv;

    /* if value is NULL or empty string, convert into an unsetenv() */
    if (!value || !strlen(value)) {
	unset_env(name, loc);
	return 0;
    }

    tv = G_store(value);
    G_strip(tv);
    if (*tv == 0) {
	G_free(tv);
	unset_env(name, loc);
	return 1;
    }

    /*
     * search the array
     *   keep track of first empty slot
     *   and look for name in the environment
     */
    empty = -1;
    for (n = 0; n < st->env.count; n++) {
	struct bind *b = &st->env.binds[n];
	if (!b->name)	/* mark empty slot found */
	    empty = n;
	else if (strcmp(b->name, name) == 0 && b->loc == loc) {
	    b->value = tv;
	    return 1;
	}
    }

    /* add name to env: to empty slot if any */
    if (empty >= 0) {
	struct bind *b = &st->env.binds[empty];
	b->loc = loc;
	b->name = G_store(name);
	b->value = tv;
	return 0;
    }

    /* must increase the env list and add in */
    if (st->env.count >= st->env.size) {
	st->env.size += 20;
	st->env.binds = G_realloc(st->env.binds, st->env.size * sizeof(struct bind));
    }

    {
	struct bind *b = &st->env.binds[st->env.count++];

	b->loc = loc;
	b->name = G_store(name);
	b->value = tv;
    }

    return 0;
}