Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
yabtaour
GitHub Repository: yabtaour/Minishell-42
Path: blob/main/execution/my_mess/counting_funcs.c
1407 views
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* counting_funcs.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: ssabbaji <[email protected]> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2022/08/09 14:48:15 by ssabbaji #+# #+# */
9
/* Updated: 2022/09/20 16:28:13 by ssabbaji ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include "../../minishell.h"
14
15
int count_cmds(char **cmd)
16
{
17
char **tmp;
18
int i;
19
20
i = 0;
21
tmp = cmd;
22
while (tmp[i])
23
{
24
if (tmp)
25
i++;
26
}
27
return (i);
28
}
29
30
int c_lstcmd(t_data *data)
31
{
32
t_cmd *lst;
33
int i;
34
35
i = 0;
36
lst = data->lst_cmd;
37
while (lst)
38
{
39
i++;
40
lst = lst->next;
41
}
42
return (i);
43
}
44
45
int count_pipes(t_data *data)
46
{
47
int i;
48
int count;
49
char **cmd;
50
51
cmd = data->lst_cmd->cmd;
52
i = 0;
53
count = 0;
54
while (cmd[i])
55
{
56
if (ft_strcmp(*cmd, "|") == 0)
57
count++;
58
i++;
59
}
60
return (count);
61
}
62
63