aboutsummaryrefslogtreecommitdiff
path: root/include/ms_eval.h
blob: 12c2b7e16b3713c05631e52726ef076d38277622 (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
#ifndef MS_EVAL_H
# define MS_EVAL_H

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

/*
** arg:
**   type ARG
**   value string
**
** redir in:
**   type REDIRIN
**   value fd
**
** redir out:
**   type REDIROUT
**   value fd
**
** redir append:
**   type REDIRAPPEND
**   value fd
*/

/**
** \enum t_val_type
** \brief  A type for an evaluation node
**
** \param VAL_ERR error
** \param VAL_ERR argument
** \param VAL_REDIR redirection
** \param VAL_SEXPR S-expression
*/

typedef enum
{
	VAL_ERR,
	VAL_ARG,
	VAL_EXEC,
	VAL_REDIR_IN,
	VAL_REDIR_OUT,
	VAL_REDIR_APPEND,
	VAL_CMD,
	VAL_SEXPR,
}				t_val_type;

/**
** \brief            An evaluation node struct
** \param type       type of node
** \param data       union of possible data
** \param data::fd   file descriptor for redirection node
** \param data::str  string for error, arguments, command
*/

typedef struct
{
	t_val_type	type;
	union
	{
		char	*str;
		int		code;
		int		fd;
	}			data;
}				t_val;

/**
** \brief  evaluate an AST
** \param path  path to commands executable
** \param env   environment variables
** \param ast   Abstract syntax tree to evaluate
*/
int				ms_eval(t_path path, t_env env, t_ast *ast);

#endif