-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
92 lines (78 loc) · 2.16 KB
/
main.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
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
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdio.h>
#include <unistd.h>
using namespace std;
namespace Color {
enum Code {
FG_LIME = 46,
FG_DARKGREEN = 22,
FG_GREEN = 76,
FG_DARKYELLOW = 172,
FG_YELLOW = 226,
FG_LIGHTYELLOW = 226,
FG_DARKRED = 88,
FG_RED = 160,
FG_LIGHTRED = 196,
FG_PURPLE = 129,
FG_DARKPURPLE = 89,
FG_LIGHTPURPLE = 171,
FG_PINK = 219,
FG_LIGHTPINK = 201
};
}
int main(int argc, char* argv[]) {
if(isatty(fileno(stdin))){
std::cout << "You can run this only using pipe!";
return 1;
}
string open = "\33[38;5;" + to_string(Color::FG_LIME) + "m";
string filtered = "\33[38;5;" + to_string(Color::FG_YELLOW) + "m";
string closed ="\33[38;5;" + to_string(Color::FG_RED) + "m";
string pink = "\33[38;5;" + to_string(Color::FG_PURPLE) + "m";
string def = "\33[0m";
int c;
string sScanOutput = "";
while((c = getc(stdin)) != EOF) { sScanOutput += char(c); }
string line;
stringstream ssScanOutput(sScanOutput);
bool firstChar = true;
while(getline(ssScanOutput, line, '\n')){
if(line.find("open") != string::npos){
cout << open << line << def << endl;
continue;
}
if(line.find("filtered") != string::npos){
cout << filtered << line << def << endl;
continue;
}
size_t pos1 = line.find("|");
size_t pos2 = line.find(":");
vector<char> v = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
'!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
'-', '_', '=', '+', '[', ']', '{', '}', '\\', '|',
';', ':', '\'', '"', ',', '<', '.', '>', '/', '?',
'`', '~'};
if((line.find("|") != string::npos) && (line.find(":") != string::npos)){
firstChar = true;
for(int i = 0; i < line.size(); i++){
if(i >= pos1 && i <= pos2 && firstChar == false && line.find("(RSA)") == string::npos && line.find("(ECDSA)") == string::npos && line.find("(ED25519)") == string::npos){
cout << pink << line[i] << def;
} else {
cout << def << line[i];
}
firstChar = false;
}
cout << endl;
continue;
} else {
cout << def << line << endl;
}
}
return 0;
}