compiling

This commit is contained in:
Loic Deridder
2025-02-12 13:32:12 +01:00
parent d03d1cf9ef
commit 256724e601
32 changed files with 74 additions and 67 deletions

View File

@@ -13,7 +13,6 @@
#ifndef BUILTINS_H #ifndef BUILTINS_H
# define BUILTINS_H # define BUILTINS_H
# include "../minishell.h"
# include <stdio.h> # include <stdio.h>
# include <sys/types.h> # include <sys/types.h>
# include <signal.h> # include <signal.h>
@@ -23,9 +22,13 @@
# include <stdlib.h> # include <stdlib.h>
# include <string.h> # include <string.h>
typedef struct s_ast_n t_ast_n;
typedef struct s_node t_node;
typedef struct s_msh t_msh;
# define UNSET_ARG "not enough arguments" # define UNSET_ARG "not enough arguments"
# define EXPRT_INV "not a valid identifier" # define EXPRT_INV "not a valid identifier"
// void echo(char *msg, int flag);
int builtin_echo(t_ast_n *node, char **envp); int builtin_echo(t_ast_n *node, char **envp);
int builtin_exit(char **arg, bool depth, t_ast_n *node); int builtin_exit(char **arg, bool depth, t_ast_n *node);
int builtin_pwd(char **arg); int builtin_pwd(char **arg);

View File

@@ -13,11 +13,12 @@
#ifndef ENV_H #ifndef ENV_H
# define ENV_H # define ENV_H
# include "../minishell.h"
# include <unistd.h> # include <unistd.h>
# include <stdlib.h> # include <stdlib.h>
# include <stdbool.h> # include <stdbool.h>
typedef struct s_msh t_msh;
//VAR //VAR
int count_var(char **envp); int count_var(char **envp);
int get_var_index(char *key, t_msh *msh); int get_var_index(char *key, t_msh *msh);

View File

@@ -13,7 +13,6 @@
#ifndef EXEC_H #ifndef EXEC_H
# define EXEC_H # define EXEC_H
# include "../minishell.h"
# include <stdio.h> # include <stdio.h>
# include <sys/wait.h> # include <sys/wait.h>
# include <sys/types.h> # include <sys/types.h>
@@ -21,6 +20,8 @@
# include <unistd.h> # include <unistd.h>
# include <time.h> # include <time.h>
typedef struct s_ast_n t_ast_n;
int execute_command(t_ast_n *node); int execute_command(t_ast_n *node);
//EXEC_REDIR //EXEC_REDIR

View File

@@ -13,10 +13,11 @@
#ifndef EXPANDER_H #ifndef EXPANDER_H
# define EXPANDER_H # define EXPANDER_H
# include "../minishell.h"
# include <sys/types.h> # include <sys/types.h>
# include <dirent.h> # include <dirent.h>
typedef struct s_ast_n t_ast_n;
int in_dquote(char *str, char *ch); int in_dquote(char *str, char *ch);
int in_squote(char *str, char *ch); int in_squote(char *str, char *ch);
int expand_var(t_ast_n *node, int j); int expand_var(t_ast_n *node, int j);

View File

@@ -13,26 +13,6 @@
#ifndef MINISHELL_H #ifndef MINISHELL_H
# define MINISHELL_H # define MINISHELL_H
# define DEBUG 1
# ifndef DIO_PATH
# define DIO_PATH "ast.xml"
# endif
typedef struct s_ast_n t_ast_n;
typedef struct s_node t_node;
typedef struct s_msh
{
int ex_code;
t_ast_n *head;
int here_fd;
char *input;
int hist;
char **env;
} t_msh;
# include <stdio.h> # include <stdio.h>
# include <readline/readline.h> # include <readline/readline.h>
# include <readline/history.h> # include <readline/history.h>
@@ -42,7 +22,6 @@ typedef struct s_msh
# include <signal.h> # include <signal.h>
# include <termios.h> # include <termios.h>
# include <sys/ioctl.h> # include <sys/ioctl.h>
# include "../lib/libft/libft.h" # include "../lib/libft/libft.h"
# include "parser/ast.h" # include "parser/ast.h"
# include "parser/drawio.h" # include "parser/drawio.h"
@@ -54,6 +33,26 @@ typedef struct s_msh
# include "exec/exec.h" # include "exec/exec.h"
# include "exec/expander.h" # include "exec/expander.h"
# define DEBUG 1
# ifndef DIO_PATH
# define DIO_PATH "ast.xml"
# endif
typedef struct s_ast_n t_ast_n;
typedef struct s_node t_node;
typedef struct s_msh t_msh;
typedef struct s_msh
{
int ex_code;
t_ast_n *head;
int here_fd;
char *input;
int hist;
char **env;
} t_msh;
t_msh *init_msh(char **envp); t_msh *init_msh(char **envp);
void free_msh(t_msh *msh); void free_msh(t_msh *msh);
void free_child(t_msh *msh); void free_child(t_msh *msh);

View File

@@ -13,8 +13,8 @@
#ifndef AST_H #ifndef AST_H
# define AST_H # define AST_H
/*# include "../../includes/env.h"*/ typedef struct s_node t_node;
# include "../minishell.h" typedef struct s_msh t_msh;
typedef enum e_state typedef enum e_state
{ {

View File

@@ -13,7 +13,10 @@
#ifndef DRAWIO_H #ifndef DRAWIO_H
# define DRAWIO_H # define DRAWIO_H
# include "../minishell.h" # include "../../lib/libft/libft.h"
typedef struct s_ast_n t_ast_n;
typedef struct s_node t_node;
typedef struct s_dio_node typedef struct s_dio_node
{ {

View File

@@ -13,7 +13,9 @@
#ifndef HEREDOC_H #ifndef HEREDOC_H
# define HEREDOC_H # define HEREDOC_H
# include "../minishell.h"
typedef struct s_node t_node;
typedef struct s_msh t_msh;
void read_hereinput(char *limiter, t_node *lst, t_msh *msh); void read_hereinput(char *limiter, t_node *lst, t_msh *msh);
void parse_heredoc(char *limiter, t_node *lst, t_msh *msh); void parse_heredoc(char *limiter, t_node *lst, t_msh *msh);

View File

@@ -13,7 +13,9 @@
#ifndef PARSING_H #ifndef PARSING_H
# define PARSING_H # define PARSING_H
# include "../minishell.h" typedef struct s_node t_node;
typedef struct s_ast_n t_ast_n;
typedef struct s_msh t_msh;
t_ast_n *parser(char *input, t_msh *msh); t_ast_n *parser(char *input, t_msh *msh);

View File

@@ -13,8 +13,6 @@
#ifndef TOKENIZER_H #ifndef TOKENIZER_H
# define TOKENIZER_H # define TOKENIZER_H
# include "../minishell.h"
typedef enum e_token typedef enum e_token
{ {
UNSET, UNSET,

View File

@@ -6,7 +6,7 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/24 14:31:49 by lderidde #+# #+# */ /* Created: 2025/01/24 14:31:49 by lderidde #+# #+# */
/* Updated: 2025/02/03 13:12:47 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:31:38 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/24 14:31:56 by lderidde #+# #+# */ /* Created: 2025/01/24 14:31:56 by lderidde #+# #+# */
/* Updated: 2025/02/08 11:02:58 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:31:35 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/24 14:32:04 by lderidde #+# #+# */ /* Created: 2025/01/24 14:32:04 by lderidde #+# #+# */
/* Updated: 2025/01/28 09:54:32 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:31:32 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/24 14:32:13 by lderidde #+# #+# */ /* Created: 2025/01/24 14:32:13 by lderidde #+# #+# */
/* Updated: 2025/02/11 13:01:12 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:31:27 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/24 14:32:20 by lderidde #+# #+# */ /* Created: 2025/01/24 14:32:20 by lderidde #+# #+# */
/* Updated: 2025/02/11 14:25:21 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:31:24 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/24 14:32:30 by lderidde #+# #+# */ /* Created: 2025/01/24 14:32:30 by lderidde #+# #+# */
/* Updated: 2025/01/28 10:38:07 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:31:22 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/24 14:32:36 by lderidde #+# #+# */ /* Created: 2025/01/24 14:32:36 by lderidde #+# #+# */
/* Updated: 2025/02/03 13:12:14 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:31:19 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/24 14:32:41 by lderidde #+# #+# */ /* Created: 2025/01/24 14:32:41 by lderidde #+# #+# */
/* Updated: 2025/01/28 10:53:44 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:31:16 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -10,7 +10,7 @@
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../../includes/exec/exec.h" #include "../../includes/minishell.h"
int execute_command(t_ast_n *node) int execute_command(t_ast_n *node)
{ {

View File

@@ -6,11 +6,11 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/12 09:48:21 by lderidde #+# #+# */ /* Created: 2025/02/12 09:48:21 by lderidde #+# #+# */
/* Updated: 2025/02/12 09:48:21 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:31:06 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../../includes/exec/exec.h" #include "../../includes/minishell.h"
int is_builtin(char *str) int is_builtin(char *str)
{ {

View File

@@ -6,11 +6,11 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/12 10:00:08 by lderidde #+# #+# */ /* Created: 2025/02/12 10:00:08 by lderidde #+# #+# */
/* Updated: 2025/02/12 10:00:08 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:31:03 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../../includes/exec/exec.h" #include "../../includes/minishell.h"
int count_cmds(t_ast_n **pline) int count_cmds(t_ast_n **pline)
{ {

View File

@@ -10,7 +10,7 @@
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../../includes/exec/exec.h" #include "../../includes/minishell.h"
void expander_here(char **str, t_ast_n *node) void expander_here(char **str, t_ast_n *node)
{ {

View File

@@ -6,11 +6,11 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/12 09:50:12 by lderidde #+# #+# */ /* Created: 2025/02/12 09:50:12 by lderidde #+# #+# */
/* Updated: 2025/02/12 09:50:12 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:30:51 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../../includes/exec/exec.h" #include "../../includes/minishell.h"
void exec_pcmd(t_ast_n *pcmd) void exec_pcmd(t_ast_n *pcmd)
{ {

View File

@@ -6,11 +6,11 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/12 09:42:31 by lderidde #+# #+# */ /* Created: 2025/02/12 09:42:31 by lderidde #+# #+# */
/* Updated: 2025/02/12 09:42:31 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:30:49 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../../includes/exec/exec.h" #include "../../includes/minishell.h"
void handle_file(t_ast_n *node, int check, int i) void handle_file(t_ast_n *node, int check, int i)
{ {

View File

@@ -6,11 +6,11 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/12 09:52:04 by lderidde #+# #+# */ /* Created: 2025/02/12 09:52:04 by lderidde #+# #+# */
/* Updated: 2025/02/12 09:52:04 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:30:47 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../../includes/exec/exec.h" #include "../../includes/minishell.h"
int exec_shcmd(t_ast_n *node) int exec_shcmd(t_ast_n *node)
{ {

View File

@@ -6,11 +6,11 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/12 09:57:39 by lderidde #+# #+# */ /* Created: 2025/02/12 09:57:39 by lderidde #+# #+# */
/* Updated: 2025/02/12 09:57:39 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:30:44 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../../includes/exec/exec.h" #include "../../includes/minishell.h"
int execis_validchar(char c) int execis_validchar(char c)
{ {

View File

@@ -6,13 +6,11 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/10 09:09:37 by lderidde #+# #+# */ /* Created: 2025/02/10 09:09:37 by lderidde #+# #+# */
/* Updated: 2025/02/11 15:29:43 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:30:38 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../../includes/exec/expander.h" #include "../../includes/minishell.h"
#include <dirent.h>
#include <stdbool.h>
static char *_strfjoin(char *s1, char *s2) static char *_strfjoin(char *s1, char *s2)
{ {

View File

@@ -6,11 +6,11 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/07 10:23:02 by lderidde #+# #+# */ /* Created: 2025/02/07 10:23:02 by lderidde #+# #+# */
/* Updated: 2025/02/11 13:10:18 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:30:32 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../../includes/exec/expander.h" #include "../../includes/minishell.h"
void remove_quote(t_ast_n *node, int j, char c) void remove_quote(t_ast_n *node, int j, char c)
{ {

View File

@@ -6,11 +6,11 @@
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */ /* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/11 15:28:57 by lderidde #+# #+# */ /* Created: 2025/02/11 15:28:57 by lderidde #+# #+# */
/* Updated: 2025/02/11 15:28:57 by lderidde ### ########.fr */ /* Updated: 2025/02/12 13:30:27 by lderidde ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../../includes/exec/expander.h" #include "../../includes/minishell.h"
bool ft_fnmatch(const char *str, const char *pat) bool ft_fnmatch(const char *str, const char *pat)
{ {

View File

@@ -10,7 +10,7 @@
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../../includes/exec/expander.h" #include "../../includes/minishell.h"
int expand_exit(t_ast_n *node, int j, int k) int expand_exit(t_ast_n *node, int j, int k)
{ {

View File

@@ -11,7 +11,6 @@
/* ************************************************************************** */ /* ************************************************************************** */
#include "../../../includes/minishell.h" #include "../../../includes/minishell.h"
#include <unistd.h>
t_ast_n *create_ast_n(t_node *lst, t_ast_n *parent, t_msh *msh, bool subsh) t_ast_n *create_ast_n(t_node *lst, t_ast_n *parent, t_msh *msh, bool subsh)
{ {

View File

@@ -10,7 +10,7 @@
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../../includes/parser/parsing.h" #include "../../includes/minishell.h"
int syntax_err_mess(char *token_base, int selected) int syntax_err_mess(char *token_base, int selected)
{ {