-
Notifications
You must be signed in to change notification settings - Fork 0
/
print.c
71 lines (65 loc) · 2.06 KB
/
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
64
65
66
67
68
69
70
71
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* print.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zhabri <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/05 13:24:06 by zhabri #+# #+# */
/* Updated: 2023/01/12 15:21:09 by zhabri ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void print_label(t_label label)
{
printf("Operator: ");
if (label == INFILE)
printf("INFILE\n");
if (label == OUTFILE)
printf("OUTFILE\n");
if (label == PIPE)
printf("PIPE\n");
if (label == OUTFILE_A)
printf("OUTFILE (Append)\n");
if (label == HEREDOC)
printf("HEREDOC\n");
if (label == VARIABLE)
printf("VARIABLE\n");
if (label == UNKNOWN)
printf("UNKNOWN\n");
}
void print_cmds(void)
{
t_list *cmd;
if (g_glob->cmds)
{
cmd = *g_glob->cmds;
while (cmd)
{
if (cmd->content)
{
printf("cmd_idx: %i\n", (((t_cmd *)cmd->content)->cmd_idx));
printf("fd_in: %i\n", (((t_cmd *)cmd->content)->fd_in));
printf("fd_out: %i\n", (((t_cmd *)cmd->content)->fd_out));
if (!(((t_cmd *)cmd->content)->str))
printf("cmd is NULL\n");
else
printf("cmd: %s\n", (((t_cmd *)cmd->content)->str));
}
cmd = cmd->next;
}
}
}
void print_nodes(void *n)
{
t_token *node;
node = (t_token *)n;
printf("-------------\n");
printf("TOKEN %d\n", node->idx);
print_label(node->label);
printf("Input: \"%s\"\n", node->str);
printf("At idx %d\n", node->str_idx);
printf("Arg is %s\n", node->arg);
printf("-------------\n");
printf("\n");
}