32 lines
574 B
C
32 lines
574 B
C
#include "ast_neg.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
bool ast_is_neg(struct ast *node)
|
|
{
|
|
return node != NULL && node->type == AST_REDIR;
|
|
}
|
|
|
|
struct ast_neg *ast_get_neg(struct ast *node)
|
|
{
|
|
if (ast_is_neg(node))
|
|
return node->data;
|
|
return NULL;
|
|
}
|
|
|
|
struct ast *ast_create_neg(bool negation, struct ast *child)
|
|
{
|
|
struct ast_neg *node = malloc(sizeof(struct ast_neg));
|
|
if (!node)
|
|
return NULL;
|
|
|
|
return ast_create(AST_NEG, node);
|
|
}
|
|
|
|
void ast_free_neg(struct ast_neg *node)
|
|
{
|
|
if (!node)
|
|
return;
|
|
ast_free(&node->child);
|
|
free(node);
|
|
}
|