-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_print_res.c
55 lines (52 loc) · 1.22 KB
/
ft_print_res.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
#include "ft_ls.h"
void ft_printtotal(t_linfo *lst) /// Done
{
int total;
total = 0;
while (lst != NULL && lst->l_name != NULL)
{
total += lst->l_mblock;
lst = lst->next;
}
printf("total %d\n",total);
}
void ft_printlst(t_linfo *lst, int i_rtn) /// Done
{
if (i_rtn != 1)
printf("%s ",lst->l_name);
else
{
printf("%s\t", lst->l_per);
printf("%d\t", lst->l_nbrl);
printf("%s ", lst->l_owner);
printf("%s\t", lst->l_groupe);
if (lst->l_size2 == -1)
printf("%d\t", lst->l_size);
else
printf("%d , %d\t", lst->l_size, lst->l_size2);
printf("%s\t", lst->l_strtm);
printf("%s ", lst->l_name);
printf("\n");
}
}
int ft_printres(t_linfo **lst, t_sub **sub_lst, char *opt , int p_type) /// Done
{
int rtn;
int i_rtn;
t_linfo *temp_lst;
if (lst != NULL)
temp_lst = *lst;
rtn = 0;
rtn = ft_applopt(&temp_lst, sub_lst, opt, p_type); //// Apply opt
i_rtn = ft_checkchar(opt, 'l');
if (p_type == 1 && i_rtn == 1 && (*lst) != NULL) //// print Total
ft_printtotal(*lst);
while (p_type == 1 && temp_lst != NULL && temp_lst->l_name != NULL /*&& rtn != -1*/)
{
ft_printlst(temp_lst, i_rtn); //// print result
temp_lst = temp_lst->next;
}
if (p_type == 1 && i_rtn == 0)
puts("\n");
return (0);
}