-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasic.h
More file actions
executable file
·69 lines (55 loc) · 1.56 KB
/
basic.h
File metadata and controls
executable file
·69 lines (55 loc) · 1.56 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* The basic functions and data structure for the shell */
#ifndef STRUCTURE_H
#define STRUCTURE_H
#include "common.h"
#include <list>
#include <string.h>
void init_shell();
enum CommandType{
CD,
EXIT,
JOBS,
FG,
BG,
NON_BUILT_IN,
EMPTY
};
class Command{
public:
std::string name;
std::list<std::string> parameters;
CommandType type;
bool is_process; /* true if this is a external command */
bool completed = 0;
bool stopped = 0;
pid_t pid; /* process id */
int status;
Command(): pid(0) {}
Command(char *name): pid(0){
this->name = name;
}
/* helper functions */
void add_parameter(std::string p);
void show_parameters();
CommandType check_type();
size_t parameter_len();
};
class Job{
public:
std::string command_line;
std::list<Command> commands;
std::string status;
bool is_bg; /* the job is in background or not */
pid_t pgid; /* process group ID */
struct termios tmodes; /* saved terminal modes*/
Job* next; /* point to next job */
bool is_notified; /* be true is has been notified to user, otherwise before each
prompt a notification for stopped job will be given*/
Job(): pgid(0), next(NULL){
status = "Running";
is_notified = false;
}
bool is_completed(); /* check whether the job is completed */
bool is_stopped(); /* check whether the job is stopped */
};
#endif