summaryrefslogtreecommitdiffstats
path: root/src/s_struct.h
blob: ee70a317bc0d6dc87902f9a4c2b977ee24e739c9 (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
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
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   s_struct.h                                         :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */
/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */
/*                                                                            */
/* ************************************************************************** */

#ifndef S_STRUCT_H
# define S_STRUCT_H

# include <stddef.h>
# ifdef __linux__
#  include <linux/limits.h>
# else
#  include <limits.h>
# endif

# include "d_define.h"

typedef struct			s_lvars
{
	char				*name;
	char				*val;
	struct s_lvars		*next;
}						t_lvars;

typedef struct			s_lalias
{
	char				*name;
	char				*val;
	size_t				id;
	struct s_lalias		*next;
}						t_lalias;

/*
** redir(char) index
** -------------------
** -3: <<-
** -2: <<
** -1: <
**  1: >
**  2: >>
**  3: >&
**  0: means no redirection
*/

typedef struct			s_lredir
{
	char				path[PATH_MAX];
	char				*heredoc;
	int					fd;
	int					right_fd;
	char				redir;
	struct s_lredir		*next;
}						t_lredir;

typedef struct			s_com
{
	char				**argv;
	char				**env_fork;
	char				*bin;
	struct s_lredir		*rdr;
}						t_com;

struct					s_lpipes
{
	struct s_com		*com;
	struct s_lpipes		*next;
};

/*
** nextif(unsigned char) index
** ---------------------
** 0: ;
** 1: &&
** 2: ||
*/

typedef struct			s_line_block
{
	char				*lblock;
	unsigned char		nextif;
	struct s_line_block	*next;
}						t_line_block;

typedef struct			s_msh
{
	struct s_line_block	*curr;
	struct s_com		*com;
	struct s_lpipes		*pipes;
	struct s_lvars		*vars;
	struct s_lalias		*alias;
	int					argc;
	char				**argv;
	char				**envp;
	char				*prev_hist;
	char				*curr_hist_ptr;
	char				ps[4][255];
	char				env_fork_tmp[128][4096];
	char				sqb_ref[B_ID_SQB_COUNT][4];
	char				*cwd;
	int					fd;
	unsigned char		(*bu_ptr[B_BUILTINS_COUNT])(char **, struct s_msh*);
	unsigned char		ret;
}						t_msh;

#endif