-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipex.h
115 lines (82 loc) · 2.94 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pipex.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lpeeters <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/05 16:05:48 by lpeeters #+# #+# */
/* Updated: 2023/05/18 23:27:07 by lpeeters ### ########.fr */
/* */
/* ************************************************************************** */
/*if pipex.h is not defined*/
#ifndef PIPEX_H
/*then define pipex.h*/
# define PIPEX_H
/**************************************/
/* libraries and header files */
/**************************************/
/*pid_t, waitpid*/
# include <sys/types.h>
/*libft library, ft_printf, ft_strtrim, ft_split, ft_strjoin, ft_strncmp*/
# include "libft/libft.h"
/*perror*/
# include <stdio.h>
/*open*/
# include <fcntl.h>
/*pipe, fork, dup2, close, access*/
# include <unistd.h>
/*waitpid*/
# include <sys/wait.h>
/*exit*/
# include <stdlib.h>
/**************************************/
/* error handling */
/**************************************/
/*file descriptor assigning error*/
# define OPEN_ERR 1
/*incorrect input error*/
# define INPUT_ERR 2
/*pipe error*/
# define PIPE_ERR 3
/*fork error*/
# define FORK_ERR 4
/*environment error*/
# define PATH_ENV_ERR 5
/*command not found error*/
# define CMD_ERR 6
/*dup2 error*/
# define DUP2_ERR 7
/*close error*/
# define CLOSE_ERR 8
/*execve error*/
# define EXECVE_ERR 9
/**************************************/
/* memory handling */
/**************************************/
/*path directories' memory*/
# define EXIT -1
/*path directories' memory*/
# define EXECVE_MEM 9
/**************************************/
/* pipex.c */
/**************************************/
/*fetch the path needed by arg_path*/
char *fetch_paths(char **envp);
/*fetch the arguments needed by execve*/
char *arg_path(char *paths, char *cmd);
/*redirect input and program to first command*/
void child(int *p_fd, int *fd, char **av, char **envp);
/*redirect output and program to second command*/
void parent(int *p_fd, int *fd, char **av, char **envp);
/*program that will mimic a pipe like in Shell*/
int main(int ac, char **av, char **envp);
/**************************************/
/* error/handling.c */
/**************************************/
/*error handling*/
void err(int type);
/*memory handling*/
void memerr(char **array, int type, int err);
/*end if statement*/
#endif