74 lines
2.2 KiB
C
74 lines
2.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* :::::::: */
|
|
/* print_commands.c :+: :+: */
|
|
/* +:+ */
|
|
/* By: marvin <marvin@student.42.fr> +#+ */
|
|
/* +#+ */
|
|
/* Created: 2025/02/18 20:06:37 by qmennen #+# #+# */
|
|
/* Updated: 2025/03/04 18:40:35 by whaffman ######## odam.nl */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "minishell.h"
|
|
|
|
void print_commands(void *param)
|
|
{
|
|
t_command *command;
|
|
int i;
|
|
|
|
if (!DEBUG)
|
|
return ;
|
|
command = (t_command *)param;
|
|
if (!command)
|
|
return ;
|
|
printf(BOLD "\n==========================\n" RESET);
|
|
printf(GREEN BOLD "Command: " RESET "%s\n", command->args[0]);
|
|
printf(BOLD "-- Args: " RESET);
|
|
i = 0;
|
|
while (command->args[i])
|
|
printf("%s ", command->args[i++]);
|
|
printf("\n");
|
|
printf(BOLD "-- Input redirects:\n" RESET);
|
|
ft_lstiter(command->redirect_in, print_redirects);
|
|
printf(BOLD "-- Output redirects:\n" RESET);
|
|
ft_lstiter(command->redirect_out, print_redirects);
|
|
printf(BOLD "-- fd_in:" RESET " %i\n", command->fd_in);
|
|
printf(BOLD "-- fd_out:" RESET " %i\n", command->fd_out);
|
|
printf(BOLD "==========================" RESET "\n");
|
|
}
|
|
|
|
void print_redirects(void *param)
|
|
{
|
|
t_redirect *redirect;
|
|
|
|
redirect = (t_redirect *)param;
|
|
if (!redirect)
|
|
return ;
|
|
printf(" Redirect %i value %s\n", redirect->type, redirect->value);
|
|
}
|
|
|
|
void token_print(void *param)
|
|
{
|
|
t_token *token;
|
|
const char *token_type[] = {
|
|
"T_WORD",
|
|
"T_DQWORD",
|
|
"T_SQWORD",
|
|
"T_PIPE",
|
|
"T_REDIRECT_IN",
|
|
"T_REDIRECT_OUT",
|
|
"T_AND",
|
|
"T_OR",
|
|
"T_APPEND_OUT",
|
|
"T_HEREDOC",
|
|
"T_EOF",
|
|
"T_ERROR"
|
|
};
|
|
|
|
if (!DEBUG)
|
|
return ;
|
|
token = (t_token *)param;
|
|
printf( GREEN BOLD "[%s]\t\t" RESET "(%s)\n", token->value, token_type[token->type]);
|
|
}
|