-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shell.h
74 lines (57 loc) · 1.89 KB
/
Shell.h
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
70
71
72
73
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: Shell.h
* Author: Benjamin
*
* Created on 22 février 2017, 10:38
*/
#ifndef SHELL_H
#define SHELL_H
#include <map>
#include <memory>
#include "Config.h"
namespace Spatch
{
namespace Ssh
{
class Client;
class Shell
{
public:
Shell(Spatch::Configuration::Config &conf, Spatch::Ssh::Client &client);
~Shell();
void onWelcome();
int onRead();
void printPrompt();
private:
typedef int(Spatch::Ssh::Shell::*parsingCallback)(std::istringstream &);
int writeString(const std::string &str);
void printHelp();
/*
* User parsing function
*/
int list(std::istringstream &);
int listAccesses();
int connect(std::istringstream &);
int top(std::istringstream &);
int help(std::istringstream &);
/*
* Admin parsing function
*/
int adminList(std::istringstream &);
int adminListServers();
int adminListUsers();
int adminListAccesses(std::istringstream &);
int reloadConfig(std::istringstream &);
Spatch::Configuration::Config &_conf;
Spatch::Ssh::Client &_client;
static std::map<std::string, parsingCallback> _commands;
static std::map<std::string, parsingCallback> _admincommands;
};
}
}
#endif /* SHELL_H */