summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/e_externs_pipes.c20
-rw-r--r--src/e_line.c2
-rw-r--r--src/e_pipes.c2
-rw-r--r--src/p_lcom.c2
-rw-r--r--src/s_lpipes.c18
-rw-r--r--src/s_lpipes.h10
6 files changed, 28 insertions, 26 deletions
diff --git a/src/e_externs_pipes.c b/src/e_externs_pipes.c
index 6f24435..f6243e5 100644
--- a/src/e_externs_pipes.c
+++ b/src/e_externs_pipes.c
@@ -44,26 +44,28 @@ static uint8_t
}
static void
- e_pipe_child(const char *fullpath,
- t_com *ptr,
- t_msh *msh)
+ e_pipe_child(char *fullpath[],
+ uint8_t pipe_id,
+ t_com *ptr,
+ t_msh *msh)
{
uint8_t bu_id;
uint8_t ret;
dup_redirs(ptr, msh);
- if (ft_strncmp(fullpath, "builtin", 8) == 0)
+ if (ft_strncmp(fullpath[pipe_id], "builtin", 8) == 0)
{
bu_id = get_builtin_id(ptr->bin, msh);
ret = msh->bu_ptr[bu_id](ptr->argv + 1, msh);
u_eof_fd(msh->fd);
+ s_lpipes_clear(&msh->curr->pipes);
s_line_clear(&msh->curr);
s_destroy(msh);
- ft_memdel((void*)&fullpath);
+ ft_delwords(fullpath);
exit(ret);
}
else
- execve(fullpath, ptr->argv, msh->envp);
+ execve(fullpath[pipe_id], ptr->argv, msh->envp);
/* TODO: handle execve failed */
}
@@ -84,7 +86,7 @@ static size_t
}
static void
- exec_path(const char *fullpath[],
+ e_pipe_exec_path(char *fullpath[],
struct s_lpipes *head,
t_msh *msh)
{
@@ -119,7 +121,7 @@ static void
close(fd[j][FT_READ_END]);
j++;
}
- e_pipe_child(fullpath[i], head->com, msh);
+ e_pipe_child(fullpath, i, head->com, msh);
}
head = head->next;
i++;
@@ -177,6 +179,6 @@ void
rptr = rptr->next;
}
i = 0;
- exec_path((const char**)fullpath, head, msh);
+ e_pipe_exec_path(fullpath, head, msh);
ft_delwords(fullpath);
}
diff --git a/src/e_line.c b/src/e_line.c
index 6da7f77..f47170f 100644
--- a/src/e_line.c
+++ b/src/e_line.c
@@ -41,7 +41,7 @@ static void
{
if (ptr->pipes != NULL)
{
- lpipes_clear(&ptr->pipes);
+ s_lpipes_clear(&ptr->pipes);
}
}
diff --git a/src/e_pipes.c b/src/e_pipes.c
index 30fced2..6fdc149 100644
--- a/src/e_pipes.c
+++ b/src/e_pipes.c
@@ -44,5 +44,5 @@ void
/* < FT_BUILTINS_COUNT) */
/* e_builtin(ptr->pipes->one, bu_id, msh); */
e_externs_pipes(ptr->pipes, msh);
- lpipes_clear(&ptr->pipes);
+ s_lpipes_clear(&ptr->pipes);
}
diff --git a/src/p_lcom.c b/src/p_lcom.c
index 13b4d11..bd5edcb 100644
--- a/src/p_lcom.c
+++ b/src/p_lcom.c
@@ -152,7 +152,7 @@ int8_t
{
if ((link = s_line_new(NULL, msh)) == NULL)
return (-1);
- if ((split_pipes(words[i], link, msh)) == NULL)
+ if ((s_split_pipes(words[i], link, msh)) == NULL)
return (-1);
next = TRUE;
}
diff --git a/src/s_lpipes.c b/src/s_lpipes.c
index 9d10849..f6a6845 100644
--- a/src/s_lpipes.c
+++ b/src/s_lpipes.c
@@ -20,7 +20,7 @@
#include "s_struct.h"
struct s_lpipes
- *lpipes_last(struct s_lpipes *lpipes)
+ *s_lpipes_last(struct s_lpipes *lpipes)
{
while (lpipes->next != NULL)
lpipes = lpipes->next;
@@ -28,7 +28,7 @@ struct s_lpipes
}
void
- lpipes_add_back(struct s_lpipes **alpipes,
+ s_lpipes_add_back(struct s_lpipes **alpipes,
struct s_lpipes *new)
{
struct s_lpipes *tmp;
@@ -37,13 +37,13 @@ void
*alpipes = new;
else
{
- tmp = lpipes_last(*alpipes);
+ tmp = s_lpipes_last(*alpipes);
tmp->next = new;
}
}
void
- lpipes_clear(struct s_lpipes **lpipes)
+ s_lpipes_clear(struct s_lpipes **lpipes)
{
struct s_lpipes *tmp;
struct s_lpipes *renext;
@@ -62,12 +62,12 @@ void
}
struct s_lpipes
- *lpipes_new(const char pipedword[],
+ *s_lpipes_new(const char pipedword[],
t_msh *msh)
{
struct s_lpipes *link;
- if (!(link = (struct s_lpipes*)malloc(sizeof(struct s_lpipes))))
+ if ((link = (struct s_lpipes*)malloc(sizeof(struct s_lpipes))) == NULL)
return (NULL);
link->com = NULL;
if ((link->com = s_com_new(pipedword, msh)) == NULL)
@@ -79,7 +79,7 @@ struct s_lpipes
}
struct s_lpipes
- *split_pipes(const char word[],
+ *s_split_pipes(const char word[],
t_line *line,
t_msh *msh)
{
@@ -92,11 +92,11 @@ struct s_lpipes
i = 0;
while (words[i])
{
- if (!(lpipes = lpipes_new(words[i], msh)))
+ if (!(lpipes = s_lpipes_new(words[i], msh)))
{
return (NULL);
}
- lpipes_add_back(&line->pipes, lpipes);
+ s_lpipes_add_back(&line->pipes, lpipes);
i++;
}
ft_delwords(words);
diff --git a/src/s_lpipes.h b/src/s_lpipes.h
index 7b90d2c..5b2795a 100644
--- a/src/s_lpipes.h
+++ b/src/s_lpipes.h
@@ -15,11 +15,11 @@
#include "s_struct.h"
-struct s_lpipes *lpipes_last(struct s_lpipes *lpipes);
-void lpipes_add_back(struct s_lpipes **alpipes,
+struct s_lpipes *s_lpipes_last(struct s_lpipes *lpipes);
+void s_lpipes_add_back(struct s_lpipes **alpipes,
struct s_lpipes *new);
-void lpipes_clear(struct s_lpipes **lpipes);
-struct s_lpipes *lpipes_new(const char pipedword[], t_msh *msh);
-struct s_lpipes *split_pipes(const char word[], t_line *line, t_msh *msh);
+void s_lpipes_clear(struct s_lpipes **lpipes);
+struct s_lpipes *s_lpipes_new(const char pipedword[], t_msh *msh);
+struct s_lpipes *s_split_pipes(const char word[], t_line *line, t_msh *msh);
#endif