-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpipex.h
More file actions
53 lines (47 loc) · 2.07 KB
/
Copy pathpipex.h
File metadata and controls
53 lines (47 loc) · 2.07 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
42
43
44
45
46
47
48
49
50
51
52
53
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pipex.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tbui-quo <tbui-quo@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/25 19:12:40 by tbui-quo #+# #+# */
/* Updated: 2023/07/05 15:29:48 by tbui-quo ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PIPEX_H
# define PIPEX_H
# include "libft/libft.h"
# include <fcntl.h>
# include <stdlib.h>
# include <unistd.h>
# include <stdio.h>
# include <sys/types.h>
# include <sys/wait.h>
# define INPUT 1
# define OUTPUT 2
# define ERR_INPUT "Invalid number of arguments.\n"
# define ERR_PIPE "Pipe Error"
# define ERR_CMD "pipex: "
# define ERR_EXEC "Execve Error"
# define ERR_FORK "Fork Error"
# define ERR_OPEN_FILE "pipex: "
# define ERR_IMPOSSIBLE "Impossible stop sabotating my Program :("
// pipex.c
void exec(char *cmd, char **env);
void execute_child_process(char *argv[],
int *pipe_fd, char *env[], int cnum);
void execute_parent_process(int *pipe_fd, pid_t *process_id);
// util.c
void ft_free_array(char **array);
int open_input_or_output_file(char *filename, int in_or_out);
int has_file_access(const char *input_filename);
char *get_env_value_by_name(char *envVarName, char **env);
char *get_exec_path(char *cmd, char **env);
char **parse_command_with_quotes(char *cmd);
// error.c
int print_error_msg(char *error);
void print_error_cmd_not_found_and_exit(char *split_cmd, char *error);
void print_error_msg_and_exit(char *error);
void print_error_open_file_and_exit(char *filename, char *error);
#endif