-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree.h
More file actions
39 lines (31 loc) · 1.37 KB
/
tree.h
File metadata and controls
39 lines (31 loc) · 1.37 KB
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
#ifndef TREE_H
#define TREE_H
#include "list.h"
/* Тип команды для семантики */
typedef enum {
CMD_SIMPLE, /* простая команда */
CMD_PIPE, /* конвейер */
CMD_SEQ, /* cmd1 ; cmd2 */
CMD_BACKGROUND /* cmd & */
} CmdType;
/* Структура одной команды (узел дерева) */
typedef struct Command {
CmdType type;
/* Для простой команды */
char **argv; /* аргументы (NULL-терминированный массив) */
char *infile; /* переназначенный файл ввода */
char *outfile; /* переназначенный файл вывода */
int append; /* 1 если >> */
/* Для составных команд */
struct Command *left; /* левая часть (cmd1) */
struct Command *right; /* правая часть (cmd2) */
struct Command *pipe; /* следующая команда в конвейере */
struct Command *next; /* следующая команда после ; или & */
/* Фоновый режим */
int background;
} Command;
/* Функции для работы с деревом */
Command* parse_tokens(TokenList tokens);
void free_command(Command *cmd);
void print_command_tree(Command *cmd, int depth);
#endif