summaryrefslogtreecommitdiffstats
path: root/src/f_fail.c
blob: 7b48b03cef97adfd85b0a0cb1e4bdbebbc14446b (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
41
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   f_fail.c                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */
/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */
/*                                                                            */
/* ************************************************************************** */

#include <libft.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>

#include "d_define.h"
#include "s_struct.h"

static void	f_write_fail(const char concern[], const char msg[], t_msh *msh)
{
	ft_dprintf(STDERR_FILENO, "%s: %s: %s\n", msh->argv[0], concern, msg);
}

void		f_fail_no_options(const char concern[], t_msh *msh)
{
	f_write_fail(concern, F_NO_OPTIONS, msh);
}

void		f_fail_identifier(const char concern[], const char identifier[])
{
	ft_dprintf(STDERR_FILENO, "minishell: %s: `%s': not a valid identifier\n",
			concern, identifier);
}

void		f_fail_too_many_args(const char concern[], t_msh *msh)
{
	f_write_fail(concern, F_TOO_MANY_ARGS, msh);
}