-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSMBIOS Parser.cpp
55 lines (50 loc) · 1.7 KB
/
SMBIOS Parser.cpp
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
// SMBIOS Parser.cpp : This file contains the 'main' function. Program execution begins and ends there.
#include <string>
#include "Functions.h"
void displayCommands() {
std::cout << "cmds: Display available commands" << std::endl;
std::cout << "all: Display all structures" << std::endl;
std::cout << "table: Display structure table" << std::endl;
std::cout << "hex: Display the SMBIOS table bytes in hex" << std::endl;
std::cout << "<id>: Display the structure with the given ID" << std::endl;
std::cout << "quit: Exit the program" << std::endl;
}
int main() {
RawSMBIOSData* rawData = getRawData();
displayCommands();
std::cout << "> ";
std::string input;
while (std::cin >> input) {
if (input.compare("quit") == 0) {
return 0;
}
else if (input.compare("hex") == 0) {
displayHexContents(rawData);
}
else if (input.compare("all") == 0) {
displayAllStructures(rawData);
}
else if (input.compare("table") == 0) {
displayStructureTable(rawData);
}
else if (input.compare("cmds") == 0) {
displayCommands();
}
else {
try {
int index = std::stoi(input);
if (index < 0 || index >= getStructureTable(rawData).size()) {
std::cout << "ERROR: Out of bounds" << std::endl;
}
else {
displayStructure(rawData, index);
}
}
catch (std::exception& e) {
std::cout << "ERROR: Invalid command" << std::endl;
}
}
std::cout << "> ";
}
return 0;
}