42sh/src/utils/ast/ast_command.h

35 lines
811 B
C

#ifndef AST_COMMAND_H
#define AST_COMMAND_H
#include "../lists/lists.h"
#include "ast_base.h"
struct ast_command
{
struct list *command; // A list of words (char*)
struct ast_list *redirections; // A list of ASTs, all ast_redir
};
/**
* Checks if the given AST node is a command.
*/
bool ast_is_command(struct ast *node);
/**
* Retrieves the command data from the given AST node.
* Assumes that the node is of type AST_CMD.
*/
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 list *redirections);
/*
* @brief: frees the given ast_command and sets the pointer to NULL.
*/
void ast_free_command(struct ast_command *command_data);
#endif /* ! AST_COMMAND_H */