Esempio n. 1
0
int				main(int ac, char **av)
{
	int		i;
	t_flag	flg;
	t_swap	*a;
	t_swap	*b;

	a = NULL;
	b = NULL;
	i = ac - 1;
	if (ac < 2)
		ft_usage(av[0]);
	else
	{
		ft_extract_stack(av, i, &a, &flg);
		i == flg.total_mod ? ft_error() : 0;
		ft_check_duplicates(a);
		ft_init_b(i - flg.total_mod, &b);
		ft_end(a);
		ft_end(b);
		flg.infos ? ft_print_infos(a) : 0;
		a->next == NULL ? ft_exit_one_nb(a, flg) : 0;
		ft_is_sorted(a) && ft_is_null(b) ? ft_exit_already_ordered(a, flg) : 0;
		ft_launcher(a, b, &flg);
	}
	return (0);
}
Esempio n. 2
0
static void	lauch_execute_backquote(t_cmd *cmd,
	t_env *env, char *newcmd)
{
	t_list		*arg;
	t_env		c_env;
	t_cmd		c_cmd;
	t_dir		c_dir;

	arg = NULL;
	init_copy_env(&c_env, &c_cmd, &c_dir);
	c_cmd.raw = ft_strdup(newcmd);
	c_cmd.split = NULL;
	c_env.var = env_lst_copy(env);
	c_env.nb = env->nb;
	c_cmd.paths = ft_tab_dup(cmd->paths);
	c_cmd.env = env_list_to_array(c_env.var, c_env.nb);
	arg = ft_parser(c_cmd.raw);
	ft_open_close();
	ft_launcher(&arg, &c_cmd, &c_env, &c_dir);
	if (arg)
		ft_free_arg(&arg);
	ft_free_c_env(&c_env, &c_cmd, &c_dir);
	ft_open_close();
}