-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
35 lines (31 loc) · 1.35 KB
/
main.c
File metadata and controls
35 lines (31 loc) · 1.35 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
/* ************************************************************************** */
/* */
/* :::::::: */
/* main.c :+: :+: */
/* +:+ */
/* By: rutgercappendijk <rutgercappendijk@stud +#+ */
/* +#+ */
/* Created: 2021/09/17 08:40:25 by rcappend #+# #+# */
/* Updated: 2021/09/22 14:32:42 by rcappend ######## odam.nl */
/* */
/* ************************************************************************** */
#include "pipex.h"
void exit_error(int error_code, char *msg)
{
write(2, "Error!\n", 7);
write(2, msg, ft_strlen(msg));
write(2, "\n", 1);
exit(error_code);
}
int main(int argc, char **argv, char **envp)
{
t_cmd cmds[2];
int fd_in;
int fd_out;
if (argc != 5)
exit_error(1, "Usage: ./pipex file1 \"cmd1\" \"cmd2\" file2");
read_files(&fd_in, &fd_out, argv[1], argv[4]);
arg_lexer(&cmds[0], &cmds[1], argv[2], argv[3]);
pipex(fd_in, fd_out, cmds, envp);
return (0);
}