tout debut implementation pipes
This commit is contained in:
13
srcs/main.c
13
srcs/main.c
@@ -6,7 +6,7 @@
|
||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/10/04 05:59:26 by lperrey #+# #+# */
|
||||
/* Updated: 2021/10/10 15:13:26 by hulamy ### ########.fr */
|
||||
/* Updated: 2021/10/15 17:33:46 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -28,6 +28,8 @@ void shell_loop(t_all *c)
|
||||
builtin_env(0, NULL, c);
|
||||
else if (!ft_strncmp(line_input, "exit", 5)) // temp placeholder
|
||||
builtin_exit(0, NULL, c);
|
||||
else if (!ft_strncmp(line_input, "pipe ", 5)) // temp temp temp
|
||||
pipes_hugo(line_input);
|
||||
else
|
||||
printf("echo: %s\n", line_input);
|
||||
}
|
||||
@@ -71,12 +73,3 @@ int main(int argc, char *argv[], char *envp[])
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** idea about malloc protection :
|
||||
** have them(mallocand similar) done in a specific function that would check their return and accordingly exit the program or continue
|
||||
** -> so that it can be done in one line
|
||||
** void calloc_or_exit(int num, int size);
|
||||
** and possibly give it a pointer to a function that will clean before exit
|
||||
** void calloc_or_exit(int num, int size, void (*f)(void *ptr), void *ptr);
|
||||
*/
|
||||
|
||||
36
srcs/pipes_hugo.c
Normal file
36
srcs/pipes_hugo.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "minishell.h"
|
||||
|
||||
int size_tab(char **split)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (*split++)
|
||||
i++;
|
||||
return (i);
|
||||
}
|
||||
|
||||
void print_tab(char **array)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (array[i])
|
||||
{
|
||||
printf("%i: %s\n", i, array[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void pipes_hugo(char *input)
|
||||
{
|
||||
char **split;
|
||||
int nbr_pipes;
|
||||
|
||||
split = ft_split(input, '|');
|
||||
split[0] += 5; // pour sauter la premiere entree qui est "pipe"
|
||||
nbr_pipes = size_tab(split);
|
||||
//printf("%i\n", nbr_pipes);
|
||||
//print_tab(split);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user