Files
42_INT_07_minishell/srcs/main.c
LuckyLaszlo a7e0066458 refactoring
2021-10-08 19:15:21 +02:00

77 lines
2.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/04 05:59:26 by lperrey #+# #+# */
/* Updated: 2021/10/08 19:11:03 by lperrey ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void shell_loop(t_all *c)
{
char *line_input;
line_input = NULL;
while (1)
{
if (line_input)
free(line_input);
line_input = readline(c->prompt);
if (line_input && *line_input)
{
if (!ft_strncmp(line_input, "exit", 5))
exit(EXIT_SUCCESS);
else
printf("echo: %s\n", line_input);
}
//rl_redisplay();
//rl_on_new_line();
}
}
void wip_test()
{
char term_desc[2048];
char *term_type;
int term_width;
int term_height;
int ret;
term_type = getenv("TERM");
if (term_type == 0)
ft_putstr_fd("Specify a terminal type with `setenv TERM <yourtype>'.\n", 2);
ret = tgetent(term_desc, term_type);
if (ret < 0)
ft_putstr_fd("Could not access the termcap data base.\n", 2);
if (ret == 0)
ft_putstr_fd("Terminal type `%s' is not defined.\n", 2);
term_height = tgetnum ("li");
term_width = tgetnum ("co");
/* Extract information that termcap functions use. */
/* temp = tgetstr ("pc", BUFFADDR);
PC = temp ? *temp : 0;
BC = tgetstr ("le", BUFFADDR);
UP = tgetstr ("up", BUFFADDR); */
}
int main(int argc, char *argv[], char *envp[])
{
t_all c;
ft_putendl_arr_fd(envp, 1);
//char *path = getenv("PATH");
(void)argc;
(void)argv;
(void)envp;
if (!init(&c))
exit(EXIT_FAILURE);
shell_loop(&c);
return (0);
}