-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.c
More file actions
41 lines (36 loc) · 1.31 KB
/
errors.c
File metadata and controls
41 lines (36 loc) · 1.31 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* errors.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: afrancoi <afrancoi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/12/05 16:58:32 by afrancoi #+# #+# */
/* Updated: 2019/03/04 10:01:32 by afrancoi ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
#include <stdlib.h>
#include <fcntl.h>
/*
** Free the sample, put an error to stdin and return 1
*/
int ft_error_exit(char *sample)
{
if (sample)
free(sample);
ft_putendl("error");
return (0);
}
/*
** If we have 0 or 2+ args or the fd is invalid call error_exit()
*/
int ft_check_errors(int argc, char **argv)
{
if (argc != 2)
{
ft_putendl("usage : ./fillit file");
exit(1);
}
return (open(argv[1], O_RDONLY));
}