-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskClass.cpp
More file actions
104 lines (99 loc) · 3.15 KB
/
Copy pathTaskClass.cpp
File metadata and controls
104 lines (99 loc) · 3.15 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
97
98
99
100
101
102
103
104
#include <ServiceClass.h>
//#include <MenuClass.h>
//#include <WinClass.h>
#include <MenuWinClass.h>
#include <TaskClass.h>
#include <Info.h>
using namespace std;
TaskClass *TaskClass_TC = new TaskClass();
ServiceClass *ServiceClass_TC = new ServiceClass();
MenuWinClass *MenuWinClass_TC = new MenuWinClass();
volatile int signal_flag;
/*##########################################################################*/
int TaskClass::ZahlenWerk(int zahlen, string i, int max) {
int tmp = 0;
if (strcmp(i.c_str(), "++") == 0) {
if (zahlen >= max) {
tmp = 1;
} else if (zahlen == 0) {
tmp = 1;
} else if (zahlen > 0) {
tmp = ++zahlen;
} else if (zahlen < max) {
tmp = ++zahlen;
}
} else if (strcmp(i.c_str(), "--") == 0) {
if (zahlen <= 0) {
tmp = max;
} else if (zahlen == 1) {
tmp = max;
} else if (zahlen > 1) {
tmp = --zahlen;
} else if (zahlen <= max) {
tmp = --zahlen;
}
} else {
tmp = 1;
}
return tmp;
}
int TaskClass::Zeilen(string data, int maxbreite) {
int rownr = 0;
double zeiBr = (data.length() / static_cast<double>(maxbreite));
int zeiBr2;
stringstream datast(data);
string line;
for (rownr = 0; std::getline(datast, line); ++rownr) {}
zeiBr2 = static_cast<int>(ceil(zeiBr));
return (rownr + zeiBr2);
}
std::vector<std::string> TaskClass::StringTeiler(const std::string& str, char delimiter) {
std::istringstream is(str);
std::vector<std::string> result;
for (std::string cur; std::getline(is, cur, delimiter); result.push_back(cur));
return result;
}
string TaskClass::TERM_AUSGABE(string cmd) {
//cmd = "systemctl list-unit-files -t service | grep '.service' | awk '{$1=$1};1' | sort";
string data;
FILE* stream;
char buffer[BUFSIZE];
cmd.append(" 2>/dev/null"); //2>&1
stream = popen(cmd.c_str(), "r");
if (stream) {
while (!feof(stream)) {
if (fgets(buffer, BUFSIZE, stream) != nullptr) {
data.append(buffer);
}
}
pclose(stream);
}
memset(buffer, 0, BUFSIZE);
return data;
}
WINDOW* TaskClass::ClearWindow(WINDOW* TEMPWINDOW) {
clearok(TEMPWINDOW, true);
return TEMPWINDOW;
}
int TaskClass::WinFullSize(WINDOW* TmpWin, int WHCRXY, string WorH) {
if (WorH.compare("W") == 0) {
if (MenuWinClass_TC->START.WinSize.WCX_TmpWinReal(TmpWin) <= WHCRXY) {
return WHCRXY;
} else {
return MenuWinClass_TC->START.WinSize.WCX_TmpWinReal(TmpWin);
}
} else if (WorH.compare("H") == 0) {
if (MenuWinClass_TC->START.WinSize.HRY_TmpWinReal(TmpWin) <= WHCRXY) {
return WHCRXY;
} else {
return MenuWinClass_TC->START.WinSize.HRY_TmpWinReal(TmpWin);
}
}
}
/*##########################################################################*/
TaskClass::TaskClass() {
//TaskClass::DateTime.TIMEFIELD(MenuPtr->MENEU.HMWin,MenuWinClass_TC->WinSize.WCX);
}
TaskClass::~TaskClass() {
}
/*##########################################################################*/