msh-console/shell.h

50 lines
1 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 <commands.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
{
static bool undoingLine;
Commands cmds;
string ps;
string name;
void (*shellSetup)(Shell *);
class IsUndoingLineException {};
int launch(vector<string>* args);
int execute(vector<string>* args);
static void EofHandler(int);
string* read_line();
vector<string>* split_line(string* line);
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 loop();
//for in-shell commands
void addCmd(Command *cmd);
size_t howManyCmds();
};
#endif // SHELL_H