feat(redirections): ast commands now have a field for the list of redirections + redirections implemented in parser
This commit is contained in:
parent
8a5c589742
commit
399d1ed3e1
3 changed files with 13 additions and 6 deletions
|
|
@ -5,13 +5,15 @@
|
|||
|
||||
#include "../lists/lists.h"
|
||||
|
||||
struct ast *ast_create_command(struct list *command)
|
||||
struct ast *ast_create_command(struct list *command,
|
||||
struct list *redirections)
|
||||
{
|
||||
struct ast_command *command_data = malloc(sizeof(struct ast_command));
|
||||
if (!command_data)
|
||||
return NULL;
|
||||
|
||||
command_data->command = command;
|
||||
command_data->redirections = redirections;
|
||||
|
||||
return ast_create(AST_CMD, command_data);
|
||||
}
|
||||
|
|
@ -33,5 +35,6 @@ void ast_free_command(struct ast_command *command_data)
|
|||
if (command_data == NULL)
|
||||
return;
|
||||
list_deep_destroy(command_data->command);
|
||||
ast_list_deep_destroy(command_data->redirections);
|
||||
free(command_data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
struct ast_command
|
||||
{
|
||||
struct list *command; // A list of words (char*)
|
||||
struct ast_list *redirections; // A list of ASTs, all ast_redir
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -23,7 +24,8 @@ struct ast_command *ast_get_command(struct ast *node);
|
|||
/**
|
||||
* Creates a new AST node representing a command.
|
||||
*/
|
||||
struct ast *ast_create_command(struct list *command);
|
||||
struct ast *ast_create_command(struct list *command,
|
||||
struct list *redirections);
|
||||
|
||||
/*
|
||||
* @brief: frees the given ast_command and sets the pointer to NULL.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue