diff --git a/42sh/Makefile b/42sh/Makefile index 4196032e..c895beb6 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -188,6 +188,15 @@ job-control/process_free_cmd.c\ job-control/process_free_cond.c\ job-control/process_free_list.c\ job-control/process_free_subshell.c\ +job-control/process_print.c\ +job-control/process_print_case.c\ +job-control/process_print_cmd.c\ +job-control/process_print_for.c\ +job-control/process_print_function.c\ +job-control/process_print_if.c\ +job-control/process_print_subshell.c\ +job-control/process_print_until.c\ +job-control/process_print_while.c\ job-control/put_job_in_background.c\ job-control/put_job_in_foreground.c\ job-control/sigchld_handler.c\ diff --git a/42sh/includes/exec.h b/42sh/includes/exec.h index cdf63189..0ef7bb7c 100644 --- a/42sh/includes/exec.h +++ b/42sh/includes/exec.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */ -/* Updated: 2017/03/08 16:45:25 by jhalford ### ########.fr */ +/* Updated: 2017/03/08 17:46:53 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -218,4 +218,17 @@ int exec_var(t_btree **ast); int exec_case_branch(t_btree **ast); int exec_math(t_btree **ast); +/* +** Mapping pour afficher les process +*/ +void process_print(t_process *p); +int process_print_subshell(void); +int process_print_while(void); +int process_print_if(void); +int process_print_case(void); +int process_print_until(void); +int process_print_function(void); +int process_print_for(void); +void process_print_cmd(t_process *p); + #endif diff --git a/42sh/src/job-control/process_format.c b/42sh/src/job-control/process_format.c index 96052289..27173f3d 100644 --- a/42sh/src/job-control/process_format.c +++ b/42sh/src/job-control/process_format.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/09 13:05:55 by jhalford #+# #+# */ -/* Updated: 2017/03/07 21:24:17 by wescande ### ########.fr */ +/* Updated: 2017/03/08 16:21:18 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -51,7 +51,7 @@ static void process_format_com_long(t_list **plist) ft_putstr(" )"); } else*/ - ft_sstrprint(p->data.cmd.av, ' '); + process_print(p); if ((*plist)->next) ft_putstr(" |"); (*plist) = (*plist)->next; @@ -72,16 +72,7 @@ static void process_format_com_short(t_list **plist, t_flag state) p->attrs &= ~PROCESS_STATE_MASK; p->attrs &= ~PROCESS_RUNNING; } -/* if (p->attrs & PROCESS_CONTROL) - ft_putstr("script"); - else if (p->attrs & PROCESS_SUBSHELL) - { - ft_putstr("( "); - ft_putstr(p->data.cmd.av[2]); - ft_putstr(" )"); - } - else*/ - ft_sstrprint(p->data.cmd.av, ' '); + process_print(p); if ((*plist)->next) ft_putstr(" | "); (*plist) = (*plist)->next; diff --git a/42sh/src/job-control/process_print.c b/42sh/src/job-control/process_print.c new file mode 100644 index 00000000..4e0efb16 --- /dev/null +++ b/42sh/src/job-control/process_print.c @@ -0,0 +1,40 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* process_print.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: wescande +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/08 16:03:32 by wescande #+# #+# */ +/* Updated: 2017/03/08 16:20:19 by wescande ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +t_itof g_printmap[] = +{ + {PROCESS_FUNCTION, process_print_function}, + {PROCESS_BUILTIN, NULL}, + {PROCESS_FILE, NULL}, + {PROCESS_SUBSHELL, process_print_subshell}, + {PROCESS_WHILE, process_print_while}, + {PROCESS_UNTIL, process_print_until}, + {PROCESS_IF, process_print_if}, + {PROCESS_FOR, process_print_for}, + {PROCESS_CASE, process_print_case}, + {0, NULL} +}; + +void process_print(t_process *p) +{ + if (p->type == PROCESS_BUILTIN || p->type == PROCESS_FUNCTION) + { + process_print_cmd(p); + return ; + } + if (p->type >= PROCESS_MAX) + return ; + if (g_printmap[p->type].f) + (g_printmap[p->type].f)(); +} diff --git a/42sh/src/job-control/process_print_case.c b/42sh/src/job-control/process_print_case.c new file mode 100644 index 00000000..a8c63c13 --- /dev/null +++ b/42sh/src/job-control/process_print_case.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* process_print_case.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: wescande +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/08 16:15:22 by wescande #+# #+# */ +/* Updated: 2017/03/08 16:15:38 by wescande ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int process_print_case(void) +{ + ft_putstr("CASE GROUP"); + return (0); +} diff --git a/42sh/src/job-control/process_print_cmd.c b/42sh/src/job-control/process_print_cmd.c new file mode 100644 index 00000000..617dea18 --- /dev/null +++ b/42sh/src/job-control/process_print_cmd.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* process_print_cmd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: wescande +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/08 16:17:16 by wescande #+# #+# */ +/* Updated: 2017/03/08 16:20:11 by wescande ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +void process_print_cmd(t_process *p) +{ + ft_sstrprint(p->data.cmd.av, ' '); +} diff --git a/42sh/src/job-control/process_print_for.c b/42sh/src/job-control/process_print_for.c new file mode 100644 index 00000000..e671c5d3 --- /dev/null +++ b/42sh/src/job-control/process_print_for.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* process_print_for.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: wescande +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/08 16:14:21 by wescande #+# #+# */ +/* Updated: 2017/03/08 16:14:32 by wescande ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int process_print_for(void) +{ + ft_putstr("FOR GROUP"); + return (0); +} diff --git a/42sh/src/job-control/process_print_function.c b/42sh/src/job-control/process_print_function.c new file mode 100644 index 00000000..d9dbde4d --- /dev/null +++ b/42sh/src/job-control/process_print_function.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* process_print_function.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: wescande +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/08 16:12:18 by wescande #+# #+# */ +/* Updated: 2017/03/08 16:12:44 by wescande ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int process_print_function(void) +{ + ft_putstr("FUNCTION GROUP"); + return (0); +} diff --git a/42sh/src/job-control/process_print_if.c b/42sh/src/job-control/process_print_if.c new file mode 100644 index 00000000..4dc43cd2 --- /dev/null +++ b/42sh/src/job-control/process_print_if.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* process_print_if.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: wescande +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/08 16:14:48 by wescande #+# #+# */ +/* Updated: 2017/03/08 16:14:55 by wescande ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int process_print_if(void) +{ + ft_putstr("IF GROUP"); + return (0); +} diff --git a/42sh/src/job-control/process_print_subshell.c b/42sh/src/job-control/process_print_subshell.c new file mode 100644 index 00000000..ad88b517 --- /dev/null +++ b/42sh/src/job-control/process_print_subshell.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* process_print_subshell.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: wescande +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/08 16:06:06 by wescande #+# #+# */ +/* Updated: 2017/03/08 16:11:58 by wescande ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int process_print_subshell(void) +{ + ft_putstr("( SUBSHELL GROUP )"); + return (0); +} diff --git a/42sh/src/job-control/process_print_until.c b/42sh/src/job-control/process_print_until.c new file mode 100644 index 00000000..6460da08 --- /dev/null +++ b/42sh/src/job-control/process_print_until.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* process_print_until.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: wescande +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/08 16:16:00 by wescande #+# #+# */ +/* Updated: 2017/03/08 16:16:17 by wescande ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int process_print_until(void) +{ + ft_putstr("UNTIL GROUP"); + return (0); +} diff --git a/42sh/src/job-control/process_print_while.c b/42sh/src/job-control/process_print_while.c new file mode 100644 index 00000000..5c8d67d8 --- /dev/null +++ b/42sh/src/job-control/process_print_while.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* process_print_while.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: wescande +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/08 16:15:01 by wescande #+# #+# */ +/* Updated: 2017/03/08 16:15:15 by wescande ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int process_print_while(void) +{ + ft_putstr("WHILE GROUP"); + return (0); +} diff --git a/42sh/src/job-control/put_job_in_foreground.c b/42sh/src/job-control/put_job_in_foreground.c index fe5126ac..d290a3ca 100644 --- a/42sh/src/job-control/put_job_in_foreground.c +++ b/42sh/src/job-control/put_job_in_foreground.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */ -/* Updated: 2017/03/08 17:40:28 by jhalford ### ########.fr */ +/* Updated: 2017/03/08 17:47:06 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */