-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparsing.c
More file actions
94 lines (83 loc) · 2.08 KB
/
Copy pathparsing.c
File metadata and controls
94 lines (83 loc) · 2.08 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
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fbouibao <fbouibao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/05/14 15:51:19 by ssamadi #+# #+# */
/* Updated: 2021/06/05 15:24:41 by fbouibao ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell_hr.h"
void free_ags(t_commands *commands)
{
int i;
i = -1;
if (commands->arguments == NULL)
return ;
while (commands->arguments[++i])
{
free(commands->arguments[i]);
}
free(commands->arguments);
free(commands->all);
}
void free_files_rder(t_commands *commands)
{
t_filerdr *tmp;
while (1)
{
if (commands->filerdr)
tmp = commands->filerdr->next;
else
break ;
free(commands->filerdr->name);
free(commands->filerdr);
commands->filerdr = tmp;
}
}
void free_node(t_commands *commands)
{
t_commands *tmp;
while (1)
{
if (commands)
tmp = commands->next_p;
else
break ;
free(commands->path);
free(commands->type);
free(commands->command);
free_ags(commands);
free_files_rder(commands);
free(commands);
commands = tmp;
}
}
void free_list(t_commands *commands)
{
t_commands *tmp;
while (1)
{
if (commands)
tmp = commands->next;
else
break ;
free_node(commands);
commands = tmp;
}
}
void parssing_shell(char *ptr, t_env *evp, char *cmds)
{
char *buf;
t_commands *commands;
buf = NULL;
commands = new_commands();
ptr = getcwd(buf, 1024);
evp->ptr = ptr;
get_commands(evp, &commands, cmds);
free(buf);
free(ptr);
free_list(commands);
}