69 lines
1.4 KiB
C++
69 lines
1.4 KiB
C++
#ifndef SHELL_H
|
|
#define SHELL_H
|
|
#include <iostream>
|
|
#include <sys/wait.h>
|
|
#include <unistd.h>
|
|
#include <cstdlib>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <cstring>
|
|
#include <vector>
|
|
#include <csignal>
|
|
#include "command.h"
|
|
using std::string;
|
|
using std::cin;
|
|
using std::cout;
|
|
using std::cerr;
|
|
using std::string;
|
|
using std::vector;
|
|
using std::istringstream;
|
|
using std::nullptr_t;
|
|
|
|
class Shell
|
|
{
|
|
class Commands
|
|
{
|
|
vector<Command*> commands;
|
|
static bool created;
|
|
Commands(Commands&);
|
|
public:
|
|
Commands();
|
|
void add(Command*);
|
|
size_t howMany();
|
|
int launch(const vector<string>* args);
|
|
};
|
|
|
|
static bool undoingLine;
|
|
Commands cmds;
|
|
string ps;
|
|
string name;
|
|
void (*shellSetup)(Shell *);
|
|
bool notLoop;
|
|
|
|
int launch(vector<string>* args);
|
|
int execute(vector<string>* args);
|
|
static void EofHandler(int);
|
|
string* read_line();
|
|
vector<string>* split_line(string* line);
|
|
|
|
class IsUndoingLineException {};
|
|
|
|
public:
|
|
Shell( string n="msh", string ps="MSH$",void (*s)(Shell*)=0);
|
|
string getPs() const;
|
|
void setPs(const string &value);
|
|
string getName() const;
|
|
void setName(const string &value);
|
|
void launch();
|
|
|
|
//for in-shell commands
|
|
void addCmd(Command *cmd);
|
|
size_t howManyCmds();
|
|
|
|
//exceptions
|
|
class CommandsAlreadyCreatedException{};
|
|
class CommandNotFoundException{};
|
|
class ShellLaunchInSetupException{};
|
|
};
|
|
|
|
#endif // SHELL_H
|