-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipex.h
55 lines (44 loc) · 1.9 KB
/
pipex.h
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pipex.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ana-lda- <ana-lda-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/28 15:26:16 by ana-lda- #+# #+# */
/* Updated: 2024/09/12 13:46:06 by ana-lda- ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PIPEX_H
# define PIPEX_H
# include <unistd.h>
# include "libft/libft.h"
# include <fcntl.h>
# include <sys/wait.h>
# include <stdio.h>
# include <stdlib.h>
# define EXIT_COMMAND 127
# define SINGLE_QUOTE 39
typedef struct s_pipex
{
int pid;
char **cmd1;
char **cmd2;
char **path_name;
int fd[2];
} t_pipex;
/**********************UTILS********************/
t_pipex init_pipex(char **argv, char **envp);
void handle_input(int argc, char **argv);
char **get_path_name(char **env);
char **ft_split_trim(char *str, char c);
/**********************ERROR********************/
void error_exit(char *error_message, int error_exit);
void free_array(char **array);
void cleanup_and_exit(t_pipex *pipex, char *error_message, int error_code);
/***********************PIPEX********************/
void child_process(t_pipex *pipex, char *infile, char **env);
void parent_process(t_pipex *pipex, char *outfile, char **env);
void exec(t_pipex *pipex, char **env, char c);
void exec_cmd_path(t_pipex *ppx, int i, char **cmd, char **envp);
#endif