mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
redirection parsing: add utility function for t_redirection
This commit is contained in:
parent
cf517bb7f8
commit
b0c34f36ef
3 changed files with 49 additions and 1 deletions
1
Makefile
1
Makefile
|
|
@ -50,6 +50,7 @@ srcs = \
|
|||
src/parser/wordsplit/tokenizing_6_10.c \
|
||||
src/parser/wordsplit/wordsplit.c \
|
||||
src/parser/wordsplit/wordsplit_utils.c \
|
||||
src/postprocess/redirections/redirection.c \
|
||||
src/postprocess/redirections/redirection_parsing.c \
|
||||
|
||||
objs = $(srcs:.c=.o)
|
||||
|
|
|
|||
43
src/postprocess/redirections/redirection.c
Normal file
43
src/postprocess/redirections/redirection.c
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* redirection.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/07 14:26:26 by khais #+# #+# */
|
||||
/* Updated: 2025/03/07 14:34:28 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "redirection.h"
|
||||
#include "libft.h"
|
||||
|
||||
/*
|
||||
** create a new redirection, with the given data
|
||||
**
|
||||
** In case of allocation error, marker is not freed
|
||||
*/
|
||||
t_redirection *redirection_create(t_redir_type type,
|
||||
t_worddesc *marker)
|
||||
{
|
||||
t_redirection *outvalue;
|
||||
|
||||
outvalue = ft_calloc(1, sizeof(t_redirection));
|
||||
if (outvalue == NULL)
|
||||
return (NULL);
|
||||
outvalue->marker = marker;
|
||||
outvalue->type = type;
|
||||
return (outvalue);
|
||||
}
|
||||
|
||||
/*
|
||||
** free all the memory associated with the given redirection
|
||||
*/
|
||||
void redirection_destroy(t_redirection *redirection)
|
||||
{
|
||||
if (redirection == NULL)
|
||||
return ;
|
||||
worddesc_destroy(redirection->marker);
|
||||
free(redirection);
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/07 14:26:06 by khais #+# #+# */
|
||||
/* Updated: 2025/03/07 14:44:12 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/07 14:49:24 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -25,4 +25,8 @@ typedef struct s_redirection
|
|||
t_worddesc *marker;
|
||||
} t_redirection;
|
||||
|
||||
t_redirection *redirection_create(t_redir_type type,
|
||||
t_worddesc *marker);
|
||||
void redirection_destroy(t_redirection *redirection);
|
||||
|
||||
#endif // REDIRECTION_BASICS_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue