-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.c
More file actions
48 lines (43 loc) · 1.5 KB
/
errors.c
File metadata and controls
48 lines (43 loc) · 1.5 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* errors.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dhuss <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/10 09:28:57 by dhuss #+# #+# */
/* Updated: 2024/07/19 12:03:01 by dhuss ### ########.fr */
/* */
/* ************************************************************************** */
#include "pipex.h"
void error_argc(void)
{
ft_putstr_fd("Error: ", 2);
ft_putstr_fd("invalid argc number\n", 2);
}
void error_strlen(void)
{
ft_putstr_fd("Error: ", 2);
ft_putstr_fd("invalid filename length\n", 2);
}
void error_cmd_not_found(char *str)
{
ft_putstr_fd("pipex: ", 2);
ft_putstr_fd(str, 2);
ft_putstr_fd(": command not found\n", 2);
}
void error_custom(int err_num, char *str)
{
if (err_num <= 106)
perror("pipex: input");
else
{
if (err_num == E_CUSTOM_ARGC)
error_argc();
else if (err_num == E_CUSTOM_STRLEN)
error_strlen();
else if (err_num == 127)
error_cmd_not_found(str);
}
exit(err_num);
}