summaryrefslogtreecommitdiffstats
path: root/src/s_line.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-08 19:32:40 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-08 19:32:40 +0200
commitd742075e1af0c063ef9677f157263c0d45253f73 (patch)
tree656be50d447b90308647a253e3ba6ba75a751b13 /src/s_line.c
parentUpdate (diff)
download42-minishell-d742075e1af0c063ef9677f157263c0d45253f73.tar.gz
42-minishell-d742075e1af0c063ef9677f157263c0d45253f73.tar.bz2
42-minishell-d742075e1af0c063ef9677f157263c0d45253f73.tar.xz
42-minishell-d742075e1af0c063ef9677f157263c0d45253f73.tar.zst
42-minishell-d742075e1af0c063ef9677f157263c0d45253f73.zip
Rework in progress
Diffstat (limited to 'src/s_line.c')
-rw-r--r--src/s_line.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/src/s_line.c b/src/s_line.c
index ae0ec07..b198fff 100644
--- a/src/s_line.c
+++ b/src/s_line.c
@@ -14,26 +14,30 @@
#include <stdlib.h>
#include <stdint.h>
+#include "d_define.h"
#include "p_line.h"
#include "s_com.h"
#include "s_struct.h"
-t_line
- *s_line_last(t_line *line)
+t_line_block
+ *s_line_last(t_line_block *line)
{
while (line->next != NULL)
+ {
line = line->next;
+ }
return (line);
}
void
- s_line_add_back(t_line **aline,
- t_line *new)
+ s_line_add_back(t_line_block **aline, t_line_block *new)
{
- t_line *tmp;
+ t_line_block *tmp;
- if (!*aline)
+ if (*aline == NULL)
+ {
*aline = new;
+ }
else
{
tmp = s_line_last(*aline);
@@ -42,45 +46,43 @@ void
}
void
- s_line_clear(t_line **line)
+ s_line_clear(t_line_block **line)
{
- t_line *tmp;
- t_line *renext;
+ t_line_block *tmp;
+ t_line_block *renext;
- if (!line)
+ if (line == NULL)
+ {
return ;
+ }
tmp = *line;
while (tmp != NULL)
{
renext = tmp->next;
- if (tmp->com != NULL)
- {
- s_com_destroy(&tmp->com);
- }
ft_memdel((void*)&tmp);
tmp = renext;
}
*line = NULL;
}
-t_line
- *s_line_new(const char word[],
- t_msh *msh)
+t_line_block
+ *s_line_new(const char word[], uint8_t nextif)
{
- t_line *link;
+ t_line_block *link;
- if ((link = (t_line*)malloc(sizeof(t_line))) == NULL)
+ if ((link = (t_line_block*)malloc(sizeof(t_line_block))) == NULL)
return (NULL);
- link->nextif = 0;
- link->com = NULL;
- link->pipes = NULL;
+ link->lblock[0] = C_NUL;
+ link->nextif = nextif;
link->next = NULL;
if (word == NULL)
{
link->next = NULL;
return (link);
}
- if ((link->com = s_com_new(word, msh)) == NULL)
- return (NULL);
+ else
+ {
+ ft_strlcpy(link->lblock, word, 4096);
+ }
return (link);
}