diff options
Diffstat (limited to 'src/s_line.c')
-rw-r--r-- | src/s_line.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/src/s_line.c b/src/s_line.c index b47b453..c6e2e0b 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,44 @@ 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->lblock); 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 = NULL; + link->nextif = nextif; link->next = NULL; if (word == NULL) { link->next = NULL; return (link); } - link->com = s_com_new(word, msh); - /* TODO: check link->com = NULL */ + else if ((link->lblock = ft_strdup(word)) == NULL) + { + return (NULL); + } return (link); } |