/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   builtins.c                                         :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: sede-san <sede-san@student.42madrid.com    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2025/12/01 17:04:57 by sede-san          #+#    #+#             */
/*   Updated: 2026/02/08 19:51:38 by sede-san         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "builtins.h"

u_int8_t	set_builtins(
	t_minishell *minishell
) {
	minishell->builtins
		= ft_hashmap_new(4, ft_hashmap_hashstr, ft_hashmap_strcmp);
	if (minishell->builtins == NULL)
		return (0);
	ft_hashmap_put(minishell->builtins, ft_strdup("cd"), builtin_cd);
	ft_hashmap_put(minishell->builtins, ft_strdup("echo"), builtin_echo);
	ft_hashmap_put(minishell->builtins, ft_strdup("exit"), builtin_exit);
	ft_hashmap_put(minishell->builtins, ft_strdup("pwd"), builtin_pwd);
	return (1);
}

u_int8_t	is_builtin(
	const char *command_name,
	t_minishell *minishell
) {
	return (ft_hashmap_contains_key(minishell->builtins, command_name));
}
