-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
96 lines (79 loc) · 2.47 KB
/
main.cpp
File metadata and controls
96 lines (79 loc) · 2.47 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <iostream>
#include <fstream>
#include <string>
#include "terminal/users/userreg.h"
//#include "terminal/cmdmode/mode.h"
#define MAX_CHAR 4
class comn {
public:
std::string core1[MAX_CHAR];
char parametrs[1];
int parametrs1;
int parametrs2;
};
extern "C" void terminal() {
std::string logfileopen;
std::string cmd;
comn cmdsys;
cmdsys.core1[0] = "version";
cmdsys.core1[1] = "log";
cmdsys.core1[2] = "systeminfo";
cmdsys.core1[3] = "clear ";
std::ofstream log("log_file.log", std::ios::app);
if (log.is_open()) {
while (true) {
std::cout << "C::" /*<< name_user*/ << "ALPHA/> ";
std::getline(std::cin, cmd);
if (cmd == cmdsys.core1[0]) {
std::cout << " Version 1.0.0\n code: _Lite_" << std::endl;
log << "USERS: " << cmd << " -- command complete!" << std::endl;
}
else if (cmd == "help") {
for (int i = 0; i <= MAX_CHAR; i++) {
std::cout << cmdsys.core1[i] << std::endl;
if (i == MAX_CHAR) {terminal();}
}
}
else if (cmd == cmdsys.core1[1]) {
std::ifstream logscript("log_file.log");
std::cout << "Log:" << std::endl;
if (logscript.is_open()) {
while (std::getline(logscript, logfileopen)) {
std::cout << logfileopen << std::endl;
}
}
logscript.close();
log << "USERS:" << cmd << " -- command complete!" << std::endl;
}
else if (cmd == cmdsys.core1[2]) {
std::cout << "Function is not released!" << std::endl;
}
else if (cmd == "exit") {
std::cout << "Closing terminal..." << std::endl;
log << "USERS: " << cmd << " -- command complete!" << std::endl;
break;
return;
}
else if (cmd == cmdsys.core1[3]) {
std::cout << "test" << std::endl;
}
else if (cmd == "cmd_mode") {
// mode();
std::cout << "Function is not released!" << std::endl;
}
else {
std::cout << "Command not found" << std::endl;
log << "USERS: " << cmd << " -- command not found" << std::endl;
}
}
}
else {
std::cout << "TerminalShell error! Log file not report" << std::endl;
}
log.close();
}
int main() {
usrreg();
terminal();
return 0;
}