chepa
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/05 18:20:21 by marde-vr #+# #+# */
|
/* Created: 2024/03/05 18:20:21 by marde-vr #+# #+# */
|
||||||
/* Updated: 2024/04/03 15:46:27 by tomoron ### ########.fr */
|
/* Updated: 2024/04/07 17:14:57 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
48
srcs/debug.c
48
srcs/debug.c
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/18 15:46:50 by tomoron #+# #+# */
|
/* Created: 2024/02/18 15:46:50 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/04/02 17:22:43 by tomoron ### ########.fr */
|
/* Updated: 2024/04/07 17:27:45 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -22,28 +22,33 @@ void print_parsed_token(t_token *token)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_cmd_type(t_cmd_type type, char *value)
|
||||||
|
{
|
||||||
|
if(type == CMD)
|
||||||
|
printf("[CMD : %s] ", value);
|
||||||
|
if(type == PAREN)
|
||||||
|
printf("[PAREN : %s] ", value);
|
||||||
|
if(type == AND)
|
||||||
|
printf("[AND] ");
|
||||||
|
if(type == OR)
|
||||||
|
printf("[OR] ");
|
||||||
|
if(type == PIPE)
|
||||||
|
printf("[PIPE] ");
|
||||||
|
if(type == RED_O_APP)
|
||||||
|
printf("[RED_O_APP : %s] ", value);
|
||||||
|
if(type == RED_O)
|
||||||
|
printf("[RED_O : %s] ", value);
|
||||||
|
if(type == RED_I)
|
||||||
|
printf("[RED_I : %s] ", value);
|
||||||
|
if(type == HERE_DOC)
|
||||||
|
printf("[HERE_DOC : %s] ", value);
|
||||||
|
}
|
||||||
|
|
||||||
void print_parsed_cmd(t_cmd *cmd)
|
void print_parsed_cmd(t_cmd *cmd)
|
||||||
{
|
{
|
||||||
while(cmd)
|
while(cmd)
|
||||||
{
|
{
|
||||||
if(cmd->cmd_type == CMD)
|
print_cmd_type(cmd->cmd_type, cmd->value);
|
||||||
printf("[CMD : %s] ", cmd->value);
|
|
||||||
if(cmd->cmd_type == PAREN)
|
|
||||||
printf("[PAREN : %s] ", cmd->value);
|
|
||||||
if(cmd->cmd_type == AND)
|
|
||||||
printf("[AND] ");
|
|
||||||
if(cmd->cmd_type == OR)
|
|
||||||
printf("[OR] ");
|
|
||||||
if(cmd->cmd_type == PIPE)
|
|
||||||
printf("[PIPE] ");
|
|
||||||
if(cmd->cmd_type == RED_O_APP)
|
|
||||||
printf("[RED_O_APP : %s] ", cmd->value);
|
|
||||||
if(cmd->cmd_type == RED_O)
|
|
||||||
printf("[RED_O : %s] ", cmd->value);
|
|
||||||
if(cmd->cmd_type == RED_I)
|
|
||||||
printf("[RED_I : %s] ", cmd->value);
|
|
||||||
if(cmd->cmd_type == HERE_DOC)
|
|
||||||
printf("[HERE_DOC : %s] ", cmd->value);
|
|
||||||
cmd = cmd->next;
|
cmd = cmd->next;
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@ -53,4 +58,9 @@ void print_msh_struct(t_msh *msh)
|
|||||||
{
|
{
|
||||||
printf("in_fd : %d\n", msh->in_fd);
|
printf("in_fd : %d\n", msh->in_fd);
|
||||||
printf("out_fd : %d\n", msh->out_fd);
|
printf("out_fd : %d\n", msh->out_fd);
|
||||||
|
printf("in_type: ");
|
||||||
|
print_cmd_type(msh->in_type, 0);
|
||||||
|
printf("\nout_type: ");
|
||||||
|
print_cmd_type(msh->out_type, 0);
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
|
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/04/04 13:30:31 by tomoron ### ########.fr */
|
/* Updated: 2024/04/07 17:47:44 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -56,6 +56,8 @@ void exec_command_bonus(t_msh *msh, char *cmd_str)
|
|||||||
print_msh_struct(msh); // debug
|
print_msh_struct(msh); // debug
|
||||||
print_parsed_token(msh->tokens); // debug
|
print_parsed_token(msh->tokens); // debug
|
||||||
exec_commands(msh);
|
exec_commands(msh);
|
||||||
|
msh->in_fd = 0;
|
||||||
|
msh->out_fd = 0;
|
||||||
}
|
}
|
||||||
while (cmds && (is_cmd_type(cmds) || cmds->cmd_type == PIPE
|
while (cmds && (is_cmd_type(cmds) || cmds->cmd_type == PIPE
|
||||||
|| is_output_type(cmds) || is_input_type(cmds)))
|
|| is_output_type(cmds) || is_input_type(cmds)))
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/05 19:10:52 by marde-vr #+# #+# */
|
/* Created: 2024/03/05 19:10:52 by marde-vr #+# #+# */
|
||||||
/* Updated: 2024/04/04 16:44:37 by tomoron ### ########.fr */
|
/* Updated: 2024/04/07 17:34:58 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ void get_out_type(t_msh *msh, t_cmd *cmds)
|
|||||||
cur_cmd = cur_cmd->next;
|
cur_cmd = cur_cmd->next;
|
||||||
if (cur_cmd->cmd_type == CMD || cur_cmd->cmd_type == PAREN)
|
if (cur_cmd->cmd_type == CMD || cur_cmd->cmd_type == PAREN)
|
||||||
msh->out_type = 0;
|
msh->out_type = 0;
|
||||||
else if(cur_cmd && !is_output_type(cur_cmd) && !is_operand_type(cur_cmd) && cur_cmd->cmd_type != PIPE)
|
else if(cur_cmd && is_output_type(cur_cmd) && !is_operand_type(cur_cmd) && cur_cmd->cmd_type != PIPE)
|
||||||
{
|
{
|
||||||
msh->out_type = cur_cmd->cmd_type;
|
msh->out_type = cur_cmd->cmd_type;
|
||||||
filename = parse_command(cur_cmd->value, msh->env);
|
filename = parse_command(cur_cmd->value, msh->env);
|
||||||
|
Reference in New Issue
Block a user