-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_check_utils_bonus.c
62 lines (57 loc) · 1.54 KB
/
error_check_utils_bonus.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
52
53
54
55
56
57
58
59
60
61
62
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error_check_utils_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmeier <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/02 09:44:39 by mariusmeier #+# #+# */
/* Updated: 2024/05/07 15:54:58 by mmeier ### ########.fr */
/* */
/* ************************************************************************** */
#include "mini_talk_bonus.h"
int not_only_digits(char *str)
{
int i;
i = 0;
while (str[i])
{
if (!ft_isdigit(str[i]))
return (1);
i++;
}
return (0);
}
int error_message(int code)
{
if (code == 0)
{
ft_putstr_fd("ERROR.\nInvalid server-pid :(\n", 2);
return (-1);
}
if (code == 1)
{
ft_putstr_fd("ERROR.\nInvalid input :(\n", 2);
return (-1);
}
if (code == 2)
{
ft_putstr_fd("ERROR.\nSIGUSR1 could not be configured :(\n", 2);
exit (1);
}
if (code == 3)
{
ft_putstr_fd("ERROR.\nSIGUSR2 could not be configured :(\n", 2);
exit (1);
}
return (0);
}
void free_and_exit(char **str)
{
if (*str)
{
free(*str);
*str = NULL;
}
exit (1);
}