ajout affichage du job control

This commit is contained in:
wescande 2017-03-08 16:24:25 +01:00
parent 145c116e18
commit 86a733ffe5
13 changed files with 218 additions and 14 deletions

View file

@ -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\

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
/* Updated: 2017/03/08 14:58:19 by wescande ### ########.fr */
/* Updated: 2017/03/08 16:19:22 by wescande ### ########.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

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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;

View file

@ -0,0 +1,40 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_print.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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)();
}

View file

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_print_case.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_print_cmd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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, ' ');
}

View file

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_print_for.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_print_function.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_print_if.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_print_subshell.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_print_until.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_print_while.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */
/* Updated: 2017/03/08 15:05:31 by wescande ### ########.fr */
/* Updated: 2017/03/08 15:34:45 by wescande ### ########.fr */
/* */
/* ************************************************************************** */