norme
This commit is contained in:
@@ -27,13 +27,17 @@
|
|||||||
# include <signal.h>
|
# include <signal.h>
|
||||||
# include <dirent.h>
|
# include <dirent.h>
|
||||||
# include <termios.h>
|
# include <termios.h>
|
||||||
# include <curses.h> // sudo apt install libncurses-dev (OR libncurses5-dev)
|
|
||||||
|
// sudo apt install libncurses-dev (OR libncurses5-dev)
|
||||||
|
# include <curses.h>
|
||||||
# include <term.h>
|
# include <term.h>
|
||||||
|
|
||||||
# include <stdio.h>
|
// sudo apt install libreadline-dev
|
||||||
# include <readline/readline.h> // sudo apt install libreadline-dev
|
# include <readline/readline.h>
|
||||||
# include <readline/history.h>
|
# include <readline/history.h>
|
||||||
|
|
||||||
|
# include <stdio.h>
|
||||||
|
|
||||||
# include "minishell_structs.h"
|
# include "minishell_structs.h"
|
||||||
# include "minishell_macro.h"
|
# include "minishell_macro.h"
|
||||||
# include "minishell_term_colors.h"
|
# include "minishell_term_colors.h"
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
// Init
|
// Init
|
||||||
int init(t_all *c, char *envp[]);
|
int init(t_all *c, char *envp[]);
|
||||||
int set_signals_handling(struct sigaction *ori_signal_behaviour,
|
int set_signals_handling(struct sigaction *ori_signal_behaviour,
|
||||||
struct sigaction *signal_behaviour);
|
struct sigaction *signal_behaviour);
|
||||||
int set_terminal_attributes(struct termios *ori_termios,
|
int set_terminal_attributes(struct termios *ori_termios,
|
||||||
struct termios *interactive_termios,
|
struct termios *interactive_termios,
|
||||||
int *termios_changed);
|
int *termios_changed);
|
||||||
|
|
||||||
// Shell modes
|
// Shell modes
|
||||||
void shell_loop(t_all *c);
|
void shell_loop(t_all *c);
|
||||||
|
|||||||
@@ -13,8 +13,7 @@
|
|||||||
#ifndef MINISHELL_STRUCTS_H
|
#ifndef MINISHELL_STRUCTS_H
|
||||||
# define MINISHELL_STRUCTS_H
|
# define MINISHELL_STRUCTS_H
|
||||||
|
|
||||||
struct s_all;
|
struct s_all *g_all;
|
||||||
struct s_all *g_all;
|
|
||||||
|
|
||||||
enum e_token_id
|
enum e_token_id
|
||||||
{
|
{
|
||||||
@@ -22,10 +21,12 @@ enum e_token_id
|
|||||||
T_LESS = '<',
|
T_LESS = '<',
|
||||||
T_GREAT = '>',
|
T_GREAT = '>',
|
||||||
T_PIPE = '|',
|
T_PIPE = '|',
|
||||||
T_DLESS, //'<<'
|
T_DLESS,
|
||||||
T_DGREAT, //'>>'
|
T_DGREAT,
|
||||||
T_WORD
|
T_WORD
|
||||||
};
|
};
|
||||||
|
// T_DLESS == '<<'
|
||||||
|
// T_DGREAT == '>>'
|
||||||
|
|
||||||
typedef struct s_token
|
typedef struct s_token
|
||||||
{
|
{
|
||||||
@@ -34,7 +35,7 @@ typedef struct s_token
|
|||||||
enum e_token_id id;
|
enum e_token_id id;
|
||||||
} t_token;
|
} t_token;
|
||||||
|
|
||||||
typedef int (*t_builtin_ptr)(int,char **,struct s_all *);
|
typedef int (*t_builtin_ptr)(int,char **,struct s_all *);
|
||||||
|
|
||||||
typedef struct s_cmd
|
typedef struct s_cmd
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,10 +15,10 @@
|
|||||||
static char *init_prompt_base(void);
|
static char *init_prompt_base(void);
|
||||||
static char *init_prompt(char *prompt_base);
|
static char *init_prompt(char *prompt_base);
|
||||||
|
|
||||||
int init(t_all *c, char *envp[])
|
int init(t_all *c, char *envp[])
|
||||||
{
|
{
|
||||||
g_all = c;
|
g_all = c;
|
||||||
ft_bzero(c, sizeof *c);
|
ft_bzero(c, sizeof (*c));
|
||||||
c->envp = ft_dup_2d_char_arr(envp);
|
c->envp = ft_dup_2d_char_arr(envp);
|
||||||
if (!c->envp)
|
if (!c->envp)
|
||||||
return (ft_reti_perror(0, "ft_dup_2d_char_arr(envp) error"));
|
return (ft_reti_perror(0, "ft_dup_2d_char_arr(envp) error"));
|
||||||
@@ -32,7 +32,7 @@ int init(t_all *c, char *envp[])
|
|||||||
if (isatty(STDIN_FILENO))
|
if (isatty(STDIN_FILENO))
|
||||||
{
|
{
|
||||||
if (!set_terminal_attributes(&c->ori_termios, &c->interactive_termios,
|
if (!set_terminal_attributes(&c->ori_termios, &c->interactive_termios,
|
||||||
&c->termios_changed))
|
&c->termios_changed))
|
||||||
return (ft_reti_perror(0, "set_terminal_attributes() error"));
|
return (ft_reti_perror(0, "set_terminal_attributes() error"));
|
||||||
}
|
}
|
||||||
return (1);
|
return (1);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int check_operators(t_token *t, char *input, int *i, int *t_i);
|
int check_operators(t_token *t, char *input, int *i, int *t_i);
|
||||||
|
|
||||||
enum e_in_quote_state
|
enum e_in_quote_state
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int fill_token(t_token *t, char *input, int *i, int *t_i);
|
int fill_token(t_token *t, char *input, int *i, int *t_i);
|
||||||
|
|
||||||
static t_token *alloc_token(size_t content_len);
|
static t_token *alloc_token(size_t content_len);
|
||||||
@@ -41,7 +42,7 @@ static t_token *alloc_token(size_t content_len)
|
|||||||
{
|
{
|
||||||
t_token *token;
|
t_token *token;
|
||||||
|
|
||||||
token = ft_calloc(1, sizeof *token);
|
token = ft_calloc(1, sizeof (*token));
|
||||||
if (!token)
|
if (!token)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
token->content = ft_calloc(content_len + 1, 1);
|
token->content = ft_calloc(content_len + 1, 1);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int valid_io_redirect(t_token **token_list);
|
int valid_io_redirect(t_token **token_list);
|
||||||
|
|
||||||
static int valid_command_rule1(t_token **token_list);
|
static int valid_command_rule1(t_token **token_list);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int valid_command(t_token **token_list);
|
int valid_command(t_token **token_list);
|
||||||
|
|
||||||
int valid_pipeline(t_token **token_list)
|
int valid_pipeline(t_token **token_list)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int valid_pipeline(t_token **token_list);
|
int valid_pipeline(t_token **token_list);
|
||||||
|
|
||||||
int valid_syntax(t_token *token_list)
|
int valid_syntax(t_token *token_list)
|
||||||
@@ -18,7 +19,7 @@ int valid_syntax(t_token *token_list)
|
|||||||
if (valid_pipeline(&token_list))
|
if (valid_pipeline(&token_list))
|
||||||
return (1);
|
return (1);
|
||||||
else
|
else
|
||||||
{ // WIP ERROR
|
{
|
||||||
ft_putstr_fd("minishell: syntax error near unexpected token \'", 2);
|
ft_putstr_fd("minishell: syntax error near unexpected token \'", 2);
|
||||||
ft_putstr_fd(token_list->content, 2);
|
ft_putstr_fd(token_list->content, 2);
|
||||||
ft_putstr_fd("\'\n", 2);
|
ft_putstr_fd("\'\n", 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user