forked from sruthi2498/MyShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
all_include.h
105 lines (77 loc) · 2.37 KB
/
all_include.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <time.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "simple_command_functions.h"
#include "command_functions.h"
#include "helper_to_parser.h"
#include "alias_functions.h"
#include "arrow.h"
#include "stack.h"
#include "edit.h"
#define MAX_NUMBER_OF_SIMPLE_COMMANDS 10
#define MAX_NUMBER_OF_ARGUMENTS 10
#define MAX_LEN_OF_ARG 20
#define MAX_CHAR_SIZE_OF_COMMAND 100
#define MAX_CHAR_SIZE_OF_SIMPLECOMMAND 10
#define WRITE_SIZE 250
#define STACK_SIZE 25 //max history allows up to 50 commands
#define STACK_ELEM_SIZE 100 //size of each elem in the stack
#define ALIAS_TABLE_SIZE 50
#define PROMPT_SIZE 100
int sc;
int comm;
int Top;
int HistoryPointer;
struct stack_elem{
//actual command
char * command;
//pid for the process
int pid;
//time at which command was run
char * time_str;
};
struct stack_elem stack[STACK_SIZE];
struct Aliastruct{
char * aliasname;
char * command;
}AliasTable[ALIAS_TABLE_SIZE];
int counter;
// Describes a simple command and arguments
struct SimpleCommand {
// Available space for arguments currently preallocated
int _numberOfAvailableArguments;
// Number of arguments
int _numberOfArguments;
// Array of arguments
char ** _arguments;
};
// Describes a complete command with the multiple pipes if any
// and input/output redirection if any.
struct Command {
int _numberOfAvailableSimpleCommands;
int _numberOfSimpleCommands;
//array of simple commands
struct SimpleCommand _simpleCommands[MAX_NUMBER_OF_SIMPLE_COMMANDS];
//variables _outFile, _inputFile, _errFile
// ->will be NULL if no redirection was done
// ->or the name of the file they are being redirected to
char * _outFile;
char * _inputFile;
char * _errFile;
int flag_for_outfile;
// 1 : ls > list : If file exists it'll be replaced.
// 2 : ls >> list :If file not exists it'll be created. If it exists, it'll be appended to the end of file.
int _background;
};
struct Command CurrentCommand;
struct SimpleCommand CurrentSimpleCommand;
char** parsed_arg;
char** parsed_final_arg;
int count_arg;
char * Prompt;