-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpipex.c
More file actions
34 lines (31 loc) · 1.61 KB
/
pipex.c
File metadata and controls
34 lines (31 loc) · 1.61 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pipex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yrhiba <yrhiba@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/20 02:13:28 by yrhiba #+# #+# */
/* Updated: 2022/12/06 03:46:43 by yrhiba ### ########.fr */
/* */
/* ************************************************************************** */
#include "pipex.h"
int main(int ac, char const *av[], char const *ev[])
{
t_pipex *vars;
vars = (t_pipex *)malloc(sizeof(t_pipex));
if (!vars)
return (perror("error (vars allocation)"), EXIT_FAILURE);
vars->cmds_count = getcmdscount(vars, ac, av);
if ((int)vars->cmds_count == -1)
return (free(vars), perror("error (getcmdscount)"), EXIT_FAILURE);
vars->pipes = getpipes((vars->cmds_count) + 1);
if (!vars->pipes)
return (free(vars), perror("error (getpipes)"), EXIT_FAILURE);
vars->fds = getfds(ac, av, vars);
if (!(vars->fds))
return (rtnfds(vars), perror("error (getfds)"), EXIT_FAILURE);
if (startforking(vars, getcmds(vars, av), ev, vars->fds))
return (rtnforking(vars), EXIT_FAILURE);
return (rtnpipex(vars), EXIT_SUCCESS);
}