-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from ErwannLesech/add_ionumbers
feat<ionumbers>: add ionumbers in lexer
- Loading branch information
Showing
9 changed files
with
147 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "../ast/ast.h" | ||
#include "ast_eval.h" | ||
|
||
#include <unistd.h> | ||
#include <fcntl.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <sys/wait.h> | ||
|
||
int redir_output(struct ast_node *node, bool logger_enabled) | ||
{ | ||
if (logger_enabled) | ||
{ | ||
printf("redir_output\n"); | ||
} | ||
int stat = 0; | ||
char *file_name = node->children[node->children_count - 1]->value; | ||
int fd = open(file_name, O_WRONLY | O_CREAT | O_TRUNC, 0644); | ||
if (fd == -1) | ||
{ | ||
return -1; | ||
} | ||
|
||
int stdout_fd = dup(STDOUT_FILENO); | ||
if (stdout_fd == -1) | ||
{ | ||
return -1; | ||
} | ||
|
||
// boucle pour dup les différents redirs | ||
|
||
// mettre à null les nodes redirs et réaranger l'arbre | ||
|
||
exec_cmd(node->children[0], false); | ||
|
||
close(fd); | ||
int status; | ||
waitpid(pid, &status, 0); | ||
stat = WEXITSTATUS(status); | ||
return stat; | ||
} | ||
|
||
int redir_manager(struct ast_node *ast, bool logger_enabled) | ||
{ | ||
if (logger_enabled) | ||
{ | ||
printf("redir_manager\n"); | ||
} | ||
if (ast->children_count < 2) | ||
{ | ||
return 0; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
#include <stddef.h> | ||
|
||
#include "token.h" | ||
#include "../options/options.h" | ||
|
||
/** | ||
* \struct lexer | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters