Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 69 lines (55 sloc) 1.56 KB
/* 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
You can’t perform that action at this time.