diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-01-28 18:19:38 +0100 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2021-01-29 14:12:44 +0100 |
commit | 3acf28c259f1a393badcc2e99c9646e19a911f98 (patch) | |
tree | 78ea9191604c1aca520d358af0927b2c007dbf78 /unsupported/UnsupportedProcess.c | |
parent | bd694c0ce60a60e29dc4ae22923f251fbd196332 (diff) |
Unsupported: pass compilation
Diffstat (limited to 'unsupported/UnsupportedProcess.c')
-rw-r--r-- | unsupported/UnsupportedProcess.c | 69 |
1 files changed, 60 insertions, 9 deletions
diff --git a/unsupported/UnsupportedProcess.c b/unsupported/UnsupportedProcess.c index 0f1f0f8c..4f77eee9 100644 --- a/unsupported/UnsupportedProcess.c +++ b/unsupported/UnsupportedProcess.c @@ -5,10 +5,16 @@ Released under the GNU GPLv2, see the COPYING file in the source distribution for its full text. */ -#include "Process.h" +#include "config.h" // IWYU pragma: keep + #include "UnsupportedProcess.h" + #include <stdlib.h> +#include "CRT.h" +#include "Process.h" + + const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = { [0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, }, [PID] = { .name = "PID", .title = "PID", .description = "Process/thread ID", .flags = 0, .pidColumn = true, }, @@ -37,17 +43,62 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = { [TGID] = { .name = "TGID", .title = "TGID", .description = "Thread group ID (i.e. process ID)", .flags = 0, .pidColumn = true, }, }; -Process* UnsupportedProcess_new(Settings* settings) { - Process* this = xCalloc(1, sizeof(Process)); - Object_setClass(this, Class(Process)); +Process* UnsupportedProcess_new(const Settings* settings) { + Process* this = xCalloc(1, sizeof(UnsupportedProcess)); + Object_setClass(this, Class(UnsupportedProcess)); Process_init(this, settings); return this; } -void UnsupportedProcess_delete(Object* cast) { - Process* this = (Process*) cast; - Object_setClass(this, Class(Process)); - Process_done((Process*)cast); +void Process_delete(Object* cast) { + Process* super = (Process*) cast; + Process_done(super); // free platform-specific fields here - free(this); + free(cast); +} + +static void UnsupportedProcess_writeField(const Process* this, RichString* str, ProcessField field) { + const UnsupportedProcess* up = (const UnsupportedProcess*) this; + bool coloring = this->settings->highlightMegabytes; + char buffer[256]; buffer[255] = '\0'; + int attr = CRT_colors[DEFAULT_COLOR]; + size_t n = sizeof(buffer) - 1; + + (void) up; + (void) coloring; + (void) n; + + switch (field) { + /* Add platform specific fields */ + default: + Process_writeField(this, str, field); + return; + } + RichString_appendWide(str, attr, buffer); +} + +static int UnsupportedProcess_compareByKey(const Process* v1, const Process* v2, ProcessField key) { + const UnsupportedProcess* p1 = (const UnsupportedProcess*)v1; + const UnsupportedProcess* p2 = (const UnsupportedProcess*)v2; + + (void) p1; + (void) p2; + + switch (key) { + /* Add platform specific fields */ + default: + return Process_compareByKey_Base(v1, v2, key); + } } + +const ProcessClass UnsupportedProcess_class = { + .super = { + .extends = Class(Process), + .display = Process_display, + .delete = Process_delete, + .compare = Process_compare + }, + .writeField = UnsupportedProcess_writeField, + .getCommandStr = NULL, + .compareByKey = UnsupportedProcess_compareByKey +}; |