aboutsummaryrefslogtreecommitdiff
path: root/include/eval.h
blob: e2f3c8be022b0ff7799f3bf5dfbd576c269b51cc (plain)
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
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   eval.h                                             :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: charles <charles@student.42.fr>            +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/01 17:05:30 by charles           #+#    #+#             */
/*   Updated: 2020/10/09 13:40:26 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#ifndef EVAL_H
# define EVAL_H

/*
** \file   eval.h
** \brief  Evaluation module
*/

# include "minishell.h"
# include "lexer.h"
# include "parser.h"

typedef struct		s_fork_param_args
{
	t_env			env;
	t_ast			*ast;
	int				fds[2];
}					t_fork_param_args;

typedef struct
{
	char			exec_path[PATH_MAX + 1];
	char			**argv;
	t_env			env;
	t_builtin_entry	*builtin;
}					t_fork_param_cmd;

typedef int			(*t_wrapped_func)(void *param);

# define FD_NONE -2
# define FD_WRITE 1
# define FD_READ 0

extern pid_t		g_child_pid;

/*
** eval.c
*/

int					fork_wrap(int fds[2], void *passed, t_wrapped_func wrapped);
int					eval(int fds[2], t_env env, t_ast *ast);

/*
** cmd.c
*/

int					eval_cmd(int fds[2], t_env env, t_ast *ast);

/*
** operation.c
*/

int					eval_operation(int fds[2], t_env env, t_ast *ast);
int					eval_pipeline(int fds[2], t_env env, t_ast *ast);

/*
** parenthesis.c
*/

int					eval_parenthesis(int fds[2], t_env env, t_ast *ast);

/*
** redir.c
*/

int					redir_extract(t_tok_lst **redirs, t_env env, int fds[2]);

#endif