diff --git a/42sh/includes/builtin.h b/42sh/includes/builtin.h index 5efa6dff..be6045e4 100644 --- a/42sh/includes/builtin.h +++ b/42sh/includes/builtin.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 17:21:56 by jhalford #+# #+# */ -/* Updated: 2017/02/27 20:28:37 by ariard ### ########.fr */ +/* Updated: 2017/03/07 17:29:38 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,4 +32,6 @@ int builtin_bg(const char *path, char *const av[], char *const envp[]); int builtin_history(const char *path, char *const av[], char *const envp[]); int builtin_hash(const char *path, char *const av[], char *const envp[]); +extern t_stof g_builtins[]; + #endif diff --git a/42sh/includes/exec.h b/42sh/includes/exec.h index 9daf4e1e..abb4d9c6 100644 --- a/42sh/includes/exec.h +++ b/42sh/includes/exec.h @@ -6,13 +6,15 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */ -/* Updated: 2017/03/07 16:36:47 by ariard ### ########.fr */ +/* Updated: 2017/03/07 19:43:43 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef EXEC_H # define EXEC_H +# include + # define PIPE_READ 0 # define PIPE_WRITE 1 @@ -42,9 +44,37 @@ # define EXEC_IS_IF_BRANCH(j) (j & EXEC_IF_BRANCH) # define EXEC_IS_CASE_BRANCH(j) (j & EXEC_CASE_BRANCH) -# include "libft.h" -# include "types.h" -# include "job_control.h" +struct s_data_cmd +{ + char **av; + char *path; + t_execf *execf; + struct stat stat; +}; + +struct s_data_cond +{ + t_btree *condition; + t_btree *content; +}; + +struct s_data_list +{ + char *word; + t_ld *list_word; + t_btree *content; +}; + +union u_process_data +{ + struct s_data_cmd cmd; + struct s_data_cond d_while; + struct s_data_cond d_if; + struct s_data_cond d_else; + struct s_data_cond d_elif; + struct s_data_list d_for; +// struct s_data_cond case; +}; enum e_process_type { @@ -59,12 +89,12 @@ enum e_process_type }; typedef enum e_process_type t_process_type; +typedef union u_process_data t_process_data; +typedef struct s_data_cond t_data_while; +typedef struct s_data_cond t_data_if; struct s_process { - /* char **av; */ - /* char *path; */ - /* t_execf *execf; */ t_process_type type; t_process_data data; pid_t pid; @@ -87,7 +117,6 @@ struct s_exec int control_count; }; -#include "minishell.h" extern t_itof g_execmap[]; extern t_itof g_redirmap[]; @@ -103,18 +132,19 @@ int exec_or_if(t_btree **ast); int exec_and_if(t_btree **ast); int exec_pipe(t_btree **ast); /* int exec_redir(t_btree **ast); */ -int exec_cmd(t_btree **ast); +//int exec_cmd(t_btree **ast); +int exec_leaf(t_btree **ast); -int exec_while(t_btree **ast); -int exec_if(t_btree **ast); -int exec_elif(t_btree **ast); -int exec_else(t_btree **ast); -int exec_until(t_btree **ast); -int exec_default(t_btree **ast); +//int exec_while(t_btree **ast); +//int exec_if(t_btree **ast); +//int exec_elif(t_btree **ast); +//int exec_else(t_btree **ast); +//int exec_until(t_btree **ast); +//int exec_default(t_btree **ast); int exec_var(t_btree **ast); -int exec_for(t_btree **ast); -int exec_case(t_btree **ast); -int exec_case_branch(t_btree **ast); +//int exec_for(t_btree **ast); +//int exec_case(t_btree **ast); +//int exec_case_branch(t_btree **ast); int exec_math(t_btree **ast); int launch_process(t_process *p); @@ -145,8 +175,15 @@ void redir_free(void *data, size_t content_size); char **token_to_argv(t_ld *ld, int do_match); +# include int add_new_job(t_job *job); int error_badidentifier(char *name); +/* +** Mapping pour set les process +*/ +int set_process_map(t_process *p, t_btree *ast, t_cmd *cmd); + +int set_process_cmd(t_process *p, t_btree *ast, t_cmd *cmd); #endif diff --git a/42sh/includes/ft_readline.h b/42sh/includes/ft_readline.h index 92c78218..419d74df 100644 --- a/42sh/includes/ft_readline.h +++ b/42sh/includes/ft_readline.h @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/23 10:35:44 by gwojda #+# #+# */ -/* Updated: 2017/02/21 19:51:19 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 18:36:00 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -54,20 +54,6 @@ # define TOUCHE_F5 892427035 # define TOUCHE_F6 925981467 -/* # define PROMPT_QUOTES "quote> " */ -/* # define PROMPT_DQUOTES "dquote> " */ -/* # define PROMPT_BQUOTES "bquote> " */ -/* # define PROMPT_ACCOLADE "cursh> " */ -/* # define PROMPT_BRACKET "subsh> " */ -/* # define PROMPT_BSLASH "> " */ - -/* # define SIZE_PROMPT_QUOTES 7 */ -/* # define SIZE_PROMPT_DQUOTES 8 */ -/* # define SIZE_PROMPT_BQUOTES 8 */ -/* # define SIZE_PROMPT_ACCOLADE 7 */ -/* # define SIZE_PROMPT_BRACKET 7 */ -/* # define SIZE_PROMPT_BSLASH 2 */ - # define IS_QUOTES (1 << 0) # define IS_BQUOTES (1 << 1) # define IS_DQUOTES (1 << 2) diff --git a/42sh/includes/glob.h b/42sh/includes/glob.h index 26d18d42..f8b965ec 100644 --- a/42sh/includes/glob.h +++ b/42sh/includes/glob.h @@ -6,15 +6,13 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/04 16:31:18 by wescande #+# #+# */ -/* Updated: 2017/03/03 20:39:05 by wescande ### ########.fr */ +/* Updated: 2017/03/07 18:18:33 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef GLOB_H # define GLOB_H -# include "minishell.h" - # define CH(x) ((char **)(x)->content) # define UCH(x) ((unsigned char **)(x)->content) # define SCH(x) ((char **)(x).content) @@ -105,31 +103,4 @@ char **ft_strsplit_spe(const char *str, const unsigned char *esc, char c); unsigned char **ft_strsplit_esc(const char *str, const unsigned char *esc, char c); -/* -** LIST D: -*/ -void ft_ld_new(t_ld **alst, void *content); -t_ld *ft_ld_front(t_ld *ld); -void ft_ld_pushfront(t_ld **alst, void *content); -void ft_ld_pushback(t_ld **alst, void *content); -size_t ft_ld_size(t_ld *ld); -void ft_ld_del(t_ld **ld, void (*del)()); -void ft_ld_clear(t_ld **ld, void (*del)()); -void ft_ld_reverse(t_ld **lst); -t_ld *ft_ld_back(t_ld *ld); -t_ld *ft_ld_swap(t_ld *l_cur); -char **ft_ld_to_tab(t_ld *ld); -t_ld *ft_ld_order(t_ld *ld, int (*f)(), void (*del)()); - -/* -** str: -*/ - -char *ft_strjoinf(char *str, char *str2, int mode); -char *ft_strsubf(char *s, unsigned int start, - size_t len, short int mode); -void ft_tabdel(char ***mytab); -int ft_tablen(char **mytab); - -void *ft_memrealloc(void *ptr, size_t old_s, size_t new_s); #endif diff --git a/42sh/includes/minishell.h b/42sh/includes/minishell.h index 7fab094a..2a98dd10 100644 --- a/42sh/includes/minishell.h +++ b/42sh/includes/minishell.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */ -/* Updated: 2017/03/07 14:27:40 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 18:38:08 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,48 +14,24 @@ # define MINISHELL_H # define SHELL_NAME "minishell" +# include +# include +# include +# include +# include + # include "libft.h" # include "types.h" # include "lexer.h" # include "parser.h" # include "ft_readline.h" +# include "job_control.h" # include "exec.h" # include "builtin.h" -# include "job_control.h" # include "glob.h" # include "completion.h" # include "hash.h" -# include -# include -# include -# include -# include -# include - -# define SH_INTERACTIVE (1 << 0) -# define SH_OPTS_JOBC (1 << 1) -# define SH_OPTS_LC (1 << 2) -# define SH_MODE_INPUT (1 << 3) -# define SH_MODE_EXEC (1 << 4) - -# define SH_MODE_MASK (SH_MODE_INPUT | SH_MODE_EXEC) -# define SH_HAS_JOBC(b) (b & SH_OPTS_JOBC) -# define SH_IS_INTERACTIVE(b) (b & SH_INTERACTIVE) -# define SH_NO_INTERACTIVE(b) !(b & SH_INTERACTIVE) - -# define SH_MSG_NOJOBC "no job-control" - -struct s_script -{ - char *buffer; - int fd; - int size; - int lc; -}; - -typedef struct s_script t_script; - struct s_data { char **env; @@ -70,8 +46,6 @@ struct s_data t_list *lst_func; }; -extern t_stof g_builtins[]; - void shell_get_opts(int ac, char **av); char *shell_get_avdata(); void shell_init(int ac, char **av); diff --git a/42sh/includes/parser.h b/42sh/includes/parser.h index 69bf088f..a144c663 100644 --- a/42sh/includes/parser.h +++ b/42sh/includes/parser.h @@ -12,11 +12,8 @@ #ifndef PARSER_H # define PARSER_H -# include "minishell.h" - /* - * Parse POSIX grammar - * +** Parse POSIX grammar */ enum e_parstate @@ -43,8 +40,6 @@ struct s_aggrematch int erase_sym; }; -extern t_aggrematch g_aggrematch[]; - struct s_prodmatch { t_type token; @@ -52,22 +47,21 @@ struct s_prodmatch t_sym new_sym; }; -extern t_prodmatch g_prodmatch[]; - struct s_stackmatch { t_sym top; t_sym under; }; -extern t_stackmatch g_stackmatch[]; - struct s_errormatch { t_type token; char *error; }; +extern t_aggrematch g_aggrematch[]; +extern t_prodmatch g_prodmatch[]; +extern t_stackmatch g_stackmatch[]; extern t_errormatch g_errormatch[]; void parser_init(t_parser *parser); diff --git a/42sh/includes/types.h b/42sh/includes/types.h index 13287494..aeeebf7c 100644 --- a/42sh/includes/types.h +++ b/42sh/includes/types.h @@ -6,44 +6,72 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */ -/* Updated: 2017/03/07 16:37:18 by ariard ### ########.fr */ +/* Updated: 2017/03/07 19:43:22 by ariard ### ########.fr */ +/* Updated: 2017/03/07 18:35:11 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef TYPES_H # define TYPES_H -typedef struct s_data t_data; +# include + +# define SH_INTERACTIVE (1 << 0) +# define SH_OPTS_JOBC (1 << 1) +# define SH_OPTS_LC (1 << 2) +# define SH_MODE_INPUT (1 << 3) +# define SH_MODE_EXEC (1 << 4) + +# define SH_MODE_MASK (SH_MODE_INPUT | SH_MODE_EXEC) +# define SH_HAS_JOBC(b) (b & SH_OPTS_JOBC) +# define SH_IS_INTERACTIVE(b) (b & SH_INTERACTIVE) +# define SH_NO_INTERACTIVE(b) !(b & SH_INTERACTIVE) + +# define SH_MSG_NOJOBC "no job-control" typedef long long t_type; typedef long long t_flag; + +typedef struct s_data t_data; typedef struct s_line t_line; typedef struct s_comp t_comp; typedef struct s_exec t_exec; typedef struct s_jobc t_jobc; typedef enum e_mode t_mode; +/* +** Execution types +*/ + typedef struct s_lexer t_lexer; typedef enum e_lexstate t_lexstate; typedef struct s_token t_token; typedef struct s_rvwords t_rvwords; typedef struct s_ld t_ld; + +/* +** Execution types +*/ + +typedef int t_condition; +typedef struct s_job t_job; +typedef struct s_process t_process; +typedef int (t_execf)(const char *path, + char *const argv[], + char *const envp[]); + +/* +** Parser types +*/ + typedef struct s_astnode t_astnode; typedef struct s_redir t_redir; typedef struct s_cmd t_cmd; typedef union u_astdata t_astdata; typedef union u_word t_word; - -typedef int t_condition; -typedef struct s_job t_job; -typedef struct s_execmap t_execmap; -typedef struct s_redirmap t_redirmap; -typedef struct s_process t_process; -typedef int (t_execf)(const char *path, char *const argv[], char *const envp[]); - -typedef int t_sym; typedef struct s_parser t_parser; +typedef int t_sym; typedef enum e_parstate t_parstate; typedef struct s_aggrematch t_aggrematch; typedef struct s_prodmatch t_prodmatch; @@ -169,4 +197,33 @@ enum e_sym TERMINUS = 300, }; +/* +** LIST D: +*/ + +void ft_ld_new(t_ld **alst, void *content); +t_ld *ft_ld_front(t_ld *ld); +void ft_ld_pushfront(t_ld **alst, void *content); +void ft_ld_pushback(t_ld **alst, void *content); +size_t ft_ld_size(t_ld *ld); +void ft_ld_del(t_ld **ld, void (*del)()); +void ft_ld_clear(t_ld **ld, void (*del)()); +void ft_ld_reverse(t_ld **lst); +t_ld *ft_ld_back(t_ld *ld); +t_ld *ft_ld_swap(t_ld *l_cur); +char **ft_ld_to_tab(t_ld *ld); +t_ld *ft_ld_order(t_ld *ld, int (*f)(), void (*del)()); + +/* +** str: +*/ + +char *ft_strjoinf(char *str, char *str2, int mode); +char *ft_strsubf(char *s, unsigned int start, + size_t len, short int mode); +void ft_tabdel(char ***mytab); +int ft_tablen(char **mytab); + +void *ft_memrealloc(void *ptr, size_t old_s, size_t new_s); + #endif diff --git a/42sh/libft b/42sh/libft index 6a6a23b2..bc489f86 160000 --- a/42sh/libft +++ b/42sh/libft @@ -1 +1 @@ -Subproject commit 6a6a23b2839a5ec7322bdc6adbb2d3dad3d1023c +Subproject commit bc489f8664fdc24317c31b3069811f54b1178643 diff --git a/42sh/src/addls b/42sh/src/addls deleted file mode 100644 index 8b137891..00000000 --- a/42sh/src/addls +++ /dev/null @@ -1 +0,0 @@ - diff --git a/42sh/src/builtin/bt_read_get.c b/42sh/src/builtin/bt_read_get.c index f2e70ab1..575d694e 100644 --- a/42sh/src/builtin/bt_read_get.c +++ b/42sh/src/builtin/bt_read_get.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "builtin_read.h" +#include "minishell.h" int bt_read_getdelim(t_read *data, char *arg) { diff --git a/42sh/src/builtin/bt_read_parse.c b/42sh/src/builtin/bt_read_parse.c index 15aaff94..d79c754c 100644 --- a/42sh/src/builtin/bt_read_parse.c +++ b/42sh/src/builtin/bt_read_parse.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "builtin_read.h" +#include "minishell.h" static t_readopt *bt_read_getopt(char letter) { diff --git a/42sh/src/builtin/bt_read_term.c b/42sh/src/builtin/bt_read_term.c index 131eaaf7..b0a7477b 100644 --- a/42sh/src/builtin/bt_read_term.c +++ b/42sh/src/builtin/bt_read_term.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "builtin.h" +#include "minishell.h" struct termios bt_read_term(int init) { diff --git a/42sh/src/builtin/builtin_cd.c b/42sh/src/builtin/builtin_cd.c index 4884205e..e3ace609 100644 --- a/42sh/src/builtin/builtin_cd.c +++ b/42sh/src/builtin/builtin_cd.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "builtin.h" +#include "minishell.h" #define CDOPT_L (1 << 0) #define CDOPT_P (1 << 1) diff --git a/42sh/src/builtin/builtin_echo.c b/42sh/src/builtin/builtin_echo.c index f84c9123..2fd4f3de 100644 --- a/42sh/src/builtin/builtin_echo.c +++ b/42sh/src/builtin/builtin_echo.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "builtin.h" +#include "minishell.h" int builtin_echo(const char *path, char *const av[], char *const envp[]) { diff --git a/42sh/src/builtin/builtin_read.c b/42sh/src/builtin/builtin_read.c index cba5e4e6..264f2b3b 100644 --- a/42sh/src/builtin/builtin_read.c +++ b/42sh/src/builtin/builtin_read.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "builtin_read.h" +#include "minishell.h" t_readopt g_readtab[] = { diff --git a/42sh/src/builtin/is_builtin.c b/42sh/src/builtin/is_builtin.c index 7854d6b8..c48252ed 100644 --- a/42sh/src/builtin/is_builtin.c +++ b/42sh/src/builtin/is_builtin.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 13:09:57 by jhalford #+# #+# */ -/* Updated: 2017/03/07 16:05:47 by ariard ### ########.fr */ +/* Updated: 2017/03/07 19:42:54 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/completion/c_binary.c b/42sh/src/completion/c_binary.c index bccc73d8..bf359ca4 100644 --- a/42sh/src/completion/c_binary.c +++ b/42sh/src/completion/c_binary.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "completion.h" +#include "minishell.h" /* ** Retrieve the path from the env and create a char ** from the PATH pattern. diff --git a/42sh/src/completion/c_clear.c b/42sh/src/completion/c_clear.c index 815d12b5..80f6f3fb 100644 --- a/42sh/src/completion/c_clear.c +++ b/42sh/src/completion/c_clear.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "completion.h" +#include "minishell.h" /* ** Clear the list from the memory diff --git a/42sh/src/completion/c_files.c b/42sh/src/completion/c_files.c index dba7bc4f..5931ca22 100644 --- a/42sh/src/completion/c_files.c +++ b/42sh/src/completion/c_files.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "completion.h" +#include "minishell.h" /* ** If the parsing for local file fail. The function is called to check if the diff --git a/42sh/src/completion/c_init.c b/42sh/src/completion/c_init.c index d9701694..5b5c6934 100644 --- a/42sh/src/completion/c_init.c +++ b/42sh/src/completion/c_init.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "completion.h" +#include "minishell.h" /* ** Trim if there's many commands in a raw separed with a semi colon. diff --git a/42sh/src/completion/c_matching.c b/42sh/src/completion/c_matching.c index 761f6ef3..25936087 100644 --- a/42sh/src/completion/c_matching.c +++ b/42sh/src/completion/c_matching.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "completion.h" +#include "minishell.h" /* ** Start the parsing for the autocompletion. diff --git a/42sh/src/completion/c_misc.c b/42sh/src/completion/c_misc.c index fbdd425a..eb740791 100644 --- a/42sh/src/completion/c_misc.c +++ b/42sh/src/completion/c_misc.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "completion.h" +#include "minishell.h" /* ** Support: Return the size of a char**. diff --git a/42sh/src/completion/c_output.c b/42sh/src/completion/c_output.c index 6b9f280d..6704ad3a 100644 --- a/42sh/src/completion/c_output.c +++ b/42sh/src/completion/c_output.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "completion.h" +#include "minishell.h" /* ** Update of the struct data. diff --git a/42sh/src/completion/c_parser.c b/42sh/src/completion/c_parser.c index f611f4df..3788ff73 100644 --- a/42sh/src/completion/c_parser.c +++ b/42sh/src/completion/c_parser.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "completion.h" +#include "minishell.h" /* ** Add the matching element to the list diff --git a/42sh/src/completion/c_pathsolver.c b/42sh/src/completion/c_pathsolver.c index 752d874d..6ab88f40 100644 --- a/42sh/src/completion/c_pathsolver.c +++ b/42sh/src/completion/c_pathsolver.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "completion.h" +#include "minishell.h" /* ** Solve the tilde pattern in the path diff --git a/42sh/src/completion/c_printer.c b/42sh/src/completion/c_printer.c index f43163de..c46fd10d 100644 --- a/42sh/src/completion/c_printer.c +++ b/42sh/src/completion/c_printer.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "completion.h" +#include "minishell.h" /* ** Print the name with or without an underline and colored upon file type diff --git a/42sh/src/completion/c_rematch.c b/42sh/src/completion/c_rematch.c index 13421f70..6771e656 100644 --- a/42sh/src/completion/c_rematch.c +++ b/42sh/src/completion/c_rematch.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "completion.h" +#include "minishell.h" /* ** Recreate a c->match value by adding the new key pressed to it. diff --git a/42sh/src/completion/c_sizing.c b/42sh/src/completion/c_sizing.c index 2d7adda9..559b3329 100644 --- a/42sh/src/completion/c_sizing.c +++ b/42sh/src/completion/c_sizing.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "completion.h" +#include "minishell.h" /* ** Get the max length from the list diff --git a/42sh/src/completion/c_terminal.c b/42sh/src/completion/c_terminal.c index 1b5d28a2..58d01bd7 100644 --- a/42sh/src/completion/c_terminal.c +++ b/42sh/src/completion/c_terminal.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "completion.h" +#include "minishell.h" /* ** Clear the previous list from the screen and restore the same position. diff --git a/42sh/src/completion/completion.c b/42sh/src/completion/completion.c index 42705b56..ba4717c7 100644 --- a/42sh/src/completion/completion.c +++ b/42sh/src/completion/completion.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "completion.h" +#include "minishell.h" /* ** Function to select the next item in the list if it has already been created diff --git a/42sh/src/exec/ast_free.c b/42sh/src/exec/ast_free.c index 4975673e..e9577366 100644 --- a/42sh/src/exec/ast_free.c +++ b/42sh/src/exec/ast_free.c @@ -6,11 +6,11 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/05 11:50:51 by jhalford #+# #+# */ -/* Updated: 2017/03/05 18:05:43 by ariard ### ########.fr */ +/* Updated: 2017/03/07 18:34:27 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" void read_redir(void *data) { diff --git a/42sh/src/exec/error_badidentifier.c b/42sh/src/exec/error_badidentifier.c index 9883f60d..9238d892 100644 --- a/42sh/src/exec/error_badidentifier.c +++ b/42sh/src/exec/error_badidentifier.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int error_badidentifier(char *name) { diff --git a/42sh/src/exec/exec_ampersand.c b/42sh/src/exec/exec_ampersand.c index 4480fc2e..a95c357c 100644 --- a/42sh/src/exec/exec_ampersand.c +++ b/42sh/src/exec/exec_ampersand.c @@ -6,11 +6,11 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 16:01:30 by jhalford #+# #+# */ -/* Updated: 2017/03/03 19:35:21 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 18:24:12 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int exec_ampersand(t_btree **ast) { diff --git a/42sh/src/exec/exec_and_if.c b/42sh/src/exec/exec_and_if.c index 42ee38a7..b37c2fbc 100644 --- a/42sh/src/exec/exec_and_if.c +++ b/42sh/src/exec/exec_and_if.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int exec_and_if(t_btree **ast) { diff --git a/42sh/src/exec/exec_case.c b/42sh/src/exec/exec_case.c index ed982dac..6df7a837 100644 --- a/42sh/src/exec/exec_case.c +++ b/42sh/src/exec/exec_case.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int exec_case(t_btree **ast) { diff --git a/42sh/src/exec/exec_case_branch.c b/42sh/src/exec/exec_case_branch.c index 2d0db420..552f8c83 100644 --- a/42sh/src/exec/exec_case_branch.c +++ b/42sh/src/exec/exec_case_branch.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int exec_case_branch(t_btree **ast) { diff --git a/42sh/src/exec/exec_command.c b/42sh/src/exec/exec_command.c index e3179079..db331164 100644 --- a/42sh/src/exec/exec_command.c +++ b/42sh/src/exec/exec_command.c @@ -6,35 +6,12 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 17:28:14 by jhalford #+# #+# */ -/* Updated: 2017/03/07 15:09:45 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 17:33:50 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ -#include "exec.h" - -char **token_to_argv(t_ld *ld, int do_match) -{ - char **my_tab; - int index; - char **expand; - char **content; - - my_tab = NULL; - while (ld) - { - content = ld->content; - if ((expand = glob(content[0], (unsigned char *)content[1], (unsigned char *)content[2], do_match))) - { - index = -1; - while (expand[++index]) - my_tab = ft_sstradd(my_tab, expand[index]); - ft_tabdel(&expand); - } - ld = ld->next; - } - return (my_tab); -} - +#include "minishell.h" +/* int exec_cmd(t_btree **ast) { t_process p; @@ -58,4 +35,4 @@ int exec_cmd(t_btree **ast) if (p.fdout != STDOUT) close(p.fdout); return (0); -} +}*/ diff --git a/42sh/src/exec/exec_default.c b/42sh/src/exec/exec_default.c index 287cc995..796a10a7 100644 --- a/42sh/src/exec/exec_default.c +++ b/42sh/src/exec/exec_default.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int exec_default(t_btree **ast) { diff --git a/42sh/src/exec/exec_elif.c b/42sh/src/exec/exec_elif.c index 34ad5d9a..c4a5fa4a 100644 --- a/42sh/src/exec/exec_elif.c +++ b/42sh/src/exec/exec_elif.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int exec_elif(t_btree **ast) { diff --git a/42sh/src/exec/exec_for.c b/42sh/src/exec/exec_for.c index 632f5773..cd147533 100644 --- a/42sh/src/exec/exec_for.c +++ b/42sh/src/exec/exec_for.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int exec_for(t_btree **ast) { diff --git a/42sh/src/exec/exec_func.c b/42sh/src/exec/exec_func.c index a4a34f66..7255d850 100644 --- a/42sh/src/exec/exec_func.c +++ b/42sh/src/exec/exec_func.c @@ -10,6 +10,6 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" diff --git a/42sh/src/exec/exec_if.c b/42sh/src/exec/exec_if.c index c1a59aef..493f4237 100644 --- a/42sh/src/exec/exec_if.c +++ b/42sh/src/exec/exec_if.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int exec_if(t_btree **ast) { diff --git a/42sh/src/exec/exec_leaf.c b/42sh/src/exec/exec_leaf.c new file mode 100644 index 00000000..e237cb99 --- /dev/null +++ b/42sh/src/exec/exec_leaf.c @@ -0,0 +1,38 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* exec_leaf.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: wescande +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */ +/* Updated: 2017/03/07 17:34:51 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int exec_leaf(t_btree **ast) +{ + t_process p; + t_job *job; + + job = &data_singleton()->exec.job; + if (set_process(&p, *ast)) + return (1); + if (!(launch_process(&p))) + { + job_addprocess(&p); + if (IS_PIPEEND(p)) + { + if (JOB_IS_FG(job->attrs)) + put_job_in_foreground(job, 0); + else + put_job_in_background(job, 0); + } + job->pgid = 0; + } + if (p.fdout != STDOUT) + close(p.fdout); + return (0); +} diff --git a/42sh/src/exec/exec_math.c b/42sh/src/exec/exec_math.c index e157ef4c..7f9c994a 100644 --- a/42sh/src/exec/exec_math.c +++ b/42sh/src/exec/exec_math.c @@ -6,11 +6,11 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 10:58:49 by ariard #+# #+# */ -/* Updated: 2017/03/07 13:42:11 by ariard ### ########.fr */ +/* Updated: 2017/03/07 16:00:24 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" static int get_math(char *stream, char **var, char **value, char **operator) { @@ -45,7 +45,7 @@ static int do_math(char **value, char *operator) ope2 = ft_atoi(&operator[2]); else ope2 = 0; - if (operator[0] == '/' && ope2 == 0) + if ((operator[0] == '/' || operator[0] == '%') && ope2 == 0) ope1 = 0; else { diff --git a/42sh/src/exec/exec_or_if.c b/42sh/src/exec/exec_or_if.c index 5cc45a5e..50def42a 100644 --- a/42sh/src/exec/exec_or_if.c +++ b/42sh/src/exec/exec_or_if.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int exec_or_if(t_btree **ast) { diff --git a/42sh/src/exec/exec_pipe.c b/42sh/src/exec/exec_pipe.c index 63c280c0..3668da9e 100644 --- a/42sh/src/exec/exec_pipe.c +++ b/42sh/src/exec/exec_pipe.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int exec_pipe(t_btree **ast) { diff --git a/42sh/src/exec/exec_semi.c b/42sh/src/exec/exec_semi.c index c7848424..4a0d2699 100644 --- a/42sh/src/exec/exec_semi.c +++ b/42sh/src/exec/exec_semi.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int exec_semi(t_btree **ast) { diff --git a/42sh/src/exec/exec_until.c b/42sh/src/exec/exec_until.c index eb0ebff2..c8b4943a 100644 --- a/42sh/src/exec/exec_until.c +++ b/42sh/src/exec/exec_until.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int exec_until(t_btree **ast) { diff --git a/42sh/src/exec/exec_var.c b/42sh/src/exec/exec_var.c index b01c2f39..578422d2 100644 --- a/42sh/src/exec/exec_var.c +++ b/42sh/src/exec/exec_var.c @@ -6,11 +6,11 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 11:12:05 by ariard #+# #+# */ -/* Updated: 2017/03/07 14:40:30 by ariard ### ########.fr */ +/* Updated: 2017/03/07 18:37:38 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" static int set_var(char *stream, char **var, char **value) { diff --git a/42sh/src/exec/exec_while.c b/42sh/src/exec/exec_while.c index c10149e4..f04632e2 100644 --- a/42sh/src/exec/exec_while.c +++ b/42sh/src/exec/exec_while.c @@ -6,24 +6,52 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/30 17:33:53 by ariard #+# #+# */ -/* Updated: 2017/03/07 16:34:30 by ariard ### ########.fr */ +/* Updated: 2017/03/07 19:42:33 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int exec_while(t_btree **ast) { + int ret; DG("exec while condition"); ft_exec(&(*ast)->left); DG("ret :[%s]", ft_getenv(data_singleton()->env, "?")); - ++data_singleton()->exec.control_count; while (!(ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0"))) { DG("in the while"); ft_exec(&(*ast)->right); + ret = ft_atoi(ft_getenv(data_singleton()->env, "?")); ft_exec(&(*ast)->left); } - --data_singleton()->exec.control_count; + exit(ret); return (0); } + +static int do_while(t_process *p) +{ + int ret; + return (ret); +} + +int launch_while(t_process *p) +{ + pid_t pid; + + if (SH_IS_INTERACTIVE(data_singleton()->opts)) + { + pid = fork(); + if (pid == 0) + exit(do_while(p)); + else if (pid > 0) + { + p->pid = pid; + process_setgroup(p, pid); + return (0); + } + } + else + do_while(p); + return (1); +} diff --git a/42sh/src/exec/ft_exec.c b/42sh/src/exec/ft_exec.c index cc616e6c..de7451eb 100644 --- a/42sh/src/exec/ft_exec.c +++ b/42sh/src/exec/ft_exec.c @@ -6,11 +6,11 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */ -/* Updated: 2017/03/07 15:08:58 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 17:00:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" t_itof g_execmap[] = { @@ -20,18 +20,18 @@ t_itof g_execmap[] = {TK_AND_IF, &exec_and_if}, {TK_OR_IF, &exec_or_if}, {TK_PIPE, &exec_pipe}, - {TK_WHILE, &exec_while}, - {TK_IF, &exec_if}, + {TK_WHILE, &exec_leaf}, + {TK_IF, &exec_leaf}, {TK_ELIF, &exec_elif}, - {TK_ELSE, &exec_else}, - {TK_UNTIL, &exec_until}, - {TK_FOR, &exec_for}, - {TK_CASE, &exec_case}, + {TK_ELSE, &exec_leaf}, + {TK_UNTIL, &exec_leaf}, + {TK_FOR, &exec_leaf}, + {TK_CASE, &exec_leaf}, {TK_PAREN_OPEN, &exec_case_branch}, {TK_ASSIGNEMENT_WORD, &exec_var}, {MATH, &exec_math}, - /* {TK_SUBSHELL, &exec_}, */ - {CMD, &exec_cmd}, + /* {TK_SUBSHELL, &exec_leaf}, */ + {CMD, &exec_leaf}, {0, 0}, }; @@ -44,9 +44,9 @@ int ft_exec(t_btree **ast) if (!*ast) return (0); item = (*ast)->item; - while (g_execmap[i].type) + while (g_execmap[i].id) { - if (item->type == g_execmap[i].type) + if (item->type == g_execmap[i].id) return ((*g_execmap[i].f)(ast)); i++; } diff --git a/42sh/src/exec/launch_builtin.c b/42sh/src/exec/launch_builtin.c new file mode 100644 index 00000000..aed14ec5 --- /dev/null +++ b/42sh/src/exec/launch_builtin.c @@ -0,0 +1,40 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* launch_builtin.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/07 15:48:24 by jhalford #+# #+# */ +/* Updated: 2017/03/07 16:51:58 by wescande ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int launch_builtin(t_process *p) +{ + pid_t pid; + + if (IS_PIPESINGLE(*p)) + { + if (process_redirect(p)) + return (0); + set_exitstatus((*p->data.cmd.execf)(p->data.cmd.path, p->data.cmd.av, data_singleton()->env), 1); + return (0); + } + pid = fork(); + if (pid == 0) + { + process_setgroup(p, 0); + process_setsig(); + if (process_redirect(p)) + exit (1); + exit((*p->data.cmd.execf)(p->data.cmd.path, p->data.cmd.av, data_singleton()->env)); + } + else if (pid > 0) + return (pid); + else if (pid == -1) + ft_dprintf(2, "{red}%s: internal fork error{eoc}\n", SHELL_NAME); + return (0); +} diff --git a/42sh/src/exec/launch_file.c b/42sh/src/exec/launch_file.c index c482d419..149a9b54 100644 --- a/42sh/src/exec/launch_file.c +++ b/42sh/src/exec/launch_file.c @@ -6,54 +6,44 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */ -/* Updated: 2017/03/07 14:54:18 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 17:02:08 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ +#include "minishell.h" + int launch_file(t_process *p) { int pid; - if (p->attrs & PROCESS_BUILTIN && IS_PIPESINGLE(*p)) - { - if (process_redirect(p)) - return (1); - set_exitstatus((*p->execf)(p->path, p->av, data_singleton()->env), 1); - return (1); - } - p->attrs &= ~PROCESS_STATE_MASK; - p->attrs |= PROCESS_RUNNING; - if (p->attrs & (PROCESS_BINARY | PROCESS_SCRIPT) - && access(p->path, X_OK) == -1) - { - ft_dprintf(2, "{red}%s: permission denied: %s{eoc}\n", SHELL_NAME, p->av[0]); - set_exitstatus(126, 1); - return (1); - } pid = fork(); if (pid == 0) { - if (p->attrs & PROCESS_UNKNOWN) + if (!p->data.cmd.path) { - ft_dprintf(2, "{red}%s: command not found: %s{eoc}\n", SHELL_NAME, p->av[0]); + ft_dprintf(2, "{red}%s: command not found: %s{eoc}\n", SHELL_NAME, p->data.cmd.av[0]); exit(127); } + else if (S_ISDIR(p->data.cmd.stat.st_mode)) + { + ft_dprintf(2, "{red}%s: %s: Is a directory{eoc}\n", SHELL_NAME, p->data.cmd.av[0]); + exit(126); + } + else if (access(p->data.cmd.path, X_OK) == -1) + { + ft_dprintf(2, "{red}%s: permission denied: %s{eoc}\n", SHELL_NAME, p->data.cmd.av[0]); + exit(126); + } process_setgroup(p, 0); process_setsig(); if (process_redirect(p)) exit (1); - if (p->attrs & PROCESS_BUILTIN) - exit((*p->execf)(p->path, p->av, data_singleton()->env)); - (*p->execf)(p->path, p->av, data_singleton()->env); - ft_dprintf(2, "{red}%s: internal execve error on %s{eoc}\n", SHELL_NAME, p->av[0]); + (*p->data.cmd.execf)(p->data.cmd.path, p->data.cmd.av, data_singleton()->env); + ft_dprintf(2, "{red}%s: internal execve error on %s{eoc}\n", SHELL_NAME, p->data.cmd.av[0]); } else if (pid > 0) - { - p->pid = pid; - process_setgroup(p, pid); - return (0); - } + return (pid); else if (pid == -1) ft_dprintf(2, "{red}%s: internal fork error{eoc}\n", SHELL_NAME); - return (1); + return (0); } diff --git a/42sh/src/exec/launch_process.c b/42sh/src/exec/launch_process.c index ebf4c0eb..db41b562 100644 --- a/42sh/src/exec/launch_process.c +++ b/42sh/src/exec/launch_process.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */ -/* Updated: 2017/03/07 15:04:44 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 17:04:54 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,29 +15,37 @@ t_itof g_launchmap[] = { {PROCESS_FUNCTION, NULL}, - {PROCESS_BUILTIN, NULL}, + {PROCESS_BUILTIN, launch_builtin}, {PROCESS_FILE, launch_file}, {PROCESS_SUBSHELL, NULL}, {PROCESS_WHILE, NULL}, {PROCESS_IF, NULL}, {PROCESS_FOR, NULL}, {PROCESS_CASE, NULL}, + {0, NULL} }; int launch_process(t_process *p) { int i; + int pid; i = 0; - /* DG("gonna launch [%s]", p->av[0]); */ - /* DG("fdin=[%i]", p->fdin); */ - /* DG("fdout=[%i]", p->fdout); */ - while (g_launchmap[i].type) + while (g_launchmap[i].id) { - if (p->type == g_launchmap[i].type) + if (p->type == g_launchmap[i].id) + { if (!g_launchmap[i].f) return (-1); - return ((*g_launchmap[i].f)(p)); + p->attrs &= ~PROCESS_STATE_MASK; + p->attrs |= PROCESS_RUNNING; + if ((pid = (*g_launchmap[i].f)(p))) + { + p->pid = pid; + process_setgroup(p, pid); + return (0); + } + } i++; } return (-1); diff --git a/42sh/src/exec/mark_process_status.c b/42sh/src/exec/mark_process_status.c index eeca4a86..ecc3c9ea 100644 --- a/42sh/src/exec/mark_process_status.c +++ b/42sh/src/exec/mark_process_status.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" int mark_process_status(pid_t pid, int status) { diff --git a/42sh/src/exec/process_redirect.c b/42sh/src/exec/process_redirect.c index 2bb7f19d..3e9b2460 100644 --- a/42sh/src/exec/process_redirect.c +++ b/42sh/src/exec/process_redirect.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" t_redirmap g_redirmap[] = { diff --git a/42sh/src/exec/process_reset.c b/42sh/src/exec/process_reset.c index 7ab34d1d..3b5c065e 100644 --- a/42sh/src/exec/process_reset.c +++ b/42sh/src/exec/process_reset.c @@ -6,17 +6,17 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/07 17:44:22 by jhalford #+# #+# */ -/* Updated: 2017/03/06 12:29:17 by wescande ### ########.fr */ +/* Updated: 2017/03/07 14:36:21 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" void process_reset(t_process *p) { - p->av = NULL; - p->path = NULL; - p->execf = NULL; +// p->av = NULL; +// p->path = NULL; +// p->execf = NULL; p->pid = 0; /* p->fdin = STDIN; */ /* p->fdout = STDOUT; */ @@ -24,4 +24,6 @@ void process_reset(t_process *p) p->redirs = NULL; p->status = -1; p->attrs = 0; +// p->condition = NULL; +// p->content = NULL; } diff --git a/42sh/src/exec/process_setexec.c b/42sh/src/exec/process_setexec.c index 1114f927..2f4ba13a 100644 --- a/42sh/src/exec/process_setexec.c +++ b/42sh/src/exec/process_setexec.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 17:07:10 by jhalford #+# #+# */ -/* Updated: 2017/03/07 14:49:45 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 16:54:13 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,27 +14,27 @@ int process_setexec(t_process *p) { - p->path = NULL; + p->data.cmd.path = NULL; + p->data.cmd.execf = NULL; /* if ((p->execf = is_function(p))) */ /* p->type = PROCESS_FUNCTION; */ if ((p->data.cmd.execf = is_builtin(p))) p->type = PROCESS_BUILTIN; - else if (ft_hash(p)) + else if (ft_strchr(p->data.cmd.av[0], '/')) { - p->data.cmd.execf = &execve; p->type = PROCESS_FILE; - } - else if (ft_strchr(p->av[0], '/')) - { p->data.cmd.execf = &execve; - p->type = PROCESS_FILE; - p->data.cmd.path = ft_strdup(p->av[0]); + p->data.cmd.path = ft_strdup(p->data.cmd.av[0]); + stat(p->data.cmd.path, &p->data.cmd.stat); } else { - p->execf = NULL; - p->attrs |= PROCESS_UNKNOWN; - return (1); + p->type = PROCESS_FILE; + if (ft_hash(p)) + { + p->data.cmd.execf = &execve; + stat(p->data.cmd.path, &p->data.cmd.stat); + } } return (0); } diff --git a/42sh/src/exec/process_setgroup.c b/42sh/src/exec/process_setgroup.c index 8654d2f8..60caf7e9 100644 --- a/42sh/src/exec/process_setgroup.c +++ b/42sh/src/exec/process_setgroup.c @@ -10,8 +10,8 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" -#include "exec.h" +#include "minishell.h" +#include "minishell.h" int process_setgroup(t_process *p, pid_t pid) { diff --git a/42sh/src/exec/process_setsig.c b/42sh/src/exec/process_setsig.c index b2a68b09..821137ea 100644 --- a/42sh/src/exec/process_setsig.c +++ b/42sh/src/exec/process_setsig.c @@ -1,4 +1,4 @@ -#include "exec.h" +#include "minishell.h" void process_setsig(void) { diff --git a/42sh/src/exec/redir_free.c b/42sh/src/exec/redir_free.c index 5befbe63..fa19403f 100644 --- a/42sh/src/exec/redir_free.c +++ b/42sh/src/exec/redir_free.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" void redir_free(void *data, size_t content_size) { diff --git a/42sh/src/exec/redirect_dgreat.c b/42sh/src/exec/redirect_dgreat.c index f890172b..66fc6881 100644 --- a/42sh/src/exec/redirect_dgreat.c +++ b/42sh/src/exec/redirect_dgreat.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int redirect_dgreat(t_redir *redir) { diff --git a/42sh/src/exec/redirect_dless.c b/42sh/src/exec/redirect_dless.c index 0244098d..9a1a7873 100644 --- a/42sh/src/exec/redirect_dless.c +++ b/42sh/src/exec/redirect_dless.c @@ -9,7 +9,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int redirect_dless(t_redir *redir) { diff --git a/42sh/src/exec/redirect_great.c b/42sh/src/exec/redirect_great.c index fee82964..13810ae4 100644 --- a/42sh/src/exec/redirect_great.c +++ b/42sh/src/exec/redirect_great.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int redirect_great(t_redir* redir) { diff --git a/42sh/src/exec/redirect_greatand.c b/42sh/src/exec/redirect_greatand.c index 002375e8..d2bf02aa 100644 --- a/42sh/src/exec/redirect_greatand.c +++ b/42sh/src/exec/redirect_greatand.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int redirect_greatand(t_redir *redir) { diff --git a/42sh/src/exec/redirect_less.c b/42sh/src/exec/redirect_less.c index c8df2f62..2a1e6809 100644 --- a/42sh/src/exec/redirect_less.c +++ b/42sh/src/exec/redirect_less.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int redirect_less(t_redir *redir) { diff --git a/42sh/src/exec/redirect_lessand.c b/42sh/src/exec/redirect_lessand.c index bb9987d6..9c184b82 100644 --- a/42sh/src/exec/redirect_lessand.c +++ b/42sh/src/exec/redirect_lessand.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int redirect_lessand(t_redir *redir) { diff --git a/42sh/src/exec/set_process.c b/42sh/src/exec/set_process.c index a8e9c708..9e9f1764 100644 --- a/42sh/src/exec/set_process.c +++ b/42sh/src/exec/set_process.c @@ -6,11 +6,11 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */ -/* Updated: 2017/03/07 15:09:36 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 15:34:31 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ -#include "exec.h" +#include "minishell.h" int set_process(t_process *p, t_btree *ast) { @@ -28,8 +28,6 @@ int set_process(t_process *p, t_btree *ast) || (EXEC_IS_OR_IF(exec->attrs) && ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0") == 0)) return (1); - if (!(p->av = token_to_argv(cmd->token, 1))) - return (1); fds[PIPE_WRITE] = STDOUT; fds[PIPE_READ] = STDIN; if (op == TK_AMP) @@ -41,14 +39,8 @@ int set_process(t_process *p, t_btree *ast) p->fdout = fds[PIPE_WRITE]; exec->fdin = fds[PIPE_READ]; p->redirs = ft_lstmap(cmd->redir, ft_id); - t_list *tmp = p->redirs; - while (tmp) - { - t_redir *toto = tmp->content; - printf("IIIIIIIIIIIIIIIIIIIIIII%lld |%d| {%s}\n", toto->type, toto->n, toto->word); - tmp= tmp->next; - } - process_setexec(p); + if (set_process_map(p, ast, cmd)) + return (1); if (exec->control_count) p->attrs |= PROCESS_CONTROL; return (0); diff --git a/42sh/src/exec/set_process_cmd.c b/42sh/src/exec/set_process_cmd.c new file mode 100644 index 00000000..022e0305 --- /dev/null +++ b/42sh/src/exec/set_process_cmd.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* set_process_cmd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: wescande +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/07 15:06:05 by wescande #+# #+# */ +/* Updated: 2017/03/07 15:50:51 by wescande ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int set_process_cmd(t_process *p, t_btree *ast, t_cmd *cmd) +{ + if (!(p->data.cmd.av = token_to_argv(cmd->token, 1))) + return (1); + process_setexec(p); + return (0); +} diff --git a/42sh/src/exec/set_process_map.c b/42sh/src/exec/set_process_map.c new file mode 100644 index 00000000..004bb01a --- /dev/null +++ b/42sh/src/exec/set_process_map.c @@ -0,0 +1,52 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* set_process_map.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: wescande +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/07 15:08:12 by wescande #+# #+# */ +/* Updated: 2017/03/07 15:50:56 by wescande ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +t_itof g_setprocessmap[] = +{ + {TK_NEWLINE, NULL}, + {TK_SEMI, NULL}, + {TK_AMP, NULL}, + {TK_AND_IF, NULL}, + {TK_OR_IF,NULL}, + {TK_PIPE, NULL}, + {TK_WHILE, NULL}, + {TK_IF, NULL}, + {TK_ELIF, NULL}, + {TK_ELSE, NULL}, + {TK_UNTIL, NULL}, + {TK_FOR, NULL}, + {TK_CASE, NULL}, + {TK_PAREN_OPEN, NULL}, + {TK_ASSIGNEMENT_WORD, NULL}, + {MATH, NULL}, + /* {TK_SUBSHELL, &exec_}, */ + {CMD, &set_process_cmd}, + {0, NULL} +}; + +int set_process_map(t_process *p, t_btree *ast, t_cmd *cmd) +{ + int i; + + i = 0; + if (!ast) + return (0); + while (g_setprocessmap[i].id) + { + if (p->type == g_setprocessmap[i].id) + return ((*g_setprocessmap[i].f)(p, ast, cmd)); + i++; + } + return (0); +} diff --git a/42sh/src/exec/token_to_argv.c b/42sh/src/exec/token_to_argv.c new file mode 100644 index 00000000..10b2c192 --- /dev/null +++ b/42sh/src/exec/token_to_argv.c @@ -0,0 +1,38 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* token_to_argv.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: wescande +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/07 15:55:53 by wescande #+# #+# */ +/* Updated: 2017/03/07 15:56:25 by wescande ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +char **token_to_argv(t_ld *ld, int do_match) +{ + char **my_tab; + int index; + char **expand; + char **content; + + my_tab = NULL; + while (ld) + { + content = ld->content; + if ((expand = glob(content[0], + (unsigned char *)content[1], + (unsigned char *)content[2], do_match))) + { + index = -1; + while (expand[++index]) + my_tab = ft_sstradd(my_tab, expand[index]); + ft_tabdel(&expand); + } + ld = ld->next; + } + return (my_tab); +} diff --git a/42sh/src/glob/dir_glob.c b/42sh/src/glob/dir_glob.c index f4be218d..2e9f3281 100644 --- a/42sh/src/glob/dir_glob.c +++ b/42sh/src/glob/dir_glob.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "glob.h" +#include "minishell.h" int is_directory(const char *path) { diff --git a/42sh/src/glob/esc_print.c b/42sh/src/glob/esc_print.c index 44de1fb5..504e95bd 100644 --- a/42sh/src/glob/esc_print.c +++ b/42sh/src/glob/esc_print.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "glob.h" +#include "minishell.h" void esc_print(char *str, unsigned char *esc) { diff --git a/42sh/src/glob/expand_bquote.c b/42sh/src/glob/expand_bquote.c index 7c7c0667..d09f7c17 100644 --- a/42sh/src/glob/expand_bquote.c +++ b/42sh/src/glob/expand_bquote.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "glob.h" +#include "minishell.h" static void expand_all_bquote(t_bquote *me, char *content, char *ifs) diff --git a/42sh/src/glob/expand_brace.c b/42sh/src/glob/expand_brace.c index c0055817..1a77bf28 100644 --- a/42sh/src/glob/expand_brace.c +++ b/42sh/src/glob/expand_brace.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "glob.h" +#include "minishell.h" /* ** expand_brace return expansion of a string. diff --git a/42sh/src/glob/expand_esc.c b/42sh/src/glob/expand_esc.c index f66bf422..d5b8104e 100644 --- a/42sh/src/glob/expand_esc.c +++ b/42sh/src/glob/expand_esc.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "glob.h" +#include "minishell.h" unsigned char *calc_expand_esc(const unsigned char *esc, int nb_start, int *nb_middle, int *nb_end) diff --git a/42sh/src/glob/expand_home.c b/42sh/src/glob/expand_home.c index 79c56448..d9c325a7 100644 --- a/42sh/src/glob/expand_home.c +++ b/42sh/src/glob/expand_home.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "glob.h" +#include "minishell.h" void do_expand_home(t_bquote *me, char *home) { diff --git a/42sh/src/glob/expand_var.c b/42sh/src/glob/expand_var.c index ed163a76..1de56e57 100644 --- a/42sh/src/glob/expand_var.c +++ b/42sh/src/glob/expand_var.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "glob.h" +#include "minishell.h" /* ** expand_var return value of $var in the string. diff --git a/42sh/src/glob/ft_strsplit_esc.c b/42sh/src/glob/ft_strsplit_esc.c index 6e050cb7..897b4eb3 100644 --- a/42sh/src/glob/ft_strsplit_esc.c +++ b/42sh/src/glob/ft_strsplit_esc.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "glob.h" +#include "minishell.h" static int ft_strlen_c(const char *str, const char *fix, const unsigned char *esc, char c) diff --git a/42sh/src/glob/ft_strsplit_spe.c b/42sh/src/glob/ft_strsplit_spe.c index 3d69627c..cc65dcf2 100644 --- a/42sh/src/glob/ft_strsplit_spe.c +++ b/42sh/src/glob/ft_strsplit_spe.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "glob.h" +#include "minishell.h" static int ft_strlen_c(const char *str, const char *fix, const unsigned char *esc, char c) diff --git a/42sh/src/glob/glob.c b/42sh/src/glob/glob.c index 91b58a4a..b44b5c89 100644 --- a/42sh/src/glob/glob.c +++ b/42sh/src/glob/glob.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "glob.h" +#include "minishell.h" /* ** glob return expansion of a string. diff --git a/42sh/src/glob/is_char_esc.c b/42sh/src/glob/is_char_esc.c index 13061165..0f83bff6 100644 --- a/42sh/src/glob/is_char_esc.c +++ b/42sh/src/glob/is_char_esc.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "glob.h" +#include "minishell.h" int is_char_esc(const unsigned char *esc, const char *ini_str, const char *str_pos) diff --git a/42sh/src/glob/match_pattern.c b/42sh/src/glob/match_pattern.c index d98fd7e2..f3573fe5 100644 --- a/42sh/src/glob/match_pattern.c +++ b/42sh/src/glob/match_pattern.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "glob.h" +#include "minishell.h" static int match_bracket_char(char **cmp, const char *pat, char c, int neg) { diff --git a/42sh/src/hash_table/ft_add_hash.c b/42sh/src/hash_table/ft_add_hash.c index 403ee64d..5e2d95d3 100644 --- a/42sh/src/hash_table/ft_add_hash.c +++ b/42sh/src/hash_table/ft_add_hash.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/18 11:20:11 by gwojda #+# #+# */ -/* Updated: 2017/03/07 14:43:33 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 16:56:04 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,10 +18,10 @@ int ft_add_hash(t_process *p) t_hash hash; if (!(hash.path = ft_findexec( - ft_getenv(data_singleton()->env, "PATH"), p->av[0]))) + ft_getenv(data_singleton()->env, "PATH"), p->data.cmd.av[0]))) return (0); - hash.key = ft_strdup(p->av[0]); - id = ft_hash_str(p->av[0]); + hash.key = ft_strdup(p->data.cmd.av[0]); + id = ft_hash_str(p->data.cmd.av[0]); ft_lsteadd(&(g_hash[id]), ft_lstnew(&hash, sizeof(t_hash))); p->data.cmd.path = ft_strdup(hash.path); return (1); diff --git a/42sh/src/hash_table/hash.c b/42sh/src/hash_table/hash.c index b7022ec5..2276a4e1 100644 --- a/42sh/src/hash_table/hash.c +++ b/42sh/src/hash_table/hash.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/18 11:06:19 by gwojda #+# #+# */ -/* Updated: 2017/03/04 18:50:56 by ariard ### ########.fr */ +/* Updated: 2017/03/07 16:02:41 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/hash_table/is_hash.c b/42sh/src/hash_table/is_hash.c index 03fdf717..385401e3 100644 --- a/42sh/src/hash_table/is_hash.c +++ b/42sh/src/hash_table/is_hash.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/18 11:08:40 by gwojda #+# #+# */ -/* Updated: 2017/02/18 16:42:12 by gwojda ### ########.fr */ +/* Updated: 2017/03/07 14:45:20 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,12 +18,12 @@ int ft_is_hash(t_process *p) t_list *ref; int id; - id = ft_hash_str(p->av[0]); + id = ft_hash_str(p->data.cmd.av[0]); list = g_hash[id]; ref = list; while (list) { - if (!ft_strcmp(((t_hash *)list->content)->key, p->av[0])) + if (!ft_strcmp(((t_hash *)list->content)->key, p->data.cmd.av[0])) { if (access(((t_hash *)list->content)->path, X_OK)) { @@ -31,7 +31,7 @@ int ft_is_hash(t_process *p) ft_lstdelone(&list, &ft_hash_free); return (0); } - p->path = ft_strdup(((t_hash *)list->content)->path); + p->data.cmd.path = ft_strdup(((t_hash *)list->content)->path); return (1); } ref = list; diff --git a/42sh/src/job-control/builtin_bg.c b/42sh/src/job-control/builtin_bg.c index f58a1d1e..99eb37fc 100644 --- a/42sh/src/job-control/builtin_bg.c +++ b/42sh/src/job-control/builtin_bg.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" int builtin_bg(const char *path, char *const av[], char *const envp[]) { diff --git a/42sh/src/job-control/builtin_fg.c b/42sh/src/job-control/builtin_fg.c index 50d9cb69..9e7720f6 100644 --- a/42sh/src/job-control/builtin_fg.c +++ b/42sh/src/job-control/builtin_fg.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" int builtin_fg(const char *path, char *const av[], char *const envp[]) { diff --git a/42sh/src/job-control/builtin_jobs.c b/42sh/src/job-control/builtin_jobs.c index f2a83ee0..70395bf6 100644 --- a/42sh/src/job-control/builtin_jobs.c +++ b/42sh/src/job-control/builtin_jobs.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" static int bt_jobs_parse(char **av, int *i) { diff --git a/42sh/src/job-control/do_job_notification.c b/42sh/src/job-control/do_job_notification.c index 0e2aeef6..48829692 100644 --- a/42sh/src/job-control/do_job_notification.c +++ b/42sh/src/job-control/do_job_notification.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" int do_job_notification(void) { diff --git a/42sh/src/job-control/job_addprocess.c b/42sh/src/job-control/job_addprocess.c index 8afe2cee..42c5229e 100644 --- a/42sh/src/job-control/job_addprocess.c +++ b/42sh/src/job-control/job_addprocess.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" int job_addprocess(t_process *p) { diff --git a/42sh/src/job-control/job_format.c b/42sh/src/job-control/job_format.c index 5c811a86..dde4e0fb 100644 --- a/42sh/src/job-control/job_format.c +++ b/42sh/src/job-control/job_format.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" void job_format(t_job *j, int opts) { diff --git a/42sh/src/job-control/job_format_head.c b/42sh/src/job-control/job_format_head.c index c7b8854f..f874933e 100644 --- a/42sh/src/job-control/job_format_head.c +++ b/42sh/src/job-control/job_format_head.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" void job_format_head(t_job *j) { diff --git a/42sh/src/job-control/job_free.c b/42sh/src/job-control/job_free.c index db63e7f2..7046cfe7 100644 --- a/42sh/src/job-control/job_free.c +++ b/42sh/src/job-control/job_free.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" void job_free(void *content, size_t content_size) { diff --git a/42sh/src/job-control/job_getprocess.c b/42sh/src/job-control/job_getprocess.c index 3ad82217..17eec5d2 100644 --- a/42sh/src/job-control/job_getprocess.c +++ b/42sh/src/job-control/job_getprocess.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" t_list *job_getprocess(pid_t pid) { diff --git a/42sh/src/job-control/job_getrank.c b/42sh/src/job-control/job_getrank.c index f07263e0..6da80d6b 100644 --- a/42sh/src/job-control/job_getrank.c +++ b/42sh/src/job-control/job_getrank.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" void job_getrank(int (*rank)[2]) { diff --git a/42sh/src/job-control/job_is_completed.c b/42sh/src/job-control/job_is_completed.c index 9742515a..c289614f 100644 --- a/42sh/src/job-control/job_is_completed.c +++ b/42sh/src/job-control/job_is_completed.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" int job_is_completed(int id) { diff --git a/42sh/src/job-control/job_is_stopped.c b/42sh/src/job-control/job_is_stopped.c index b7c20a91..60eed462 100644 --- a/42sh/src/job-control/job_is_stopped.c +++ b/42sh/src/job-control/job_is_stopped.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" int job_is_stopped(int id) { diff --git a/42sh/src/job-control/job_kill_all.c b/42sh/src/job-control/job_kill_all.c index 1d36a8a6..ded01abd 100644 --- a/42sh/src/job-control/job_kill_all.c +++ b/42sh/src/job-control/job_kill_all.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" void job_kill_all(void) { diff --git a/42sh/src/job-control/job_notify_change.c b/42sh/src/job-control/job_notify_change.c index fd6c7728..3ec46e79 100644 --- a/42sh/src/job-control/job_notify_change.c +++ b/42sh/src/job-control/job_notify_change.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" void job_notify_change(int id) { diff --git a/42sh/src/job-control/job_notify_new.c b/42sh/src/job-control/job_notify_new.c index 1b39f0ea..d19feb96 100644 --- a/42sh/src/job-control/job_notify_new.c +++ b/42sh/src/job-control/job_notify_new.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" void job_notify_new(t_job *job) { diff --git a/42sh/src/job-control/job_remove.c b/42sh/src/job-control/job_remove.c index 2ffe9c8a..794a6c44 100644 --- a/42sh/src/job-control/job_remove.c +++ b/42sh/src/job-control/job_remove.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" void job_remove(int id) { diff --git a/42sh/src/job-control/job_run.c b/42sh/src/job-control/job_run.c index bd9d0f48..412af6df 100644 --- a/42sh/src/job-control/job_run.c +++ b/42sh/src/job-control/job_run.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" void job_run(t_job *job, int foreground) { diff --git a/42sh/src/job-control/job_update_status.c b/42sh/src/job-control/job_update_status.c index 5e314792..cae2b934 100644 --- a/42sh/src/job-control/job_update_status.c +++ b/42sh/src/job-control/job_update_status.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" void job_update_status(void) { diff --git a/42sh/src/job-control/job_wait.c b/42sh/src/job-control/job_wait.c index 38f18f8f..966b5f3c 100644 --- a/42sh/src/job-control/job_wait.c +++ b/42sh/src/job-control/job_wait.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" int job_wait(int id) { diff --git a/42sh/src/job-control/mark_job_as_running.c b/42sh/src/job-control/mark_job_as_running.c index 3d5f3cfb..ae34335f 100644 --- a/42sh/src/job-control/mark_job_as_running.c +++ b/42sh/src/job-control/mark_job_as_running.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" void mark_job_as_running(t_job *j) { diff --git a/42sh/src/job-control/process_format.c b/42sh/src/job-control/process_format.c index 9e0f9d62..8954b13d 100644 --- a/42sh/src/job-control/process_format.c +++ b/42sh/src/job-control/process_format.c @@ -6,11 +6,11 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/09 13:05:55 by jhalford #+# #+# */ -/* Updated: 2017/03/06 12:32:05 by wescande ### ########.fr */ +/* Updated: 2017/03/07 14:46:12 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" static void process_format_state(t_process *p) { @@ -47,11 +47,11 @@ static void process_format_com_long(t_list **plist) else if (p->attrs & PROCESS_SUBSHELL) { ft_putstr("( "); - ft_putstr(p->av[2]); +// ft_putstr(p->data.cmd.av[2]); ft_putstr(" )"); } else - ft_sstrprint(p->av, ' '); + ft_sstrprint(p->data.cmd.av, ' '); if ((*plist)->next) ft_putstr(" |"); (*plist) = (*plist)->next; @@ -77,11 +77,11 @@ static void process_format_com_short(t_list **plist, t_flag state) else if (p->attrs & PROCESS_SUBSHELL) { ft_putstr("( "); - ft_putstr(p->av[2]); + ft_putstr(p->data.cmd.av[2]); ft_putstr(" )"); } else - ft_sstrprint(p->av, ' '); + ft_sstrprint(p->data.cmd.av, ' '); if ((*plist)->next) ft_putstr(" | "); (*plist) = (*plist)->next; diff --git a/42sh/src/job-control/process_free.c b/42sh/src/job-control/process_free.c index ea62d4bf..f4e0047c 100644 --- a/42sh/src/job-control/process_free.c +++ b/42sh/src/job-control/process_free.c @@ -6,11 +6,11 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */ -/* Updated: 2017/03/05 16:00:27 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 14:46:41 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" void process_free(void *content, size_t content_size) { @@ -18,8 +18,8 @@ void process_free(void *content, size_t content_size) (void)content_size; p = content; - ft_strdel(&p->path); - ft_sstrfree(p->av); - /* ft_lstdel(&p->redirs, ft_lst_cfree); */ + ft_strdel(&p->data.cmd.path); + ft_sstrfree(p->data.cmd.av); + ft_lstdel(&p->redirs, ft_lst_cfree); free(p); } diff --git a/42sh/src/job-control/put_job_in_background.c b/42sh/src/job-control/put_job_in_background.c index 895b58a9..8498bea7 100644 --- a/42sh/src/job-control/put_job_in_background.c +++ b/42sh/src/job-control/put_job_in_background.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" int put_job_in_background(t_job *j, int cont) { diff --git a/42sh/src/job-control/put_job_in_foreground.c b/42sh/src/job-control/put_job_in_foreground.c index c5b75d0b..67570957 100644 --- a/42sh/src/job-control/put_job_in_foreground.c +++ b/42sh/src/job-control/put_job_in_foreground.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "job_control.h" +#include "minishell.h" int put_job_in_foreground(t_job *j, int cont) { diff --git a/42sh/src/lexer/get_lexer_stack.c b/42sh/src/lexer/get_lexer_stack.c index 55fdbe9c..b37ec859 100644 --- a/42sh/src/lexer/get_lexer_stack.c +++ b/42sh/src/lexer/get_lexer_stack.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int get_lexer_stack(t_lexer lexer) { diff --git a/42sh/src/lexer/get_reserved_words.c b/42sh/src/lexer/get_reserved_words.c index 4d14e54d..e1c525ff 100644 --- a/42sh/src/lexer/get_reserved_words.c +++ b/42sh/src/lexer/get_reserved_words.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" t_rvwords g_rvwords[] = diff --git a/42sh/src/lexer/get_state_global.c b/42sh/src/lexer/get_state_global.c index 79793c70..5fd8532e 100644 --- a/42sh/src/lexer/get_state_global.c +++ b/42sh/src/lexer/get_state_global.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" t_lexstate get_state_global(t_lexer *lexer) { diff --git a/42sh/src/lexer/get_state_redir.c b/42sh/src/lexer/get_state_redir.c index 6ea22d94..d4d60d3b 100644 --- a/42sh/src/lexer/get_state_redir.c +++ b/42sh/src/lexer/get_state_redir.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" t_lexstate get_state_redir(t_lexer *lexer) { diff --git a/42sh/src/lexer/insert_newline.c b/42sh/src/lexer/insert_newline.c index 6d39ec5d..7a24a0ca 100644 --- a/42sh/src/lexer/insert_newline.c +++ b/42sh/src/lexer/insert_newline.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" int insert_newline(t_list **alst) { diff --git a/42sh/src/lexer/lexer_assignement_word.c b/42sh/src/lexer/lexer_assignement_word.c index a6bae9dd..2f802e33 100644 --- a/42sh/src/lexer/lexer_assignement_word.c +++ b/42sh/src/lexer/lexer_assignement_word.c @@ -6,11 +6,11 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/24 20:28:13 by ariard #+# #+# */ -/* Updated: 2017/03/02 19:11:25 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 18:36:23 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_assignement_word(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_backslash.c b/42sh/src/lexer/lexer_backslash.c index abd2a95c..3418e2a2 100644 --- a/42sh/src/lexer/lexer_backslash.c +++ b/42sh/src/lexer/lexer_backslash.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_backslash(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_bquote.c b/42sh/src/lexer/lexer_bquote.c index b4360556..2e7cb813 100644 --- a/42sh/src/lexer/lexer_bquote.c +++ b/42sh/src/lexer/lexer_bquote.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_bquote(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_curly_braces.c b/42sh/src/lexer/lexer_curly_braces.c index 1674027a..d6eee381 100644 --- a/42sh/src/lexer/lexer_curly_braces.c +++ b/42sh/src/lexer/lexer_curly_braces.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" int lexer_curly_braces(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_default.c b/42sh/src/lexer/lexer_default.c index 0fff3b18..a2802c5c 100644 --- a/42sh/src/lexer/lexer_default.c +++ b/42sh/src/lexer/lexer_default.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_default(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_delim.c b/42sh/src/lexer/lexer_delim.c index 648aa8a0..d67b61d5 100644 --- a/42sh/src/lexer/lexer_delim.c +++ b/42sh/src/lexer/lexer_delim.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_delim(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_dless.c b/42sh/src/lexer/lexer_dless.c index f0e0ee4d..d3859b87 100644 --- a/42sh/src/lexer/lexer_dless.c +++ b/42sh/src/lexer/lexer_dless.c @@ -1,4 +1,4 @@ -#include "lexer.h" +#include "minishell.h" int lexer_dless(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_dquote.c b/42sh/src/lexer/lexer_dquote.c index b158a14d..10455689 100644 --- a/42sh/src/lexer/lexer_dquote.c +++ b/42sh/src/lexer/lexer_dquote.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_dquote(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_end.c b/42sh/src/lexer/lexer_end.c index dcc162c8..4e3be646 100644 --- a/42sh/src/lexer/lexer_end.c +++ b/42sh/src/lexer/lexer_end.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_end(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_great.c b/42sh/src/lexer/lexer_great.c index 7e43e814..6e582bdc 100644 --- a/42sh/src/lexer/lexer_great.c +++ b/42sh/src/lexer/lexer_great.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_great(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_greatand.c b/42sh/src/lexer/lexer_greatand.c index 4f802455..83d96d8b 100644 --- a/42sh/src/lexer/lexer_greatand.c +++ b/42sh/src/lexer/lexer_greatand.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_greatand(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_init.c b/42sh/src/lexer/lexer_init.c index 799a52db..a7000895 100644 --- a/42sh/src/lexer/lexer_init.c +++ b/42sh/src/lexer/lexer_init.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" void lexer_init(t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_less.c b/42sh/src/lexer/lexer_less.c index 92d6bf45..9d08611c 100644 --- a/42sh/src/lexer/lexer_less.c +++ b/42sh/src/lexer/lexer_less.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_less(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_lessand.c b/42sh/src/lexer/lexer_lessand.c index 1e5cfb20..f7d30d45 100644 --- a/42sh/src/lexer/lexer_lessand.c +++ b/42sh/src/lexer/lexer_lessand.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_lessand(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_lex.c b/42sh/src/lexer/lexer_lex.c index 8dadd9e3..9ec90b49 100644 --- a/42sh/src/lexer/lexer_lex.c +++ b/42sh/src/lexer/lexer_lex.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int (*g_lexer[])(t_list **alst, t_lexer *lexer) = { diff --git a/42sh/src/lexer/lexer_newline.c b/42sh/src/lexer/lexer_newline.c index 31b45b4b..b2256091 100644 --- a/42sh/src/lexer/lexer_newline.c +++ b/42sh/src/lexer/lexer_newline.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_newline(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_number.c b/42sh/src/lexer/lexer_number.c index b7eb03b4..f986fb12 100644 --- a/42sh/src/lexer/lexer_number.c +++ b/42sh/src/lexer/lexer_number.c @@ -6,11 +6,11 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 12:06:45 by jhalford #+# #+# */ -/* Updated: 2017/03/05 18:03:34 by ariard ### ########.fr */ +/* Updated: 2017/03/07 13:55:25 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_number(t_list **alst, t_lexer *lexer) { @@ -28,6 +28,7 @@ int lexer_number(t_list **alst, t_lexer *lexer) else if (ft_isdigit(lexer->str[lexer->pos]) && ft_isdigit(lexer->str[lexer->pos + 1])) { + DG(); token_append(token, lexer, 0, 0); lexer->pos++; return (lexer_number(alst, lexer)); @@ -36,13 +37,16 @@ int lexer_number(t_list **alst, t_lexer *lexer) && (lexer->str[lexer->pos + 1] == '>' || lexer->str[lexer->pos + 1] == '<')) { + DG(); token_append(token, lexer, 0, 0); lexer->pos++; return (lexer_lex(&(*alst)->next, lexer)); } else { + DG(); token->type = TK_WORD; + lexer->state = DEFAULT; token_append(token, lexer, 0, 0); lexer->pos++; return (lexer_lex(alst, lexer)); diff --git a/42sh/src/lexer/lexer_paren.c b/42sh/src/lexer/lexer_paren.c index db8b0545..735e56fe 100644 --- a/42sh/src/lexer/lexer_paren.c +++ b/42sh/src/lexer/lexer_paren.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_paren(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_quote.c b/42sh/src/lexer/lexer_quote.c index 9b1afbd1..67cbc4c7 100644 --- a/42sh/src/lexer/lexer_quote.c +++ b/42sh/src/lexer/lexer_quote.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_quote(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_sep.c b/42sh/src/lexer/lexer_sep.c index b5eb571c..c159a930 100644 --- a/42sh/src/lexer/lexer_sep.c +++ b/42sh/src/lexer/lexer_sep.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int lexer_sep(t_list **alst, t_lexer *lexer) { diff --git a/42sh/src/lexer/lexer_word.c b/42sh/src/lexer/lexer_word.c index d10c9e48..48a69ef4 100644 --- a/42sh/src/lexer/lexer_word.c +++ b/42sh/src/lexer/lexer_word.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" static int word_is_assignment(t_token *token) { diff --git a/42sh/src/lexer/token_append.c b/42sh/src/lexer/token_append.c index 75de9fb1..45a45b97 100644 --- a/42sh/src/lexer/token_append.c +++ b/42sh/src/lexer/token_append.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int token_append_char(t_token *token, char c, short int esc, short int esc2) diff --git a/42sh/src/lexer/token_cmp_type.c b/42sh/src/lexer/token_cmp_type.c index 23ad5562..4185bc7b 100644 --- a/42sh/src/lexer/token_cmp_type.c +++ b/42sh/src/lexer/token_cmp_type.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" int token_cmp_type(t_token *token, t_type *ref) { diff --git a/42sh/src/lexer/token_free.c b/42sh/src/lexer/token_free.c index d88b0e1b..0727f7a5 100644 --- a/42sh/src/lexer/token_free.c +++ b/42sh/src/lexer/token_free.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" void token_free(void *data, size_t size) { diff --git a/42sh/src/lexer/token_init.c b/42sh/src/lexer/token_init.c index dcf4a219..4739d61b 100644 --- a/42sh/src/lexer/token_init.c +++ b/42sh/src/lexer/token_init.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" t_token *token_init(void) { diff --git a/42sh/src/lexer/token_print.c b/42sh/src/lexer/token_print.c index 4f71879f..c4529027 100644 --- a/42sh/src/lexer/token_print.c +++ b/42sh/src/lexer/token_print.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "lexer.h" +#include "minishell.h" void token_print(t_list *lst) { diff --git a/42sh/src/main/data_init.c b/42sh/src/main/data_init.c index 78d413f7..ce7e2a03 100644 --- a/42sh/src/main/data_init.c +++ b/42sh/src/main/data_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ -/* Updated: 2017/03/03 19:45:05 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 16:38:43 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,14 +23,6 @@ int data_init(void) data->env = ft_sstrdup(environ); data->comp = NULL; data->opts = 0; - /* data->exec.process.path = NULL; */ - /* data->exec.process.av = NULL; */ - /* data->exec.process.to_close = 0; */ - /* data->exec.process.fdin = STDIN; */ - /* data->exec.process.fdout = STDOUT; */ - /* data->exec.process.pid = 0; */ - /* data->exec.process.attributes = 0; */ - /* data->exec.process.redirs = NULL; */ data->exec.fd_save[0] = fcntl(0, F_DUPFD_CLOEXEC); data->exec.fd_save[1] = fcntl(1, F_DUPFD_CLOEXEC); data->exec.fd_save[2] = fcntl(2, F_DUPFD_CLOEXEC); @@ -38,12 +30,10 @@ int data_init(void) data->exec.fdin = STDIN; data->exec.attrs = 0; - /* data->exec.aol_status = NULL; */ - /* data->exec.aol_search = 0; */ - /* data->exec.job.id = 0; */ - /* data->exec.job.pgid = 0; */ - /* data->exec.job.attributes = 0; */ - /* data->exec.job.first_process = 0; */ + data->exec.job.id = 0; + data->exec.job.pgid = 0; + data->exec.job.attrs = 0; + data->exec.job.first_process = NULL; data->jobc.first_job = NULL; data->jobc.current_id = 1; diff --git a/42sh/src/main/instruction_free.c b/42sh/src/main/instruction_free.c index 5f27155a..69a80006 100644 --- a/42sh/src/main/instruction_free.c +++ b/42sh/src/main/instruction_free.c @@ -1,4 +1,4 @@ -#include "parser.h" +#include "minishell.h" int instruction_free(t_list **token, t_parser *parser, t_btree **ast) { diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index d95cd569..ad862a61 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2017/03/07 15:53:42 by ariard ### ########.fr */ +/* Updated: 2017/03/07 16:41:02 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index 272440d7..abf15a8e 100644 --- a/42sh/src/main/shell_init.c +++ b/42sh/src/main/shell_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */ -/* Updated: 2017/03/03 19:45:52 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 16:38:13 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/parser/add_case.c b/42sh/src/parser/add_case.c index 582a966d..04a3cdea 100644 --- a/42sh/src/parser/add_case.c +++ b/42sh/src/parser/add_case.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" int iscase(t_btree **ast, t_list **lst) { diff --git a/42sh/src/parser/add_cmd.c b/42sh/src/parser/add_cmd.c index 0518acf6..87165860 100644 --- a/42sh/src/parser/add_cmd.c +++ b/42sh/src/parser/add_cmd.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" t_distrostree g_distrostree[] = { diff --git a/42sh/src/parser/add_condition.c b/42sh/src/parser/add_condition.c index bc62c84f..902606c5 100644 --- a/42sh/src/parser/add_condition.c +++ b/42sh/src/parser/add_condition.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" int iscondition(t_btree **ast, t_list **lst) { diff --git a/42sh/src/parser/add_func.c b/42sh/src/parser/add_func.c index cc481f37..736e7e22 100644 --- a/42sh/src/parser/add_func.c +++ b/42sh/src/parser/add_func.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" int isfunc_name(t_btree **ast, t_list **lst) { diff --git a/42sh/src/parser/add_loop.c b/42sh/src/parser/add_loop.c index 427b0741..b393ebef 100644 --- a/42sh/src/parser/add_loop.c +++ b/42sh/src/parser/add_loop.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" int isloop(t_btree **ast, t_list **lst) { diff --git a/42sh/src/parser/add_math.c b/42sh/src/parser/add_math.c index 78a3f414..a309a957 100644 --- a/42sh/src/parser/add_math.c +++ b/42sh/src/parser/add_math.c @@ -1,4 +1,4 @@ -#include "parser.h" +#include "minishell.h" int ismath(t_btree **ast, t_list **lst) { diff --git a/42sh/src/parser/add_number.c b/42sh/src/parser/add_number.c index 7ed5d7de..67873692 100644 --- a/42sh/src/parser/add_number.c +++ b/42sh/src/parser/add_number.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" int isionumber(t_btree **ast, t_list **lst) { diff --git a/42sh/src/parser/add_redir.c b/42sh/src/parser/add_redir.c index ce91da7c..41df28a0 100644 --- a/42sh/src/parser/add_redir.c +++ b/42sh/src/parser/add_redir.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" int isdir_sep(t_btree **ast, t_list **list) { diff --git a/42sh/src/parser/add_sep.c b/42sh/src/parser/add_sep.c index 111c7786..2985134c 100644 --- a/42sh/src/parser/add_sep.c +++ b/42sh/src/parser/add_sep.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" int add_sep(t_btree **ast, t_list **lst) { diff --git a/42sh/src/parser/add_subshell.c b/42sh/src/parser/add_subshell.c index 80dea8e7..9b5f6c58 100644 --- a/42sh/src/parser/add_subshell.c +++ b/42sh/src/parser/add_subshell.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" int issubshell(t_btree **ast, t_list **lst) { diff --git a/42sh/src/parser/add_var.c b/42sh/src/parser/add_var.c index 661446b4..e191490f 100644 --- a/42sh/src/parser/add_var.c +++ b/42sh/src/parser/add_var.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" int isvar(t_btree **ast, t_list **lst) { diff --git a/42sh/src/parser/aggregate_sym.c b/42sh/src/parser/aggregate_sym.c index 1bb11af8..65edcf13 100644 --- a/42sh/src/parser/aggregate_sym.c +++ b/42sh/src/parser/aggregate_sym.c @@ -9,7 +9,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" t_aggrematch g_aggrematch[] = { diff --git a/42sh/src/parser/build_tree.c b/42sh/src/parser/build_tree.c index 0cfc358a..a51e1241 100644 --- a/42sh/src/parser/build_tree.c +++ b/42sh/src/parser/build_tree.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" t_treematch g_treematch[] = { diff --git a/42sh/src/parser/error_syntax.c b/42sh/src/parser/error_syntax.c index d48228c6..e3ebe5e4 100644 --- a/42sh/src/parser/error_syntax.c +++ b/42sh/src/parser/error_syntax.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" t_errormatch g_errormatch[] = { diff --git a/42sh/src/parser/eval_sym.c b/42sh/src/parser/eval_sym.c index a4322aaf..957c647d 100644 --- a/42sh/src/parser/eval_sym.c +++ b/42sh/src/parser/eval_sym.c @@ -9,7 +9,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" t_stackmatch g_stackmatch[] = { diff --git a/42sh/src/parser/ft_parse.c b/42sh/src/parser/ft_parse.c index dcd34b83..ee706c67 100644 --- a/42sh/src/parser/ft_parse.c +++ b/42sh/src/parser/ft_parse.c @@ -9,7 +9,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" static void insert_linebreak(t_list **lst) { diff --git a/42sh/src/parser/parser_init.c b/42sh/src/parser/parser_init.c index 1c884a72..6b807a98 100644 --- a/42sh/src/parser/parser_init.c +++ b/42sh/src/parser/parser_init.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" void parser_init(t_parser *parser) { diff --git a/42sh/src/parser/pop_stack.c b/42sh/src/parser/pop_stack.c index 59e57a09..dca7b2f1 100644 --- a/42sh/src/parser/pop_stack.c +++ b/42sh/src/parser/pop_stack.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" int pop_stack(t_list **stack, t_sym erase_sym) { diff --git a/42sh/src/parser/produce_sym.c b/42sh/src/parser/produce_sym.c index 37ad0815..8cf01e20 100644 --- a/42sh/src/parser/produce_sym.c +++ b/42sh/src/parser/produce_sym.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" t_prodmatch g_prodmatch[] = { diff --git a/42sh/src/parser/push_stack.c b/42sh/src/parser/push_stack.c index 0ac6061b..1f2ba51e 100644 --- a/42sh/src/parser/push_stack.c +++ b/42sh/src/parser/push_stack.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" //int push_stack(t_sym *stack, t_sym new_sym) int push_stack(t_list **stack, t_sym sym) diff --git a/42sh/src/parser/read_stack.c b/42sh/src/parser/read_stack.c index 0e7450af..ddb76ad3 100644 --- a/42sh/src/parser/read_stack.c +++ b/42sh/src/parser/read_stack.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" char *read_state(t_sym current) { diff --git a/42sh/src/parser/tree_wrapper.c b/42sh/src/parser/tree_wrapper.c index 81415d2e..1a11caaf 100644 --- a/42sh/src/parser/tree_wrapper.c +++ b/42sh/src/parser/tree_wrapper.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "parser.h" +#include "minishell.h" int join_ast(t_btree **ast, t_btree **new_node) {