minishell/inc/typedef.h

86 lines
1.9 KiB
C

/* ************************************************************************** */
/* */
/* :::::::: */
/* typedef.h :+: :+: */
/* +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/02/05 12:36:08 by whaffman #+# #+# */
/* Updated: 2025/03/19 13:46:51 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
#ifndef TYPEDEF_H
# define TYPEDEF_H
typedef enum e_token_type
{
T_WORD,
T_DQWORD,
T_SQWORD,
T_PIPE,
T_REDIRECT_IN,
T_REDIRECT_OUT,
T_AND,
T_OR,
T_APPEND_OUT,
T_HEREDOC,
T_EOF,
T_ERROR
} t_token_type;
typedef struct s_environment
{
char *name;
char *value;
} t_environment;
typedef struct s_token
{
t_token_type type;
char *value;
int position;
} t_token;
typedef struct s_lexer
{
char *input;
int pos;
int n_pos;
char current_char;
} t_lexer;
typedef struct s_redirect
{
enum e_token_type type;
char *value;
} t_redirect;
typedef struct s_command
{
//char *command;
char **args;
// t_list *environment;
t_list *redirect_in;
t_list *redirect_out;
int fd_in;
int fd_out;
int n_fds;
int pid;
int exit_status;
} t_command;
typedef struct s_minishell
{
t_list *environment;
char *line;
t_lexer *lexer;
t_list *tokens;
t_list *commands;
t_list *freelist;
int exit_status;
} t_minishell;
typedef int (*t_builtin_fn)(t_minishell *, t_command *);
#endif // TYPEDEF_H