Пример #1
0
int		check_builtins(t_cmd *cmds, char **env)
{
    int		cur_case;
    char		**builtins;
    int		found;
    int		(*fptr[6])(t_cmd *, char ***);

    found = -1;
    cur_case = -1;
    if ((builtins = my_split(get_builtins(), ';')) == NULL)
        return (-1);
    fill_func_ptr(fptr);
    if (cmds->name != NULL)
    {
        while (builtins[++cur_case])
            if (my_strncmp(builtins[cur_case], cmds->name,
                           get_longest_string(builtins[cur_case], cmds->name)) == 0)
            {
                fptr[cur_case](cmds, &env);
                found = 1;
            }
        free_tab(builtins);
    }
    return (found);
}
Пример #2
0
void			free_builtins(void)
{
	t_builtins	*builtins;

	builtins = get_builtins();
	ft_map_delete(*builtins, free_builtin_entry);
	free(builtins);
}
Пример #3
0
t_builtin		get_builtin(const char *command_name)
{
	t_builtin	builtin;

	builtin = (t_builtin)ft_map_get(*get_builtins(),
									(char *)command_name,
									(t_simple_hash_func)ft_djb2);
	return (builtin);
}