-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_ex.c
71 lines (62 loc) · 1.42 KB
/
utils_ex.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils_ex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rdanyell <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/01 16:15:18 by rdanyell #+# #+# */
/* Updated: 2022/06/17 13:26:02 by rdanyell ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int lstsize(t_com *lst)
{
int i;
i = 0;
if (lst)
{
while (lst)
{
i++;
lst = lst->next;
}
}
return (i);
}
int envsize(t_envp *lst)
{
int i;
i = 0;
if (lst)
{
while (lst)
{
i++;
lst = lst->next;
}
}
return (i);
}
int count_array(t_com *com)
{
int i;
i = 0;
while (com->arg[i])
i++;
return (i);
}
int count_pipes(t_com *com)
{
t_com *command;
int pipes;
pipes = 0;
command = com;
while (command)
{
if (command->delim == 1)
pipes++;
command = command->next;
}
return (pipes);
}