summaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2015-08-20 00:32:47 -0300
committerHisham Muhammad <hisham@gobolinux.org>2015-08-20 00:32:47 -0300
commit9428010121d849344b33b66dec312b6a51ea564f (patch)
treeae4284959359c87a1748240e5a568742e7e1db00 /linux
parent8bd603cb68fb5dd768b5b23ffe0c6f09f5340ceb (diff)
Make column width calculation dynamic.
Closes #228.
Diffstat (limited to 'linux')
-rw-r--r--linux/LinuxProcess.c47
-rw-r--r--linux/LinuxProcess.h5
2 files changed, 14 insertions, 38 deletions
diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c
index 16e7f55b..fe2f6e18 100644
--- a/linux/LinuxProcess.c
+++ b/linux/LinuxProcess.c
@@ -217,40 +217,19 @@ ProcessFieldData Process_fields[] = {
[LAST_PROCESSFIELD] = { .name = "*** report bug! ***", .title = NULL, .description = NULL, .flags = 0, },
};
-char* Process_pidFormat = "%7u ";
-char* Process_tpgidFormat = "%7u ";
-
-void Process_setupColumnWidths() {
- int maxPid = Platform_getMaxPid();
- if (maxPid == -1) return;
- if (maxPid > 99999) {
- Process_fields[PID].title = " PID ";
- Process_fields[PPID].title = " PPID ";
- #ifdef HAVE_OPENVZ
- Process_fields[VPID].title = " VPID ";
- #endif
- Process_fields[TPGID].title = " TPGID ";
- Process_fields[TGID].title = " TGID ";
- Process_fields[PGRP].title = " PGRP ";
- Process_fields[SESSION].title = " SESN ";
- Process_fields[OOM].title = " OOM ";
- Process_pidFormat = "%7u ";
- Process_tpgidFormat = "%7d ";
- } else {
- Process_fields[PID].title = " PID ";
- Process_fields[PPID].title = " PPID ";
- #ifdef HAVE_OPENVZ
- Process_fields[VPID].title = " VPID ";
- #endif
- Process_fields[TPGID].title = "TPGID ";
- Process_fields[TGID].title = " TGID ";
- Process_fields[PGRP].title = " PGRP ";
- Process_fields[SESSION].title = " SESN ";
- Process_fields[OOM].title = " OOM ";
- Process_pidFormat = "%5u ";
- Process_tpgidFormat = "%5d ";
- }
-}
+ProcessPidColumn Process_pidColumns[] = {
+ { .id = PID, .label = "PID" },
+ { .id = PPID, .label = "PPID" },
+ #ifdef HAVE_OPENVZ
+ { .id = VPID, .label = "VPID" },
+ #endif
+ { .id = TPGID, .label = "TPGID" },
+ { .id = TGID, .label = "TGID" },
+ { .id = PGRP, .label = "PGRP" },
+ { .id = SESSION, .label = "SESN" },
+ { .id = OOM, .label = "OOM" },
+ { .id = 0, .label = NULL },
+};
ProcessClass LinuxProcess_class = {
.super = {
diff --git a/linux/LinuxProcess.h b/linux/LinuxProcess.h
index aa63b599..f2d81aa3 100644
--- a/linux/LinuxProcess.h
+++ b/linux/LinuxProcess.h
@@ -129,10 +129,7 @@ typedef struct LinuxProcess_ {
extern ProcessFieldData Process_fields[];
-extern char* Process_pidFormat;
-extern char* Process_tpgidFormat;
-
-void Process_setupColumnWidths();
+extern ProcessPidColumn Process_pidColumns[];
extern ProcessClass LinuxProcess_class;

© 2014-2024 Faster IT GmbH | imprint | privacy policy