Exemple #1
0
void				command_funct(t_funct *f, char **cmd, int i)
{
	pid_t			child;

	while (f)
	{
		if (ft_strcmp(cmd[0], f->key) == 0)
		{
			while (f->content[i])
			{
				if ((child = fork()) == 0)
				{
					if ((search_dollar(f->content[i])))
						replace_dol(&f->content[i], cmd, 0);
					parser_bis(f->content[i]);
					exit(0);
				}
				wait(NULL);
				i++;
			}
			break ;
		}
		if (ft_sort_str(cmd[0], f->key) == 1)
			f = f->right;
		else
			f = f->left;
	}
}
Exemple #2
0
t_funct			*delete_node_funct(t_funct *f, char *command)
{
	t_funct		*tmp;

	tmp = NULL;
	if (f == NULL)
		return (f);
	if (ft_sort_str(command, f->key) == 1)
		f->right = delete_node_funct(f->right, command);
	else if (ft_strcmp(command, f->key) != 0)
		f->left = delete_node_funct(f->left, command);
	else
	{
		if (f->left == NULL)
			return ((tmp = free_node_funct(f->right, f, tmp)));
		else if (f->right == NULL)
			return ((tmp = free_node_funct(f->left, f, tmp)));
		tmp = min_value_funct(f->right);
		ft_free(&f->key);
		ft_free_array(&f->content);
		f->key = ft_strdup(tmp->key);
		f->content = ft_strdup_array(tmp->content);
		f->right = delete_node_funct(f->right, tmp->key);
	}
	return (f);
}
Exemple #3
0
t_var			*delete_node_var(t_var *v, char *command)
{
	t_var		*tmp;

	tmp = NULL;
	if (v == NULL)
		return (v);
	if (ft_sort_str(command, v->key) == 1)
		v->right = delete_node_var(v->right, command);
	else if (ft_strcmp(command, v->key) != 0)
		v->left = delete_node_var(v->left, command);
	else
	{
		if (v->left == NULL)
			return ((tmp = free_node_var(v->right, v, tmp)));
		else if (v->right == NULL)
			return ((tmp = free_node_var(v->left, v, tmp)));
		tmp = min_value_var(v->right);
		ft_free(&v->key);
		ft_free(&v->value);
		v->key = ft_strdup(tmp->key);
		v->value = ft_strdup(tmp->value);
		v->right = delete_node_var(v->right, tmp->key);
	}
	return (v);
}
Exemple #4
0
int	main(int ac, char **av)
{
	t_ft_ls		data;
	char		*op;

	ft_init_t_ft_ls(&data);
	op = ft_get_arg(&data, av, ac);
	ft_set_op(op, &data);
	if (data.nb_path > 1)
		ft_sort_str(&(data.path), data.nb_path, data.op_r);
	ft_browse(&data);
	ft_free_lst(&data);
	ft_strdel(&op);
	return (0);
}
void	ft_sort_params(int argc, char **argv)
{
	int		i;
	char	*temp;
	int		j;

	i = 1;
	while (++i < argc)
	{
		j = 0;
		if (ft_sort_str(argv[i], argv[i - 1]) == 1)
		{
			temp = argv[i];
			argv[i] = argv[i - 1];
			argv[i - 1] = temp;
			i = 1;
		}
	}
}
void	ft_sort_wordtab(char **tab)
{
	int		i;
	char	*temp;
	int		j;

	i = 1;
	while (tab[i] != '\0')
	{
		j = 0;
		if (ft_sort_str(tab[i], tab[i - 1]) == 1)
		{
			temp = tab[i];
			tab[i] = tab[i - 1];
			tab[i - 1] = temp;
			i = 1;
		}
		i++;
	}
}