This commit is contained in:
Loic Deridder
2025-01-27 15:46:18 +01:00
parent 775f25a837
commit 1efc094d19
7 changed files with 319 additions and 52 deletions

58
includes/ast.h Normal file
View File

@@ -0,0 +1,58 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ast.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/24 08:23:27 by lderidde #+# #+# */
/* Updated: 2025/01/27 14:15:24 by lderidde ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef AST_H
# define AST_H
# include "env.h"
typedef enum e_state
{
UNDEF,
_AND,
_OR,
_CMD,
_PLINE
} t_state;
typedef enum e_redir
{
_NR,
_RED_L,
_RED_R,
_RED_DR
} t_redir;
typedef struct s_ast_n
{
t_state state;
struct s_ast_n *parent;
struct s_ast_n *left;
struct s_ast_n *right;
struct s_ast_n **pline;
int ex_code;
struct s_ast_n *head;
char *cmd;
char **args;
int fds[2];
int _stdout;
int _stdin;
t_redir redir;
char *infile;
char *outfile;
int shlvl;
char **env;
} t_ast_n;
t_ast_n *return_hardcode_ast(char **envp);
#endif

25
includes/exec.h Normal file
View File

@@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* exec.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/27 11:21:23 by lderidde #+# #+# */
/* Updated: 2025/01/27 15:02:20 by lderidde ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef EXEC_H
#define EXEC_H
# include <stdio.h>
# include <sys/wait.h>
# include <sys/types.h>
# include <stdlib.h>
# include <unistd.h>
# include "ast.h"
int execute_command(t_ast_n *node);
#endif

View File

@@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/27 11:25:25 by lderidde #+# #+# */
/* Updated: 2025/01/27 14:15:38 by lderidde ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MINISHELL_H
# define MINISHELL_H
@@ -11,6 +23,8 @@
# include "../lib/libft/libft.h"
# include "builtins.h"
# include "env.h"
# include "exec.h"
# include "ast.h"
# define POW1 "\033[1;38;2;21;22;26;48;2;92;106;178m"
# define POW2 "\033[1;38;2;92;106;178;48;2;54;54;54m"