diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-07-27 18:55:07 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-07-27 18:55:07 +0200 |
commit | 487a66394061f2d14a2fa421302966b5442d643f (patch) | |
tree | 34237d4e9cb85f94bcefd46f399d2224dff3f6b3 /src/f_fail.c | |
parent | Correct shell prompt (diff) | |
download | 42-minishell-487a66394061f2d14a2fa421302966b5442d643f.tar.gz 42-minishell-487a66394061f2d14a2fa421302966b5442d643f.tar.bz2 42-minishell-487a66394061f2d14a2fa421302966b5442d643f.tar.xz 42-minishell-487a66394061f2d14a2fa421302966b5442d643f.tar.zst 42-minishell-487a66394061f2d14a2fa421302966b5442d643f.zip |
I couldn't see shit
Diffstat (limited to 'src/f_fail.c')
-rw-r--r-- | src/f_fail.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/f_fail.c b/src/f_fail.c new file mode 100644 index 0000000..aae00fb --- /dev/null +++ b/src/f_fail.c @@ -0,0 +1,58 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* 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 + write_fail(const char concern[], + const char msg[], + t_msh *msh) +{ + ft_dprintf(STDERR_FILENO, "%s: %s: %s\n", msh->shname, concern, msg); +} + +void + fail_no_options(const char concern[], + t_msh *msh) +{ + write_fail(concern, FT_FAIL_NO_OPTIONS, msh); +} + +void + fail_identifier(const char concern[], + const char identifier[], + t_msh *msh) +{ + ft_dprintf(STDERR_FILENO, "%s: %s: `%s': not a valid identifier\n", + msh->shname, concern, identifier); +} + +void + fail_too_many_args(const char concern[], + t_msh *msh) +{ + write_fail(concern, FT_FAIL_TOO_MANY_ARGS, msh); +} + +void + fail_alloc(t_msh *msh) +{ + ft_dprintf(STDERR_FILENO, "%s: %s\n", msh->shname, strerror(errno)); + exit(FT_RET_ALLOC); +} |