forked from kyomawolf/minishell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DEBUG_print.c
63 lines (57 loc) · 1.63 KB
/
DEBUG_print.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* DEBUG_print.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mstrantz <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/12 18:31:46 by jkasper #+# #+# */
/* Updated: 2021/12/23 22:55:51 by mstrantz ### ########.fr */
/* */
/* ************************************************************************** */
#include "struct.h"
#include <stdio.h>
void print_chars(int amount, char c)
{
while (amount > 0)
{
printf("%c", c);
amount--;
}
}
void print_command(t_simple_com *com)
{
int i;
i = 0;
printf("|");
if (com->arguments == NULL)
printf(" (NEXT)");
else
{
while (com->arguments[i] != NULL)
printf(" %s ", com->arguments[i++]);
}
printf("\n");
}
void print_binary_tree(t_bin *prin, int dep)
{
int i;
i = 0;
if (prin->child != NULL)
{
while (prin->child[i] != NULL)
{
if (prin->child[i]->child != NULL)
print_binary_tree(prin->child[i], dep + 1);
else
{
print_chars(dep, '\t');
if (prin->child[i]->command->arguments == NULL)
printf("NULL\n");
else
print_command(prin->child[i]->command);
}
i++;
}
}
}