diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ft_e_lcom.c | 10 | ||||
| -rw-r--r-- | src/ft_e_pipes.c | 47 | ||||
| -rw-r--r-- | src/ft_e_pipes.h | 20 | ||||
| -rw-r--r-- | src/ft_s_destroy.c | 1 | ||||
| -rw-r--r-- | src/ft_s_lpipes.c | 4 | 
5 files changed, 74 insertions, 8 deletions
diff --git a/src/ft_e_lcom.c b/src/ft_e_lcom.c index 3f5f81a..54db581 100644 --- a/src/ft_e_lcom.c +++ b/src/ft_e_lcom.c @@ -11,9 +11,12 @@  /* ************************************************************************** */  #include <libft.h> +#include <stdint.h>  #include "ft_e_builtins.h"  #include "ft_e_externs.h" +#include "ft_e_pipes.h" +#include "ft_s_lpipes.h"  #include "ft_s_struct.h"  static uint8_t @@ -42,12 +45,7 @@ void  	{  		if (ptr->pipes)  		{ -			ft_printf("%s\n", ptr->pipes->one->com); -			if ((bu_id = ft_get_builtin_id(ptr->pipes->one->com, msh)) -				< FT_BUILTINS_COUNT) -				ft_e_builtin(ptr->pipes->one, bu_id, msh); -			else -				ft_e_extern(ptr->pipes->one, msh); +			ft_e_pipes(ptr, msh);  		}  		else if (ptr->com)  		{ diff --git a/src/ft_e_pipes.c b/src/ft_e_pipes.c new file mode 100644 index 0000000..81c8a08 --- /dev/null +++ b/src/ft_e_pipes.c @@ -0,0 +1,47 @@ +/* ************************************************************************** */ +/*                                                                            */ +/*                                                        :::      ::::::::   */ +/*   ft_e_pipes.c                                       :+:      :+:    :+:   */ +/*                                                    +:+ +:+         +:+     */ +/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ +/*                                                +#+#+#+#+#+   +#+           */ +/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ +/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ +/*                                                                            */ +/* ************************************************************************** */ + +#include <libft.h> + +#include "ft_e_builtins.h" +#include "ft_e_externs.h" +#include "ft_s_lpipes.h" +#include "ft_s_struct.h" + +static uint8_t +	ft_get_builtin_id(const char com[], +					t_msh *msh) +{ +	uint8_t	i; + +	i = 0; +	while (msh->bu_ref[i] && ft_strncmp(com, msh->bu_ref[i], +		ft_strlen(msh->bu_ref[i]) + 1) != 0) +	{ +		i++; +	} +	return (i); +} + +void +	ft_e_pipes(t_lcom *ptr, +			t_msh *msh) +{ +	uint8_t	bu_id; + +	if ((bu_id = ft_get_builtin_id(ptr->pipes->one->com, msh)) +		< FT_BUILTINS_COUNT) +		ft_e_builtin(ptr->pipes->one, bu_id, msh); +	else +		ft_e_extern(ptr->pipes->one, msh); +	ft_lpipes_clear(&ptr->pipes); +} diff --git a/src/ft_e_pipes.h b/src/ft_e_pipes.h new file mode 100644 index 0000000..f801b21 --- /dev/null +++ b/src/ft_e_pipes.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/*                                                                            */ +/*                                                        :::      ::::::::   */ +/*   ft_e_pipes.h                                       :+:      :+:    :+:   */ +/*                                                    +:+ +:+         +:+     */ +/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ +/*                                                +#+#+#+#+#+   +#+           */ +/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ +/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ +/*                                                                            */ +/* ************************************************************************** */ + +#ifndef FT_E_PIPES_H +#define FT_E_PIPES_H + +#include "ft_s_struct.h" + +void	ft_e_pipes(t_lcom *ptr, t_msh *msh); + +#endif diff --git a/src/ft_s_destroy.c b/src/ft_s_destroy.c index 08980b5..22009c8 100644 --- a/src/ft_s_destroy.c +++ b/src/ft_s_destroy.c @@ -22,6 +22,7 @@ void  	ft_memdel((void*)&msh->cwd);  	ft_memdel((void*)&msh->shname);  	ft_delwords(msh->bu_ref); +	ft_delwords(msh->envp);  	ft_lvars_clear(&msh->vars);  	ft_memdel((void*)&msh);  } diff --git a/src/ft_s_lpipes.c b/src/ft_s_lpipes.c index dcdc2ec..8bd34de 100644 --- a/src/ft_s_lpipes.c +++ b/src/ft_s_lpipes.c @@ -82,7 +82,6 @@ struct s_lpipes  					t_lcom *lcom,  					t_msh *msh)  { -	struct s_lpipes	*link;  	struct s_lpipes	*lpipes;  	char			**words;  	size_t			i; @@ -91,9 +90,10 @@ struct s_lpipes  		return (NULL);  	i = 0;  	if (!(lpipes = (struct s_lpipes*)malloc(sizeof(struct s_lpipes)))) +		return (NULL);  	while (words[i])  	{ -		if (!(link = ft_lpipes_new(words[i], msh))) +		if (!(lpipes = ft_lpipes_new(words[i], msh)))  		{  			return (NULL);  		}  | 
