forked from MaroIsLife/Minishell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_three.c
71 lines (64 loc) · 975 Bytes
/
main_three.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
#include "minishell.h"
int num_of_node(t_pipe *tmp)
{
int i;
i = 0;
while (tmp)
{
if (tmp->next == NULL)
return (i);
tmp = tmp->next;
i++;
}
return (i);
}
void freeList_pipe(t_pipe *head)
{
t_pipe *tmp;
int i;
int n;
n = num_of_node(head);
i = 0;
while (head != NULL)
{
write (2, "how here\n", 9);
tmp = head;
head = head->next;
free(tmp->cmd);
if (tmp->pipef)
free(tmp->pipef);
if (tmp->arg)
{
while (tmp->arg[i])
free(tmp->arg[i++]);
}
free(tmp->arg);
}
free(tmp);
}
char *get_x_env(char **envp, char *envv_name)
{
int i;
int b;
int c;
b = 0;
c = 0;
i = 0;
while (envp[i] != NULL)
{
if (ft_strncmp(envp[i], envv_name, ft_strlen(envv_name)) == 0
&& envp[i][ft_strlen(envv_name)] == '=')
return (ft_strrchr(envp[i], '=') + 1);
i++;
}
return (0);
}
void init(t_source *src)
{
src->founderror = 0;
src->offset = 0;
src->dquotes = 0;
src->squotes = 0;
src->aslash = 0;
src->offset = 0;
}