-
Notifications
You must be signed in to change notification settings - Fork 0
/
command_handler.h
55 lines (38 loc) · 1.89 KB
/
command_handler.h
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
#ifndef COMMAND_HANDLER_H
#define COMMAND_HANDLER_H 1
#include "command.h"
/* FINITE STATE MACHINE STATES for parsing the shell command */
#define START (100)
#define COMMAND (200)
#define PIPE (300)
#define INPUT_REDIRECT (400)
#define OUTPUT_REDIRECT (500)
#define NON_BLOCKING_COMMAND (600)
#define END (700)
#define INVALID (-1)
typedef struct IOContext {
int stdout_fileno, stdin_fileno;
} IOContext;
/* parser for shell command arguments */
int command_argument_parser(IronShellCommand *sh_command);
/* reads the mulitple shell command from user */
int read_command(char *command_buffer, int max_command_length);
/* returns the shell delimiter state */
int get_shell_delimiter_state(char shell_delimiter);
/* checks if the given character is shell delimiter */
bool check_shell_delimiter(char ch);
/* parser for the multiple shell commads */
int parser(char *token, char *command);
/* FSM based approach for command handler */
void command_handler(char *command_buffer);
/* function executes the iron shell commands concurrently without blocking
* the shell prompt with the sense of background process
*/
void execute_shell_command(IronShellCommand shell_command);
/* function executes the iron shell command connecting to a pipe */
void execute_shell_command_with_pipe(IronShellCommand shell_command, int pfd[]);
/* saves the current context of the standard file descripters */
void save_io_context();
/* restores the context of the standard IO file descripter */
void restore_io_context();
#endif /* COMMAND_HANDLER_H */