diff options
Diffstat (limited to 'cmd.h')
-rw-r--r-- | cmd.h | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -1,16 +1,21 @@ | |||
1 | #ifndef CMD_H | 1 | #ifndef CMD_H |
2 | #define CMD_H | 2 | #define CMD_H |
3 | 3 | ||
4 | #include <pwd.h> | ||
4 | #include <stdbool.h> | 5 | #include <stdbool.h> |
5 | #include <stdio.h> | 6 | #include <stdio.h> |
6 | #include <stdlib.h> | 7 | #include <stdlib.h> |
7 | #include <string.h> | 8 | #include <string.h> |
9 | #include <sys/types.h> | ||
10 | #include <sys/wait.h> | ||
11 | #include <unistd.h> | ||
12 | #include <fcntl.h> | ||
8 | 13 | ||
9 | typedef enum { | 14 | typedef enum { |
10 | CMD_TYPE_NORMAL, | 15 | CMD_NORMAL, |
11 | CMD_TYPE_PIPE, | 16 | CMD_PIPE, |
12 | CMD_TYPE_AND, | 17 | CMD_AND, |
13 | CMD_TYPE_OR, | 18 | CMD_OR, |
14 | // add more command types as needed | 19 | // add more command types as needed |
15 | } CommandType; | 20 | } CommandType; |
16 | 21 | ||
@@ -20,9 +25,13 @@ typedef struct Command { | |||
20 | int argc; | 25 | int argc; |
21 | struct Command *left; // a pointer to the left sub-command | 26 | struct Command *left; // a pointer to the left sub-command |
22 | struct Command *right; // a pointer to the right sub-command | 27 | struct Command *right; // a pointer to the right sub-command |
28 | int redirectFD[3]; | ||
29 | char *redirectFile[3]; | ||
30 | bool background; | ||
23 | } Command; | 31 | } Command; |
24 | 32 | ||
25 | Command* newcmd(); | 33 | void showPrompt(); |
34 | Command *newcmd(); | ||
26 | int runcmd(Command *cmd); | 35 | int runcmd(Command *cmd); |
27 | void freecmd(Command *cmd); | 36 | void freecmd(Command *cmd); |
28 | void printcmd(Command *cmd); | 37 | void printcmd(Command *cmd); |