summaryrefslogtreecommitdiffstats
path: root/linux/LinuxProcess.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2015-01-21 23:27:31 -0200
committerHisham Muhammad <hisham@gobolinux.org>2015-01-21 23:27:31 -0200
commit3383d8e5561dfc6fb2b65e0a194df94ccb5e08af (patch)
treedafba704561386b31b6b8af6dafb5b9a2ba7453c /linux/LinuxProcess.c
parent36b78328843d0dae0d0fadbd0e814a8a1546327c (diff)
Sorry about the mega-patch.
This is a work-in-progress, code is currently broken. (Some actions, and notably, the header, are missing.)
Diffstat (limited to 'linux/LinuxProcess.c')
-rw-r--r--linux/LinuxProcess.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c
index be4e627a..8a67f608 100644
--- a/linux/LinuxProcess.c
+++ b/linux/LinuxProcess.c
@@ -45,22 +45,23 @@ bool LinuxProcess_setIOPriority(LinuxProcess* this, IOPriority ioprio) {
return (LinuxProcess_updateIOPriority(this) == ioprio);
}
-void LinuxProcess_writeField(LinuxProcess* this, RichString* str, ProcessField field) {
+void Process_writeField(Process* this, RichString* str, ProcessField field) {
+ LinuxProcess* lp = (LinuxProcess*) this;
char buffer[256]; buffer[255] = '\0';
int attr = CRT_colors[DEFAULT_COLOR];
int n = sizeof(buffer) - 1;
switch (field) {
case IO_PRIORITY: {
- int klass = IOPriority_class(this->ioPriority);
+ int klass = IOPriority_class(lp->ioPriority);
if (klass == IOPRIO_CLASS_NONE) {
// see note [1] above
- snprintf(buffer, n, "B%1d ", (int) (this->super.nice + 20) / 5);
+ snprintf(buffer, n, "B%1d ", (int) (this->nice + 20) / 5);
} else if (klass == IOPRIO_CLASS_BE) {
- snprintf(buffer, n, "B%1d ", IOPriority_data(this->ioPriority));
+ snprintf(buffer, n, "B%1d ", IOPriority_data(lp->ioPriority));
} else if (klass == IOPRIO_CLASS_RT) {
attr = CRT_colors[PROCESS_HIGH_PRIORITY];
- snprintf(buffer, n, "R%1d ", IOPriority_data(this->ioPriority));
- } else if (this->ioPriority == IOPriority_Idle) {
+ snprintf(buffer, n, "R%1d ", IOPriority_data(lp->ioPriority));
+ } else if (lp->ioPriority == IOPriority_Idle) {
attr = CRT_colors[PROCESS_LOW_PRIORITY];
snprintf(buffer, n, "id ");
} else {
@@ -69,25 +70,26 @@ void LinuxProcess_writeField(LinuxProcess* this, RichString* str, ProcessField f
break;
}
default:
- snprintf(buffer, n, "- ");
+ Process_writeDefaultField(this, str, field);
+ return;
}
RichString_append(str, attr, buffer);
}
-long LinuxProcess_compare(const void* v1, const void* v2) {
+long Process_compare(const void* v1, const void* v2) {
LinuxProcess *p1, *p2;
- ProcessList *pl = ((Process*)v1)->pl;
- if (pl->direction == 1) {
+ Settings *settings = ((Process*)v1)->settings;
+ if (settings->direction == 1) {
p1 = (LinuxProcess*)v1;
p2 = (LinuxProcess*)v2;
} else {
p2 = (LinuxProcess*)v1;
p1 = (LinuxProcess*)v2;
}
- switch (pl->sortKey) {
+ switch (settings->sortKey) {
case IO_PRIORITY:
return LinuxProcess_effectiveIOPriority(p1) - LinuxProcess_effectiveIOPriority(p2);
default:
- return (p1->super.pid - p2->super.pid);
+ return Process_defaultCompare(v1, v2);
}
}