save commit
This commit is contained in:
@@ -6,19 +6,18 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/29 22:09:51 by sede-san #+# #+# */
|
||||
/* Updated: 2025/12/01 17:53:57 by sede-san ### ########.fr */
|
||||
/* Updated: 2026/02/08 19:42:50 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef BUILTINS_H
|
||||
# define BUILTINS_H
|
||||
|
||||
# include "libft.h"
|
||||
# include "minishell.h"
|
||||
# include "ft_args.h"
|
||||
# include "minishell.h"
|
||||
# include "core.h"
|
||||
|
||||
typedef unsigned char (*t_builtin_func)(t_command cmd, t_minishell *msh);
|
||||
|
||||
typedef unsigned char (*t_builtin_func)(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Functions */
|
||||
@@ -26,24 +25,24 @@ typedef unsigned char (*t_builtin_func)(t_command cmd, t_minishell *msh);
|
||||
|
||||
/* builtins.c */
|
||||
|
||||
extern u_int8_t set_builtins(t_minishell *msh);
|
||||
extern u_int8_t set_builtins(t_minishell *minishell);
|
||||
|
||||
extern u_int8_t is_builtin(const char *command_name, t_minishell *msh);
|
||||
extern u_int8_t is_builtin(const char *command_name, t_minishell *minishell);
|
||||
|
||||
/* cd.c */
|
||||
|
||||
extern u_int8_t builtin_cd(t_command cmd, t_minishell *msh);
|
||||
extern u_int8_t builtin_cd(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/* echo.c */
|
||||
|
||||
extern u_int8_t builtin_echo(t_command cmd, t_minishell *msh);
|
||||
extern u_int8_t builtin_echo(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/* exit.c */
|
||||
|
||||
extern u_int8_t builtin_exit(t_command cmd, t_minishell *msh);
|
||||
extern u_int8_t builtin_exit(t_command cmd, t_minishell *minishell);
|
||||
|
||||
/* pwd.c */
|
||||
|
||||
extern u_int8_t builtin_pwd(t_command cmd, t_minishell *msh);
|
||||
extern u_int8_t builtin_pwd(t_command cmd, t_minishell *minishell);
|
||||
|
||||
#endif /* BUILTINS_H */
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/22 19:10:13 by sede-san #+# #+# */
|
||||
/* Updated: 2025/12/01 17:02:10 by sede-san ### ########.fr */
|
||||
/* Updated: 2026/02/09 18:45:41 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -50,8 +50,8 @@ typedef struct s_minishell
|
||||
{
|
||||
t_variables variables;
|
||||
t_hashmap *builtins;
|
||||
u_int8_t exit_status;
|
||||
u_int8_t exit;
|
||||
uint8_t exit_status;
|
||||
bool exit;
|
||||
} t_minishell;
|
||||
|
||||
/**
|
||||
@@ -69,8 +69,19 @@ typedef struct s_command
|
||||
int argc;
|
||||
char **argv;
|
||||
char *path;
|
||||
t_list *redirections;
|
||||
} t_command;
|
||||
|
||||
/**
|
||||
* @brief Default shell prompt string
|
||||
*/
|
||||
# define DEFAULT_PS1 "minishell > "
|
||||
|
||||
/**
|
||||
* @brief Default secondary prompt string for multiline input
|
||||
*/
|
||||
# define DEFAULT_PS2 "> "
|
||||
|
||||
/******************************************************************************/
|
||||
/* Functions */
|
||||
/******************************************************************************/
|
||||
@@ -79,7 +90,7 @@ typedef struct s_command
|
||||
|
||||
extern int minishell_init(t_minishell *minishell, char **envp);
|
||||
|
||||
extern u_int8_t minishell_run(t_minishell *minishell);
|
||||
extern uint8_t minishell_run(t_minishell *minishell);
|
||||
|
||||
extern void minishell_clear(t_minishell *minishell);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/28 13:08:33 by sede-san #+# #+# */
|
||||
/* Updated: 2025/10/28 14:20:23 by sede-san ### ########.fr */
|
||||
/* Updated: 2026/02/08 21:32:56 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -14,6 +14,18 @@
|
||||
# define EXECUTOR_H
|
||||
|
||||
# include "minishell.h"
|
||||
# include "core.h"
|
||||
# include <stdint.h>
|
||||
|
||||
# define READ_PIPE 0
|
||||
# define WRITE_PIPE 1
|
||||
|
||||
typedef struct s_pipeline
|
||||
{
|
||||
int prev_read_fd;
|
||||
int pipefd[2];
|
||||
} t_pipeline;
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Functions */
|
||||
@@ -21,6 +33,9 @@
|
||||
|
||||
// executor.c
|
||||
|
||||
extern u_int8_t execute(t_command command, t_minishell *minishell);
|
||||
# define PIPE_ERROR -1
|
||||
# define FORK_ERROR -1
|
||||
|
||||
extern uint8_t execute(t_list *command, t_minishell *minishell);
|
||||
|
||||
#endif /* EXECUTOR_H */
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/20 16:35:10 by sede-san #+# #+# */
|
||||
/* Updated: 2025/10/30 12:20:08 by sede-san ### ########.fr */
|
||||
/* Updated: 2026/02/09 18:38:16 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
# include "libft.h"
|
||||
# include "ft_printf.h"
|
||||
# include "chardefs.h"
|
||||
# include "core.h"
|
||||
# include "parser.h"
|
||||
# include "executor.h"
|
||||
# include "builtins.h"
|
||||
# include <stdbool.h>
|
||||
# include <stdint.h>
|
||||
# include <readline/readline.h> // readline(3), rl_clear_history(),
|
||||
// rl_on_new_line(), rl_replace_line(),
|
||||
// rl_redisplay()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/22 19:03:51 by sede-san #+# #+# */
|
||||
/* Updated: 2025/10/30 12:44:51 by sede-san ### ########.fr */
|
||||
/* Updated: 2026/02/09 20:36:19 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -14,6 +14,46 @@
|
||||
# define PARSER_H
|
||||
|
||||
# include "minishell.h"
|
||||
# include "core.h"
|
||||
# include "builtins.h"
|
||||
|
||||
# define PIPE_STR "|"
|
||||
# define REDIRECT_IN_STR "<"
|
||||
# define REDIRECT_OUT_STR ">"
|
||||
# define APPEND_STR ">>"
|
||||
# define HEREDOC_STR "<<"
|
||||
|
||||
# define TOKENS_COUNT 5
|
||||
|
||||
typedef enum e_token_type
|
||||
{
|
||||
TOKEN_WORD,
|
||||
TOKEN_PIPE,
|
||||
TOKEN_REDIRECT_IN,
|
||||
TOKEN_REDIRECT_OUT,
|
||||
TOKEN_APPEND,
|
||||
TOKEN_HEREDOC
|
||||
} t_token_type;
|
||||
|
||||
typedef struct s_token
|
||||
{
|
||||
t_token_type type;
|
||||
char *value;
|
||||
} t_token;
|
||||
|
||||
typedef enum e_redirection_type
|
||||
{
|
||||
REDIRECT_IN,
|
||||
REDIRECT_OUT,
|
||||
APPEND,
|
||||
HEREDOC
|
||||
} t_redirection_type;
|
||||
|
||||
typedef struct s_redirection
|
||||
{
|
||||
t_redirection_type type;
|
||||
char *target;
|
||||
} t_redirection;
|
||||
|
||||
/******************************************************************************/
|
||||
/* Functions */
|
||||
@@ -21,6 +61,6 @@
|
||||
|
||||
// parser.c
|
||||
|
||||
extern t_command parse(char *line, t_minishell *minishell);
|
||||
extern t_list *parse(char *line, t_minishell *minishell);
|
||||
|
||||
#endif /* PARSER_H */
|
||||
|
||||
Reference in New Issue
Block a user