From f80394a20254938142011855f2954b3f63fe5909 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Tue, 15 Sep 2020 08:00:00 +0200 Subject: New upstream version 3.0.2 --- .gitignore | 1 - .travis.yml | 1 + Action.c | 32 ------- Action.h | 26 ++---- Affinity.c | 12 --- Affinity.h | 30 ++---- AffinityPanel.c | 13 +-- AffinityPanel.h | 24 +---- AvailableColumnsPanel.c | 9 -- AvailableColumnsPanel.h | 5 +- AvailableMetersPanel.c | 17 ---- AvailableMetersPanel.h | 5 +- BatteryMeter.c | 9 -- BatteryMeter.h | 2 - CPUMeter.c | 33 +------ CPUMeter.h | 10 -- CRT.c | 117 +----------------------- CRT.h | 57 +++--------- CategoriesPanel.c | 16 ---- CategoriesPanel.h | 7 +- ChangeLog | 20 +++- CheckItem.c | 11 --- CheckItem.h | 11 +-- ClockMeter.c | 3 - ClockMeter.h | 2 - ColorsPanel.c | 13 --- ColorsPanel.h | 11 +-- ColumnsPanel.c | 12 --- ColumnsPanel.h | 9 +- DisplayOptionsPanel.c | 14 --- DisplayOptionsPanel.h | 5 +- EnvScreen.c | 9 +- EnvScreen.h | 10 +- FunctionBar.c | 13 --- FunctionBar.h | 19 ++-- Hashtable.c | 20 ---- Hashtable.h | 16 ++-- Header.c | 26 +----- Header.h | 35 +++---- HostnameMeter.c | 3 - HostnameMeter.h | 2 - IncSet.c | 34 ------- IncSet.h | 24 ++--- InfoScreen.c | 36 -------- InfoScreen.h | 14 ++- ListItem.c | 11 --- ListItem.h | 11 +-- LoadAverageMeter.c | 3 - LoadAverageMeter.h | 2 - Macros.h | 16 ++++ MainPanel.c | 19 ---- MainPanel.h | 23 ++--- Makefile.am | 37 +------- MemoryMeter.c | 3 - MemoryMeter.h | 2 - Meter.c | 98 -------------------- Meter.h | 55 ++--------- MetersPanel.c | 19 ---- MetersPanel.h | 14 +-- Object.c | 40 -------- Object.h | 6 +- OpenFilesScreen.c | 24 ----- OpenFilesScreen.h | 11 +-- Panel.c | 86 ++--------------- Panel.h | 62 +++++-------- Process.c | 162 --------------------------------- Process.h | 36 +++----- ProcessList.c | 69 +------------- ProcessList.h | 34 ++++--- RichString.c | 57 +----------- RichString.h | 32 +++---- ScreenManager.c | 43 --------- ScreenManager.h | 18 ++-- Settings.c | 68 -------------- Settings.h | 15 +-- SignalsPanel.c | 8 -- SignalsPanel.h | 6 +- StringUtils.c | 12 --- StringUtils.h | 16 ++-- SwapMeter.c | 3 - SwapMeter.h | 2 - TasksMeter.c | 5 +- TasksMeter.h | 2 - TraceScreen.c | 16 ---- TraceScreen.h | 14 ++- UptimeMeter.c | 3 - UptimeMeter.h | 2 - UsersTable.c | 7 -- UsersTable.h | 10 +- Vector.c | 23 +---- Vector.h | 44 ++++----- XAlloc.c | 5 - XAlloc.h | 14 ++- configure.ac | 3 +- darwin/Battery.h | 3 - darwin/DarwinCRT.h | 3 - darwin/DarwinProcess.c | 15 --- darwin/DarwinProcess.h | 3 - darwin/DarwinProcessList.c | 26 +----- darwin/DarwinProcessList.h | 5 +- darwin/Platform.c | 11 --- darwin/Platform.h | 6 -- dragonflybsd/Battery.h | 2 - dragonflybsd/DragonFlyBSDCRT.h | 6 -- dragonflybsd/DragonFlyBSDProcess.c | 28 ------ dragonflybsd/DragonFlyBSDProcess.h | 10 -- dragonflybsd/DragonFlyBSDProcessList.c | 54 +---------- dragonflybsd/DragonFlyBSDProcessList.h | 11 +-- dragonflybsd/Platform.c | 12 --- dragonflybsd/Platform.h | 7 -- freebsd/Battery.h | 2 - freebsd/FreeBSDCRT.h | 3 - freebsd/FreeBSDProcess.c | 27 ------ freebsd/FreeBSDProcess.h | 12 +-- freebsd/FreeBSDProcessList.c | 52 +---------- freebsd/FreeBSDProcessList.h | 11 +-- freebsd/Platform.c | 12 --- freebsd/Platform.h | 7 -- htop.c | 18 ++-- htop.h | 19 ---- linux/Battery.h | 22 +---- linux/IOPriority.c | 40 -------- linux/IOPriority.h | 4 - linux/IOPriorityPanel.c | 5 - linux/IOPriorityPanel.h | 6 +- linux/LinuxCRT.h | 7 +- linux/LinuxProcess.c | 144 ----------------------------- linux/LinuxProcess.h | 25 ++--- linux/LinuxProcessList.c | 99 +------------------- linux/LinuxProcessList.h | 46 +--------- linux/Platform.c | 13 +-- linux/Platform.h | 28 +++--- openbsd/Battery.h | 2 - openbsd/OpenBSDCRT.h | 3 - openbsd/OpenBSDProcess.c | 20 ---- openbsd/OpenBSDProcess.h | 10 +- openbsd/OpenBSDProcessList.c | 53 +---------- openbsd/OpenBSDProcessList.h | 24 +---- openbsd/Platform.c | 8 -- openbsd/Platform.h | 14 +-- scripts/MakeHeader.py.in | 104 --------------------- solaris/Battery.h | 3 - solaris/Platform.c | 22 ----- solaris/Platform.h | 3 - solaris/SolarisCRT.h | 5 - solaris/SolarisProcess.c | 44 --------- solaris/SolarisProcess.h | 11 +-- solaris/SolarisProcessList.c | 45 +-------- solaris/SolarisProcessList.h | 8 +- unsupported/Battery.h | 3 - unsupported/Platform.c | 6 -- unsupported/Platform.h | 2 - unsupported/UnsupportedCRT.h | 3 - unsupported/UnsupportedProcess.c | 6 -- unsupported/UnsupportedProcess.h | 4 - unsupported/UnsupportedProcessList.c | 7 +- unsupported/UnsupportedProcessList.h | 6 +- zfs/ZfsArcMeter.h | 4 +- zfs/ZfsArcStats.h | 3 - zfs/ZfsCompressedArcMeter.h | 2 - zfs/openzfs_sysctl.h | 2 - 161 files changed, 367 insertions(+), 2933 deletions(-) create mode 100644 Macros.h delete mode 100644 htop.h delete mode 100644 linux/IOPriority.c delete mode 100644 scripts/MakeHeader.py.in diff --git a/.gitignore b/.gitignore index b642d7c..f94f3f5 100644 --- a/.gitignore +++ b/.gitignore @@ -39,5 +39,4 @@ libtool ltmain.sh m4/ missing -scripts/MakeHeader.py stamp-h1 diff --git a/.travis.yml b/.travis.yml index 22a5e07..b3e358d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ compiler: - gcc os: + - freebsd - linux - osx diff --git a/Action.c b/Action.c index d9cc5ab..90d6bfe 100644 --- a/Action.c +++ b/Action.c @@ -30,38 +30,6 @@ in the source distribution for its full text. #include #include -/*{ - -#include "IncSet.h" -#include "Settings.h" -#include "Header.h" -#include "UsersTable.h" -#include "ProcessList.h" -#include "Panel.h" - -typedef enum { - HTOP_OK = 0x00, - HTOP_REFRESH = 0x01, - HTOP_RECALCULATE = 0x03, // implies HTOP_REFRESH - HTOP_SAVE_SETTINGS = 0x04, - HTOP_KEEP_FOLLOWING = 0x08, - HTOP_QUIT = 0x10, - HTOP_REDRAW_BAR = 0x20, - HTOP_UPDATE_PANELHDR = 0x41, // implies HTOP_REFRESH -} Htop_Reaction; - -typedef Htop_Reaction (*Htop_Action)(); - -typedef struct State_ { - Settings* settings; - UsersTable* ut; - ProcessList* pl; - Panel* panel; - Header* header; -} State; - -}*/ - Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess) { Panel* panel = st->panel; Header* header = st->header; diff --git a/Action.h b/Action.h index 4c5971b..0ec0537 100644 --- a/Action.h +++ b/Action.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Action #define HEADER_Action /* @@ -9,13 +7,11 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ - -#include "IncSet.h" -#include "Settings.h" #include "Header.h" -#include "UsersTable.h" -#include "ProcessList.h" #include "Panel.h" +#include "ProcessList.h" +#include "Settings.h" +#include "UsersTable.h" typedef enum { HTOP_OK = 0x00, @@ -38,20 +34,14 @@ typedef struct State_ { Header* header; } State; +Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess); -extern Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess); - -// ---------------------------------------- - -extern bool Action_setUserOnly(const char* userName, uid_t* userId); - -extern Htop_Reaction Action_setSortKey(Settings* settings, ProcessField sortKey); - -// ---------------------------------------- +bool Action_setUserOnly(const char* userName, uid_t* userId); -extern Htop_Reaction Action_follow(State* st); +Htop_Reaction Action_setSortKey(Settings* settings, ProcessField sortKey); +Htop_Reaction Action_follow(State* st); -extern void Action_setBindings(Htop_Action* keys); +void Action_setBindings(Htop_Action* keys); #endif diff --git a/Affinity.c b/Affinity.c index b6eafce..3ea45a9 100644 --- a/Affinity.c +++ b/Affinity.c @@ -21,18 +21,6 @@ in the source distribution for its full text. #include #endif -/*{ -#include "Process.h" -#include "ProcessList.h" - -typedef struct Affinity_ { - ProcessList* pl; - int size; - int used; - int* cpus; -} Affinity; - -}*/ Affinity* Affinity_new(ProcessList* pl) { Affinity* this = xCalloc(1, sizeof(Affinity)); diff --git a/Affinity.h b/Affinity.h index 3c71603..20d0047 100644 --- a/Affinity.h +++ b/Affinity.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Affinity #define HEADER_Affinity /* @@ -10,15 +8,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#ifdef HAVE_LIBHWLOC -#if __linux__ -#define HTOP_HWLOC_CPUBIND_FLAG HWLOC_CPUBIND_THREAD -#else -#define HTOP_HWLOC_CPUBIND_FLAG HWLOC_CPUBIND_PROCESS -#endif -#elif HAVE_LINUX_AFFINITY -#endif - #include "Process.h" #include "ProcessList.h" @@ -29,24 +18,17 @@ typedef struct Affinity_ { int* cpus; } Affinity; +Affinity* Affinity_new(ProcessList* pl); -extern Affinity* Affinity_new(ProcessList* pl); - -extern void Affinity_delete(Affinity* this); - -extern void Affinity_add(Affinity* this, int id); - -#ifdef HAVE_LIBHWLOC - -extern Affinity* Affinity_get(Process* proc, ProcessList* pl); +void Affinity_delete(Affinity* this); -extern bool Affinity_set(Process* proc, Arg arg); +void Affinity_add(Affinity* this, int id); -#elif HAVE_LINUX_AFFINITY +#if defined(HAVE_LIBHWLOC) || defined(HAVE_LINUX_AFFINITY) -extern Affinity* Affinity_get(Process* proc, ProcessList* pl); +Affinity* Affinity_get(Process* proc, ProcessList* pl); -extern bool Affinity_set(Process* proc, Arg arg); +bool Affinity_set(Process* proc, Arg arg); #endif diff --git a/AffinityPanel.c b/AffinityPanel.c index 1ffa900..d0a9e6d 100644 --- a/AffinityPanel.c +++ b/AffinityPanel.c @@ -17,13 +17,6 @@ in the source distribution for its full text. #include #endif -/*{ -#include "Panel.h" -#include "Affinity.h" -#include "ProcessList.h" - -}*/ - typedef struct MaskItem_ { Object super; const char* text; @@ -375,9 +368,9 @@ Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity, int* width) { for (int i = 0; i < pl->cpuCount; i++) { char number[16]; xSnprintf(number, 9, "CPU %d", Settings_cpuId(pl->settings, i)); - unsigned width = 4 + strlen(number); - if (width > this->width) - this->width = width; + unsigned cpu_width = 4 + strlen(number); + if (cpu_width > this->width) + this->width = cpu_width; bool isSet = false; if (curCpu < affinity->used && affinity->cpus[curCpu] == i) { diff --git a/AffinityPanel.h b/AffinityPanel.h index 54d4f24..61e4287 100644 --- a/AffinityPanel.h +++ b/AffinityPanel.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_AffinityPanel #define HEADER_AffinityPanel /* @@ -9,32 +7,14 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#ifdef HAVE_LIBHWLOC -#endif - #include "Panel.h" #include "Affinity.h" #include "ProcessList.h" - - -#ifdef HAVE_LIBHWLOC - -#endif - - -#ifdef HAVE_LIBHWLOC - -#endif - -#ifdef HAVE_LIBHWLOC - -#endif - extern PanelClass AffinityPanel_class; -extern Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity, int* width); +Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity, int* width); -extern Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl); +Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl); #endif diff --git a/AvailableColumnsPanel.c b/AvailableColumnsPanel.c index 1e548dc..8aedde2 100644 --- a/AvailableColumnsPanel.c +++ b/AvailableColumnsPanel.c @@ -16,15 +16,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Panel.h" - -typedef struct AvailableColumnsPanel_ { - Panel super; - Panel* columns; -} AvailableColumnsPanel; - -}*/ static const char* const AvailableColumnsFunctions[] = {" ", " ", " ", " ", "Add ", " ", " ", " ", " ", "Done ", NULL}; diff --git a/AvailableColumnsPanel.h b/AvailableColumnsPanel.h index 2d6daf4..6292805 100644 --- a/AvailableColumnsPanel.h +++ b/AvailableColumnsPanel.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_AvailableColumnsPanel #define HEADER_AvailableColumnsPanel /* @@ -16,9 +14,8 @@ typedef struct AvailableColumnsPanel_ { Panel* columns; } AvailableColumnsPanel; - extern PanelClass AvailableColumnsPanel_class; -extern AvailableColumnsPanel* AvailableColumnsPanel_new(Panel* columns); +AvailableColumnsPanel* AvailableColumnsPanel_new(Panel* columns); #endif diff --git a/AvailableMetersPanel.c b/AvailableMetersPanel.c index 5dac10b..0533cfb 100644 --- a/AvailableMetersPanel.c +++ b/AvailableMetersPanel.c @@ -16,23 +16,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Settings.h" -#include "Panel.h" -#include "ScreenManager.h" -#include "ProcessList.h" - -typedef struct AvailableMetersPanel_ { - Panel super; - ScreenManager* scr; - - Settings* settings; - Header* header; - Panel* leftPanel; - Panel* rightPanel; -} AvailableMetersPanel; - -}*/ static void AvailableMetersPanel_delete(Object* object) { Panel* super = (Panel*) object; diff --git a/AvailableMetersPanel.h b/AvailableMetersPanel.h index 00e0f59..ecebb28 100644 --- a/AvailableMetersPanel.h +++ b/AvailableMetersPanel.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_AvailableMetersPanel #define HEADER_AvailableMetersPanel /* @@ -24,9 +22,8 @@ typedef struct AvailableMetersPanel_ { Panel* rightPanel; } AvailableMetersPanel; - extern PanelClass AvailableMetersPanel_class; -extern AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Header* header, Panel* leftMeters, Panel* rightMeters, ScreenManager* scr, ProcessList* pl); +AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Header* header, Panel* leftMeters, Panel* rightMeters, ScreenManager* scr, ProcessList* pl); #endif diff --git a/BatteryMeter.c b/BatteryMeter.c index 716b775..859df9d 100644 --- a/BatteryMeter.c +++ b/BatteryMeter.c @@ -18,15 +18,6 @@ This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com). #include #include -/*{ -#include "Meter.h" - -typedef enum ACPresence_ { - AC_ABSENT, - AC_PRESENT, - AC_ERROR -} ACPresence; -}*/ int BatteryMeter_attributes[] = { BATTERY diff --git a/BatteryMeter.h b/BatteryMeter.h index bf8d2e8..658cd3f 100644 --- a/BatteryMeter.h +++ b/BatteryMeter.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_BatteryMeter #define HEADER_BatteryMeter /* diff --git a/CPUMeter.c b/CPUMeter.c index 6131a09..cb77e71 100644 --- a/CPUMeter.c +++ b/CPUMeter.c @@ -16,35 +16,10 @@ in the source distribution for its full text. #include #include -/*{ -#include "Meter.h" - -typedef enum { - CPU_METER_NICE = 0, - CPU_METER_NORMAL = 1, - CPU_METER_KERNEL = 2, - CPU_METER_IRQ = 3, - CPU_METER_SOFTIRQ = 4, - CPU_METER_STEAL = 5, - CPU_METER_GUEST = 6, - CPU_METER_IOWAIT = 7, - CPU_METER_FREQUENCY = 8, - CPU_METER_ITEMCOUNT = 9, // number of entries in this enum -} CPUMeterValues; - -}*/ - int CPUMeter_attributes[] = { CPU_NICE, CPU_NORMAL, CPU_SYSTEM, CPU_IRQ, CPU_SOFTIRQ, CPU_STEAL, CPU_GUEST, CPU_IOWAIT }; -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif -#ifndef MAX -#define MAX(a,b) ((a)>(b)?(a):(b)) -#endif - static void CPUMeter_init(Meter* this) { int cpu = this->param; if (this->pl->cpuCount > 1) { @@ -65,18 +40,12 @@ static void CPUMeter_updateValues(Meter* this, char* buffer, int size) { memset(this->values, 0, sizeof(double) * CPU_METER_ITEMCOUNT); double percent = Platform_setCPUValues(this, cpu); if (this->pl->settings->showCPUFrequency) { - /* Initial frequency is in MHz. Emit it as GHz if it's larger than 1000MHz */ double cpuFrequency = this->values[CPU_METER_FREQUENCY]; - char unit = 'M'; char cpuFrequencyBuffer[16]; if (cpuFrequency < 0) { xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "N/A"); } else { - if (cpuFrequency > 1000) { - cpuFrequency /= 1000; - unit = 'G'; - } - xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "%.3f%cHz", cpuFrequency, unit); + xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "%.0fMHz", cpuFrequency); } if (this->pl->settings->showCPUUsage) { xSnprintf(buffer, size, "%5.1f%% %s", percent, cpuFrequencyBuffer); diff --git a/CPUMeter.h b/CPUMeter.h index 890e5db..d66eefb 100644 --- a/CPUMeter.h +++ b/CPUMeter.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_CPUMeter #define HEADER_CPUMeter /* @@ -24,16 +22,8 @@ typedef enum { CPU_METER_ITEMCOUNT = 9, // number of entries in this enum } CPUMeterValues; - extern int CPUMeter_attributes[]; -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif -#ifndef MAX -#define MAX(a,b) ((a)>(b)?(a):(b)) -#endif - extern MeterClass CPUMeter_class; extern MeterClass AllCPUsMeter_class; diff --git a/CRT.c b/CRT.c index 0d83bf4..7776c4e 100644 --- a/CRT.c +++ b/CRT.c @@ -39,116 +39,6 @@ in the source distribution for its full text. #define ColorPairGrayBlack ColorPair(Magenta,Magenta) #define ColorIndexGrayBlack ColorIndex(Magenta,Magenta) -#define KEY_WHEELUP KEY_F(20) -#define KEY_WHEELDOWN KEY_F(21) -#define KEY_RECLICK KEY_F(22) - -//#link curses - -/*{ -#include - -typedef enum TreeStr_ { - TREE_STR_HORZ, - TREE_STR_VERT, - TREE_STR_RTEE, - TREE_STR_BEND, - TREE_STR_TEND, - TREE_STR_OPEN, - TREE_STR_SHUT, - TREE_STR_COUNT -} TreeStr; - -typedef enum ColorSchemes_ { - COLORSCHEME_DEFAULT = 0, - COLORSCHEME_MONOCHROME = 1, - COLORSCHEME_BLACKONWHITE = 2, - COLORSCHEME_LIGHTTERMINAL = 3, - COLORSCHEME_MIDNIGHT = 4, - COLORSCHEME_BLACKNIGHT = 5, - COLORSCHEME_BROKENGRAY = 6, - LAST_COLORSCHEME = 7, -} ColorSchemes; - -typedef enum ColorElements_ { - RESET_COLOR, - DEFAULT_COLOR, - FUNCTION_BAR, - FUNCTION_KEY, - FAILED_SEARCH, - PANEL_HEADER_FOCUS, - PANEL_HEADER_UNFOCUS, - PANEL_SELECTION_FOCUS, - PANEL_SELECTION_FOLLOW, - PANEL_SELECTION_UNFOCUS, - LARGE_NUMBER, - METER_TEXT, - METER_VALUE, - LED_COLOR, - UPTIME, - BATTERY, - TASKS_RUNNING, - SWAP, - PROCESS, - PROCESS_SHADOW, - PROCESS_TAG, - PROCESS_MEGABYTES, - PROCESS_TREE, - PROCESS_R_STATE, - PROCESS_D_STATE, - PROCESS_BASENAME, - PROCESS_HIGH_PRIORITY, - PROCESS_LOW_PRIORITY, - PROCESS_THREAD, - PROCESS_THREAD_BASENAME, - BAR_BORDER, - BAR_SHADOW, - GRAPH_1, - GRAPH_2, - MEMORY_USED, - MEMORY_BUFFERS, - MEMORY_BUFFERS_TEXT, - MEMORY_CACHE, - LOAD, - LOAD_AVERAGE_FIFTEEN, - LOAD_AVERAGE_FIVE, - LOAD_AVERAGE_ONE, - CHECK_BOX, - CHECK_MARK, - CHECK_TEXT, - CLOCK, - HELP_BOLD, - HOSTNAME, - CPU_NICE, - CPU_NICE_TEXT, - CPU_NORMAL, - CPU_SYSTEM, - CPU_IOWAIT, - CPU_IRQ, - CPU_SOFTIRQ, - CPU_STEAL, - CPU_GUEST, - PRESSURE_STALL_TEN, - PRESSURE_STALL_SIXTY, - PRESSURE_STALL_THREEHUNDRED, - ZFS_MFU, - ZFS_MRU, - ZFS_ANON, - ZFS_HEADER, - ZFS_OTHER, - ZFS_COMPRESSED, - ZFS_RATIO, - LAST_COLORELEMENT -} ColorElements; - -extern void CRT_fatalError(const char* note) __attribute__ ((noreturn)); - -extern void CRT_handleSIGSEGV(int sgn); - -#define KEY_ALT(x) (KEY_F(64 - 26) + (x - 'A')) - -}*/ - const char *CRT_treeStrAscii[TREE_STR_COUNT] = { "-", // TREE_STR_HORZ "|", // TREE_STR_VERT @@ -656,12 +546,7 @@ void CRT_restorePrivileges() { #else -/* Turn setuid operations into NOPs */ - -#ifndef CRT_dropPrivileges -#define CRT_dropPrivileges() -#define CRT_restorePrivileges() -#endif +// In this case, the setuid operations are defined as macros in CRT.h #endif diff --git a/CRT.h b/CRT.h index 7d5c8ad..8a5d6ac 100644 --- a/CRT.h +++ b/CRT.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_CRT #define HEADER_CRT /* @@ -9,32 +7,11 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#if HAVE_SETUID_ENABLED -#endif - -#define ColorIndex(i,j) ((7-i)*8+j) - -#define ColorPair(i,j) COLOR_PAIR(ColorIndex(i,j)) - -#define Black COLOR_BLACK -#define Red COLOR_RED -#define Green COLOR_GREEN -#define Yellow COLOR_YELLOW -#define Blue COLOR_BLUE -#define Magenta COLOR_MAGENTA -#define Cyan COLOR_CYAN -#define White COLOR_WHITE - -#define ColorPairGrayBlack ColorPair(Magenta,Magenta) -#define ColorIndexGrayBlack ColorIndex(Magenta,Magenta) +#include -#define KEY_WHEELUP KEY_F(20) +#define KEY_WHEELUP KEY_F(20) #define KEY_WHEELDOWN KEY_F(21) -#define KEY_RECLICK KEY_F(22) - -//#link curses - -#include +#define KEY_RECLICK KEY_F(22) typedef enum TreeStr_ { TREE_STR_HORZ, @@ -129,9 +106,9 @@ typedef enum ColorElements_ { LAST_COLORELEMENT } ColorElements; -extern void CRT_fatalError(const char* note) __attribute__ ((noreturn)); +void CRT_fatalError(const char* note) __attribute__ ((noreturn)); -extern void CRT_handleSIGSEGV(int sgn); +void CRT_handleSIGSEGV(int sgn); #define KEY_ALT(x) (KEY_F(64 - 26) + (x - 'A')) @@ -162,19 +139,15 @@ extern int CRT_scrollWheelVAmount; extern char* CRT_termType; -// TODO move color scheme to Settings, perhaps? - extern int CRT_colorScheme; extern void *backtraceArray[128]; #if HAVE_SETUID_ENABLED -#define DIE(msg) do { CRT_done(); fprintf(stderr, msg); exit(1); } while(0) - -extern void CRT_dropPrivileges(); +void CRT_dropPrivileges(); -extern void CRT_restorePrivileges(); +void CRT_restorePrivileges(); #else @@ -187,20 +160,18 @@ extern void CRT_restorePrivileges(); #endif -// TODO: pass an instance of Settings instead. - -extern void CRT_init(int delay, int colorScheme, bool allowUnicode); +void CRT_init(int delay, int colorScheme, bool allowUnicode); -extern void CRT_done(); +void CRT_done(); -extern void CRT_fatalError(const char* note); +void CRT_fatalError(const char* note); -extern int CRT_readKey(); +int CRT_readKey(); -extern void CRT_disableDelay(); +void CRT_disableDelay(); -extern void CRT_enableDelay(); +void CRT_enableDelay(); -extern void CRT_setColors(int colorScheme); +void CRT_setColors(int colorScheme); #endif diff --git a/CategoriesPanel.c b/CategoriesPanel.c index 437f1a7..8a1e16d 100644 --- a/CategoriesPanel.c +++ b/CategoriesPanel.c @@ -17,22 +17,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Panel.h" -#include "Settings.h" -#include "ScreenManager.h" -#include "ProcessList.h" - -typedef struct CategoriesPanel_ { - Panel super; - ScreenManager* scr; - - Settings* settings; - Header* header; - ProcessList* pl; -} CategoriesPanel; - -}*/ static const char* const CategoriesFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL}; diff --git a/CategoriesPanel.h b/CategoriesPanel.h index 44c6842..fefc3e9 100644 --- a/CategoriesPanel.h +++ b/CategoriesPanel.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_CategoriesPanel #define HEADER_CategoriesPanel /* @@ -23,11 +21,10 @@ typedef struct CategoriesPanel_ { ProcessList* pl; } CategoriesPanel; - -extern void CategoriesPanel_makeMetersPage(CategoriesPanel* this); +void CategoriesPanel_makeMetersPage(CategoriesPanel* this); extern PanelClass CategoriesPanel_class; -extern CategoriesPanel* CategoriesPanel_new(ScreenManager* scr, Settings* settings, Header* header, ProcessList* pl); +CategoriesPanel* CategoriesPanel_new(ScreenManager* scr, Settings* settings, Header* header, ProcessList* pl); #endif diff --git a/ChangeLog b/ChangeLog index a45b973..4df88d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,15 +1,26 @@ +What's new in version 3.0.2 + +* BUGFIX: Drop 'vim_mode' - several issues, needs rethink +* BUGFIX: fix regression in -u optional-argument handling +* Build system rework to remove python, header generation + (thanks to Zev Weiss and Hugo Musso Gualandi) +* BUGFIX: report nice level correctly on Solaris + (thanks to Dominik Hassler) +* CI, code quality improvements + (thanks to Tobias Kortkamp, Christian Hesse, Benny Baumann) + What's new in version 3.0.1 * Coverity fixes, CI improvements, documentation updates * BUGFIX: Fix early exit with longer sysfs battery paths * BUGFIX: Improve OOM output, fix sorting -(thanks to Christian Göttsche) + (thanks to Christian Göttsche) * Rework check buttons and tree open/closed -(thanks to Bert Wesarg) + (thanks to Bert Wesarg) * Add -U/--no-unicode option to disable unicode -(thanks to Christian Hesse) + (thanks to Christian Hesse) * Improvements to the affinity panel -(thanks to Bert Wesarg) + (thanks to Bert Wesarg) What's new in version 3.0.0 @@ -18,7 +29,6 @@ What's new in version 3.0.0 of community maintainers have volunteered to take over a fork at https://htop.dev and https://github.com/htop-dev to keep the project going. - * Support ZFS ARC statistics (thanks to Ross Williams) * Support more than 2 smaller CPU meter columns diff --git a/CheckItem.c b/CheckItem.c index 910981e..d14149e 100644 --- a/CheckItem.c +++ b/CheckItem.c @@ -12,17 +12,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Object.h" - -typedef struct CheckItem_ { - Object super; - char* text; - bool* ref; - bool value; -} CheckItem; - -}*/ static void CheckItem_delete(Object* cast) { CheckItem* this = (CheckItem*)cast; diff --git a/CheckItem.h b/CheckItem.h index dbd1a03..11ac35f 100644 --- a/CheckItem.h +++ b/CheckItem.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_CheckItem #define HEADER_CheckItem /* @@ -18,15 +16,14 @@ typedef struct CheckItem_ { bool value; } CheckItem; - extern ObjectClass CheckItem_class; -extern CheckItem* CheckItem_newByRef(char* text, bool* ref); +CheckItem* CheckItem_newByRef(char* text, bool* ref); -extern CheckItem* CheckItem_newByVal(char* text, bool value); +CheckItem* CheckItem_newByVal(char* text, bool value); -extern void CheckItem_set(CheckItem* this, bool value); +void CheckItem_set(CheckItem* this, bool value); -extern bool CheckItem_get(CheckItem* this); +bool CheckItem_get(CheckItem* this); #endif diff --git a/ClockMeter.c b/ClockMeter.c index 0af8862..3168b3e 100644 --- a/ClockMeter.c +++ b/ClockMeter.c @@ -11,9 +11,6 @@ in the source distribution for its full text. #include -/*{ -#include "Meter.h" -}*/ int ClockMeter_attributes[] = { CLOCK diff --git a/ClockMeter.h b/ClockMeter.h index 3e0aef5..e888d58 100644 --- a/ClockMeter.h +++ b/ClockMeter.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_ClockMeter #define HEADER_ClockMeter /* diff --git a/ColorsPanel.c b/ColorsPanel.c index b2d3500..cfd975d 100644 --- a/ColorsPanel.c +++ b/ColorsPanel.c @@ -20,19 +20,6 @@ in the source distribution for its full text. // * Add a define in CRT.h that matches the order of the array // * Add the colors in CRT_setColors -/*{ -#include "Panel.h" -#include "Settings.h" -#include "ScreenManager.h" - -typedef struct ColorsPanel_ { - Panel super; - - Settings* settings; - ScreenManager* scr; -} ColorsPanel; - -}*/ static const char* const ColorsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL}; diff --git a/ColorsPanel.h b/ColorsPanel.h index 82b782b..479fad0 100644 --- a/ColorsPanel.h +++ b/ColorsPanel.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_ColorsPanel #define HEADER_ColorsPanel /* @@ -9,12 +7,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -// TO ADD A NEW SCHEME: -// * Increment the size of bool check in ColorsPanel.h -// * Add the entry in the ColorSchemeNames array below in the file -// * Add a define in CRT.h that matches the order of the array -// * Add the colors in CRT_setColors - #include "Panel.h" #include "Settings.h" #include "ScreenManager.h" @@ -26,9 +18,8 @@ typedef struct ColorsPanel_ { ScreenManager* scr; } ColorsPanel; - extern PanelClass ColorsPanel_class; -extern ColorsPanel* ColorsPanel_new(Settings* settings, ScreenManager* scr); +ColorsPanel* ColorsPanel_new(Settings* settings, ScreenManager* scr); #endif diff --git a/ColumnsPanel.c b/ColumnsPanel.c index de89fa2..587175c 100644 --- a/ColumnsPanel.c +++ b/ColumnsPanel.c @@ -16,18 +16,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Panel.h" -#include "Settings.h" - -typedef struct ColumnsPanel_ { - Panel super; - - Settings* settings; - bool moving; -} ColumnsPanel; - -}*/ static const char* const ColumnsFunctions[] = {" ", " ", " ", " ", " ", " ", "MoveUp", "MoveDn", "Remove", "Done ", NULL}; diff --git a/ColumnsPanel.h b/ColumnsPanel.h index 669dc02..be139a6 100644 --- a/ColumnsPanel.h +++ b/ColumnsPanel.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_ColumnsPanel #define HEADER_ColumnsPanel /* @@ -19,13 +17,12 @@ typedef struct ColumnsPanel_ { bool moving; } ColumnsPanel; - extern PanelClass ColumnsPanel_class; -extern ColumnsPanel* ColumnsPanel_new(Settings* settings); +ColumnsPanel* ColumnsPanel_new(Settings* settings); -extern int ColumnsPanel_fieldNameToIndex(const char* name); +int ColumnsPanel_fieldNameToIndex(const char* name); -extern void ColumnsPanel_update(Panel* super); +void ColumnsPanel_update(Panel* super); #endif diff --git a/DisplayOptionsPanel.c b/DisplayOptionsPanel.c index 42375e6..6978e23 100644 --- a/DisplayOptionsPanel.c +++ b/DisplayOptionsPanel.c @@ -14,19 +14,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Panel.h" -#include "Settings.h" -#include "ScreenManager.h" - -typedef struct DisplayOptionsPanel_ { - Panel super; - - Settings* settings; - ScreenManager* scr; -} DisplayOptionsPanel; - -}*/ static const char* const DisplayOptionsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL}; @@ -100,7 +87,6 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Also show CPU percentage numerically"), &(settings->showCPUUsage))); Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Also show CPU frequency"), &(settings->showCPUFrequency))); Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Enable the mouse"), &(settings->enableMouse))); - Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Enable vim mode"), &(settings->vimMode))); #ifdef HAVE_LIBHWLOC Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Show topology when selecting affinity by default"), &(settings->topologyAffinity))); #endif diff --git a/DisplayOptionsPanel.h b/DisplayOptionsPanel.h index d9de400..499b2fc 100644 --- a/DisplayOptionsPanel.h +++ b/DisplayOptionsPanel.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_DisplayOptionsPanel #define HEADER_DisplayOptionsPanel /* @@ -20,9 +18,8 @@ typedef struct DisplayOptionsPanel_ { ScreenManager* scr; } DisplayOptionsPanel; - extern PanelClass DisplayOptionsPanel_class; -extern DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* scr); +DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* scr); #endif diff --git a/EnvScreen.c b/EnvScreen.c index 855023a..479a45d 100644 --- a/EnvScreen.c +++ b/EnvScreen.c @@ -11,13 +11,6 @@ #include #include -/*{ -#include "InfoScreen.h" - -typedef struct EnvScreen_ { - InfoScreen super; -} EnvScreen; -}*/ InfoScreenClass EnvScreen_class = { .super = { @@ -44,7 +37,7 @@ void EnvScreen_draw(InfoScreen* this) { void EnvScreen_scan(InfoScreen* this) { Panel* panel = this->display; - int idx = MAX(Panel_getSelectedIndex(panel), 0); + int idx = MAXIMUM(Panel_getSelectedIndex(panel), 0); Panel_prune(panel); diff --git a/EnvScreen.h b/EnvScreen.h index 025cb8d..54dfa41 100644 --- a/EnvScreen.h +++ b/EnvScreen.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_EnvScreen #define HEADER_EnvScreen @@ -11,12 +9,12 @@ typedef struct EnvScreen_ { extern InfoScreenClass EnvScreen_class; -extern EnvScreen* EnvScreen_new(Process* process); +EnvScreen* EnvScreen_new(Process* process); -extern void EnvScreen_delete(Object* this); +void EnvScreen_delete(Object* this); -extern void EnvScreen_draw(InfoScreen* this); +void EnvScreen_draw(InfoScreen* this); -extern void EnvScreen_scan(InfoScreen* this); +void EnvScreen_scan(InfoScreen* this); #endif diff --git a/FunctionBar.c b/FunctionBar.c index 8661bf0..e05f72e 100644 --- a/FunctionBar.c +++ b/FunctionBar.c @@ -14,19 +14,6 @@ in the source distribution for its full text. #include #include -/*{ - -#include - -typedef struct FunctionBar_ { - int size; - char** functions; - char** keys; - int* events; - bool staticData; -} FunctionBar; - -}*/ static const char* const FunctionBar_FKeys[] = {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", NULL}; diff --git a/FunctionBar.h b/FunctionBar.h index ee5b934..486990f 100644 --- a/FunctionBar.h +++ b/FunctionBar.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_FunctionBar #define HEADER_FunctionBar /* @@ -9,7 +7,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ - #include typedef struct FunctionBar_ { @@ -20,20 +17,18 @@ typedef struct FunctionBar_ { bool staticData; } FunctionBar; +FunctionBar* FunctionBar_newEnterEsc(const char* enter, const char* esc); +FunctionBar* FunctionBar_new(const char* const* functions, const char* const* keys, const int* events); -extern FunctionBar* FunctionBar_newEnterEsc(const char* enter, const char* esc); - -extern FunctionBar* FunctionBar_new(const char* const* functions, const char* const* keys, const int* events); - -extern void FunctionBar_delete(FunctionBar* this); +void FunctionBar_delete(FunctionBar* this); -extern void FunctionBar_setLabel(FunctionBar* this, int event, const char* text); +void FunctionBar_setLabel(FunctionBar* this, int event, const char* text); -extern void FunctionBar_draw(const FunctionBar* this, char* buffer); +void FunctionBar_draw(const FunctionBar* this, char* buffer); -extern void FunctionBar_drawAttr(const FunctionBar* this, char* buffer, int attr); +void FunctionBar_drawAttr(const FunctionBar* this, char* buffer, int attr); -extern int FunctionBar_synthesizeEvent(const FunctionBar* this, int pos); +int FunctionBar_synthesizeEvent(const FunctionBar* this, int pos); #endif diff --git a/Hashtable.c b/Hashtable.c index 3436dad..bb9517a 100644 --- a/Hashtable.c +++ b/Hashtable.c @@ -11,26 +11,6 @@ in the source distribution for its full text. #include #include -/*{ -#include - -typedef struct Hashtable_ Hashtable; - -typedef void(*Hashtable_PairFunction)(int, void*, void*); - -typedef struct HashtableItem { - unsigned int key; - void* value; - struct HashtableItem* next; -} HashtableItem; - -struct Hashtable_ { - int size; - HashtableItem** buckets; - int items; - bool owner; -}; -}*/ #ifdef DEBUG diff --git a/Hashtable.h b/Hashtable.h index 32b0218..144f01c 100644 --- a/Hashtable.h +++ b/Hashtable.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Hashtable #define HEADER_Hashtable /* @@ -30,20 +28,20 @@ struct Hashtable_ { #ifdef DEBUG -extern int Hashtable_count(Hashtable* this); +int Hashtable_count(Hashtable* this); #endif -extern Hashtable* Hashtable_new(int size, bool owner); +Hashtable* Hashtable_new(int size, bool owner); -extern void Hashtable_delete(Hashtable* this); +void Hashtable_delete(Hashtable* this); -extern void Hashtable_put(Hashtable* this, unsigned int key, void* value); +void Hashtable_put(Hashtable* this, unsigned int key, void* value); -extern void* Hashtable_remove(Hashtable* this, unsigned int key); +void* Hashtable_remove(Hashtable* this, unsigned int key); -extern void* Hashtable_get(Hashtable* this, unsigned int key); +void* Hashtable_get(Hashtable* this, unsigned int key); -extern void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData); +void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData); #endif diff --git a/Header.c b/Header.c index c8cfaab..d2f3b88 100644 --- a/Header.c +++ b/Header.c @@ -16,30 +16,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Meter.h" -#include "Settings.h" -#include "Vector.h" - -typedef struct Header_ { - Vector** columns; - Settings* settings; - struct ProcessList_* pl; - int nrColumns; - int pad; - int height; -} Header; - -}*/ - -#ifndef MAX -#define MAX(a,b) ((a)>(b)?(a):(b)) -#endif - -#ifndef Header_forEachColumn -#define Header_forEachColumn(this_, i_) for (int (i_)=0; (i_) < (this_)->nrColumns; ++(i_)) -#endif - Header* Header_new(struct ProcessList_* pl, Settings* settings, int nrColumns) { Header* this = xCalloc(1, sizeof(Header)); this->columns = xCalloc(nrColumns, sizeof(Vector*)); @@ -211,7 +187,7 @@ int Header_calculateHeight(Header* this) { Meter* meter = (Meter*) Vector_get(meters, i); height += meter->h; } - maxHeight = MAX(maxHeight, height); + maxHeight = MAXIMUM(maxHeight, height); } this->height = maxHeight; this->pad = pad; diff --git a/Header.h b/Header.h index f518245..b221bec 100644 --- a/Header.h +++ b/Header.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Header #define HEADER_Header /* @@ -22,39 +20,32 @@ typedef struct Header_ { int height; } Header; - -#ifndef MAX -#define MAX(a,b) ((a)>(b)?(a):(b)) -#endif - -#ifndef Header_forEachColumn #define Header_forEachColumn(this_, i_) for (int (i_)=0; (i_) < (this_)->nrColumns; ++(i_)) -#endif -extern Header* Header_new(struct ProcessList_* pl, Settings* settings, int nrColumns); +Header* Header_new(struct ProcessList_* pl, Settings* settings, int nrColumns); -extern void Header_delete(Header* this); +void Header_delete(Header* this); -extern void Header_populateFromSettings(Header* this); +void Header_populateFromSettings(Header* this); -extern void Header_writeBackToSettings(const Header* this); +void Header_writeBackToSettings(const Header* this); -extern MeterModeId Header_addMeterByName(Header* this, char* name, int column); +MeterModeId Header_addMeterByName(Header* this, char* name, int column); -extern void Header_setMode(Header* this, int i, MeterModeId mode, int column); +void Header_setMode(Header* this, int i, MeterModeId mode, int column); -extern Meter* Header_addMeterByClass(Header* this, MeterClass* type, int param, int column); +Meter* Header_addMeterByClass(Header* this, MeterClass* type, int param, int column); -extern int Header_size(Header* this, int column); +int Header_size(Header* this, int column); -extern char* Header_readMeterName(Header* this, int i, int column); +char* Header_readMeterName(Header* this, int i, int column); -extern MeterModeId Header_readMeterMode(Header* this, int i, int column); +MeterModeId Header_readMeterMode(Header* this, int i, int column); -extern void Header_reinit(Header* this); +void Header_reinit(Header* this); -extern void Header_draw(const Header* this); +void Header_draw(const Header* this); -extern int Header_calculateHeight(Header* this); +int Header_calculateHeight(Header* this); #endif diff --git a/HostnameMeter.c b/HostnameMeter.c index 4c3b051..60bd812 100644 --- a/HostnameMeter.c +++ b/HostnameMeter.c @@ -11,9 +11,6 @@ in the source distribution for its full text. #include -/*{ -#include "Meter.h" -}*/ int HostnameMeter_attributes[] = { HOSTNAME diff --git a/HostnameMeter.h b/HostnameMeter.h index 3697dff..ecfab1a 100644 --- a/HostnameMeter.h +++ b/HostnameMeter.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_HostnameMeter #define HEADER_HostnameMeter /* diff --git a/IncSet.c b/IncSet.c index eaab549..e9e2893 100644 --- a/IncSet.c +++ b/IncSet.c @@ -7,45 +7,11 @@ in the source distribution for its full text. #include "IncSet.h" #include "StringUtils.h" -#include "Panel.h" #include "ListItem.h" #include "CRT.h" #include #include -/*{ - -#include "FunctionBar.h" -#include "Panel.h" -#include - -#define INCMODE_MAX 40 - -typedef enum { - INC_SEARCH = 0, - INC_FILTER = 1 -} IncType; - -#define IncSet_filter(inc_) (inc_->filtering ? inc_->modes[INC_FILTER].buffer : NULL) - -typedef struct IncMode_ { - char buffer[INCMODE_MAX+1]; - int index; - FunctionBar* bar; - bool isFilter; -} IncMode; - -typedef struct IncSet_ { - IncMode modes[2]; - IncMode* active; - FunctionBar* defaultBar; - bool filtering; - bool found; -} IncSet; - -typedef const char* (*IncMode_GetPanelValue)(Panel*, int); - -}*/ static void IncMode_reset(IncMode* mode) { mode->index = 0; diff --git a/IncSet.h b/IncSet.h index 136436e..2fb22c4 100644 --- a/IncSet.h +++ b/IncSet.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_IncSet #define HEADER_IncSet /* @@ -9,7 +7,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ - #include "FunctionBar.h" #include "Panel.h" #include @@ -40,25 +37,24 @@ typedef struct IncSet_ { typedef const char* (*IncMode_GetPanelValue)(Panel*, int); +void IncSet_reset(IncSet* this, IncType type); -extern void IncSet_reset(IncSet* this, IncType type); - -extern IncSet* IncSet_new(FunctionBar* bar); +IncSet* IncSet_new(FunctionBar* bar); -extern void IncSet_delete(IncSet* this); +void IncSet_delete(IncSet* this); -extern bool IncSet_next(IncSet* this, IncType type, Panel* panel, IncMode_GetPanelValue getPanelValue); +bool IncSet_next(IncSet* this, IncType type, Panel* panel, IncMode_GetPanelValue getPanelValue); -extern bool IncSet_prev(IncSet* this, IncType type, Panel* panel, IncMode_GetPanelValue getPanelValue); +bool IncSet_prev(IncSet* this, IncType type, Panel* panel, IncMode_GetPanelValue getPanelValue); -extern bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue getPanelValue, Vector* lines); +bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue getPanelValue, Vector* lines); -extern const char* IncSet_getListItemValue(Panel* panel, int i); +const char* IncSet_getListItemValue(Panel* panel, int i); -extern void IncSet_activate(IncSet* this, IncType type, Panel* panel); +void IncSet_activate(IncSet* this, IncType type, Panel* panel); -extern void IncSet_drawBar(IncSet* this); +void IncSet_drawBar(IncSet* this); -extern int IncSet_synthesizeEvent(IncSet* this, int x); +int IncSet_synthesizeEvent(IncSet* this, int x); #endif diff --git a/InfoScreen.c b/InfoScreen.c index 5c586bd..8a6a3be 100644 --- a/InfoScreen.c +++ b/InfoScreen.c @@ -13,42 +13,6 @@ #include #include -/*{ -#include "Process.h" -#include "Panel.h" -#include "FunctionBar.h" -#include "IncSet.h" - -typedef struct InfoScreen_ InfoScreen; - -typedef void(*InfoScreen_Scan)(InfoScreen*); -typedef void(*InfoScreen_Draw)(InfoScreen*); -typedef void(*InfoScreen_OnErr)(InfoScreen*); -typedef bool(*InfoScreen_OnKey)(InfoScreen*, int); - -typedef struct InfoScreenClass_ { - ObjectClass super; - const InfoScreen_Scan scan; - const InfoScreen_Draw draw; - const InfoScreen_OnErr onErr; - const InfoScreen_OnKey onKey; -} InfoScreenClass; - -#define As_InfoScreen(this_) ((InfoScreenClass*)(((InfoScreen*)(this_))->super.klass)) -#define InfoScreen_scan(this_) As_InfoScreen(this_)->scan((InfoScreen*)(this_)) -#define InfoScreen_draw(this_) As_InfoScreen(this_)->draw((InfoScreen*)(this_)) -#define InfoScreen_onErr(this_) As_InfoScreen(this_)->onErr((InfoScreen*)(this_)) -#define InfoScreen_onKey(this_, ch_) As_InfoScreen(this_)->onKey((InfoScreen*)(this_), ch_) - -struct InfoScreen_ { - Object super; - Process* process; - Panel* display; - FunctionBar* bar; - IncSet* inc; - Vector* lines; -}; -}*/ static const char* const InfoScreenFunctions[] = {"Search ", "Filter ", "Refresh", "Done ", NULL}; diff --git a/InfoScreen.h b/InfoScreen.h index e5d6bb6..93665c1 100644 --- a/InfoScreen.h +++ b/InfoScreen.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_InfoScreen #define HEADER_InfoScreen @@ -38,16 +36,16 @@ struct InfoScreen_ { Vector* lines; }; -extern InfoScreen* InfoScreen_init(InfoScreen* this, Process* process, FunctionBar* bar, int height, const char* panelHeader); +InfoScreen* InfoScreen_init(InfoScreen* this, Process* process, FunctionBar* bar, int height, const char* panelHeader); -extern InfoScreen* InfoScreen_done(InfoScreen* this); +InfoScreen* InfoScreen_done(InfoScreen* this); -extern void InfoScreen_drawTitled(InfoScreen* this, const char* fmt, ...); +void InfoScreen_drawTitled(InfoScreen* this, const char* fmt, ...); -extern void InfoScreen_addLine(InfoScreen* this, const char* line); +void InfoScreen_addLine(InfoScreen* this, const char* line); -extern void InfoScreen_appendLine(InfoScreen* this, const char* line); +void InfoScreen_appendLine(InfoScreen* this, const char* line); -extern void InfoScreen_run(InfoScreen* this); +void InfoScreen_run(InfoScreen* this); #endif diff --git a/ListItem.c b/ListItem.c index abaf5d0..73129fa 100644 --- a/ListItem.c +++ b/ListItem.c @@ -15,17 +15,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Object.h" - -typedef struct ListItem_ { - Object super; - char* value; - int key; - bool moving; -} ListItem; - -}*/ static void ListItem_delete(Object* cast) { ListItem* this = (ListItem*)cast; diff --git a/ListItem.h b/ListItem.h index 402c5c4..3fea725 100644 --- a/ListItem.h +++ b/ListItem.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_ListItem #define HEADER_ListItem /* @@ -18,15 +16,14 @@ typedef struct ListItem_ { bool moving; } ListItem; - extern ObjectClass ListItem_class; -extern ListItem* ListItem_new(const char* value, int key); +ListItem* ListItem_new(const char* value, int key); -extern void ListItem_append(ListItem* this, const char* text); +void ListItem_append(ListItem* this, const char* text); -extern const char* ListItem_getRef(ListItem* this); +const char* ListItem_getRef(ListItem* this); -extern long ListItem_compare(const void* cast1, const void* cast2); +long ListItem_compare(const void* cast1, const void* cast2); #endif diff --git a/LoadAverageMeter.c b/LoadAverageMeter.c index e29433f..db397b6 100644 --- a/LoadAverageMeter.c +++ b/LoadAverageMeter.c @@ -10,9 +10,6 @@ in the source distribution for its full text. #include "CRT.h" #include "Platform.h" -/*{ -#include "Meter.h" -}*/ int LoadAverageMeter_attributes[] = { LOAD_AVERAGE_ONE, LOAD_AVERAGE_FIVE, LOAD_AVERAGE_FIFTEEN diff --git a/LoadAverageMeter.h b/LoadAverageMeter.h index bd18f4d..83d3c8f 100644 --- a/LoadAverageMeter.h +++ b/LoadAverageMeter.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_LoadAverageMeter #define HEADER_LoadAverageMeter /* diff --git a/Macros.h b/Macros.h new file mode 100644 index 0000000..cb84b29 --- /dev/null +++ b/Macros.h @@ -0,0 +1,16 @@ +#ifndef HEADER_Macros +#define HEADER_Macros + +#ifndef MINIMUM +#define MINIMUM(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef MAXIMUM +#define MAXIMUM(a, b) ((a) > (b) ? (a) : (b)) +#endif + +#ifndef CLAMP +#define CLAMP(x, low, high) (((x) > (high)) ? (high) : MAXIMUM(x, low)) +#endif + +#endif diff --git a/MainPanel.c b/MainPanel.c index 55be17b..eb7e663 100644 --- a/MainPanel.c +++ b/MainPanel.c @@ -13,25 +13,6 @@ in the source distribution for its full text. #include -/*{ -#include "Panel.h" -#include "Action.h" -#include "Settings.h" - -typedef struct MainPanel_ { - Panel super; - State* state; - IncSet* inc; - Htop_Action *keys; - pid_t pidSearch; -} MainPanel; - -typedef bool(*MainPanel_ForeachProcessFn)(Process*, Arg); - -#define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar) - -}*/ - static const char* const MainFunctions[] = {"Help ", "Setup ", "Search ", "Filter ", "Tree ", "SortBy ", "Nice - ", "Nice + ", "Kill ", "Quit ", NULL}; void MainPanel_updateTreeFunctions(MainPanel* this, bool mode) { diff --git a/MainPanel.h b/MainPanel.h index 6162d8e..ca06472 100644 --- a/MainPanel.h +++ b/MainPanel.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_MainPanel #define HEADER_MainPanel /* @@ -10,9 +8,9 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#include "Panel.h" #include "Action.h" -#include "Settings.h" +#include "IncSet.h" +#include "Panel.h" typedef struct MainPanel_ { Panel super; @@ -26,23 +24,22 @@ typedef bool(*MainPanel_ForeachProcessFn)(Process*, Arg); #define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar) +void MainPanel_updateTreeFunctions(MainPanel* this, bool mode); -extern void MainPanel_updateTreeFunctions(MainPanel* this, bool mode); - -extern void MainPanel_pidSearch(MainPanel* this, int ch); +void MainPanel_pidSearch(MainPanel* this, int ch); -extern int MainPanel_selectedPid(MainPanel* this); +int MainPanel_selectedPid(MainPanel* this); -extern const char* MainPanel_getValue(MainPanel* this, int i); +const char* MainPanel_getValue(MainPanel* this, int i); -extern bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, Arg arg, bool* wasAnyTagged); +bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, Arg arg, bool* wasAnyTagged); extern PanelClass MainPanel_class; -extern MainPanel* MainPanel_new(); +MainPanel* MainPanel_new(); -extern void MainPanel_setState(MainPanel* this, State* state); +void MainPanel_setState(MainPanel* this, State* state); -extern void MainPanel_delete(Object* object); +void MainPanel_delete(Object* object); #endif diff --git a/Makefile.am b/Makefile.am index d455b4d..50fb586 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,7 @@ AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS = htop dist_man_MANS = htop.1 -EXTRA_DIST = $(dist_man_MANS) htop.desktop htop.png scripts/MakeHeader.py \ +EXTRA_DIST = $(dist_man_MANS) htop.desktop htop.png \ install-sh autogen.sh missing applicationsdir = $(datadir)/applications applications_DATA = htop.desktop @@ -29,14 +29,12 @@ InfoScreen.c XAlloc.c myhtopheaders = AvailableColumnsPanel.h AvailableMetersPanel.h \ CategoriesPanel.h CheckItem.h ClockMeter.h ColorsPanel.h ColumnsPanel.h \ CPUMeter.h CRT.h MainPanel.h DisplayOptionsPanel.h FunctionBar.h \ -Hashtable.h Header.h htop.h ListItem.h LoadAverageMeter.h MemoryMeter.h \ +Hashtable.h Header.h ListItem.h LoadAverageMeter.h MemoryMeter.h \ BatteryMeter.h Meter.h MetersPanel.h Object.h Panel.h ProcessList.h RichString.h \ ScreenManager.h Settings.h SignalsPanel.h StringUtils.h SwapMeter.h \ TasksMeter.h UptimeMeter.h TraceScreen.h UsersTable.h Vector.h Process.h \ AffinityPanel.h HostnameMeter.h OpenFilesScreen.h Affinity.h IncSet.h Action.h \ -EnvScreen.h InfoScreen.h XAlloc.h - -all_platform_headers = +EnvScreen.h InfoScreen.h XAlloc.h Macros.h # Linux # ----- @@ -54,11 +52,9 @@ linux_platform_headers = \ zfs/ZfsCompressedArcMeter.h \ zfs/ZfsArcStats.h -all_platform_headers += $(linux_platform_headers) - if HTOP_LINUX AM_LDFLAGS += -rdynamic -myhtopplatsources = linux/Platform.c linux/IOPriorityPanel.c linux/IOPriority.c \ +myhtopplatsources = linux/Platform.c linux/IOPriorityPanel.c \ linux/LinuxProcess.c linux/LinuxProcessList.c linux/LinuxCRT.c linux/Battery.c \ linux/PressureStallMeter.c \ zfs/ZfsArcMeter.c zfs/ZfsCompressedArcMeter.c zfs/ZfsArcStats.c @@ -80,8 +76,6 @@ freebsd_platform_headers = \ zfs/ZfsArcStats.h \ zfs/openzfs_sysctl.h -all_platform_headers += $(freebsd_platform_headers) - if HTOP_FREEBSD myhtopplatsources = freebsd/Platform.c freebsd/FreeBSDProcessList.c \ freebsd/FreeBSDProcess.c freebsd/FreeBSDCRT.c freebsd/Battery.c \ @@ -100,8 +94,6 @@ dragonflybsd_platform_headers = \ dragonflybsd/DragonFlyBSDCRT.h \ dragonflybsd/Battery.h -all_platform_headers += $(dragonflybsd_platform_headers) - if HTOP_DRAGONFLYBSD AM_LDFLAGS += -lkvm -lkinfo -lexecinfo myhtopplatsources = dragonflybsd/Platform.c dragonflybsd/DragonFlyBSDProcessList.c \ @@ -120,8 +112,6 @@ openbsd_platform_headers = \ openbsd/OpenBSDCRT.h \ openbsd/Battery.h -all_platform_headers += $(openbsd_platform_headers) - if HTOP_OPENBSD myhtopplatsources = openbsd/Platform.c openbsd/OpenBSDProcessList.c \ openbsd/OpenBSDProcess.c openbsd/OpenBSDCRT.c openbsd/Battery.c @@ -143,8 +133,6 @@ darwin_platform_headers = \ zfs/ZfsArcStats.h \ zfs/openzfs_sysctl.h -all_platform_headers += $(darwin_platform_headers) - if HTOP_DARWIN AM_LDFLAGS += -framework IOKit -framework CoreFoundation myhtopplatsources = darwin/Platform.c darwin/DarwinProcess.c \ @@ -167,8 +155,6 @@ solaris_platform_headers = \ zfs/ZfsCompressedArcMeter.h \ zfs/ZfsArcStats.h -all_platform_headers += $(solaris_platform_headers) - if HTOP_SOLARIS myhtopplatsources = solaris/Platform.c \ solaris/SolarisProcess.c solaris/SolarisProcessList.c \ @@ -188,8 +174,6 @@ unsupported_platform_headers = \ unsupported/UnsupportedCRT.h \ unsupported/Battery.h -all_platform_headers += $(unsupported_platform_headers) - if HTOP_UNSUPPORTED myhtopplatsources = unsupported/Platform.c \ unsupported/UnsupportedProcess.c unsupported/UnsupportedProcessList.c \ @@ -200,19 +184,9 @@ endif # ---- -SUFFIXES = .h - -BUILT_SOURCES = $(myhtopheaders) $(myhtopplatheaders) htop_SOURCES = $(myhtopheaders) $(myhtopplatheaders) $(myhtopsources) $(myhtopplatsources) nodist_htop_SOURCES = config.h -.PHONY: htop-headers clean-htop-headers - -htop-headers: $(myhtopheaders) $(all_platform_headers) - -clean-htop-headers: - -rm -f $(myhtopheaders) $(all_platform_headers) - target: echo $(htop_SOURCES) @@ -225,9 +199,6 @@ debug: coverage: $(MAKE) all CFLAGS="" AM_CPPFLAGS="-fprofile-arcs -ftest-coverage -DDEBUG" LDFLAGS="-lgcov" -.c.h: - ./scripts/MakeHeader.py $< - cppcheck: cppcheck -q -v . --enable=all -DHAVE_CGROUP -DHAVE_OPENVZ -DHAVE_TASKSTATS diff --git a/MemoryMeter.c b/MemoryMeter.c index 8d5d809..91f75b9 100644 --- a/MemoryMeter.c +++ b/MemoryMeter.c @@ -16,9 +16,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Meter.h" -}*/ int MemoryMeter_attributes[] = { MEMORY_USED, MEMORY_BUFFERS, MEMORY_CACHE diff --git a/MemoryMeter.h b/MemoryMeter.h index 6ddae92..771aa73 100644 --- a/MemoryMeter.h +++ b/MemoryMeter.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_MemoryMeter #define HEADER_MemoryMeter /* diff --git a/Meter.c b/Meter.c index 699a788..00c49ce 100644 --- a/Meter.c +++ b/Meter.c @@ -11,7 +11,6 @@ in the source distribution for its full text. #include "Object.h" #include "CRT.h" #include "StringUtils.h" -#include "ListItem.h" #include "Settings.h" #include @@ -19,108 +18,11 @@ in the source distribution for its full text. #include #include #include -#include - -#define METER_BUFFER_LEN 256 #define GRAPH_DELAY (DEFAULT_DELAY/2) #define GRAPH_HEIGHT 4 /* Unit: rows (lines) */ -/*{ -#include "ListItem.h" - -#include - -typedef struct Meter_ Meter; - -typedef void(*Meter_Init)(Meter*); -typedef void(*Meter_Done)(Meter*); -typedef void(*Meter_UpdateMode)(Meter*, int); -typedef void(*Meter_UpdateValues)(Meter*, char*, int); -typedef void(*Meter_Draw)(Meter*, int, int, int); - -typedef struct MeterClass_ { - ObjectClass super; - const Meter_Init init; - const Meter_Done done; - const Meter_UpdateMode updateMode; - const Meter_Draw draw; - const Meter_UpdateValues updateValues; - const int defaultMode; - const double total; - const int* attributes; - const char* name; - const char* uiName; - const char* caption; - const char* description; - const char maxItems; - char curItems; -} MeterClass; - -#define As_Meter(this_) ((MeterClass*)((this_)->super.klass)) -#define Meter_initFn(this_) As_Meter(this_)->init -#define Meter_init(this_) As_Meter(this_)->init((Meter*)(this_)) -#define Meter_done(this_) As_Meter(this_)->done((Meter*)(this_)) -#define Meter_updateModeFn(this_) As_Meter(this_)->updateMode -#define Meter_updateMode(this_, m_) As_Meter(this_)->updateMode((Meter*)(this_), m_) -#define Meter_drawFn(this_) As_Meter(this_)->draw -#define Meter_doneFn(this_) As_Meter(this_)->done -#define Meter_updateValues(this_, buf_, sz_) \ - As_Meter(this_)->updateValues((Meter*)(this_), buf_, sz_) -#define Meter_defaultMode(this_) As_Meter(this_)->defaultMode -#define Meter_getItems(this_) As_Meter(this_)->curItems -#define Meter_setItems(this_, n_) As_Meter(this_)->curItems = (n_) -#define Meter_attributes(this_) As_Meter(this_)->attributes -#define Meter_name(this_) As_Meter(this_)->name -#define Meter_uiName(this_) As_Meter(this_)->uiName - -struct Meter_ { - Object super; - Meter_Draw draw; - - char* caption; - int mode; - int param; - void* drawData; - int h; - struct ProcessList_* pl; - double* values; - double total; -}; - -typedef struct MeterMode_ { - Meter_Draw draw; - const char* uiName; - int h; -} MeterMode; - -typedef enum { - CUSTOM_METERMODE = 0, - BAR_METERMODE, - TEXT_METERMODE, - GRAPH_METERMODE, - LED_METERMODE, - LAST_METERMODE -} MeterModeId; - -typedef struct GraphData_ { - struct timeval time; - double values[METER_BUFFER_LEN]; -} GraphData; - -}*/ - -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif -#ifndef MAX -#define MAX(a,b) ((a)>(b)?(a):(b)) -#endif -#ifndef CLAMP -#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) -#endif - MeterClass Meter_class = { .super = { .extends = Class(Object) diff --git a/Meter.h b/Meter.h index 56d46f2..c4d0039 100644 --- a/Meter.h +++ b/Meter.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Meter #define HEADER_Meter /* @@ -9,16 +7,11 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#define METER_BUFFER_LEN 256 - -#define GRAPH_DELAY (DEFAULT_DELAY/2) - -#define GRAPH_HEIGHT 4 /* Unit: rows (lines) */ - #include "ListItem.h" - #include +#define METER_BUFFER_LEN 256 + typedef struct Meter_ Meter; typedef void(*Meter_Init)(Meter*); @@ -96,54 +89,22 @@ typedef struct GraphData_ { double values[METER_BUFFER_LEN]; } GraphData; - -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif -#ifndef MAX -#define MAX(a,b) ((a)>(b)?(a):(b)) -#endif -#ifndef CLAMP -#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) -#endif - extern MeterClass Meter_class; -extern Meter* Meter_new(struct ProcessList_* pl, int param, MeterClass* type); +Meter* Meter_new(struct ProcessList_* pl, int param, MeterClass* type); -extern int Meter_humanUnit(char* buffer, unsigned long int value, int size); +int Meter_humanUnit(char* buffer, unsigned long int value, int size); -extern void Meter_delete(Object* cast); +void Meter_delete(Object* cast); -extern void Meter_setCaption(Meter* this, const char* caption); +void Meter_setCaption(Meter* this, const char* caption); -extern void Meter_setMode(Meter* this, int modeIndex); +void Meter_setMode(Meter* this, int modeIndex); -extern ListItem* Meter_toListItem(Meter* this, bool moving); - -/* ---------- TextMeterMode ---------- */ - -/* ---------- BarMeterMode ---------- */ - -/* ---------- GraphMeterMode ---------- */ - -#ifdef HAVE_LIBNCURSESW - -#define PIXPERROW_UTF8 4 -#endif - -#define PIXPERROW_ASCII 2 - -/* ---------- LEDMeterMode ---------- */ - -#ifdef HAVE_LIBNCURSESW - -#endif +ListItem* Meter_toListItem(Meter* this, bool moving); extern MeterMode* Meter_modes[]; -/* Blank meter */ - extern int BlankMeter_attributes[]; extern MeterClass BlankMeter_class; diff --git a/MetersPanel.c b/MetersPanel.c index 397a6c7..417834a 100644 --- a/MetersPanel.c +++ b/MetersPanel.c @@ -11,25 +11,6 @@ in the source distribution for its full text. #include #include "CRT.h" -/*{ -#include "Panel.h" -#include "Settings.h" -#include "ScreenManager.h" - -typedef struct MetersPanel_ MetersPanel; - -struct MetersPanel_ { - Panel super; - - Settings* settings; - Vector* meters; - ScreenManager* scr; - MetersPanel* leftNeighbor; - MetersPanel* rightNeighbor; - bool moving; -}; - -}*/ // Note: In code the meters are known to have bar/text/graph "Modes", but in UI // we call them "Styles". diff --git a/MetersPanel.h b/MetersPanel.h index 12eabbe..c02ce1c 100644 --- a/MetersPanel.h +++ b/MetersPanel.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_MetersPanel #define HEADER_MetersPanel /* @@ -26,18 +24,10 @@ struct MetersPanel_ { bool moving; }; - -// Note: In code the meters are known to have bar/text/graph "Modes", but in UI -// we call them "Styles". -// We avoid UTF-8 arrows ← → here as they might display full-width on Chinese -// terminals, breaking our aligning. -// In , arrows (U+2019..U+2199) are -// considered "Ambiguous characters". - -extern void MetersPanel_setMoving(MetersPanel* this, bool moving); +void MetersPanel_setMoving(MetersPanel* this, bool moving); extern PanelClass MetersPanel_class; -extern MetersPanel* MetersPanel_new(Settings* settings, const char* header, Vector* meters, ScreenManager* scr); +MetersPanel* MetersPanel_new(Settings* settings, const char* header, Vector* meters, ScreenManager* scr); #endif diff --git a/Object.c b/Object.c index 5edcc60..4d8045d 100644 --- a/Object.c +++ b/Object.c @@ -8,46 +8,6 @@ in the source distribution for its full text. #include "Object.h" -/*{ -#include "RichString.h" -#include "XAlloc.h" - -typedef struct Object_ Object; - -typedef void(*Object_Display)(Object*, RichString*); -typedef long(*Object_Compare)(const void*, const void*); -typedef void(*Object_Delete)(Object*); - -#define Object_getClass(obj_) ((Object*)(obj_))->klass -#define Object_setClass(obj_, class_) Object_getClass(obj_) = (ObjectClass*) class_ - -#define Object_delete(obj_) Object_getClass(obj_)->delete((Object*)(obj_)) -#define Object_displayFn(obj_) Object_getClass(obj_)->display -#define Object_display(obj_, str_) Object_getClass(obj_)->display((Object*)(obj_), str_) -#define Object_compare(obj_, other_) Object_getClass(obj_)->compare((const void*)(obj_), other_) - -#define Class(class_) ((ObjectClass*)(&(class_ ## _class))) - -#define AllocThis(class_) (class_*) xMalloc(sizeof(class_)); Object_setClass(this, Class(class_)); - -typedef struct ObjectClass_ { - const void* extends; - const Object_Display display; - const Object_Delete delete; - const Object_Compare compare; -} ObjectClass; - -struct Object_ { - ObjectClass* klass; -}; - -typedef union { - int i; - void* v; -} Arg; - -}*/ - ObjectClass Object_class = { .extends = NULL }; diff --git a/Object.h b/Object.h index 9be948f..50a5f12 100644 --- a/Object.h +++ b/Object.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Object #define HEADER_Object /* @@ -12,6 +10,7 @@ in the source distribution for its full text. #include "RichString.h" #include "XAlloc.h" +#include "Macros.h" typedef struct Object_ Object; @@ -47,12 +46,11 @@ typedef union { void* v; } Arg; - extern ObjectClass Object_class; #ifdef DEBUG -extern bool Object_isA(Object* o, const ObjectClass* klass); +bool Object_isA(Object* o, const ObjectClass* klass); #endif diff --git a/OpenFilesScreen.c b/OpenFilesScreen.c index 658b186..3e45bf8 100644 --- a/OpenFilesScreen.c +++ b/OpenFilesScreen.c @@ -23,30 +23,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "InfoScreen.h" - -typedef struct OpenFiles_Data_ { - char* data[256]; -} OpenFiles_Data; - -typedef struct OpenFiles_ProcessData_ { - OpenFiles_Data data; - int error; - struct OpenFiles_FileData_* files; -} OpenFiles_ProcessData; - -typedef struct OpenFiles_FileData_ { - OpenFiles_Data data; - struct OpenFiles_FileData_* next; -} OpenFiles_FileData; - -typedef struct OpenFilesScreen_ { - InfoScreen super; - pid_t pid; -} OpenFilesScreen; - -}*/ InfoScreenClass OpenFilesScreen_class = { .super = { diff --git a/OpenFilesScreen.h b/OpenFilesScreen.h index 39c71d5..2c83cf1 100644 --- a/OpenFilesScreen.h +++ b/OpenFilesScreen.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_OpenFilesScreen #define HEADER_OpenFilesScreen /* @@ -31,15 +29,14 @@ typedef struct OpenFilesScreen_ { pid_t pid; } OpenFilesScreen; - extern InfoScreenClass OpenFilesScreen_class; -extern OpenFilesScreen* OpenFilesScreen_new(Process* process); +OpenFilesScreen* OpenFilesScreen_new(Process* process); -extern void OpenFilesScreen_delete(Object* this); +void OpenFilesScreen_delete(Object* this); -extern void OpenFilesScreen_draw(InfoScreen* this); +void OpenFilesScreen_draw(InfoScreen* this); -extern void OpenFilesScreen_scan(InfoScreen* this); +void OpenFilesScreen_scan(InfoScreen* this); #endif diff --git a/Panel.c b/Panel.c index 348fd23..b77483d 100644 --- a/Panel.c +++ b/Panel.c @@ -19,72 +19,6 @@ in the source distribution for its full text. #include #include -//#link curses - -/*{ -#include "Object.h" -#include "Vector.h" -#include "FunctionBar.h" - -typedef struct Panel_ Panel; - -typedef enum HandlerResult_ { - HANDLED = 0x01, - IGNORED = 0x02, - BREAK_LOOP = 0x04, - REDRAW = 0x08, - RESCAN = 0x10, - SYNTH_KEY = 0x20, -} HandlerResult; - -#define EVENT_SET_SELECTED -1 - -#define EVENT_HEADER_CLICK(x_) (-10000 + x_) -#define EVENT_IS_HEADER_CLICK(ev_) (ev_ >= -10000 && ev_ <= -9000) -#define EVENT_HEADER_CLICK_GET_X(ev_) (ev_ + 10000) - -typedef HandlerResult(*Panel_EventHandler)(Panel*, int); - -typedef struct PanelClass_ { - const ObjectClass super; - const Panel_EventHandler eventHandler; -} PanelClass; - -#define As_Panel(this_) ((PanelClass*)((this_)->super.klass)) -#define Panel_eventHandlerFn(this_) As_Panel(this_)->eventHandler -#define Panel_eventHandler(this_, ev_) As_Panel(this_)->eventHandler((Panel*)(this_), ev_) - -struct Panel_ { - Object super; - int x, y, w, h; - WINDOW* window; - Vector* items; - int selected; - int oldSelected; - int selectedLen; - void* eventHandlerState; - int scrollV; - short scrollH; - bool needsRedraw; - FunctionBar* currentBar; - FunctionBar* defaultBar; - RichString header; - int selectionColor; -}; - -#define Panel_setDefaultBar(this_) do{ (this_)->currentBar = (this_)->defaultBar; }while(0) - -}*/ - -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif -#ifndef MAX -#define MAX(a,b) ((a)>(b)?(a):(b)) -#endif - -#define KEY_CTRL(l) ((l)-'A'+1) - PanelClass Panel_class = { .super = { .extends = Class(Object), @@ -290,7 +224,7 @@ void Panel_draw(Panel* this, bool focus) { mvhline(y, x, ' ', this->w); if (scrollH < headerLen) { RichString_printoffnVal(this->header, y, x, scrollH, - MIN(headerLen - scrollH, this->w)); + MINIMUM(headerLen - scrollH, this->w)); } attrset(CRT_colors[RESET_COLOR]); y++; @@ -301,7 +235,7 @@ void Panel_draw(Panel* this, bool focus) { this->scrollV = 0; this->needsRedraw = true; } else if (this->scrollV >= size) { - this->scrollV = MAX(size - 1, 0); + this->scrollV = MAXIMUM(size - 1, 0); this->needsRedraw = true; } // ensure selection is on screen @@ -314,7 +248,7 @@ void Panel_draw(Panel* this, bool focus) { } int first = this->scrollV; - int upTo = MIN(first + h, size); + int upTo = MINIMUM(first + h, size); int selectionColor = focus ? this->selectionColor @@ -328,7 +262,7 @@ void Panel_draw(Panel* this, bool focus) { RichString_begin(item); Object_display(itemObj, &item); int itemLen = RichString_sizeVal(item); - int amt = MIN(itemLen - scrollH, this->w); + int amt = MINIMUM(itemLen - scrollH, this->w); bool selected = (i == this->selected); if (selected) { attrset(selectionColor); @@ -363,13 +297,13 @@ void Panel_draw(Panel* this, bool focus) { mvhline(y+ this->oldSelected - first, x+0, ' ', this->w); if (scrollH < oldLen) RichString_printoffnVal(old, y+this->oldSelected - first, x, - scrollH, MIN(oldLen - scrollH, this->w)); + scrollH, MINIMUM(oldLen - scrollH, this->w)); attrset(selectionColor); mvhline(y+this->selected - first, x+0, ' ', this->w); RichString_setAttr(&new, selectionColor); if (scrollH < newLen) RichString_printoffnVal(new, y+this->selected - first, x, - scrollH, MIN(newLen - scrollH, this->w)); + scrollH, MINIMUM(newLen - scrollH, this->w)); attrset(CRT_colors[RESET_COLOR]); RichString_end(new); RichString_end(old); @@ -404,7 +338,7 @@ bool Panel_onKey(Panel* this, int key) { case KEY_LEFT: case KEY_CTRL('B'): if (this->scrollH > 0) { - this->scrollH -= MAX(CRT_scrollHAmount, 0); + this->scrollH -= MAXIMUM(CRT_scrollHAmount, 0); this->needsRedraw = true; } break; @@ -415,12 +349,12 @@ bool Panel_onKey(Panel* this, int key) { break; case KEY_PPAGE: this->selected -= (this->h - 1); - this->scrollV = MAX(0, this->scrollV - this->h + 1); + this->scrollV = MAXIMUM(0, this->scrollV - this->h + 1); this->needsRedraw = true; break; case KEY_NPAGE: this->selected += (this->h - 1); - this->scrollV = MAX(0, MIN(Vector_size(this->items) - this->h, + this->scrollV = MAXIMUM(0, MINIMUM(Vector_size(this->items) - this->h, this->scrollV + this->h - 1)); this->needsRedraw = true; break; @@ -452,7 +386,7 @@ bool Panel_onKey(Panel* this, int key) { break; case KEY_CTRL('E'): case '$': - this->scrollH = MAX(this->selectedLen - this->w, 0); + this->scrollH = MAXIMUM(this->selectedLen - this->w, 0); this->needsRedraw = true; break; default: diff --git a/Panel.h b/Panel.h index 4b517f3..480e2c0 100644 --- a/Panel.h +++ b/Panel.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Panel #define HEADER_Panel /* @@ -9,8 +7,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -//#link curses - #include "Object.h" #include "Vector.h" #include "FunctionBar.h" @@ -63,66 +59,58 @@ struct Panel_ { #define Panel_setDefaultBar(this_) do{ (this_)->currentBar = (this_)->defaultBar; }while(0) - -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif -#ifndef MAX -#define MAX(a,b) ((a)>(b)?(a):(b)) -#endif - #define KEY_CTRL(l) ((l)-'A'+1) extern PanelClass Panel_class; -extern Panel* Panel_new(int x, int y, int w, int h, bool owner, ObjectClass* type, FunctionBar* fuBar); +Panel* Panel_new(int x, int y, int w, int h, bool owner, ObjectClass* type, FunctionBar* fuBar); -extern void Panel_delete(Object* cast); +void Panel_delete(Object* cast); -extern void Panel_init(Panel* this, int x, int y, int w, int h, ObjectClass* type, bool owner, FunctionBar* fuBar); +void Panel_init(Panel* this, int x, int y, int w, int h, ObjectClass* type, bool owner, FunctionBar* fuBar); -extern void Panel_done(Panel* this); +void Panel_done(Panel* this); -extern void Panel_setSelectionColor(Panel* this, int color); +void Panel_setSelectionColor(Panel* this, int color); -extern RichString* Panel_getHeader(Panel* this); +RichString* Panel_getHeader(Panel* this); -extern void Panel_setHeader(Panel* this, const char* header); +void Panel_setHeader(Panel* this, const char* header); -extern void Panel_move(Panel* this, int x, int y); +void Panel_move(Panel* this, int x, int y); -extern void Panel_resize(Panel* this, int w, int h); +void Panel_resize(Panel* this, int w, int h); -extern void Panel_prune(Panel* this); +void Panel_prune(Panel* this); -extern void Panel_add(Panel* this, Object* o); +void Panel_add(Panel* this, Object* o); -extern void Panel_insert(Panel* this, int i, Object* o); +void Panel_insert(Panel* this, int i, Object* o); -extern void Panel_set(Panel* this, int i, Object* o); +void Panel_set(Panel* this, int i, Object* o); -extern Object* Panel_get(Panel* this, int i); +Object* Panel_get(Panel* this, int i); -extern Object* Panel_remove(Panel* this, int i); +Object* Panel_remove(Panel* this, int i); -extern Object* Panel_getSelected(Panel* this); +Object* Panel_getSelected(Panel* this); -extern void Panel_moveSelectedUp(Panel* this); +void Panel_moveSelectedUp(Panel* this); -extern void Panel_moveSelectedDown(Panel* this); +void Panel_moveSelectedDown(Panel* this); -extern int Panel_getSelectedIndex(Panel* this); +int Panel_getSelectedIndex(Panel* this); -extern int Panel_size(Panel* this); +int Panel_size(Panel* this); -extern void Panel_setSelected(Panel* this, int selected); +void Panel_setSelected(Panel* this, int selected); -extern void Panel_draw(Panel* this, bool focus); +void Panel_draw(Panel* this, bool focus); -extern void Panel_splice(Panel *this, Vector* from); +void Panel_splice(Panel *this, Vector* from); -extern bool Panel_onKey(Panel* this, int key); +bool Panel_onKey(Panel* this, int key); -extern HandlerResult Panel_selectByTyping(Panel* this, int ch); +HandlerResult Panel_selectByTyping(Panel* this, int ch); #endif diff --git a/Process.c b/Process.c index 6a0d56b..7a04c0f 100644 --- a/Process.c +++ b/Process.c @@ -21,7 +21,6 @@ in the source distribution for its full text. #include #include #include -#include #include #include #include @@ -37,169 +36,8 @@ in the source distribution for its full text. #include #endif -#ifdef __ANDROID__ -#define SYS_ioprio_get __NR_ioprio_get -#define SYS_ioprio_set __NR_ioprio_set -#endif - -// On Linux, this works only with glibc 2.1+. On earlier versions -// the behavior is similar to have a hardcoded page size. -#ifndef PAGE_SIZE -#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) ) -#endif -#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K ) - -/*{ -#include "Object.h" - -#include - -#define PROCESS_FLAG_IO 0x0001 - -typedef enum ProcessFields { - NULL_PROCESSFIELD = 0, - PID = 1, - COMM = 2, - STATE = 3, - PPID = 4, - PGRP = 5, - SESSION = 6, - TTY_NR = 7, - TPGID = 8, - MINFLT = 10, - MAJFLT = 12, - PRIORITY = 18, - NICE = 19, - STARTTIME = 21, - PROCESSOR = 38, - M_SIZE = 39, - M_RESIDENT = 40, - ST_UID = 46, - PERCENT_CPU = 47, - PERCENT_MEM = 48, - USER = 49, - TIME = 50, - NLWP = 51, - TGID = 52, -} ProcessField; - -typedef struct ProcessPidColumn_ { - int id; - const char* label; -} ProcessPidColumn; - -typedef struct Process_ { - Object super; - - struct Settings_* settings; - - unsigned long long int time; - pid_t pid; - pid_t ppid; - pid_t tgid; - char* comm; - int commLen; - int indent; - - int basenameOffset; - bool updated; - - char state; - bool tag; - bool showChildren; - bool show; - unsigned int pgrp; - unsigned int session; - unsigned int tty_nr; - int tpgid; - uid_t st_uid; - unsigned long int flags; - int processor; - - float percent_cpu; - float percent_mem; - char* user; - - long int priority; - long int nice; - long int nlwp; - char starttime_show[8]; - time_t starttime_ctime; - - long m_size; - long m_resident; - - int exit_signal; - - unsigned long int minflt; - unsigned long int majflt; - #ifdef DEBUG - long int itrealvalue; - unsigned long int vsize; - long int rss; - unsigned long int rlim; - unsigned long int startcode; - unsigned long int endcode; - unsigned long int startstack; - unsigned long int kstkesp; - unsigned long int kstkeip; - unsigned long int signal; - unsigned long int blocked; - unsigned long int sigignore; - unsigned long int sigcatch; - unsigned long int wchan; - unsigned long int nswap; - unsigned long int cnswap; - #endif - -} Process; - -typedef struct ProcessFieldData_ { - const char* name; - const char* title; - const char* description; - int flags; -} ProcessFieldData; - -// Implemented in platform-specific code: -void Process_writeField(Process* this, RichString* str, ProcessField field); -long Process_compare(const void* v1, const void* v2); -void Process_delete(Object* cast); -bool Process_isThread(Process* this); -extern ProcessFieldData Process_fields[]; -extern ProcessPidColumn Process_pidColumns[]; -extern char Process_pidFormat[20]; - -typedef Process*(*Process_New)(struct Settings_*); -typedef void (*Process_WriteField)(Process*, RichString*, ProcessField); - -typedef struct ProcessClass_ { - const ObjectClass super; - const Process_WriteField writeField; -} ProcessClass; - -#define As_Process(this_) ((ProcessClass*)((this_)->super.klass)) - -#define Process_getParentPid(process_) (process_->tgid == process_->pid ? process_->ppid : process_->tgid) - -#define Process_isChildOf(process_, pid_) (process_->tgid == pid_ || (process_->tgid == process_->pid && process_->ppid == pid_)) - -#define Process_sortState(state) ((state) == 'I' ? 0x100 : (state)) - -}*/ - static int Process_getuid = -1; -#define ONE_K 1024L -#define ONE_M (ONE_K * ONE_K) -#define ONE_G (ONE_M * ONE_K) -#define ONE_T ((long long)ONE_G * ONE_K) - -#define ONE_DECIMAL_K 1000L -#define ONE_DECIMAL_M (ONE_DECIMAL_K * ONE_DECIMAL_K) -#define ONE_DECIMAL_G (ONE_DECIMAL_M * ONE_DECIMAL_K) -#define ONE_DECIMAL_T ((long long)ONE_DECIMAL_G * ONE_DECIMAL_K) - char Process_pidFormat[20] = "%7d "; static char Process_titleBuffer[20][20]; diff --git a/Process.h b/Process.h index 3085f16..ebf5cdf 100644 --- a/Process.h +++ b/Process.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Process #define HEADER_Process /* @@ -10,10 +8,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#ifdef MAJOR_IN_MKDEV -#elif defined(MAJOR_IN_SYSMACROS) -#endif - #ifdef __ANDROID__ #define SYS_ioprio_get __NR_ioprio_get #define SYS_ioprio_set __NR_ioprio_set @@ -175,36 +169,36 @@ typedef struct ProcessClass_ { extern char Process_pidFormat[20]; -extern void Process_setupColumnWidths(); +void Process_setupColumnWidths(); -extern void Process_humanNumber(RichString* str, unsigned long number, bool coloring); +void Process_humanNumber(RichString* str, unsigned long number, bool coloring); -extern void Process_colorNumber(RichString* str, unsigned long long number, bool coloring); +void Process_colorNumber(RichString* str, unsigned long long number, bool coloring); -extern void Process_printTime(RichString* str, unsigned long long totalHundredths); +void Process_printTime(RichString* str, unsigned long long totalHundredths); -extern void Process_outputRate(RichString* str, char* buffer, int n, double rate, int coloring); +void Process_outputRate(RichString* str, char* buffer, int n, double rate, int coloring); -extern void Process_writeField(Process* this, RichString* str, ProcessField field); +void Process_writeField(Process* this, RichString* str, ProcessField field); -extern void Process_display(Object* cast, RichString* out); +void Process_display(Object* cast, RichString* out); -extern void Process_done(Process* this); +void Process_done(Process* this); extern ProcessClass Process_class; -extern void Process_init(Process* this, struct Settings_* settings); +void Process_init(Process* this, struct Settings_* settings); -extern void Process_toggleTag(Process* this); +void Process_toggleTag(Process* this); -extern bool Process_setPriority(Process* this, int priority); +bool Process_setPriority(Process* this, int priority); -extern bool Process_changePriorityBy(Process* this, Arg delta); +bool Process_changePriorityBy(Process* this, Arg delta); -extern bool Process_sendSignal(Process* this, Arg sgn); +bool Process_sendSignal(Process* this, Arg sgn); -extern long Process_pidCompare(const void* v1, const void* v2); +long Process_pidCompare(const void* v1, const void* v2); -extern long Process_compare(const void* v1, const void* v2); +long Process_compare(const void* v1, const void* v2); #endif diff --git a/ProcessList.c b/ProcessList.c index 36b494e..aa529d5 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -14,75 +14,12 @@ in the source distribution for its full text. #include #include -/*{ -#include "Vector.h" -#include "Hashtable.h" -#include "UsersTable.h" -#include "Panel.h" -#include "Process.h" -#include "Settings.h" -#ifdef HAVE_LIBHWLOC -#include -#endif - -#ifndef MAX_NAME -#define MAX_NAME 128 -#endif - -#ifndef MAX_READ -#define MAX_READ 2048 -#endif - -typedef struct ProcessList_ { - Settings* settings; - - Vector* processes; - Vector* processes2; - Hashtable* processTable; - UsersTable* usersTable; - - Panel* panel; - int following; - uid_t userId; - const char* incFilter; - Hashtable* pidWhiteList; - - #ifdef HAVE_LIBHWLOC - hwloc_topology_t topology; - bool topologyOk; - #endif - - int totalTasks; - int runningTasks; - int userlandThreads; - int kernelThreads; - - unsigned long long int totalMem; - unsigned long long int usedMem; - unsigned long long int freeMem; - unsigned long long int sharedMem; - unsigned long long int buffersMem; - unsigned long long int cachedMem; - unsigned long long int totalSwap; - unsigned long long int usedSwap; - unsigned long long int freeSwap; - - int cpuCount; - -} ProcessList; - -ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidWhiteList, uid_t userId); -void ProcessList_delete(ProcessList* pl); -void ProcessList_goThroughEntries(ProcessList* pl); - -}*/ - -ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) { +ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) { this->processes = Vector_new(klass, true, DEFAULT_SIZE); this->processTable = Hashtable_new(140, false); this->usersTable = usersTable; - this->pidWhiteList = pidWhiteList; + this->pidMatchList = pidMatchList; this->userId = userId; // tree-view auxiliary buffer @@ -317,7 +254,7 @@ void ProcessList_rebuildPanel(ProcessList* this) { if ( (!p->show) || (this->userId != (uid_t) -1 && (p->st_uid != this->userId)) || (incFilter && !(String_contains_i(p->comm, incFilter))) - || (this->pidWhiteList && !Hashtable_get(this->pidWhiteList, p->tgid)) ) + || (this->pidMatchList && !Hashtable_get(this->pidMatchList, p->tgid)) ) hidden = true; if (!hidden) { diff --git a/ProcessList.h b/ProcessList.h index ddc6f3f..7b572d8 100644 --- a/ProcessList.h +++ b/ProcessList.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_ProcessList #define HEADER_ProcessList /* @@ -40,7 +38,7 @@ typedef struct ProcessList_ { int following; uid_t userId; const char* incFilter; - Hashtable* pidWhiteList; + Hashtable* pidMatchList; #ifdef HAVE_LIBHWLOC hwloc_topology_t topology; @@ -66,37 +64,37 @@ typedef struct ProcessList_ { } ProcessList; -ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidWhiteList, uid_t userId); +ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidMatchList, uid_t userId); void ProcessList_delete(ProcessList* pl); void ProcessList_goThroughEntries(ProcessList* pl); -extern ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId); +ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId); -extern void ProcessList_done(ProcessList* this); +void ProcessList_done(ProcessList* this); -extern void ProcessList_setPanel(ProcessList* this, Panel* panel); +void ProcessList_setPanel(ProcessList* this, Panel* panel); -extern void ProcessList_printHeader(ProcessList* this, RichString* header); +void ProcessList_printHeader(ProcessList* this, RichString* header); -extern void ProcessList_add(ProcessList* this, Process* p); +void ProcessList_add(ProcessList* this, Process* p); -extern void ProcessList_remove(ProcessList* this, Process* p); +void ProcessList_remove(ProcessList* this, Process* p); -extern Process* ProcessList_get(ProcessList* this, int idx); +Process* ProcessList_get(ProcessList* this, int idx); -extern int ProcessList_size(ProcessList* this); +int ProcessList_size(ProcessList* this); -extern void ProcessList_sort(ProcessList* this); +void ProcessList_sort(ProcessList* this); -extern ProcessField ProcessList_keyAt(ProcessList* this, int at); +ProcessField ProcessList_keyAt(ProcessList* this, int at); -extern void ProcessList_expandTree(ProcessList* this); +void ProcessList_expandTree(ProcessList* this); -extern void ProcessList_rebuildPanel(ProcessList* this); +void ProcessList_rebuildPanel(ProcessList* this); -extern Process* ProcessList_getProcess(ProcessList* this, pid_t pid, bool* preExisting, Process_New constructor); +Process* ProcessList_getProcess(ProcessList* this, pid_t pid, bool* preExisting, Process_New constructor); -extern void ProcessList_scan(ProcessList* this); +void ProcessList_scan(ProcessList* this); #endif diff --git a/RichString.c b/RichString.c index d246f1e..b97e34e 100644 --- a/RichString.c +++ b/RichString.c @@ -7,66 +7,11 @@ in the source distribution for its full text. #include "RichString.h" #include "XAlloc.h" +#include "Macros.h" #include #include -#define RICHSTRING_MAXLEN 350 - -/*{ -#include "config.h" -#include - -#include -#ifdef HAVE_NCURSESW_CURSES_H -#include -#elif HAVE_NCURSES_NCURSES_H -#include -#elif HAVE_NCURSES_CURSES_H -#include -#elif HAVE_NCURSES_H -#include -#elif HAVE_CURSES_H -#include -#endif - -#ifdef HAVE_LIBNCURSESW -#include -#endif - -#define RichString_size(this) ((this)->chlen) -#define RichString_sizeVal(this) ((this).chlen) - -#define RichString_begin(this) RichString (this); memset(&this, 0, sizeof(RichString)); (this).chptr = (this).chstr; -#define RichString_beginAllocated(this) memset(&this, 0, sizeof(RichString)); (this).chptr = (this).chstr; -#define RichString_end(this) RichString_prune(&(this)); - -#ifdef HAVE_LIBNCURSESW -#define RichString_printVal(this, y, x) mvadd_wchstr(y, x, (this).chptr) -#define RichString_printoffnVal(this, y, x, off, n) mvadd_wchnstr(y, x, (this).chptr + off, n) -#define RichString_getCharVal(this, i) ((this).chptr[i].chars[0] & 255) -#define RichString_setChar(this, at, ch) do{ (this)->chptr[(at)] = (CharType) { .chars = { ch, 0 } }; } while(0) -#define CharType cchar_t -#else -#define RichString_printVal(this, y, x) mvaddchstr(y, x, (this).chptr) -#define RichString_printoffnVal(this, y, x, off, n) mvaddchnstr(y, x, (this).chptr + off, n) -#define RichString_getCharVal(this, i) ((this).chptr[i]) -#define RichString_setChar(this, at, ch) do{ (this)->chptr[(at)] = ch; } while(0) -#define CharType chtype -#endif - -typedef struct RichString_ { - int chlen; - CharType* chptr; - CharType chstr[RICHSTRING_MAXLEN+1]; -} RichString; - -}*/ - -#ifndef CLAMP -#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) -#endif - #define charBytes(n) (sizeof(CharType) * (n)) static void RichString_extendLen(RichString* this, int len) { diff --git a/RichString.h b/RichString.h index d6fa635..e6fb4c3 100644 --- a/RichString.h +++ b/RichString.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_RichString #define HEADER_RichString /* @@ -9,7 +7,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#define RICHSTRING_MAXLEN 350 #include "config.h" #include @@ -52,43 +49,36 @@ in the source distribution for its full text. #define CharType chtype #endif +#define RICHSTRING_MAXLEN 350 + typedef struct RichString_ { int chlen; CharType* chptr; CharType chstr[RICHSTRING_MAXLEN+1]; } RichString; - -#ifndef CLAMP -#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) -#endif - -#define charBytes(n) (sizeof(CharType) * (n)) - -#define RichString_setLen(this, len) do{ if(len < RICHSTRING_MAXLEN && this->chlen < RICHSTRING_MAXLEN) { RichString_setChar(this,len,0); this->chlen=len; } else RichString_extendLen(this,len); }while(0) - #ifdef HAVE_LIBNCURSESW -extern void RichString_setAttrn(RichString* this, int attrs, int start, int finish); +void RichString_setAttrn(RichString* this, int attrs, int start, int finish); -extern int RichString_findChar(RichString* this, char c, int start); +int RichString_findChar(RichString* this, char c, int start); #else -extern void RichString_setAttrn(RichString* this, int attrs, int start, int finish); +void RichString_setAttrn(RichString* this, int attrs, int start, int finish); -extern int RichString_findChar(RichString* this, char c, int start); +int RichString_findChar(RichString* this, char c, int start); #endif -extern void RichString_prune(RichString* this); +void RichString_prune(RichString* this); -extern void RichString_setAttr(RichString* this, int attrs); +void RichString_setAttr(RichString* this, int attrs); -extern void RichString_append(RichString* this, int attrs, const char* data); +void RichString_append(RichString* this, int attrs, const char* data); -extern void RichString_appendn(RichString* this, int attrs, const char* data, int len); +void RichString_appendn(RichString* this, int attrs, const char* data, int len); -extern void RichString_write(RichString* this, int attrs, const char* data); +void RichString_write(RichString* this, int attrs, const char* data); #endif diff --git a/ScreenManager.c b/ScreenManager.c index 8e5f697..92e792b 100644 --- a/ScreenManager.c +++ b/ScreenManager.c @@ -16,33 +16,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "FunctionBar.h" -#include "Vector.h" -#include "Header.h" -#include "Settings.h" -#include "Panel.h" - -typedef enum Orientation_ { - VERTICAL, - HORIZONTAL -} Orientation; - -typedef struct ScreenManager_ { - int x1; - int y1; - int x2; - int y2; - Orientation orientation; - Vector* panels; - int panelCount; - const Header* header; - const Settings* settings; - bool owner; - bool allowFocusChange; -} ScreenManager; - -}*/ ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation orientation, const Header* header, const Settings* settings, bool owner) { ScreenManager* this; @@ -190,22 +163,6 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { set_escdelay(25); ch = getch(); - if (this->settings->vimMode) { - switch (ch) { - case 'h': ch = KEY_LEFT; break; - case 'j': ch = KEY_DOWN; break; - case 'k': ch = KEY_UP; break; - case 'l': ch = KEY_RIGHT; break; - case KEY_LEFT: ch = 'h'; break; - case KEY_DOWN: ch = 'j'; break; - case KEY_UP: ch = 'k'; break; - case KEY_RIGHT: ch = 'l'; break; - case 'K': ch = 'k'; break; - case 'J': ch = 'K'; break; - case 'L': ch = 'l'; break; - } - } - HandlerResult result = IGNORED; if (ch == KEY_MOUSE && this->settings->enableMouse) { ch = ERR; diff --git a/ScreenManager.h b/ScreenManager.h index b7b5617..3c19a05 100644 --- a/ScreenManager.h +++ b/ScreenManager.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_ScreenManager #define HEADER_ScreenManager /* @@ -9,7 +7,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#include "FunctionBar.h" #include "Vector.h" #include "Header.h" #include "Settings.h" @@ -34,19 +31,18 @@ typedef struct ScreenManager_ { bool allowFocusChange; } ScreenManager; +ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation orientation, const Header* header, const Settings* settings, bool owner); -extern ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation orientation, const Header* header, const Settings* settings, bool owner); - -extern void ScreenManager_delete(ScreenManager* this); +void ScreenManager_delete(ScreenManager* this); -extern int ScreenManager_size(ScreenManager* this); +int ScreenManager_size(ScreenManager* this); -extern void ScreenManager_add(ScreenManager* this, Panel* item, int size); +void ScreenManager_add(ScreenManager* this, Panel* item, int size); -extern Panel* ScreenManager_remove(ScreenManager* this, int idx); +Panel* ScreenManager_remove(ScreenManager* this, int idx); -extern void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2); +void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2); -extern void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey); +void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey); #endif diff --git a/Settings.c b/Settings.c index 81d547b..d6ef53b 100644 --- a/Settings.c +++ b/Settings.c @@ -17,64 +17,6 @@ in the source distribution for its full text. #include #include -#define DEFAULT_DELAY 15 - -/*{ -#include "Process.h" -#include - -typedef struct { - int len; - char** names; - int* modes; -} MeterColumnSettings; - -typedef struct Settings_ { - char* filename; - - MeterColumnSettings columns[2]; - - ProcessField* fields; - int flags; - int colorScheme; - int delay; - - int cpuCount; - int direction; - ProcessField sortKey; - - bool countCPUsFromZero; - bool detailedCPUTime; - bool showCPUUsage; - bool showCPUFrequency; - bool treeView; - bool showProgramPath; - bool hideThreads; - bool shadowOtherUsers; - bool showThreadNames; - bool hideKernelThreads; - bool hideUserlandThreads; - bool highlightBaseName; - bool highlightMegabytes; - bool highlightThreads; - bool updateProcessNames; - bool accountGuestInCPUMeter; - bool headerMargin; - bool enableMouse; - bool vimMode; - #ifdef HAVE_LIBHWLOC - bool topologyAffinity; - #endif - - bool changed; -} Settings; - -#ifndef Settings_cpuId -#define Settings_cpuId(settings, cpu) ((settings)->countCPUsFromZero ? (cpu) : (cpu)+1) -#endif - -}*/ - void Settings_delete(Settings* this) { free(this->filename); free(this->fields); @@ -121,7 +63,6 @@ static void Settings_defaultMeters(Settings* this) { this->columns[i].modes = xCalloc(sizes[i], sizeof(int)); this->columns[i].len = sizes[i]; } - int r = 0; if (this->cpuCount > 8) { this->columns[0].names[0] = xStrdup("LeftCPUs2"); @@ -141,7 +82,6 @@ static void Settings_defaultMeters(Settings* this) { this->columns[0].modes[1] = BAR_METERMODE; this->columns[0].names[2] = xStrdup("Swap"); this->columns[0].modes[2] = BAR_METERMODE; - this->columns[1].names[r] = xStrdup("Tasks"); this->columns[1].modes[r++] = TEXT_METERMODE; this->columns[1].names[r] = xStrdup("LoadAverage"); @@ -172,13 +112,11 @@ static void readFields(ProcessField* fields, int* flags, const char* line) { static bool Settings_read(Settings* this, const char* fileName) { FILE* fd; - CRT_dropPrivileges(); fd = fopen(fileName, "r"); CRT_restorePrivileges(); if (!fd) return false; - bool didReadMeters = false; bool didReadFields = false; for (;;) { @@ -257,8 +195,6 @@ static bool Settings_read(Settings* this, const char* fileName) { } else if (String_eq(option[0], "right_meter_modes")) { Settings_readMeterModes(this, option[1], 1); didReadMeters = true; - } else if (String_eq(option[0], "vim_mode")) { - this->vimMode = atoi(option[1]); #ifdef HAVE_LIBHWLOC } else if (String_eq(option[0], "topology_affinity")) { this->topologyAffinity = !!atoi(option[1]); @@ -342,7 +278,6 @@ bool Settings_write(Settings* this) { fprintf(fd, "left_meter_modes="); writeMeterModes(this, fd, 0); fprintf(fd, "right_meters="); writeMeters(this, fd, 1); fprintf(fd, "right_meter_modes="); writeMeterModes(this, fd, 1); - fprintf(fd, "vim_mode=%d\n", (int) this->vimMode); #ifdef HAVE_LIBHWLOC fprintf(fd, "topology_affinity=%d\n", (int) this->topologyAffinity); #endif @@ -351,7 +286,6 @@ bool Settings_write(Settings* this) { } Settings* Settings_new(int cpuCount) { - Settings* this = xCalloc(1, sizeof(Settings)); this->sortKey = PERCENT_CPU; @@ -375,7 +309,6 @@ Settings* Settings_new(int cpuCount) { #ifdef HAVE_LIBHWLOC this->topologyAffinity = false; #endif - this->fields = xCalloc(Platform_numberOfFields+1, sizeof(ProcessField)); // TODO: turn 'fields' into a Vector, // (and ProcessFields into proper objects). @@ -406,7 +339,6 @@ Settings* Settings_new(int cpuCount) { htopDir = String_cat(home, "/.config/htop"); } legacyDotfile = String_cat(home, "/.htoprc"); - CRT_dropPrivileges(); (void) mkdir(configDir, 0700); (void) mkdir(htopDir, 0700); diff --git a/Settings.h b/Settings.h index f38b8ec..e1518ec 100644 --- a/Settings.h +++ b/Settings.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Settings #define HEADER_Settings /* @@ -22,7 +20,6 @@ typedef struct { typedef struct Settings_ { char* filename; - MeterColumnSettings columns[2]; ProcessField* fields; @@ -52,7 +49,6 @@ typedef struct Settings_ { bool accountGuestInCPUMeter; bool headerMargin; bool enableMouse; - bool vimMode; #ifdef HAVE_LIBHWLOC bool topologyAffinity; #endif @@ -60,17 +56,14 @@ typedef struct Settings_ { bool changed; } Settings; -#ifndef Settings_cpuId #define Settings_cpuId(settings, cpu) ((settings)->countCPUsFromZero ? (cpu) : (cpu)+1) -#endif - -extern void Settings_delete(Settings* this); +void Settings_delete(Settings* this); -extern bool Settings_write(Settings* this); +bool Settings_write(Settings* this); -extern Settings* Settings_new(int cpuCount); +Settings* Settings_new(int cpuCount); -extern void Settings_invertSortOrder(Settings* this); +void Settings_invertSortOrder(Settings* this); #endif diff --git a/SignalsPanel.c b/SignalsPanel.c index 2bfbcbf..8036142 100644 --- a/SignalsPanel.c +++ b/SignalsPanel.c @@ -18,14 +18,6 @@ in the source distribution for its full text. #include -/*{ - -typedef struct SignalItem_ { - const char* name; - int number; -} SignalItem; - -}*/ Panel* SignalsPanel_new() { Panel* this = Panel_new(1, 1, 1, 1, true, Class(ListItem), FunctionBar_newEnterEsc("Send ", "Cancel ")); diff --git a/SignalsPanel.h b/SignalsPanel.h index 8720376..3d910ce 100644 --- a/SignalsPanel.h +++ b/SignalsPanel.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_SignalsPanel #define HEADER_SignalsPanel /* @@ -9,13 +7,11 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ - typedef struct SignalItem_ { const char* name; int number; } SignalItem; - -extern Panel* SignalsPanel_new(); +Panel* SignalsPanel_new(); #endif diff --git a/StringUtils.c b/StringUtils.c index d7058a2..e2386e3 100644 --- a/StringUtils.c +++ b/StringUtils.c @@ -14,18 +14,6 @@ in the source distribution for its full text. #include #include -/*{ -#include - -#define String_startsWith(s, match) (strncmp((s),(match),strlen(match)) == 0) -#define String_contains_i(s1, s2) (strcasestr(s1, s2) != NULL) -}*/ - -/* - * String_startsWith gives better performance if strlen(match) can be computed - * at compile time (e.g. when they are immutable string literals). :) - */ - char* String_cat(const char* s1, const char* s2) { int l1 = strlen(s1); int l2 = strlen(s2); diff --git a/StringUtils.h b/StringUtils.h index c1070d4..cc0abb0 100644 --- a/StringUtils.h +++ b/StringUtils.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_StringUtils #define HEADER_StringUtils /* @@ -19,18 +17,18 @@ in the source distribution for its full text. * at compile time (e.g. when they are immutable string literals). :) */ -extern char* String_cat(const char* s1, const char* s2); +char* String_cat(const char* s1, const char* s2); -extern char* String_trim(const char* in); +char* String_trim(const char* in); -extern int String_eq(const char* s1, const char* s2); +int String_eq(const char* s1, const char* s2); -extern char** String_split(const char* s, char sep, int* n); +char** String_split(const char* s, char sep, int* n); -extern void String_freeArray(char** s); +void String_freeArray(char** s); -extern char* String_getToken(const char* line, const unsigned short int numMatch); +char* String_getToken(const char* line, const unsigned short int numMatch); -extern char* String_readLine(FILE* fd); +char* String_readLine(FILE* fd); #endif diff --git a/SwapMeter.c b/SwapMeter.c index 1406d6f..fcf450e 100644 --- a/SwapMeter.c +++ b/SwapMeter.c @@ -16,9 +16,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Meter.h" -}*/ int SwapMeter_attributes[] = { SWAP diff --git a/SwapMeter.h b/SwapMeter.h index 2b57fe5..69a5855 100644 --- a/SwapMeter.h +++ b/SwapMeter.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_SwapMeter #define HEADER_SwapMeter /* diff --git a/TasksMeter.c b/TasksMeter.c index 8a913ec..0b37ab2 100644 --- a/TasksMeter.c +++ b/TasksMeter.c @@ -10,9 +10,6 @@ in the source distribution for its full text. #include "Platform.h" #include "CRT.h" -/*{ -#include "Meter.h" -}*/ int TasksMeter_attributes[] = { CPU_SYSTEM, PROCESS_THREAD, PROCESS, TASKS_RUNNING @@ -23,7 +20,7 @@ static void TasksMeter_updateValues(Meter* this, char* buffer, int len) { this->values[0] = pl->kernelThreads; this->values[1] = pl->userlandThreads; this->values[2] = pl->totalTasks - pl->kernelThreads - pl->userlandThreads; - this->values[3] = MIN(pl->runningTasks, pl->cpuCount); + this->values[3] = MINIMUM(pl->runningTasks, pl->cpuCount); if (pl->totalTasks > this->total) { this->total = pl->totalTasks; } diff --git a/TasksMeter.h b/TasksMeter.h index a7a0db7..bdb62a7 100644 --- a/TasksMeter.h +++ b/TasksMeter.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_TasksMeter #define HEADER_TasksMeter /* diff --git a/TraceScreen.c b/TraceScreen.c index b4b8436..0a3485e 100644 --- a/TraceScreen.c +++ b/TraceScreen.c @@ -8,7 +8,6 @@ in the source distribution for its full text. #include "TraceScreen.h" #include "CRT.h" -#include "InfoScreen.h" #include "ProcessList.h" #include "ListItem.h" #include "IncSet.h" @@ -27,21 +26,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "InfoScreen.h" - -typedef struct TraceScreen_ { - InfoScreen super; - bool tracing; - int fdpair[2]; - int child; - FILE* strace; - int fd_strace; - bool contLine; - bool follow; -} TraceScreen; - -}*/ static const char* const TraceScreenFunctions[] = {"Search ", "Filter ", "AutoScroll ", "Stop Tracing ", "Done ", NULL}; diff --git a/TraceScreen.h b/TraceScreen.h index d43281d..1e5218c 100644 --- a/TraceScreen.h +++ b/TraceScreen.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_TraceScreen #define HEADER_TraceScreen /* @@ -25,16 +23,16 @@ typedef struct TraceScreen_ { extern InfoScreenClass TraceScreen_class; -extern TraceScreen* TraceScreen_new(Process* process); +TraceScreen* TraceScreen_new(Process* process); -extern void TraceScreen_delete(Object* cast); +void TraceScreen_delete(Object* cast); -extern void TraceScreen_draw(InfoScreen* this); +void TraceScreen_draw(InfoScreen* this); -extern bool TraceScreen_forkTracer(TraceScreen* this); +bool TraceScreen_forkTracer(TraceScreen* this); -extern void TraceScreen_updateTrace(InfoScreen* super); +void TraceScreen_updateTrace(InfoScreen* super); -extern bool TraceScreen_onKey(InfoScreen* super, int ch); +bool TraceScreen_onKey(InfoScreen* super, int ch); #endif diff --git a/UptimeMeter.c b/UptimeMeter.c index 61f6090..da1c9fd 100644 --- a/UptimeMeter.c +++ b/UptimeMeter.c @@ -9,9 +9,6 @@ in the source distribution for its full text. #include "Platform.h" #include "CRT.h" -/*{ -#include "Meter.h" -}*/ int UptimeMeter_attributes[] = { UPTIME diff --git a/UptimeMeter.h b/UptimeMeter.h index fe0bbba..5fa1e93 100644 --- a/UptimeMeter.h +++ b/UptimeMeter.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_UptimeMeter #define HEADER_UptimeMeter /* diff --git a/UsersTable.c b/UsersTable.c index f383256..86ed75c 100644 --- a/UsersTable.c +++ b/UsersTable.c @@ -18,13 +18,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Hashtable.h" - -typedef struct UsersTable_ { - Hashtable* users; -} UsersTable; -}*/ UsersTable* UsersTable_new() { UsersTable* this; diff --git a/UsersTable.h b/UsersTable.h index 9eba59a..fb3eaed 100644 --- a/UsersTable.h +++ b/UsersTable.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_UsersTable #define HEADER_UsersTable /* @@ -15,12 +13,12 @@ typedef struct UsersTable_ { Hashtable* users; } UsersTable; -extern UsersTable* UsersTable_new(); +UsersTable* UsersTable_new(); -extern void UsersTable_delete(UsersTable* this); +void UsersTable_delete(UsersTable* this); -extern char* UsersTable_getRef(UsersTable* this, unsigned int uid); +char* UsersTable_getRef(UsersTable* this, unsigned int uid); -extern void UsersTable_foreach(UsersTable* this, Hashtable_PairFunction f, void* userData); +void UsersTable_foreach(UsersTable* this, Hashtable_PairFunction f, void* userData); #endif diff --git a/Vector.c b/Vector.c index b5e7744..e51fd7b 100644 --- a/Vector.c +++ b/Vector.c @@ -12,25 +12,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Object.h" - -#define swap(a_,x_,y_) do{ void* tmp_ = a_[x_]; a_[x_] = a_[y_]; a_[y_] = tmp_; }while(0) - -#ifndef DEFAULT_SIZE -#define DEFAULT_SIZE -1 -#endif - -typedef struct Vector_ { - Object **array; - ObjectClass* type; - int arraySize; - int growthRate; - int items; - bool owner; -} Vector; - -}*/ Vector* Vector_new(ObjectClass* type, bool owner, int size) { Vector* this; @@ -280,7 +261,7 @@ inline Object* Vector_get(Vector* this, int idx) { #else -#define Vector_get(v_, idx_) ((v_)->array[idx_]) +// In this case, Vector_get is defined as a macro in vector.h #endif @@ -293,7 +274,7 @@ inline int Vector_size(Vector* this) { #else -#define Vector_size(v_) ((v_)->items) +// In this case, Vector_size is defined as a macro in vector.h #endif diff --git a/Vector.h b/Vector.h index 0d9f1c2..209e27c 100644 --- a/Vector.h +++ b/Vector.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Vector #define HEADER_Vector /* @@ -26,43 +24,37 @@ typedef struct Vector_ { bool owner; } Vector; +Vector* Vector_new(ObjectClass* type, bool owner, int size); -extern Vector* Vector_new(ObjectClass* type, bool owner, int size); - -extern void Vector_delete(Vector* this); +void Vector_delete(Vector* this); #ifdef DEBUG -extern int Vector_count(Vector* this); +int Vector_count(Vector* this); #endif -extern void Vector_prune(Vector* this); - -// If I were to use only one sorting algorithm for both cases, it would probably be this one: -/* - -*/ +void Vector_prune(Vector* this); -extern void Vector_quickSort(Vector* this); +void Vector_quickSort(Vector* this); -extern void Vector_insertionSort(Vector* this); +void Vector_insertionSort(Vector* this); -extern void Vector_insert(Vector* this, int idx, void* data_); +void Vector_insert(Vector* this, int idx, void* data_); -extern Object* Vector_take(Vector* this, int idx); +Object* Vector_take(Vector* this, int idx); -extern Object* Vector_remove(Vector* this, int idx); +Object* Vector_remove(Vector* this, int idx); -extern void Vector_moveUp(Vector* this, int idx); +void Vector_moveUp(Vector* this, int idx); -extern void Vector_moveDown(Vector* this, int idx); +void Vector_moveDown(Vector* this, int idx); -extern void Vector_set(Vector* this, int idx, void* data_); +void Vector_set(Vector* this, int idx, void* data_); #ifdef DEBUG -extern Object* Vector_get(Vector* this, int idx); +Object* Vector_get(Vector* this, int idx); #else @@ -72,7 +64,7 @@ extern Object* Vector_get(Vector* this, int idx); #ifdef DEBUG -extern int Vector_size(Vector* this); +int Vector_size(Vector* this); #else @@ -80,13 +72,9 @@ extern int Vector_size(Vector* this); #endif -/* - -*/ - -extern void Vector_add(Vector* this, void* data_); +void Vector_add(Vector* this, void* data_); -extern int Vector_indexOf(Vector* this, void* search_, Object_Compare compare); +int Vector_indexOf(Vector* this, void* search_, Object_Compare compare); void Vector_splice(Vector* this, Vector* from); diff --git a/XAlloc.c b/XAlloc.c index 4aa8e21..38616df 100644 --- a/XAlloc.c +++ b/XAlloc.c @@ -8,11 +8,6 @@ #include #include -/*{ -#include -#include -#include -}*/ void fail() { curs_set(1); diff --git a/XAlloc.h b/XAlloc.h index 2d46405..b933423 100644 --- a/XAlloc.h +++ b/XAlloc.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_XAlloc #define HEADER_XAlloc @@ -11,13 +9,13 @@ #include #include -extern void fail(void); +void fail(void); -extern void* xMalloc(size_t size); +void* xMalloc(size_t size); -extern void* xCalloc(size_t nmemb, size_t size); +void* xCalloc(size_t nmemb, size_t size); -extern void* xRealloc(void* ptr, size_t size); +void* xRealloc(void* ptr, size_t size); #undef xAsprintf @@ -38,9 +36,9 @@ extern void* xRealloc(void* ptr, size_t size); #endif #if (__has_attribute(nonnull) || \ ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))) -extern char* xStrdup_(const char* str) __attribute__((nonnull)); +char* xStrdup_(const char* str) __attribute__((nonnull)); #endif // __has_attribute(nonnull) || GNU C 3.3 or later -extern char* xStrdup_(const char* str); +char* xStrdup_(const char* str); #endif diff --git a/configure.ac b/configure.ac index f6498b7..30834f2 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.65) -AC_INIT([htop],[3.0.1],[htop@groups.io]) +AC_INIT([htop],[3.0.2],[htop@groups.io]) AC_CONFIG_SRCDIR([htop.c]) AC_CONFIG_AUX_DIR([.]) @@ -316,7 +316,6 @@ AM_CONDITIONAL([HTOP_SOLARIS], [test "$my_htop_platform" = solaris]) AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported]) AC_SUBST(my_htop_platform) AC_CONFIG_FILES([Makefile htop.1]) -AC_CONFIG_FILES([scripts/MakeHeader.py], [chmod +x scripts/MakeHeader.py]) AC_OUTPUT if test "$my_htop_platform" = "unsupported" diff --git a/darwin/Battery.h b/darwin/Battery.h index 8dc0cef..21a1579 100644 --- a/darwin/Battery.h +++ b/darwin/Battery.h @@ -1,9 +1,6 @@ -/* 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/darwin/DarwinCRT.h b/darwin/DarwinCRT.h index e1c22bb..5e08422 100644 --- a/darwin/DarwinCRT.h +++ b/darwin/DarwinCRT.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_DarwinCRT #define HEADER_DarwinCRT /* @@ -11,5 +9,4 @@ in the source distribution for its full text. void CRT_handleSIGSEGV(int sgn); - #endif diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c index bf5fd57..430b2b4 100644 --- a/darwin/DarwinProcess.c +++ b/darwin/DarwinProcess.c @@ -15,21 +15,6 @@ in the source distribution for its full text. #include -/*{ -#include "Settings.h" -#include "DarwinProcessList.h" - -#include - -typedef struct DarwinProcess_ { - Process super; - - uint64_t utime; - uint64_t stime; - bool taskAccess; -} DarwinProcess; - -}*/ ProcessClass DarwinProcess_class = { .super = { diff --git a/darwin/DarwinProcess.h b/darwin/DarwinProcess.h index c2058e2..cf76fa8 100644 --- a/darwin/DarwinProcess.h +++ b/darwin/DarwinProcess.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_DarwinProcess #define HEADER_DarwinProcess /* @@ -22,7 +20,6 @@ typedef struct DarwinProcess_ { bool taskAccess; } DarwinProcess; - extern ProcessClass DarwinProcess_class; DarwinProcess* DarwinProcess_new(Settings* settings); diff --git a/darwin/DarwinProcessList.c b/darwin/DarwinProcessList.c index 9b4ba11..39d99c1 100644 --- a/darwin/DarwinProcessList.c +++ b/darwin/DarwinProcessList.c @@ -54,28 +54,6 @@ int CompareKernelVersion(short int major, short int minor, short int component) return 0; } -/*{ -#include "ProcessList.h" -#include "zfs/ZfsArcStats.h" -#include -#include - -typedef struct DarwinProcessList_ { - ProcessList super; - - host_basic_info_data_t host_info; - vm_statistics_data_t vm_stats; - processor_cpu_load_info_t prev_load; - processor_cpu_load_info_t curr_load; - uint64_t kernel_threads; - uint64_t user_threads; - uint64_t global_diff; - - ZfsArcStats zfs; -} DarwinProcessList; - -}*/ - void ProcessList_getHostInfo(host_basic_info_data_t *p) { mach_msg_type_number_t info_size = HOST_BASIC_INFO_COUNT; @@ -136,11 +114,11 @@ struct kinfo_proc *ProcessList_getKInfoProcs(size_t *count) { return processes; } -ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) { +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) { size_t len; DarwinProcessList* this = xCalloc(1, sizeof(DarwinProcessList)); - ProcessList_init(&this->super, Class(Process), usersTable, pidWhiteList, userId); + ProcessList_init(&this->super, Class(Process), usersTable, pidMatchList, userId); /* Initialize the CPU information */ this->super.cpuCount = ProcessList_allocateCPULoadInfo(&this->prev_load); diff --git a/darwin/DarwinProcessList.h b/darwin/DarwinProcessList.h index 73fbd34..c6b2966 100644 --- a/darwin/DarwinProcessList.h +++ b/darwin/DarwinProcessList.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_DarwinProcessList #define HEADER_DarwinProcessList /* @@ -39,7 +37,6 @@ typedef struct DarwinProcessList_ { ZfsArcStats zfs; } DarwinProcessList; - void ProcessList_getHostInfo(host_basic_info_data_t *p); void ProcessList_freeCPULoadInfo(processor_cpu_load_info_t *p); @@ -50,7 +47,7 @@ void ProcessList_getVMStats(vm_statistics_t p); struct kinfo_proc *ProcessList_getKInfoProcs(size_t *count); -ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId); +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId); void ProcessList_delete(ProcessList* this); diff --git a/darwin/Platform.c b/darwin/Platform.c index 26e8411..a8ca45b 100644 --- a/darwin/Platform.c +++ b/darwin/Platform.c @@ -21,17 +21,6 @@ in the source distribution for its full text. #include -/*{ -#include "Action.h" -#include "SignalsPanel.h" -#include "CPUMeter.h" -#include "BatteryMeter.h" -#include "DarwinProcess.h" -}*/ - -#ifndef CLAMP -#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) -#endif ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; diff --git a/darwin/Platform.h b/darwin/Platform.h index e17661d..7dd4ae6 100644 --- a/darwin/Platform.h +++ b/darwin/Platform.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Platform #define HEADER_Platform /* @@ -16,10 +14,6 @@ in the source distribution for its full text. #include "BatteryMeter.h" #include "DarwinProcess.h" -#ifndef CLAMP -#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) -#endif - extern ProcessField Platform_defaultFields[]; extern const SignalItem Platform_signals[]; diff --git a/dragonflybsd/Battery.h b/dragonflybsd/Battery.h index efb44a8..f764a2d 100644 --- a/dragonflybsd/Battery.h +++ b/dragonflybsd/Battery.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Battery #define HEADER_Battery /* diff --git a/dragonflybsd/DragonFlyBSDCRT.h b/dragonflybsd/DragonFlyBSDCRT.h index b934ac3..2bf85f7 100644 --- a/dragonflybsd/DragonFlyBSDCRT.h +++ b/dragonflybsd/DragonFlyBSDCRT.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_DragonFlyBSDCRT #define HEADER_DragonFlyBSDCRT /* @@ -10,10 +8,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#ifdef HAVE_EXECINFO_H -#endif - void CRT_handleSIGSEGV(int sgn); - #endif diff --git a/dragonflybsd/DragonFlyBSDProcess.c b/dragonflybsd/DragonFlyBSDProcess.c index ffaf5eb..770143b 100644 --- a/dragonflybsd/DragonFlyBSDProcess.c +++ b/dragonflybsd/DragonFlyBSDProcess.c @@ -17,34 +17,6 @@ in the source distribution for its full text. #include #include -/*{ - -typedef enum DragonFlyBSDProcessFields { - // Add platform-specific fields here, with ids >= 100 - JID = 100, - JAIL = 101, - LAST_PROCESSFIELD = 102, -} DragonFlyBSDProcessField; - - -typedef struct DragonFlyBSDProcess_ { - Process super; - int kernel; - int jid; - char* jname; -} DragonFlyBSDProcess; - - -#ifndef Process_isKernelThread -#define Process_isKernelThread(_process) (_process->kernel == 1) -#endif - -#ifndef Process_isUserlandThread -//#define Process_isUserlandThread(_process) (_process->pid != _process->tgid) -#define Process_isUserlandThread(_process) (_process->nlwp > 1) -#endif - -}*/ ProcessClass DragonFlyBSDProcess_class = { .super = { diff --git a/dragonflybsd/DragonFlyBSDProcess.h b/dragonflybsd/DragonFlyBSDProcess.h index 4a0f9a5..d5e5a6e 100644 --- a/dragonflybsd/DragonFlyBSDProcess.h +++ b/dragonflybsd/DragonFlyBSDProcess.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_DragonFlyBSDProcess #define HEADER_DragonFlyBSDProcess /* @@ -10,7 +8,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ - typedef enum DragonFlyBSDProcessFields { // Add platform-specific fields here, with ids >= 100 JID = 100, @@ -18,7 +15,6 @@ typedef enum DragonFlyBSDProcessFields { LAST_PROCESSFIELD = 102, } DragonFlyBSDProcessField; - typedef struct DragonFlyBSDProcess_ { Process super; int kernel; @@ -26,16 +22,10 @@ typedef struct DragonFlyBSDProcess_ { char* jname; } DragonFlyBSDProcess; - -#ifndef Process_isKernelThread #define Process_isKernelThread(_process) (_process->kernel == 1) -#endif -#ifndef Process_isUserlandThread //#define Process_isUserlandThread(_process) (_process->pid != _process->tgid) #define Process_isUserlandThread(_process) (_process->nlwp > 1) -#endif - extern ProcessClass DragonFlyBSDProcess_class; diff --git a/dragonflybsd/DragonFlyBSDProcessList.c b/dragonflybsd/DragonFlyBSDProcessList.c index 5bc4b38..cd5526a 100644 --- a/dragonflybsd/DragonFlyBSDProcessList.c +++ b/dragonflybsd/DragonFlyBSDProcessList.c @@ -21,54 +21,6 @@ in the source distribution for its full text. #include #include -/*{ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "Hashtable.h" -#include "DragonFlyBSDProcess.h" - -#define JAIL_ERRMSGLEN 1024 -char jail_errmsg[JAIL_ERRMSGLEN]; - -typedef struct CPUData_ { - - double userPercent; - double nicePercent; - double systemPercent; - double irqPercent; - double idlePercent; - double systemAllPercent; - -} CPUData; - -typedef struct DragonFlyBSDProcessList_ { - ProcessList super; - kvm_t* kd; - - unsigned long long int memWire; - unsigned long long int memActive; - unsigned long long int memInactive; - unsigned long long int memFree; - - CPUData* cpus; - - unsigned long *cp_time_o; - unsigned long *cp_time_n; - - unsigned long *cp_times_o; - unsigned long *cp_times_n; - - Hashtable *jails; -} DragonFlyBSDProcessList; - -}*/ #define _UNUSED_ __attribute__((unused)) @@ -89,12 +41,12 @@ static int MIB_kern_cp_time[2]; static int MIB_kern_cp_times[2]; static int kernelFScale; -ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) { +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) { size_t len; char errbuf[_POSIX2_LINE_MAX]; DragonFlyBSDProcessList* dfpl = xCalloc(1, sizeof(DragonFlyBSDProcessList)); ProcessList* pl = (ProcessList*) dfpl; - ProcessList_init(pl, Class(DragonFlyBSDProcess), usersTable, pidWhiteList, userId); + ProcessList_init(pl, Class(DragonFlyBSDProcess), usersTable, pidMatchList, userId); // physical memory in system: hw.physmem // physical page size: hw.pagesize @@ -145,7 +97,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui sysctl(MIB_kern_cp_times, 2, dfpl->cp_times_o, &len, NULL, 0); } - pl->cpuCount = MAX(cpus, 1); + pl->cpuCount = MAXIMUM(cpus, 1); if (cpus == 1 ) { dfpl->cpus = xRealloc(dfpl->cpus, sizeof(CPUData)); diff --git a/dragonflybsd/DragonFlyBSDProcessList.h b/dragonflybsd/DragonFlyBSDProcessList.h index 816e66d..84ab1c5 100644 --- a/dragonflybsd/DragonFlyBSDProcessList.h +++ b/dragonflybsd/DragonFlyBSDProcessList.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_DragonFlyBSDProcessList #define HEADER_DragonFlyBSDProcessList /* @@ -10,7 +8,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ - #include #include #include @@ -23,17 +20,15 @@ in the source distribution for its full text. #include "DragonFlyBSDProcess.h" #define JAIL_ERRMSGLEN 1024 -char jail_errmsg[JAIL_ERRMSGLEN]; +extern char jail_errmsg[JAIL_ERRMSGLEN]; typedef struct CPUData_ { - double userPercent; double nicePercent; double systemPercent; double irqPercent; double idlePercent; double systemAllPercent; - } CPUData; typedef struct DragonFlyBSDProcessList_ { @@ -56,11 +51,9 @@ typedef struct DragonFlyBSDProcessList_ { Hashtable *jails; } DragonFlyBSDProcessList; - #define _UNUSED_ __attribute__((unused)) - -ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId); +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId); void ProcessList_delete(ProcessList* this); diff --git a/dragonflybsd/Platform.c b/dragonflybsd/Platform.c index 250e50e..3b8e1a0 100644 --- a/dragonflybsd/Platform.c +++ b/dragonflybsd/Platform.c @@ -27,18 +27,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Action.h" -#include "BatteryMeter.h" -#include "SignalsPanel.h" - -extern ProcessFieldData Process_fields[]; - -}*/ - -#ifndef CLAMP -#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) -#endif ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; diff --git a/dragonflybsd/Platform.h b/dragonflybsd/Platform.h index c2684f3..83c14f5 100644 --- a/dragonflybsd/Platform.h +++ b/dragonflybsd/Platform.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Platform #define HEADER_Platform /* @@ -16,11 +14,6 @@ in the source distribution for its full text. extern ProcessFieldData Process_fields[]; - -#ifndef CLAMP -#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) -#endif - extern ProcessField Platform_defaultFields[]; extern int Platform_numberOfFields; diff --git a/freebsd/Battery.h b/freebsd/Battery.h index cc5b1fe..6987d78 100644 --- a/freebsd/Battery.h +++ b/freebsd/Battery.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Battery #define HEADER_Battery /* diff --git a/freebsd/FreeBSDCRT.h b/freebsd/FreeBSDCRT.h index eb1091a..eb88fcc 100644 --- a/freebsd/FreeBSDCRT.h +++ b/freebsd/FreeBSDCRT.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_FreeBSDCRT #define HEADER_FreeBSDCRT /* @@ -11,5 +9,4 @@ in the source distribution for its full text. void CRT_handleSIGSEGV(int sgn); - #endif diff --git a/freebsd/FreeBSDProcess.c b/freebsd/FreeBSDProcess.c index c8d30f6..33dc751 100644 --- a/freebsd/FreeBSDProcess.c +++ b/freebsd/FreeBSDProcess.c @@ -16,33 +16,6 @@ in the source distribution for its full text. #include #include -/*{ - -typedef enum FreeBSDProcessFields { - // Add platform-specific fields here, with ids >= 100 - JID = 100, - JAIL = 101, - LAST_PROCESSFIELD = 102, -} FreeBSDProcessField; - - -typedef struct FreeBSDProcess_ { - Process super; - int kernel; - int jid; - char* jname; -} FreeBSDProcess; - - -#ifndef Process_isKernelThread -#define Process_isKernelThread(_process) (_process->kernel == 1) -#endif - -#ifndef Process_isUserlandThread -#define Process_isUserlandThread(_process) (_process->pid != _process->tgid) -#endif - -}*/ ProcessClass FreeBSDProcess_class = { .super = { diff --git a/freebsd/FreeBSDProcess.h b/freebsd/FreeBSDProcess.h index 23d298a..897c532 100644 --- a/freebsd/FreeBSDProcess.h +++ b/freebsd/FreeBSDProcess.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_FreeBSDProcess #define HEADER_FreeBSDProcess /* @@ -9,15 +7,13 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ - -typedef enum FreeBSDProcessFields { +typedef enum FreeBSDProcessFields_ { // Add platform-specific fields here, with ids >= 100 JID = 100, JAIL = 101, LAST_PROCESSFIELD = 102, } FreeBSDProcessField; - typedef struct FreeBSDProcess_ { Process super; int kernel; @@ -25,15 +21,9 @@ typedef struct FreeBSDProcess_ { char* jname; } FreeBSDProcess; - -#ifndef Process_isKernelThread #define Process_isKernelThread(_process) (_process->kernel == 1) -#endif -#ifndef Process_isUserlandThread #define Process_isUserlandThread(_process) (_process->pid != _process->tgid) -#endif - extern ProcessClass FreeBSDProcess_class; diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c index 8c892a0..6318d42 100644 --- a/freebsd/FreeBSDProcessList.c +++ b/freebsd/FreeBSDProcessList.c @@ -22,54 +22,8 @@ in the source distribution for its full text. #include #include -/*{ - -#include "zfs/ZfsArcStats.h" - -#include -#include -#include -#include -#include - -#define JAIL_ERRMSGLEN 1024 char jail_errmsg[JAIL_ERRMSGLEN]; -typedef struct CPUData_ { - - double userPercent; - double nicePercent; - double systemPercent; - double irqPercent; - double idlePercent; - double systemAllPercent; - -} CPUData; - -typedef struct FreeBSDProcessList_ { - ProcessList super; - kvm_t* kd; - - unsigned long long int memWire; - unsigned long long int memActive; - unsigned long long int memInactive; - unsigned long long int memFree; - - ZfsArcStats zfs; - - CPUData* cpus; - - unsigned long *cp_time_o; - unsigned long *cp_time_n; - - unsigned long *cp_times_o; - unsigned long *cp_times_n; - -} FreeBSDProcessList; - -}*/ - - static int MIB_hw_physmem[2]; static int MIB_vm_stats_vm_v_page_count[4]; static int pageSize; @@ -87,12 +41,12 @@ static int MIB_kern_cp_time[2]; static int MIB_kern_cp_times[2]; static int kernelFScale; -ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) { +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) { size_t len; char errbuf[_POSIX2_LINE_MAX]; FreeBSDProcessList* fpl = xCalloc(1, sizeof(FreeBSDProcessList)); ProcessList* pl = (ProcessList*) fpl; - ProcessList_init(pl, Class(FreeBSDProcess), usersTable, pidWhiteList, userId); + ProcessList_init(pl, Class(FreeBSDProcess), usersTable, pidMatchList, userId); // physical memory in system: hw.physmem // physical page size: hw.pagesize @@ -157,7 +111,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui sysctl(MIB_kern_cp_times, 2, fpl->cp_times_o, &len, NULL, 0); } - pl->cpuCount = MAX(cpus, 1); + pl->cpuCount = MAXIMUM(cpus, 1); if (cpus == 1 ) { fpl->cpus = xRealloc(fpl->cpus, sizeof(CPUData)); diff --git a/freebsd/FreeBSDProcessList.h b/freebsd/FreeBSDProcessList.h index 7c1b7ad..281bf3e 100644 --- a/freebsd/FreeBSDProcessList.h +++ b/freebsd/FreeBSDProcessList.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_FreeBSDProcessList #define HEADER_FreeBSDProcessList /* @@ -9,7 +7,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ - #include "zfs/ZfsArcStats.h" #include @@ -19,17 +16,15 @@ in the source distribution for its full text. #include #define JAIL_ERRMSGLEN 1024 -char jail_errmsg[JAIL_ERRMSGLEN]; +extern char jail_errmsg[JAIL_ERRMSGLEN]; typedef struct CPUData_ { - double userPercent; double nicePercent; double systemPercent; double irqPercent; double idlePercent; double systemAllPercent; - } CPUData; typedef struct FreeBSDProcessList_ { @@ -53,9 +48,7 @@ typedef struct FreeBSDProcessList_ { } FreeBSDProcessList; - - -ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId); +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId); void ProcessList_delete(ProcessList* this); diff --git a/freebsd/Platform.c b/freebsd/Platform.c index e6acebd..c51b37c 100644 --- a/freebsd/Platform.c +++ b/freebsd/Platform.c @@ -28,18 +28,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Action.h" -#include "BatteryMeter.h" -#include "SignalsPanel.h" - -extern ProcessFieldData Process_fields[]; - -}*/ - -#ifndef CLAMP -#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) -#endif ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; diff --git a/freebsd/Platform.h b/freebsd/Platform.h index 0268f2c..1a18055 100644 --- a/freebsd/Platform.h +++ b/freebsd/Platform.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Platform #define HEADER_Platform /* @@ -15,11 +13,6 @@ in the source distribution for its full text. extern ProcessFieldData Process_fields[]; - -#ifndef CLAMP -#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) -#endif - extern ProcessField Platform_defaultFields[]; extern int Platform_numberOfFields; diff --git a/htop.c b/htop.c index bbf3a91..2cf2602 100644 --- a/htop.c +++ b/htop.c @@ -57,7 +57,7 @@ static void printHelpFlag() { // ---------------------------------------- typedef struct CommandLineSettings_ { - Hashtable* pidWhiteList; + Hashtable* pidMatchList; uid_t userId; int sortKey; int delay; @@ -70,7 +70,7 @@ typedef struct CommandLineSettings_ { static CommandLineSettings parseArguments(int argc, char** argv) { CommandLineSettings flags = { - .pidWhiteList = NULL, + .pidMatchList = NULL, .userId = -1, // -1 is guaranteed to be an invalid uid_t (see setreuid(2)) .sortKey = 0, .delay = -1, @@ -98,7 +98,7 @@ static CommandLineSettings parseArguments(int argc, char** argv) { int opt, opti=0; /* Parse arguments */ - while ((opt = getopt_long(argc, argv, "hvmCs:td:u:Up:", long_opts, &opti))) { + while ((opt = getopt_long(argc, argv, "hvmCs:td:u::Up:", long_opts, &opti))) { if (opt == EOF) break; switch (opt) { case 'h': @@ -163,13 +163,13 @@ static CommandLineSettings parseArguments(int argc, char** argv) { char* saveptr; char* pid = strtok_r(argCopy, ",", &saveptr); - if(!flags.pidWhiteList) { - flags.pidWhiteList = Hashtable_new(8, false); + if(!flags.pidMatchList) { + flags.pidMatchList = Hashtable_new(8, false); } while(pid) { unsigned int num_pid = atoi(pid); - Hashtable_put(flags.pidWhiteList, num_pid, (void *) 1); + Hashtable_put(flags.pidMatchList, num_pid, (void *) 1); pid = strtok_r(NULL, ",", &saveptr); } free(argCopy); @@ -215,7 +215,7 @@ int main(int argc, char** argv) { Process_setupColumnWidths(); UsersTable* ut = UsersTable_new(); - ProcessList* pl = ProcessList_new(ut, flags.pidWhiteList, flags.userId); + ProcessList* pl = ProcessList_new(ut, flags.pidMatchList, flags.userId); Settings* settings = Settings_new(pl->cpuCount); pl->settings = settings; @@ -281,8 +281,8 @@ int main(int argc, char** argv) { UsersTable_delete(ut); Settings_delete(settings); - if(flags.pidWhiteList) { - Hashtable_delete(flags.pidWhiteList); + if(flags.pidMatchList) { + Hashtable_delete(flags.pidMatchList); } return 0; } diff --git a/htop.h b/htop.h deleted file mode 100644 index 26c1918..0000000 --- a/htop.h +++ /dev/null @@ -1,19 +0,0 @@ -/* Do not edit this file. It was automatically generated. */ - -#ifndef HEADER_htop -#define HEADER_htop -/* -htop - htop.h -(C) 2004-2011 Hisham H. Muhammad -Released under the GNU GPL, see the COPYING file -in the source distribution for its full text. -*/ - -//#link m - -// ---------------------------------------- - - -extern int main(int argc, char** argv); - -#endif diff --git a/linux/Battery.h b/linux/Battery.h index 261cff0..8ca0d7f 100644 --- a/linux/Battery.h +++ b/linux/Battery.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Battery #define HEADER_Battery /* @@ -11,24 +9,6 @@ in the source distribution for its full text. Linux battery readings written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com). */ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#define SYS_POWERSUPPLY_DIR "/sys/class/power_supply" - -// ---------------------------------------- -// READ FROM /proc -// ---------------------------------------- - -// This implementation reading from from /proc/acpi is really inefficient, -// but I think this is on the way out so I did not rewrite it. -// The /sys implementation below does things the right way. - -// ---------------------------------------- -// READ FROM /sys -// ---------------------------------------- - -extern void Battery_getData(double* level, ACPresence* isOnAC); +void Battery_getData(double* level, ACPresence* isOnAC); #endif diff --git a/linux/IOPriority.c b/linux/IOPriority.c deleted file mode 100644 index 087f7f9..0000000 --- a/linux/IOPriority.c +++ /dev/null @@ -1,40 +0,0 @@ -/* -htop - IOPriority.c -(C) 2004-2012 Hisham H. Muhammad -Released under the GNU GPL, see the COPYING file -in the source distribution for its full text. - -Based on ionice, -Copyright (C) 2005 Jens Axboe -Released under the terms of the GNU General Public License version 2 -*/ - -#include "IOPriority.h" - -/*{ - -enum { - IOPRIO_CLASS_NONE, - IOPRIO_CLASS_RT, - IOPRIO_CLASS_BE, - IOPRIO_CLASS_IDLE, -}; - -#define IOPRIO_WHO_PROCESS 1 - -#define IOPRIO_CLASS_SHIFT (13) -#define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1) - -#define IOPriority_class(ioprio_) ((int) ((ioprio_) >> IOPRIO_CLASS_SHIFT) ) -#define IOPriority_data(ioprio_) ((int) ((ioprio_) & IOPRIO_PRIO_MASK) ) - -typedef int IOPriority; - -#define IOPriority_tuple(class_, data_) (((class_) << IOPRIO_CLASS_SHIFT) | data_) - -#define IOPriority_error 0xffffffff - -#define IOPriority_None IOPriority_tuple(IOPRIO_CLASS_NONE, 0) -#define IOPriority_Idle IOPriority_tuple(IOPRIO_CLASS_IDLE, 7) - -}*/ diff --git a/linux/IOPriority.h b/linux/IOPriority.h index a4733e8..7c4f3b6 100644 --- a/linux/IOPriority.h +++ b/linux/IOPriority.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_IOPriority #define HEADER_IOPriority /* @@ -13,7 +11,6 @@ Copyright (C) 2005 Jens Axboe Released under the terms of the GNU General Public License version 2 */ - enum { IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, @@ -38,5 +35,4 @@ typedef int IOPriority; #define IOPriority_None IOPriority_tuple(IOPRIO_CLASS_NONE, 0) #define IOPriority_Idle IOPriority_tuple(IOPRIO_CLASS_IDLE, 7) - #endif diff --git a/linux/IOPriorityPanel.c b/linux/IOPriorityPanel.c index 22735bb..ebb77bf 100644 --- a/linux/IOPriorityPanel.c +++ b/linux/IOPriorityPanel.c @@ -7,11 +7,6 @@ in the source distribution for its full text. #include "IOPriorityPanel.h" -/*{ -#include "Panel.h" -#include "IOPriority.h" -#include "ListItem.h" -}*/ Panel* IOPriorityPanel_new(IOPriority currPrio) { Panel* this = Panel_new(1, 1, 1, 1, true, Class(ListItem), FunctionBar_newEnterEsc("Set ", "Cancel ")); diff --git a/linux/IOPriorityPanel.h b/linux/IOPriorityPanel.h index 906296e..04c1d43 100644 --- a/linux/IOPriorityPanel.h +++ b/linux/IOPriorityPanel.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_IOPriorityPanel #define HEADER_IOPriorityPanel /* @@ -13,8 +11,8 @@ in the source distribution for its full text. #include "IOPriority.h" #include "ListItem.h" -extern Panel* IOPriorityPanel_new(IOPriority currPrio); +Panel* IOPriorityPanel_new(IOPriority currPrio); -extern IOPriority IOPriorityPanel_getIOPriority(Panel* this); +IOPriority IOPriorityPanel_getIOPriority(Panel* this); #endif diff --git a/linux/LinuxCRT.h b/linux/LinuxCRT.h index 966dfec..c379a8f 100644 --- a/linux/LinuxCRT.h +++ b/linux/LinuxCRT.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_LinuxCRT #define HEADER_LinuxCRT /* @@ -9,9 +7,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#ifdef HAVE_EXECINFO_H -#endif - -extern void CRT_handleSIGSEGV(int sgn); +void CRT_handleSIGSEGV(int sgn); #endif diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index 5970c93..377aa5b 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -18,150 +18,6 @@ in the source distribution for its full text. #include #include -/*{ - -#define PROCESS_FLAG_LINUX_IOPRIO 0x0100 -#define PROCESS_FLAG_LINUX_OPENVZ 0x0200 -#define PROCESS_FLAG_LINUX_VSERVER 0x0400 -#define PROCESS_FLAG_LINUX_CGROUP 0x0800 -#define PROCESS_FLAG_LINUX_OOM 0x1000 -#define PROCESS_FLAG_LINUX_SMAPS 0x2000 - -typedef enum UnsupportedProcessFields { - FLAGS = 9, - ITREALVALUE = 20, - VSIZE = 22, - RSS = 23, - RLIM = 24, - STARTCODE = 25, - ENDCODE = 26, - STARTSTACK = 27, - KSTKESP = 28, - KSTKEIP = 29, - SIGNAL = 30, - BLOCKED = 31, - SSIGIGNORE = 32, - SIGCATCH = 33, - WCHAN = 34, - NSWAP = 35, - CNSWAP = 36, - EXIT_SIGNAL = 37, -} UnsupportedProcessField; - -typedef enum LinuxProcessFields { - CMINFLT = 11, - CMAJFLT = 13, - UTIME = 14, - STIME = 15, - CUTIME = 16, - CSTIME = 17, - M_SHARE = 41, - M_TRS = 42, - M_DRS = 43, - M_LRS = 44, - M_DT = 45, - #ifdef HAVE_OPENVZ - CTID = 100, - VPID = 101, - #endif - #ifdef HAVE_VSERVER - VXID = 102, - #endif - #ifdef HAVE_TASKSTATS - RCHAR = 103, - WCHAR = 104, - SYSCR = 105, - SYSCW = 106, - RBYTES = 107, - WBYTES = 108, - CNCLWB = 109, - IO_READ_RATE = 110, - IO_WRITE_RATE = 111, - IO_RATE = 112, - #endif - #ifdef HAVE_CGROUP - CGROUP = 113, - #endif - OOM = 114, - IO_PRIORITY = 115, - #ifdef HAVE_DELAYACCT - PERCENT_CPU_DELAY = 116, - PERCENT_IO_DELAY = 117, - PERCENT_SWAP_DELAY = 118, - #endif - M_PSS = 119, - M_SWAP = 120, - M_PSSWP = 121, - LAST_PROCESSFIELD = 122, -} LinuxProcessField; - -#include "IOPriority.h" - -typedef struct LinuxProcess_ { - Process super; - bool isKernelThread; - IOPriority ioPriority; - unsigned long int cminflt; - unsigned long int cmajflt; - unsigned long long int utime; - unsigned long long int stime; - unsigned long long int cutime; - unsigned long long int cstime; - long m_share; - long m_pss; - long m_swap; - long m_psswp; - long m_trs; - long m_drs; - long m_lrs; - long m_dt; - unsigned long long starttime; - #ifdef HAVE_TASKSTATS - unsigned long long io_rchar; - unsigned long long io_wchar; - unsigned long long io_syscr; - unsigned long long io_syscw; - unsigned long long io_read_bytes; - unsigned long long io_write_bytes; - unsigned long long io_cancelled_write_bytes; - unsigned long long io_rate_read_time; - unsigned long long io_rate_write_time; - double io_rate_read_bps; - double io_rate_write_bps; - #endif - #ifdef HAVE_OPENVZ - unsigned int ctid; - unsigned int vpid; - #endif - #ifdef HAVE_VSERVER - unsigned int vxid; - #endif - #ifdef HAVE_CGROUP - char* cgroup; - #endif - unsigned int oom; - char* ttyDevice; - #ifdef HAVE_DELAYACCT - unsigned long long int delay_read_time; - unsigned long long cpu_delay_total; - unsigned long long blkio_delay_total; - unsigned long long swapin_delay_total; - float cpu_delay_percent; - float blkio_delay_percent; - float swapin_delay_percent; - #endif -} LinuxProcess; - -#ifndef Process_isKernelThread -#define Process_isKernelThread(_process) (((LinuxProcess*)(_process))->isKernelThread) -#endif - -#ifndef Process_isUserlandThread -#define Process_isUserlandThread(_process) (_process->pid != _process->tgid) -#endif - -}*/ - /* semi-global */ long long btime; diff --git a/linux/LinuxProcess.h b/linux/LinuxProcess.h index 7c0a11f..021cae7 100644 --- a/linux/LinuxProcess.h +++ b/linux/LinuxProcess.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_LinuxProcess #define HEADER_LinuxProcess /* @@ -10,7 +8,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ - #define PROCESS_FLAG_LINUX_IOPRIO 0x0100 #define PROCESS_FLAG_LINUX_OPENVZ 0x0200 #define PROCESS_FLAG_LINUX_VSERVER 0x0400 @@ -143,16 +140,10 @@ typedef struct LinuxProcess_ { #endif } LinuxProcess; -#ifndef Process_isKernelThread #define Process_isKernelThread(_process) (((LinuxProcess*)(_process))->isKernelThread) -#endif -#ifndef Process_isUserlandThread #define Process_isUserlandThread(_process) (_process->pid != _process->tgid) -#endif - -/* semi-global */ extern long long btime; extern ProcessFieldData Process_fields[]; @@ -161,9 +152,9 @@ extern ProcessPidColumn Process_pidColumns[]; extern ProcessClass LinuxProcess_class; -extern LinuxProcess* LinuxProcess_new(Settings* settings); +LinuxProcess* LinuxProcess_new(Settings* settings); -extern void Process_delete(Object* cast); +void Process_delete(Object* cast); /* [1] Note that before kernel 2.6.26 a process that has not asked for @@ -175,18 +166,18 @@ extern io_priority; */ #define LinuxProcess_effectiveIOPriority(p_) (IOPriority_class(p_->ioPriority) == IOPRIO_CLASS_NONE ? IOPriority_tuple(IOPRIO_CLASS_BE, (p_->super.nice + 20) / 5) : p_->ioPriority) -extern IOPriority LinuxProcess_updateIOPriority(LinuxProcess* this); +IOPriority LinuxProcess_updateIOPriority(LinuxProcess* this); -extern bool LinuxProcess_setIOPriority(LinuxProcess* this, Arg ioprio); +bool LinuxProcess_setIOPriority(LinuxProcess* this, Arg ioprio); #ifdef HAVE_DELAYACCT -extern void LinuxProcess_printDelay(float delay_percent, char* buffer, int n); +void LinuxProcess_printDelay(float delay_percent, char* buffer, int n); #endif -extern void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field); +void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field); -extern long LinuxProcess_compare(const void* v1, const void* v2); +long LinuxProcess_compare(const void* v1, const void* v2); -extern bool Process_isThread(Process* this); +bool Process_isThread(Process* this); #endif diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index 732a86b..8dae13c 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -42,99 +42,6 @@ in the source distribution for its full text. #include #endif -/*{ - -#include "ProcessList.h" -#include "zfs/ZfsArcStats.h" - -extern long long btime; - -typedef struct CPUData_ { - unsigned long long int totalTime; - unsigned long long int userTime; - unsigned long long int systemTime; - unsigned long long int systemAllTime; - unsigned long long int idleAllTime; - unsigned long long int idleTime; - unsigned long long int niceTime; - unsigned long long int ioWaitTime; - unsigned long long int irqTime; - unsigned long long int softIrqTime; - unsigned long long int stealTime; - unsigned long long int guestTime; - - unsigned long long int totalPeriod; - unsigned long long int userPeriod; - unsigned long long int systemPeriod; - unsigned long long int systemAllPeriod; - unsigned long long int idleAllPeriod; - unsigned long long int idlePeriod; - unsigned long long int nicePeriod; - unsigned long long int ioWaitPeriod; - unsigned long long int irqPeriod; - unsigned long long int softIrqPeriod; - unsigned long long int stealPeriod; - unsigned long long int guestPeriod; - - double frequency; -} CPUData; - -typedef struct TtyDriver_ { - char* path; - unsigned int major; - unsigned int minorFrom; - unsigned int minorTo; -} TtyDriver; - -typedef struct LinuxProcessList_ { - ProcessList super; - - CPUData* cpus; - TtyDriver* ttyDrivers; - bool haveSmapsRollup; - - #ifdef HAVE_DELAYACCT - struct nl_sock *netlink_socket; - int netlink_family; - #endif - - ZfsArcStats zfs; -} LinuxProcessList; - -#ifndef PROCDIR -#define PROCDIR "/proc" -#endif - -#ifndef PROCCPUINFOFILE -#define PROCCPUINFOFILE PROCDIR "/cpuinfo" -#endif - -#ifndef PROCSTATFILE -#define PROCSTATFILE PROCDIR "/stat" -#endif - -#ifndef PROCMEMINFOFILE -#define PROCMEMINFOFILE PROCDIR "/meminfo" -#endif - -#ifndef PROCARCSTATSFILE -#define PROCARCSTATSFILE PROCDIR "/spl/kstat/zfs/arcstats" -#endif - -#ifndef PROCTTYDRIVERSFILE -#define PROCTTYDRIVERSFILE PROCDIR "/tty/drivers" -#endif - -#ifndef PROC_LINE_LENGTH -#define PROC_LINE_LENGTH 4096 -#endif - -}*/ - -#ifndef CLAMP -#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) -#endif - static ssize_t xread(int fd, void *buf, size_t count) { // Read some bytes. Retry on EINTR and when we don't get as many bytes as we requested. size_t alreadyRead = 0; @@ -242,11 +149,11 @@ static void LinuxProcessList_initNetlinkSocket(LinuxProcessList* this) { #endif -ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) { +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) { LinuxProcessList* this = xCalloc(1, sizeof(LinuxProcessList)); ProcessList* pl = &(this->super); - ProcessList_init(pl, Class(LinuxProcess), usersTable, pidWhiteList, userId); + ProcessList_init(pl, Class(LinuxProcess), usersTable, pidMatchList, userId); LinuxProcessList_initTtyDrivers(this); #ifdef HAVE_DELAYACCT @@ -283,7 +190,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui fclose(file); - pl->cpuCount = MAX(cpus - 1, 1); + pl->cpuCount = MAXIMUM(cpus - 1, 1); this->cpus = xCalloc(cpus, sizeof(CPUData)); for (int i = 0; i < cpus; i++) { diff --git a/linux/LinuxProcessList.h b/linux/LinuxProcessList.h index 86e9d3f..c484e75 100644 --- a/linux/LinuxProcessList.h +++ b/linux/LinuxProcessList.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_LinuxProcessList #define HEADER_LinuxProcessList /* @@ -9,14 +7,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#ifdef MAJOR_IN_MKDEV -#elif defined(MAJOR_IN_SYSMACROS) -#endif - -#ifdef HAVE_DELAYACCT -#endif - - #include "ProcessList.h" #include "zfs/ZfsArcStats.h" @@ -102,40 +92,10 @@ typedef struct LinuxProcessList_ { #define PROC_LINE_LENGTH 4096 #endif +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId); -#ifndef CLAMP -#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) -#endif - -#ifdef HAVE_DELAYACCT - -#endif - -extern ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId); - -extern void ProcessList_delete(ProcessList* pl); - - -#ifdef HAVE_TASKSTATS - -#endif - -#ifdef HAVE_OPENVZ - -#endif - -#ifdef HAVE_CGROUP - -#endif - -#ifdef HAVE_VSERVER - -#endif - -#ifdef HAVE_DELAYACCT - -#endif +void ProcessList_delete(ProcessList* pl); -extern void ProcessList_goThroughEntries(ProcessList* super); +void ProcessList_goThroughEntries(ProcessList* super); #endif diff --git a/linux/Platform.c b/linux/Platform.c index 0f59fed..e82d8f8 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -32,17 +32,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Action.h" -#include "MainPanel.h" -#include "BatteryMeter.h" -#include "LinuxProcess.h" -#include "SignalsPanel.h" -}*/ - -#ifndef CLAMP -#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) -#endif ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, (int)M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; @@ -248,7 +237,7 @@ char* Platform_getProcessEnv(pid_t pid) { if (fd) { size_t capacity = 4096, size = 0, bytes; env = xMalloc(capacity); - while (env && (bytes = fread(env+size, 1, capacity-size, fd)) > 0) { + while ((bytes = fread(env+size, 1, capacity-size, fd)) > 0) { size += bytes; capacity *= 2; env = xRealloc(env, capacity); diff --git a/linux/Platform.h b/linux/Platform.h index bf163a5..9f0ee7f 100644 --- a/linux/Platform.h +++ b/linux/Platform.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Platform #define HEADER_Platform /* @@ -15,10 +13,6 @@ in the source distribution for its full text. #include "LinuxProcess.h" #include "SignalsPanel.h" -#ifndef CLAMP -#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) -#endif - extern ProcessField Platform_defaultFields[]; extern int Platform_numberOfFields; @@ -27,27 +21,27 @@ extern const SignalItem Platform_signals[]; extern const unsigned int Platform_numberOfSignals; -extern void Platform_setBindings(Htop_Action* keys); +void Platform_setBindings(Htop_Action* keys); extern MeterClass* Platform_meterTypes[]; -extern int Platform_getUptime(); +int Platform_getUptime(); -extern void Platform_getLoadAverage(double* one, double* five, double* fifteen); +void Platform_getLoadAverage(double* one, double* five, double* fifteen); -extern int Platform_getMaxPid(); +int Platform_getMaxPid(); -extern double Platform_setCPUValues(Meter* this, int cpu); +double Platform_setCPUValues(Meter* this, int cpu); -extern void Platform_setMemoryValues(Meter* this); +void Platform_setMemoryValues(Meter* this); -extern void Platform_setSwapValues(Meter* this); +void Platform_setSwapValues(Meter* this); -extern void Platform_setZfsArcValues(Meter* this); +void Platform_setZfsArcValues(Meter* this); -extern void Platform_setZfsCompressedArcValues(Meter* this); -extern char* Platform_getProcessEnv(pid_t pid); +void Platform_setZfsCompressedArcValues(Meter* this); +char* Platform_getProcessEnv(pid_t pid); -extern void Platform_getPressureStall(const char *file, bool some, double* ten, double* sixty, double* threehundred); +void Platform_getPressureStall(const char *file, bool some, double* ten, double* sixty, double* threehundred); #endif diff --git a/openbsd/Battery.h b/openbsd/Battery.h index 0f05af3..e858b15 100644 --- a/openbsd/Battery.h +++ b/openbsd/Battery.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Battery #define HEADER_Battery /* diff --git a/openbsd/OpenBSDCRT.h b/openbsd/OpenBSDCRT.h index c48309a..85860a9 100644 --- a/openbsd/OpenBSDCRT.h +++ b/openbsd/OpenBSDCRT.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_OpenBSDCRT #define HEADER_OpenBSDCRT /* @@ -12,5 +10,4 @@ in the source distribution for its full text. void CRT_handleSIGSEGV(int sgn); - #endif diff --git a/openbsd/OpenBSDProcess.c b/openbsd/OpenBSDProcess.c index f54c911..1a80784 100644 --- a/openbsd/OpenBSDProcess.c +++ b/openbsd/OpenBSDProcess.c @@ -16,26 +16,6 @@ in the source distribution for its full text. #include #include -/*{ - -typedef enum OpenBSDProcessFields { - // Add platform-specific fields here, with ids >= 100 - LAST_PROCESSFIELD = 100, -} OpenBSDProcessField; - -typedef struct OpenBSDProcess_ { - Process super; -} OpenBSDProcess; - -#ifndef Process_isKernelThread -#define Process_isKernelThread(_process) (_process->pgrp == 0) -#endif - -#ifndef Process_isUserlandThread -#define Process_isUserlandThread(_process) (_process->pid != _process->tgid) -#endif - -}*/ ProcessClass OpenBSDProcess_class = { .super = { diff --git a/openbsd/OpenBSDProcess.h b/openbsd/OpenBSDProcess.h index ba55e5e..fede6f8 100644 --- a/openbsd/OpenBSDProcess.h +++ b/openbsd/OpenBSDProcess.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_OpenBSDProcess #define HEADER_OpenBSDProcess /* @@ -10,8 +8,7 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ - -typedef enum OpenBSDProcessFields { +typedef enum OpenBSDProcessFields_ { // Add platform-specific fields here, with ids >= 100 LAST_PROCESSFIELD = 100, } OpenBSDProcessField; @@ -20,14 +17,9 @@ typedef struct OpenBSDProcess_ { Process super; } OpenBSDProcess; -#ifndef Process_isKernelThread #define Process_isKernelThread(_process) (_process->pgrp == 0) -#endif -#ifndef Process_isUserlandThread #define Process_isUserlandThread(_process) (_process->pid != _process->tgid) -#endif - extern ProcessClass OpenBSDProcess_class; diff --git a/openbsd/OpenBSDProcessList.c b/openbsd/OpenBSDProcessList.c index ea40fe1..c5d79f5 100644 --- a/openbsd/OpenBSDProcessList.c +++ b/openbsd/OpenBSDProcessList.c @@ -27,58 +27,9 @@ in the source distribution for its full text. #include #include -/*{ - -#include - -typedef struct CPUData_ { - unsigned long long int totalTime; - unsigned long long int userTime; - unsigned long long int niceTime; - unsigned long long int sysTime; - unsigned long long int sysAllTime; - unsigned long long int spinTime; - unsigned long long int intrTime; - unsigned long long int idleTime; - - unsigned long long int totalPeriod; - unsigned long long int userPeriod; - unsigned long long int nicePeriod; - unsigned long long int sysPeriod; - unsigned long long int sysAllPeriod; - unsigned long long int spinPeriod; - unsigned long long int intrPeriod; - unsigned long long int idlePeriod; -} CPUData; - -typedef struct OpenBSDProcessList_ { - ProcessList super; - kvm_t* kd; - - CPUData* cpus; - -} OpenBSDProcessList; - -}*/ - -/* - * avoid relying on or conflicting with MIN() and MAX() in sys/param.h - */ -#ifndef MINIMUM -#define MINIMUM(x, y) ((x) > (y) ? (y) : (x)) -#endif - -#ifndef MAXIMUM -#define MAXIMUM(x, y) ((x) > (y) ? (x) : (y)) -#endif - -#ifndef CLAMP -#define CLAMP(x, low, high) (((x) > (high)) ? (high) : MAXIMUM(x, low)) -#endif - static long fscale; -ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) { +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) { int mib[] = { CTL_HW, HW_NCPU }; int fmib[] = { CTL_KERN, KERN_FSCALE }; int i, e; @@ -90,7 +41,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui opl = xCalloc(1, sizeof(OpenBSDProcessList)); pl = (ProcessList*) opl; size = sizeof(pl->cpuCount); - ProcessList_init(pl, Class(OpenBSDProcess), usersTable, pidWhiteList, userId); + ProcessList_init(pl, Class(OpenBSDProcess), usersTable, pidMatchList, userId); e = sysctl(mib, 2, &pl->cpuCount, &size, NULL, 0); if (e == -1 || pl->cpuCount < 1) { diff --git a/openbsd/OpenBSDProcessList.h b/openbsd/OpenBSDProcessList.h index ec9fab2..0d9defb 100644 --- a/openbsd/OpenBSDProcessList.h +++ b/openbsd/OpenBSDProcessList.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_OpenBSDProcessList #define HEADER_OpenBSDProcessList /* @@ -10,7 +8,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ - #include typedef struct CPUData_ { @@ -42,31 +39,12 @@ typedef struct OpenBSDProcessList_ { } OpenBSDProcessList; -/* - * avoid relying on or conflicting with MIN() and MAX() in sys/param.h - */ -#ifndef MINIMUM -#define MINIMUM(x, y) ((x) > (y) ? (y) : (x)) -#endif - -#ifndef MAXIMUM -#define MAXIMUM(x, y) ((x) > (y) ? (x) : (y)) -#endif - -#ifndef CLAMP -#define CLAMP(x, low, high) (((x) > (high)) ? (high) : MAXIMUM(x, low)) -#endif - -ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId); +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId); void ProcessList_delete(ProcessList* this); char *OpenBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, int* basenameEnd); -/* - * Taken from OpenBSD's ps(1). - */ void ProcessList_goThroughEntries(ProcessList* this); - #endif diff --git a/openbsd/Platform.c b/openbsd/Platform.c index 0f5279e..cb16207 100644 --- a/openbsd/Platform.c +++ b/openbsd/Platform.c @@ -37,14 +37,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Action.h" -#include "BatteryMeter.h" -#include "SignalsPanel.h" - -extern ProcessFieldData Process_fields[]; - -}*/ ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; diff --git a/openbsd/Platform.h b/openbsd/Platform.h index 56e4c40..f51d6bc 100644 --- a/openbsd/Platform.h +++ b/openbsd/Platform.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Platform #define HEADER_Platform /* @@ -16,14 +14,11 @@ in the source distribution for its full text. extern ProcessFieldData Process_fields[]; - extern ProcessField Platform_defaultFields[]; extern int Platform_numberOfFields; -/* - * See /usr/include/sys/signal.h - */ +/* see /usr/include/sys/signal.h */ extern const SignalItem Platform_signals[]; extern const unsigned int Platform_numberOfSignals; @@ -32,7 +27,6 @@ void Platform_setBindings(Htop_Action* keys); extern MeterClass* Platform_meterTypes[]; -// preserved from FreeBSD port int Platform_getUptime(); void Platform_getLoadAverage(double* one, double* five, double* fifteen); @@ -43,12 +37,6 @@ double Platform_setCPUValues(Meter* this, int cpu); void Platform_setMemoryValues(Meter* this); -/* - * Copyright (c) 1994 Thorsten Lockert - * All rights reserved. - * - * Taken almost directly from OpenBSD's top(1) - */ void Platform_setSwapValues(Meter* this); void Platform_setTasksValues(Meter* this); diff --git a/scripts/MakeHeader.py.in b/scripts/MakeHeader.py.in deleted file mode 100644 index 8a68877..0000000 --- a/scripts/MakeHeader.py.in +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env @PYTHON@ -import os, sys, io -try: - from StringIO import StringIO -except ImportError: - StringIO = io.StringIO - -ANY=1 -COPY=2 -SKIP=3 -SKIPONE=4 - -state = ANY -static = 0 - -file = io.open(sys.argv[1], "r", encoding="utf-8") -name = sys.argv[1][:-2] - -out = StringIO() - -selfheader = '#include "' + name + '.h"' - -out.write( "/* Do not edit this file. It was automatically generated. */\n" ) -out.write( "\n" ) - -out.write( "#ifndef HEADER_" + os.path.basename(name) + "\n") -out.write( "#define HEADER_" + os.path.basename(name) + "\n") -is_blank = False -for line in file.readlines(): - line = line[:-1] - if state == ANY: - if line == '/*{': - state = COPY - elif line == selfheader: - pass - elif line.find("#include") == 0: - pass - elif line.find("htop - ") == 0 and line[-2:] == ".c": - out.write(line[:-2] + ".h\n") - elif line.find("static ") != -1: - if line[-1] == "{": - state = SKIP - static = 1 - else: - state = SKIPONE - elif len(line) > 1: - static = 0 - equals = line.find(" = ") - if line[-3:] == "= {": - out.write( "extern " + line[:-4] + ";\n" ) - state = SKIP - elif equals != -1: - out.write("extern " + line[:equals] + ";\n" ) - elif line.startswith("typedef struct"): - state = SKIP - elif line[-1] == "{": - out.write("extern " + line[:-2].replace("inline ", "") + ";\n") - state = SKIP - elif line[-1] == ";": - out.write("extern " + line + "\n") - else: - out.write( line + "\n") - is_blank = False - elif line == "": - if not is_blank: - out.write( line + "\n") - is_blank = True - else: - out.write( line + "\n") - is_blank = False - elif state == COPY: - is_blank = False - if line == "}*/": - state = ANY - else: - out.write( line + "\n") - elif state == SKIP: - is_blank = False - if len(line) >= 1 and line[0] == "}": - if static == 1: - state = SKIPONE - else: - state = ANY - static = 0 - elif state == SKIPONE: - is_blank = False - state = ANY - -out.write( "\n" ) -out.write( "#endif\n" ) - -# only write a new .h file if something changed. -# This prevents a lot of recompilation during development -out.seek(0) -try: - with io.open(name + ".h", "r", encoding="utf-8") as orig: - origcontents = orig.readlines() -except: - origcontents = "" -if origcontents != out.readlines(): - with io.open(name + ".h", "w", encoding="utf-8") as new: - print("Writing "+name+".h") - new.write(out.getvalue()) -out.close() diff --git a/solaris/Battery.h b/solaris/Battery.h index 8dc0cef..21a1579 100644 --- a/solaris/Battery.h +++ b/solaris/Battery.h @@ -1,9 +1,6 @@ -/* 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/solaris/Platform.c b/solaris/Platform.c index 092f450..436c9ce 100644 --- a/solaris/Platform.c +++ b/solaris/Platform.c @@ -33,28 +33,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Action.h" -#include "BatteryMeter.h" -#include "SignalsPanel.h" -#include -#include -#include -#include - -#define kill(pid, signal) kill(pid / 1024, signal) - -extern ProcessFieldData Process_fields[]; -typedef struct var kvar_t; - -typedef struct envAccum_ { - size_t capacity; - size_t size; - size_t bytes; - char *env; -} envAccum; - -}*/ double plat_loadavg[3] = {0}; diff --git a/solaris/Platform.h b/solaris/Platform.h index dd1962d..dd8614d 100644 --- a/solaris/Platform.h +++ b/solaris/Platform.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Platform #define HEADER_Platform /* @@ -31,7 +29,6 @@ typedef struct envAccum_ { char *env; } envAccum; - extern double plat_loadavg[3]; extern const SignalItem Platform_signals[]; diff --git a/solaris/SolarisCRT.h b/solaris/SolarisCRT.h index 6ab6dfc..4e37b7f 100644 --- a/solaris/SolarisCRT.h +++ b/solaris/SolarisCRT.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_SolarisCRT #define HEADER_SolarisCRT /* @@ -10,9 +8,6 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#ifdef HAVE_EXECINFO_H -#endif - void CRT_handleSIGSEGV(int sgn); #endif diff --git a/solaris/SolarisProcess.c b/solaris/SolarisProcess.c index 514453f..ab0bcab 100644 --- a/solaris/SolarisProcess.c +++ b/solaris/SolarisProcess.c @@ -17,50 +17,6 @@ in the source distribution for its full text. #include #include -/*{ -#include "Settings.h" -#include -#include -#include - -typedef enum SolarisProcessFields { - // Add platform-specific fields here, with ids >= 100 - ZONEID = 100, - ZONE = 101, - PROJID = 102, - TASKID = 103, - POOLID = 104, - CONTID = 105, - LWPID = 106, - LAST_PROCESSFIELD = 107, -} SolarisProcessField; - - -typedef struct SolarisProcess_ { - Process super; - int kernel; - zoneid_t zoneid; - char* zname; - taskid_t taskid; - projid_t projid; - poolid_t poolid; - ctid_t contid; - bool is_lwp; - pid_t realpid; - pid_t realppid; - pid_t lwpid; -} SolarisProcess; - - -#ifndef Process_isKernelThread -#define Process_isKernelThread(_process) (_process->kernel == 1) -#endif - -#ifndef Process_isUserlandThread -#define Process_isUserlandThread(_process) (_process->pid != _process->tgid) -#endif - -}*/ ProcessClass SolarisProcess_class = { .super = { diff --git a/solaris/SolarisProcess.h b/solaris/SolarisProcess.h index 1b3492a..d36dea3 100644 --- a/solaris/SolarisProcess.h +++ b/solaris/SolarisProcess.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_SolarisProcess #define HEADER_SolarisProcess /* @@ -15,7 +13,7 @@ in the source distribution for its full text. #include #include -typedef enum SolarisProcessFields { +typedef enum SolarisProcessField_ { // Add platform-specific fields here, with ids >= 100 ZONEID = 100, ZONE = 101, @@ -27,7 +25,6 @@ typedef enum SolarisProcessFields { LAST_PROCESSFIELD = 107, } SolarisProcessField; - typedef struct SolarisProcess_ { Process super; int kernel; @@ -43,15 +40,9 @@ typedef struct SolarisProcess_ { pid_t lwpid; } SolarisProcess; - -#ifndef Process_isKernelThread #define Process_isKernelThread(_process) (_process->kernel == 1) -#endif -#ifndef Process_isUserlandThread #define Process_isUserlandThread(_process) (_process->pid != _process->tgid) -#endif - extern ProcessClass SolarisProcess_class; diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c index ab2cf68..4e4d282 100644 --- a/solaris/SolarisProcessList.c +++ b/solaris/SolarisProcessList.c @@ -25,45 +25,6 @@ in the source distribution for its full text. #define MAXCMDLINE 255 -#define GZONE "global " -#define UZONE "unknown " -/*{ - -#include "zfs/ZfsArcStats.h" - -#include -#include -#include -#include -#include -#include -#include - -#define ZONE_ERRMSGLEN 1024 -char zone_errmsg[ZONE_ERRMSGLEN]; - -typedef struct CPUData_ { - double userPercent; - double nicePercent; - double systemPercent; - double irqPercent; - double idlePercent; - double systemAllPercent; - uint64_t luser; - uint64_t lkrnl; - uint64_t lintr; - uint64_t lidle; -} CPUData; - -typedef struct SolarisProcessList_ { - ProcessList super; - kstat_ctl_t* kd; - CPUData* cpus; - ZfsArcStats zfs; -} SolarisProcessList; - -}*/ - char* SolarisProcessList_readZoneName(kstat_ctl_t* kd, SolarisProcess* sproc) { char* zname; if ( sproc->zoneid == 0 ) { @@ -77,10 +38,10 @@ char* SolarisProcessList_readZoneName(kstat_ctl_t* kd, SolarisProcess* sproc) { return zname; } -ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) { +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) { SolarisProcessList* spl = xCalloc(1, sizeof(SolarisProcessList)); ProcessList* pl = (ProcessList*) spl; - ProcessList_init(pl, Class(SolarisProcess), usersTable, pidWhiteList, userId); + ProcessList_init(pl, Class(SolarisProcess), usersTable, pidMatchList, userId); spl->kd = kstat_open(); @@ -323,7 +284,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void * sproc->poolid = _psinfo->pr_poolid; sproc->contid = _psinfo->pr_contract; proc->priority = _lwpsinfo->pr_pri; - proc->nice = _lwpsinfo->pr_nice; + proc->nice = _lwpsinfo->pr_nice - NZERO; proc->processor = _lwpsinfo->pr_onpro; proc->state = _lwpsinfo->pr_sname; // NOTE: This 'percentage' is a 16-bit BINARY FRACTIONS where 1.0 = 0x8000 diff --git a/solaris/SolarisProcessList.h b/solaris/SolarisProcessList.h index 06c1330..9da39b4 100644 --- a/solaris/SolarisProcessList.h +++ b/solaris/SolarisProcessList.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_SolarisProcessList #define HEADER_SolarisProcessList /* @@ -26,7 +24,7 @@ in the source distribution for its full text. #include #define ZONE_ERRMSGLEN 1024 -char zone_errmsg[ZONE_ERRMSGLEN]; +extern char zone_errmsg[ZONE_ERRMSGLEN]; typedef struct CPUData_ { double userPercent; @@ -48,10 +46,9 @@ typedef struct SolarisProcessList_ { ZfsArcStats zfs; } SolarisProcessList; - char* SolarisProcessList_readZoneName(kstat_ctl_t* kd, SolarisProcess* sproc); -ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId); +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId); void ProcessList_delete(ProcessList* pl); @@ -65,5 +62,4 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void * void ProcessList_goThroughEntries(ProcessList* this); - #endif diff --git a/unsupported/Battery.h b/unsupported/Battery.h index 8dc0cef..21a1579 100644 --- a/unsupported/Battery.h +++ b/unsupported/Battery.h @@ -1,9 +1,6 @@ -/* 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 index 0e46a34..420dfb7 100644 --- a/unsupported/Platform.c +++ b/unsupported/Platform.c @@ -16,12 +16,6 @@ in the source distribution for its full text. #include "HostnameMeter.h" #include "UptimeMeter.h" -/*{ -#include "Action.h" -#include "BatteryMeter.h" -#include "SignalsPanel.h" -#include "UnsupportedProcess.h" -}*/ const SignalItem Platform_signals[] = { { .name = " 0 Cancel", .number = 0 }, diff --git a/unsupported/Platform.h b/unsupported/Platform.h index 14f3d1a..2a3d768 100644 --- a/unsupported/Platform.h +++ b/unsupported/Platform.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_Platform #define HEADER_Platform /* diff --git a/unsupported/UnsupportedCRT.h b/unsupported/UnsupportedCRT.h index 3c808ca..24d63e5 100644 --- a/unsupported/UnsupportedCRT.h +++ b/unsupported/UnsupportedCRT.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_UnsupportedCRT #define HEADER_UnsupportedCRT /* @@ -11,5 +9,4 @@ in the source distribution for its full text. void CRT_handleSIGSEGV(int sgn); - #endif diff --git a/unsupported/UnsupportedProcess.c b/unsupported/UnsupportedProcess.c index e3b4689..63e26ad 100644 --- a/unsupported/UnsupportedProcess.c +++ b/unsupported/UnsupportedProcess.c @@ -9,12 +9,6 @@ in the source distribution for its full text. #include "UnsupportedProcess.h" #include -/*{ -#include "Settings.h" - -#define Process_delete UnsupportedProcess_delete - -}*/ Process* UnsupportedProcess_new(Settings* settings) { Process* this = xCalloc(1, sizeof(Process)); diff --git a/unsupported/UnsupportedProcess.h b/unsupported/UnsupportedProcess.h index 4ca3043..dbe9bf5 100644 --- a/unsupported/UnsupportedProcess.h +++ b/unsupported/UnsupportedProcess.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_UnsupportedProcess #define HEADER_UnsupportedProcess /* @@ -13,10 +11,8 @@ in the source distribution for its full text. #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 index 65749b1..fc8a54d 100644 --- a/unsupported/UnsupportedProcessList.c +++ b/unsupported/UnsupportedProcessList.c @@ -11,13 +11,10 @@ in the source distribution for its full text. #include #include -/*{ -}*/ - -ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) { +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) { ProcessList* this = xCalloc(1, sizeof(ProcessList)); - ProcessList_init(this, Class(Process), usersTable, pidWhiteList, userId); + ProcessList_init(this, Class(Process), usersTable, pidMatchList, userId); return this; } diff --git a/unsupported/UnsupportedProcessList.h b/unsupported/UnsupportedProcessList.h index 6eb1308..c4b51ac 100644 --- a/unsupported/UnsupportedProcessList.h +++ b/unsupported/UnsupportedProcessList.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_UnsupportedProcessList #define HEADER_UnsupportedProcessList /* @@ -9,9 +7,7 @@ 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); +ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId); void ProcessList_delete(ProcessList* this); diff --git a/zfs/ZfsArcMeter.h b/zfs/ZfsArcMeter.h index f2e322f..e6b59d5 100644 --- a/zfs/ZfsArcMeter.h +++ b/zfs/ZfsArcMeter.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_ZfsArcMeter #define HEADER_ZfsArcMeter /* @@ -15,7 +13,7 @@ in the source distribution for its full text. extern int ZfsArcMeter_attributes[]; -extern void ZfsArcMeter_readStats(Meter* this, ZfsArcStats* stats); +void ZfsArcMeter_readStats(Meter* this, ZfsArcStats* stats); extern MeterClass ZfsArcMeter_class; diff --git a/zfs/ZfsArcStats.h b/zfs/ZfsArcStats.h index 9368ba9..087f3fc 100644 --- a/zfs/ZfsArcStats.h +++ b/zfs/ZfsArcStats.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_ZfsArcStats #define HEADER_ZfsArcStats /* @@ -23,5 +21,4 @@ typedef struct ZfsArcStats_ { unsigned long long int uncompressed; } ZfsArcStats; - #endif diff --git a/zfs/ZfsCompressedArcMeter.h b/zfs/ZfsCompressedArcMeter.h index 5afcc99..8e64493 100644 --- a/zfs/ZfsCompressedArcMeter.h +++ b/zfs/ZfsCompressedArcMeter.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_ZfsCompressedArcMeter #define HEADER_ZfsCompressedArcMeter /* diff --git a/zfs/openzfs_sysctl.h b/zfs/openzfs_sysctl.h index 6e44ac3..adb4b24 100644 --- a/zfs/openzfs_sysctl.h +++ b/zfs/openzfs_sysctl.h @@ -1,5 +1,3 @@ -/* Do not edit this file. It was automatically generated. */ - #ifndef HEADER_openzfs_sysctl #define HEADER_openzfs_sysctl /* -- cgit v1.2.3