From ff9409b1737627857eb47f64f536a3f66b6a09a4 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 11 Apr 2016 13:01:07 +0200 Subject: Imported Upstream version 2.0.0 --- unsupported/Battery.c | 8 +++ unsupported/Battery.h | 9 +++ unsupported/Platform.c | 136 +++++++++++++++++++++++++++++++++++ unsupported/Platform.h | 46 ++++++++++++ unsupported/UnsupportedCRT.c | 21 ++++++ unsupported/UnsupportedCRT.h | 15 ++++ unsupported/UnsupportedProcess.c | 33 +++++++++ unsupported/UnsupportedProcess.h | 22 ++++++ unsupported/UnsupportedProcessList.c | 75 +++++++++++++++++++ unsupported/UnsupportedProcessList.h | 22 ++++++ 10 files changed, 387 insertions(+) create mode 100644 unsupported/Battery.c create mode 100644 unsupported/Battery.h create mode 100644 unsupported/Platform.c create mode 100644 unsupported/Platform.h create mode 100644 unsupported/UnsupportedCRT.c create mode 100644 unsupported/UnsupportedCRT.h create mode 100644 unsupported/UnsupportedProcess.c create mode 100644 unsupported/UnsupportedProcess.h create mode 100644 unsupported/UnsupportedProcessList.c create mode 100644 unsupported/UnsupportedProcessList.h (limited to 'unsupported') diff --git a/unsupported/Battery.c b/unsupported/Battery.c new file mode 100644 index 0000000..6d6e94b --- /dev/null +++ b/unsupported/Battery.c @@ -0,0 +1,8 @@ + +#include "BatteryMeter.h" + +void Battery_getData(double* level, ACPresence* isOnAC) { + *level = -1; + *isOnAC = AC_ERROR; +} + diff --git a/unsupported/Battery.h b/unsupported/Battery.h new file mode 100644 index 0000000..8dc0cef --- /dev/null +++ b/unsupported/Battery.h @@ -0,0 +1,9 @@ +/* Do not edit this file. It was automatically generated. */ + +#ifndef HEADER_Battery +#define HEADER_Battery + +void Battery_getData(double* level, ACPresence* isOnAC); + + +#endif diff --git a/unsupported/Platform.c b/unsupported/Platform.c new file mode 100644 index 0000000..0f1ba97 --- /dev/null +++ b/unsupported/Platform.c @@ -0,0 +1,136 @@ +/* +htop - unsupported/Platform.c +(C) 2014 Hisham H. Muhammad +(C) 2015 David C. Hunt +Released under the GNU GPL, see the COPYING file +in the source distribution for its full text. +*/ + +#include "Platform.h" +#include "CPUMeter.h" +#include "MemoryMeter.h" +#include "SwapMeter.h" +#include "TasksMeter.h" +#include "LoadAverageMeter.h" +#include "ClockMeter.h" +#include "HostnameMeter.h" +#include "UptimeMeter.h" + +/*{ +#include "Action.h" +#include "BatteryMeter.h" +#include "UnsupportedProcess.h" +}*/ + +ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; + +ProcessFieldData Process_fields[] = { + [0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, }, + [PID] = { .name = "PID", .title = " PID ", .description = "Process/thread ID", .flags = 0, }, + [COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, }, + [STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging)", .flags = 0, }, + [PPID] = { .name = "PPID", .title = " PPID ", .description = "Parent process ID", .flags = 0, }, + [PGRP] = { .name = "PGRP", .title = " PGRP ", .description = "Process group ID", .flags = 0, }, + [SESSION] = { .name = "SESSION", .title = " SESN ", .description = "Process's session ID", .flags = 0, }, + [TTY_NR] = { .name = "TTY_NR", .title = " TTY ", .description = "Controlling terminal", .flags = 0, }, + [TPGID] = { .name = "TPGID", .title = " TPGID ", .description = "Process ID of the fg process group of the controlling terminal", .flags = 0, }, + [MINFLT] = { .name = "MINFLT", .title = " MINFLT ", .description = "Number of minor faults which have not required loading a memory page from disk", .flags = 0, }, + [MAJFLT] = { .name = "MAJFLT", .title = " MAJFLT ", .description = "Number of major faults which have required loading a memory page from disk", .flags = 0, }, + [PRIORITY] = { .name = "PRIORITY", .title = "PRI ", .description = "Kernel's internal priority for the process", .flags = 0, }, + [NICE] = { .name = "NICE", .title = " NI ", .description = "Nice value (the higher the value, the more it lets other processes take priority)", .flags = 0, }, + [STARTTIME] = { .name = "STARTTIME", .title = "START ", .description = "Time the process was started", .flags = 0, }, + + [PROCESSOR] = { .name = "PROCESSOR", .title = "CPU ", .description = "Id of the CPU the process last executed on", .flags = 0, }, + [M_SIZE] = { .name = "M_SIZE", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, }, + [M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, }, + [ST_UID] = { .name = "ST_UID", .title = " UID ", .description = "User ID of the process owner", .flags = 0, }, + [PERCENT_CPU] = { .name = "PERCENT_CPU", .title = "CPU% ", .description = "Percentage of the CPU time the process used in the last sampling", .flags = 0, }, + [PERCENT_MEM] = { .name = "PERCENT_MEM", .title = "MEM% ", .description = "Percentage of the memory the process is using, based on resident memory size", .flags = 0, }, + [USER] = { .name = "USER", .title = "USER ", .description = "Username of the process owner (or user ID if name cannot be determined)", .flags = 0, }, + [TIME] = { .name = "TIME", .title = " TIME+ ", .description = "Total time the process has spent in user and system time", .flags = 0, }, + [NLWP] = { .name = "NLWP", .title = "NLWP ", .description = "Number of threads in the process", .flags = 0, }, + [TGID] = { .name = "TGID", .title = " TGID ", .description = "Thread group ID (i.e. process ID)", .flags = 0, }, + [100] = { .name = "*** report bug! ***", .title = NULL, .description = NULL, .flags = 0, }, +}; + +MeterClass* Platform_meterTypes[] = { + &CPUMeter_class, + &ClockMeter_class, + &LoadAverageMeter_class, + &LoadMeter_class, + &MemoryMeter_class, + &SwapMeter_class, + &TasksMeter_class, + &BatteryMeter_class, + &HostnameMeter_class, + &UptimeMeter_class, + &AllCPUsMeter_class, + &AllCPUs2Meter_class, + &LeftCPUsMeter_class, + &RightCPUsMeter_class, + &LeftCPUs2Meter_class, + &RightCPUs2Meter_class, + &BlankMeter_class, + NULL +}; + +void Platform_setBindings(Htop_Action* keys) { + (void) keys; +} + +int Platform_numberOfFields = 100; +char* Process_pidFormat = "%7u "; + +int Platform_getUptime() { + return 0; +} + +void Platform_getLoadAverage(double* one, double* five, double* fifteen) { + *one = 0; + *five = 0; + *fifteen = 0; +} + +int Platform_getMaxPid() { + return 1; +} + +void Process_setupColumnWidths() { + int maxPid = Platform_getMaxPid(); + if (maxPid == -1) return; + if (maxPid > 99999) { + Process_fields[PID].title = " PID "; + Process_fields[PPID].title = " PPID "; + Process_fields[TPGID].title = " TPGID "; + Process_fields[TGID].title = " TGID "; + Process_fields[PGRP].title = " PGRP "; + Process_fields[SESSION].title = " SESN "; + Process_pidFormat = "%7u "; + } else { + Process_fields[PID].title = " PID "; + Process_fields[PPID].title = " PPID "; + Process_fields[TPGID].title = "TPGID "; + Process_fields[TGID].title = " TGID "; + Process_fields[PGRP].title = " PGRP "; + Process_fields[SESSION].title = " SESN "; + Process_pidFormat = "%5u "; + } +} + +double Platform_setCPUValues(Meter* this, int cpu) { + return 0.0; +} + +void Platform_setMemoryValues(Meter* this) { +} + +void Platform_setSwapValues(Meter* this) { +} + +bool Process_isThread(Process* this) { + return false; +} + +char* Platform_getProcessEnv(pid_t pid) { + return NULL; +} diff --git a/unsupported/Platform.h b/unsupported/Platform.h new file mode 100644 index 0000000..ec1649d --- /dev/null +++ b/unsupported/Platform.h @@ -0,0 +1,46 @@ +/* Do not edit this file. It was automatically generated. */ + +#ifndef HEADER_Platform +#define HEADER_Platform +/* +htop - unsupported/Platform.h +(C) 2014 Hisham H. Muhammad +(C) 2015 David C. Hunt +Released under the GNU GPL, see the COPYING file +in the source distribution for its full text. +*/ + +#include "Action.h" +#include "BatteryMeter.h" +#include "UnsupportedProcess.h" + +extern ProcessField Platform_defaultFields[]; + +extern ProcessFieldData Process_fields[]; + +extern MeterClass* Platform_meterTypes[]; + +void Platform_setBindings(Htop_Action* keys); + +extern int Platform_numberOfFields; +extern char* Process_pidFormat; + +int Platform_getUptime(); + +void Platform_getLoadAverage(double* one, double* five, double* fifteen); + +int Platform_getMaxPid(); + +void Process_setupColumnWidths(); + +double Platform_setCPUValues(Meter* this, int cpu); + +void Platform_setMemoryValues(Meter* this); + +void Platform_setSwapValues(Meter* this); + +bool Process_isThread(Process* this); + +char* Platform_getProcessEnv(pid_t pid); + +#endif diff --git a/unsupported/UnsupportedCRT.c b/unsupported/UnsupportedCRT.c new file mode 100644 index 0000000..5c3a9de --- /dev/null +++ b/unsupported/UnsupportedCRT.c @@ -0,0 +1,21 @@ +/* +htop - UnsupportedCRT.c +(C) 2014 Hisham H. Muhammad +Released under the GNU GPL, see the COPYING file +in the source distribution for its full text. +*/ + +#include "config.h" +#include "CRT.h" +#include +#include + +void CRT_handleSIGSEGV(int sgn) { + (void) sgn; + CRT_done(); + fprintf(stderr, "\n\nhtop " VERSION " aborting.\n"); + fprintf(stderr, "\nUnfortunately, you seem to be using an unsupported platform!"); + fprintf(stderr, "\nPlease contact your platform package maintainer!\n\n"); + abort(); +} + diff --git a/unsupported/UnsupportedCRT.h b/unsupported/UnsupportedCRT.h new file mode 100644 index 0000000..3c808ca --- /dev/null +++ b/unsupported/UnsupportedCRT.h @@ -0,0 +1,15 @@ +/* Do not edit this file. It was automatically generated. */ + +#ifndef HEADER_UnsupportedCRT +#define HEADER_UnsupportedCRT +/* +htop - UnsupportedCRT.h +(C) 2014 Hisham H. Muhammad +Released under the GNU GPL, see the COPYING file +in the source distribution for its full text. +*/ + +void CRT_handleSIGSEGV(int sgn); + + +#endif diff --git a/unsupported/UnsupportedProcess.c b/unsupported/UnsupportedProcess.c new file mode 100644 index 0000000..ec1de78 --- /dev/null +++ b/unsupported/UnsupportedProcess.c @@ -0,0 +1,33 @@ +/* +htop - UnsupportedProcess.c +(C) 2015 Hisham H. Muhammad +Released under the GNU GPL, see the COPYING file +in the source distribution for its full text. +*/ + +#include "Process.h" +#include "UnsupportedProcess.h" +#include + +/*{ +#include "Settings.h" + +#define Process_delete UnsupportedProcess_delete + +}*/ + +Process* UnsupportedProcess_new(Settings* settings) { + Process* this = xCalloc(1, sizeof(Process)); + Object_setClass(this, Class(Process)); + Process_init(this, settings); + return this; +} + +void UnsupportedProcess_delete(Object* cast) { + Process* this = (Process*) cast; + Object_setClass(this, Class(Process)); + Process_done((Process*)cast); + // free platform-specific fields here + free(this); +} + diff --git a/unsupported/UnsupportedProcess.h b/unsupported/UnsupportedProcess.h new file mode 100644 index 0000000..4ca3043 --- /dev/null +++ b/unsupported/UnsupportedProcess.h @@ -0,0 +1,22 @@ +/* Do not edit this file. It was automatically generated. */ + +#ifndef HEADER_UnsupportedProcess +#define HEADER_UnsupportedProcess +/* +htop - UnsupportedProcess.h +(C) 2015 Hisham H. Muhammad +Released under the GNU GPL, see the COPYING file +in the source distribution for its full text. +*/ + +#include "Settings.h" + +#define Process_delete UnsupportedProcess_delete + + +Process* UnsupportedProcess_new(Settings* settings); + +void UnsupportedProcess_delete(Object* cast); + + +#endif diff --git a/unsupported/UnsupportedProcessList.c b/unsupported/UnsupportedProcessList.c new file mode 100644 index 0000000..b63f267 --- /dev/null +++ b/unsupported/UnsupportedProcessList.c @@ -0,0 +1,75 @@ +/* +htop - UnsupportedProcessList.c +(C) 2014 Hisham H. Muhammad +Released under the GNU GPL, see the COPYING file +in the source distribution for its full text. +*/ + +#include "ProcessList.h" +#include "UnsupportedProcess.h" + +#include +#include + +/*{ + +}*/ + +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) { + ProcessList* this = xCalloc(1, sizeof(ProcessList)); + ProcessList_init(this, Class(Process), usersTable, pidWhiteList, userId); + + return this; +} + +void ProcessList_delete(ProcessList* this) { + ProcessList_done(this); + free(this); +} + +void ProcessList_goThroughEntries(ProcessList* super) { + bool preExisting = true; + Process *proc; + + proc = ProcessList_getProcess(super, 1, &preExisting, UnsupportedProcess_new); + + /* Empty values */ + proc->time = proc->time + 10; + proc->pid = 1; + proc->ppid = 1; + proc->tgid = 0; + proc->comm = ""; + proc->basenameOffset = 0; + proc->updated = true; + + proc->state = 'R'; + proc->show = true; /* Reflected in proc->settings-> "hideXXX" really */ + proc->pgrp = 0; + proc->session = 0; + proc->tty_nr = 0; + proc->tpgid = 0; + proc->st_uid = 0; + proc->flags = 0; + proc->processor = 0; + + proc->percent_cpu = 2.5; + proc->percent_mem = 2.5; + proc->user = "nobody"; + + proc->priority = 0; + proc->nice = 0; + proc->nlwp = 1; + strncpy(proc->starttime_show, "Jun 01 ", sizeof(proc->starttime_show)); + proc->starttime_ctime = 1433116800; // Jun 01, 2015 + + proc->m_size = 100; + proc->m_resident = 100; + + proc->minflt = 20; + proc->majflt = 20; +} + +void UnsupportedProcessList_scan(ProcessList* this) { + (void) this; + // stub! +} diff --git a/unsupported/UnsupportedProcessList.h b/unsupported/UnsupportedProcessList.h new file mode 100644 index 0000000..58ba3d4 --- /dev/null +++ b/unsupported/UnsupportedProcessList.h @@ -0,0 +1,22 @@ +/* Do not edit this file. It was automatically generated. */ + +#ifndef HEADER_UnsupportedProcessList +#define HEADER_UnsupportedProcessList +/* +htop - UnsupportedProcessList.h +(C) 2014 Hisham H. Muhammad +Released under the GNU GPL, see the COPYING file +in the source distribution for its full text. +*/ + + + +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId); + +void ProcessList_delete(ProcessList* this); + +void ProcessList_goThroughEntries(ProcessList* super); + +void UnsupportedProcessList_scan(ProcessList* this); + +#endif -- cgit v1.2.3