-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.h
More file actions
54 lines (39 loc) · 1.24 KB
/
Copy pathshell.h
File metadata and controls
54 lines (39 loc) · 1.24 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once
#include <queue>
using namespace std;
#define LINE_LEN 80
#define MAX_ARGS 64
#define MAX_ARG_LEN 16
#define MAX_PATHS 64
#define MAX_PATH_LEN 96
#define WHITESPACE " .,\t\n"
#define MAX_COMMAND 300
struct command_t
{
char* name;
int argc;
char** argv;
char* input;
char* output;
};
//recursive execution of commands in queue
void recCall(queue<char*>& q, command_t& command, char** dirs, int* inPipe);
//Execute commandLine with pipes
void pipedExecute(char* commandLine, command_t& command, char** dirs);
//execute single nonpiped command
void executeCommand(char* commandLine, command_t& command, char** dirs, int* inPipe, int* outPipe);
// print prompt for terminal
void printPrompt();
// takes input from the terminal
void readCommand(char*& buffer);
// returns array of directories to search
int parsePath(char* dirs[]);
// parses arguments and io redirection into command_t
void parseCommand(char* commandLine, command_t& command);
// parses IO redirection to command_t
void parseIO(char* commandLine, command_t& command);
bool checkAlphaNum(char n);
//returns absolute path of a command in **dirs
char* lookupPath(char** argv, char** dir);
//checks if command is internal
bool internalComm(command_t& command, char** dirs);