-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtoyshell.h
91 lines (80 loc) · 1.91 KB
/
toyshell.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
#include <string>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
using namespace std;
extern char **environ;
struct command{
int size;
char **token;
};
struct job{
int jobId;
int processId;
string line;
struct tm * timeInfo;
};
class ToyShell
{
public:
ToyShell();
~ToyShell();
void tokenize( string command);
void tokenizeTemp( string command);
void tokenizePath( char* command);
bool alias();
int getHistoryCommand(string line);
void saveHistory();
int execute();
string errorMessage(int status);
int unixCommand();
void unixExecution(string spath);
int aliasLimit;
int aliasSizeX;
//string original;
string name;
int count;
string terminator;
string scriptName;
string pScriptName;
command * workCommand;
command * tempCommand;
command * path;
int jobLimit;
int jobSize;
int jobStored;
job * jobs;
string oldpwd;
string storedA[10][2];
string * history;
int historySize;
int historyArraySize;
int input;
int output;
int aInput;
int aOutput;
void increaseCount();
private:
void setShellName(string newName);
void setShellTerminator(string newTerminator);
void outputHistory();
void newAlias();
void outputAlias();
int saveAlias(string fileName);
int readAlias(string fileName);
void storeBackJob(int processId);
void backJobs();
void frontJob(string);
int cull(string);
void backCommand();
bool condition();
int conditionHelper(bool);
void changeDirectories();
string checkPath(string);
int executeScript();
int piping();
int inputFile(string);
int outputFile(string);
int subProcess(string path, int inputStream);
};