-
Notifications
You must be signed in to change notification settings - Fork 0
/
sub_main.c
81 lines (75 loc) · 2.2 KB
/
sub_main.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sub_main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zwalad <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/04 17:03:14 by zwalad #+# #+# */
/* Updated: 2022/08/25 16:04:03 by zwalad ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
t_list *pipe_pipe(t_list *p)
{
p->m->val[p->m->j] = NULL;
p->m->inf[p->m->ii] = NULL;
p->m->ouf[p->m->oo] = NULL;
p->m->open[p->m->op] = ZERO;
p->m->her[p->m->hr] = NULL;
p->i++;
p->i = skip_space(p->line, p->i);
p->m = addlast_node(&p->m, new_node(p));
p->m = p->m->next;
p->m->next = NULL;
return (p);
}
t_mini *sf_salaw(t_mini *tmp, t_list *p)
{
p->m->val[p->m->j] = NULL;
p->m->inf[p->m->ii] = NULL;
p->m->ouf[p->m->oo] = NULL;
p->m->open[p->m->op] = ZERO;
p->m->her[p->m->hr] = NULL;
p->m->next = NULL;
p->m = tmp;
return (p->m);
}
t_list *parser_v2(t_list *p)
{
while (p->error != 1 && p->line[p->i])
{
p->i = skip_space(p->line, p->i);
if (p->line[p->i] != '<' && p->line[p->i] != '>'
&& p->line[p->i] != '|'
&& p->error != 1)
p = grep_command(p);
if ((p->line[p->i] == '<' || p->line[p->i] == '>')
&& p->error != 1)
p = grep_files(p);
if (p->line[p->i] == '|' && p->error != 1)
p = pipe_pipe(p);
if ((p->line[p->i] == '"' || p->line[p->i] == '\'')
&& p->error != 1)
p = qts_help(p);
}
return (p);
}
t_list *parser(t_var *var, t_list *p)
{
t_mini *tmp;
p->var = var;
struct_init(p);
tmp = p->m;
if (p->ext != 1 && p->errorx != 1)
{
if (p->error != 1)
{
p->m->j = 0;
p = parser_v2(p);
p->m = sf_salaw(tmp, p);
}
free(p->line);
}
return (p);
}