aboutsummaryrefslogtreecommitdiff
path: root/src/repl.c
blob: fe9faf36694c625e5b49784b00f61dd55a0d6d6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   repl.c                                             :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: chuhlig <chuhlig@student.42.fr>            +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2024/06/24 16:07:04 by dkaiser           #+#    #+#             */
/*   Updated: 2024/08/11 14:41:29 by chuhlig          ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "../include/minishell.h"
#include "token.h"

void	repl(const char *prompt)
{
	char	*input;
	t_token	*token_list;
	t_token	*current;
	t_token	*next;

	while (1)
	{
		input = readline(prompt);
		if (input == NULL)
			return ;
		add_history(input);
		token_list = NULL;
		current = token_list;
		tokenizer(input, &token_list, '\0');
		while (current != NULL)
		{
			next = current->next;
			free_token(current);
			current = next;
		}
		free(input);
	}
}