2024-04-25 11:46:41 +02:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* ::: :::::::: */
|
|
|
|
/* main.c :+: :+: :+: */
|
|
|
|
/* +:+ +:+ +:+ */
|
2024-05-22 14:51:52 +02:00
|
|
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
2024-04-25 11:46:41 +02:00
|
|
|
/* +#+#+#+#+#+ +#+ */
|
|
|
|
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
|
2024-05-25 14:06:42 +02:00
|
|
|
/* Updated: 2024/05/24 15:01:05 by adjoly ### ########.fr */
|
2024-04-25 11:46:41 +02:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
2024-05-13 17:33:29 +02:00
|
|
|
#include <stdio.h>
|
2024-04-25 11:46:41 +02:00
|
|
|
#include <readline/readline.h>
|
2024-04-30 12:36:16 +02:00
|
|
|
#include <readline/history.h>
|
2024-04-27 17:39:26 +02:00
|
|
|
#include <stdlib.h>
|
2024-04-30 12:36:16 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <fcntl.h>
|
2024-05-09 16:46:13 +02:00
|
|
|
#include "libft.h"
|
2024-04-30 12:36:16 +02:00
|
|
|
#include "minishell.h"
|
2024-05-09 16:46:13 +02:00
|
|
|
#include "parsing.h"
|
2024-05-23 20:53:07 +02:00
|
|
|
#include "prompt.h"
|
2024-04-25 11:46:41 +02:00
|
|
|
|
2024-05-23 20:53:07 +02:00
|
|
|
/*void print_cmd(t_cmd cmd)
|
2024-04-25 11:46:41 +02:00
|
|
|
{
|
2024-05-07 11:04:20 +02:00
|
|
|
ft_putendl_fd(cmd.cmd, 1);
|
|
|
|
while (*(cmd.argv))
|
2024-04-27 17:39:26 +02:00
|
|
|
{
|
2024-05-07 11:04:20 +02:00
|
|
|
ft_putendl_fd(*(cmd.argv), 1);
|
|
|
|
(cmd.argv)++;
|
2024-04-27 17:39:26 +02:00
|
|
|
}
|
2024-05-23 20:53:07 +02:00
|
|
|
}*/
|
2024-04-25 11:46:41 +02:00
|
|
|
|
2024-05-09 16:46:13 +02:00
|
|
|
void print_pipe(t_list *pipe)
|
|
|
|
{
|
|
|
|
t_list *tmp;
|
|
|
|
|
|
|
|
tmp = pipe;
|
2024-05-23 20:53:07 +02:00
|
|
|
while (tmp)
|
2024-05-09 16:46:13 +02:00
|
|
|
{
|
2024-05-23 20:53:07 +02:00
|
|
|
ft_putendl_fd(tmp->content, STDOUT_FILENO);
|
2024-05-09 16:46:13 +02:00
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-25 11:46:41 +02:00
|
|
|
int main(int ac, char **av, char **env)
|
|
|
|
{
|
2024-05-22 15:38:50 +02:00
|
|
|
//ft_heredoc("EOF");
|
2024-04-25 11:46:41 +02:00
|
|
|
char *test;
|
2024-05-02 15:50:58 +02:00
|
|
|
char *prompt;
|
2024-05-23 20:53:07 +02:00
|
|
|
char **lll;
|
|
|
|
t_list *piped;
|
2024-05-25 14:06:42 +02:00
|
|
|
//t_token *token;
|
2024-04-25 11:46:41 +02:00
|
|
|
|
|
|
|
(void)ac;
|
|
|
|
(void)av;
|
|
|
|
(void)env;
|
|
|
|
while (1)
|
|
|
|
{
|
2024-05-02 15:50:58 +02:00
|
|
|
prompt = get_prompt();
|
|
|
|
test = readline(prompt);
|
2024-05-02 15:54:16 +02:00
|
|
|
free(prompt);
|
2024-04-30 12:36:16 +02:00
|
|
|
add_history(test);
|
2024-04-25 11:46:41 +02:00
|
|
|
lll = ft_split(test, ' ');
|
2024-04-27 17:39:26 +02:00
|
|
|
if (!*lll)
|
2024-05-22 14:53:27 +02:00
|
|
|
continue ;
|
2024-04-27 17:39:26 +02:00
|
|
|
if (is_str(test, "exit"))
|
|
|
|
break;
|
2024-05-23 20:53:07 +02:00
|
|
|
piped = __split_pipe(test);
|
2024-05-25 14:06:42 +02:00
|
|
|
print_redir(__to_redir(piped->content));
|
|
|
|
//free(token);
|
2024-05-23 20:53:07 +02:00
|
|
|
free(test);
|
|
|
|
ft_lstclear(&piped, &free);
|
2024-05-07 11:04:20 +02:00
|
|
|
ft_free("a", &lll);
|
2024-04-25 11:46:41 +02:00
|
|
|
}
|
2024-05-07 11:04:20 +02:00
|
|
|
ft_free("a", &lll);
|
2024-04-25 11:46:41 +02:00
|
|
|
return (0);
|
|
|
|
}
|
2024-05-23 20:53:07 +02:00
|
|
|
|
|
|
|
/*int main()
|
|
|
|
{
|
|
|
|
char *ll = "asdf\"xf\"asfffd";
|
|
|
|
t_quote d;
|
|
|
|
|
|
|
|
d = is_inquote(ll, 6);
|
|
|
|
ft_printf("%c\n", *(ll+6));
|
|
|
|
print_quote_type(d);
|
|
|
|
}*/
|