-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.c
51 lines (45 loc) · 1.61 KB
/
errors.c
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
42
43
44
45
46
47
48
49
50
51
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* errors.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: irychkov <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/26 18:40:57 by irychkov #+# #+# */
/* Updated: 2024/09/29 00:56:19 by irychkov ### ########.fr */
/* */
/* ************************************************************************** */
#include "pipex.h"
static void error_msg(char *msg, char *name)
{
write(2, "zsh:1: ", 7);
write(2, msg, ft_strlen(msg));
write(2, ": ", 2);
if (name && name[0] != '\0')
write(2, name, ft_strlen(name));
write(2, "\n", 1);
}
void error_permission(char *name, int code, t_pipex *fds)
{
error_msg("permission denied", name);
free_pipex(fds);
exit (code);
}
void error_command(char *name, t_pipex *fds)
{
error_msg("command not found", name);
free_pipex(fds);
exit (127);
}
void error_nofile(char *name, int code, t_pipex *fds)
{
error_msg("no such file or directory", name);
free_pipex(fds);
exit (code);
}
void error_directory(char *name, int code, t_pipex *fds)
{
error_msg("is a directory", name);
free_pipex(fds);
exit (code);
}