diff --git a/CRT.c b/CRT.c index 149cd519b..0a7666da4 100644 --- a/CRT.c +++ b/CRT.c @@ -129,6 +129,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [FAILED_READ] = A_BOLD | ColorPair(Red, Black), [PAUSED] = A_BOLD | ColorPair(Yellow, Cyan), [UPTIME] = A_BOLD | ColorPair(Cyan, Black), + [FLEX] = A_BOLD | ColorPair(Cyan, Black), [BATTERY] = A_BOLD | ColorPair(Cyan, Black), [LARGE_NUMBER] = A_BOLD | ColorPair(Red, Black), [METER_SHADOW] = A_BOLD | ColorPairGrayBlack, @@ -247,6 +248,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [FAILED_READ] = A_BOLD, [PAUSED] = A_BOLD | A_REVERSE, [UPTIME] = A_BOLD, + [FLEX] = A_BOLD, [BATTERY] = A_BOLD, [LARGE_NUMBER] = A_BOLD, [METER_SHADOW] = A_DIM, @@ -365,6 +367,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [FAILED_READ] = ColorPair(Red, White), [PAUSED] = A_BOLD | ColorPair(Yellow, Cyan), [UPTIME] = ColorPair(Yellow, White), + [FLEX] = ColorPair(Yellow, White), [BATTERY] = ColorPair(Yellow, White), [LARGE_NUMBER] = ColorPair(Red, White), [METER_SHADOW] = ColorPair(Blue, White), @@ -483,6 +486,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [FAILED_READ] = ColorPair(Red, Black), [PAUSED] = A_BOLD | ColorPair(Yellow, Cyan), [UPTIME] = ColorPair(Yellow, Black), + [FLEX] = ColorPair(Yellow, Black), [BATTERY] = ColorPair(Yellow, Black), [LARGE_NUMBER] = ColorPair(Red, Black), [METER_SHADOW] = A_BOLD | ColorPairGrayBlack, @@ -601,6 +605,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [FAILED_READ] = A_BOLD | ColorPair(Red, Blue), [PAUSED] = A_BOLD | ColorPair(Yellow, Cyan), [UPTIME] = A_BOLD | ColorPair(Yellow, Blue), + [FLEX] = A_BOLD | ColorPair(Yellow, Blue), [BATTERY] = A_BOLD | ColorPair(Yellow, Blue), [LARGE_NUMBER] = A_BOLD | ColorPair(Red, Blue), [METER_SHADOW] = ColorPair(Cyan, Blue), @@ -719,6 +724,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [FAILED_READ] = A_BOLD | ColorPair(Red, Black), [PAUSED] = A_BOLD | ColorPair(Yellow, Green), [UPTIME] = ColorPair(Green, Black), + [FLEX] = ColorPair(Green, Black), [BATTERY] = ColorPair(Green, Black), [LARGE_NUMBER] = A_BOLD | ColorPair(Red, Black), [METER_SHADOW] = A_BOLD | ColorPairGrayBlack, diff --git a/CRT.h b/CRT.h index eb3df1d7f..5d27a2a7c 100644 --- a/CRT.h +++ b/CRT.h @@ -154,6 +154,7 @@ typedef enum ColorElements_ { DYNAMIC_MAGENTA, DYNAMIC_YELLOW, DYNAMIC_WHITE, + FLEX, LAST_COLORELEMENT } ColorElements; diff --git a/FlexMeter.c b/FlexMeter.c new file mode 100644 index 000000000..a0231fa07 --- /dev/null +++ b/FlexMeter.c @@ -0,0 +1,217 @@ +/* +htop - FlexMeter.c +(C) 2024 Stoyan Bogdanov +Released under the GNU GPLv2+, see the COPYING file +in the source distribution for its full text. +*/ + +#include +#include +#include +#include +#include +#include + +#include "CRT.h" +#include "config.h" +#include "FlexMeter.h" +#include "Object.h" + + +#define FLEX_CFG_FOLDER ".config/htop/FlexMeter" + +typedef struct { + char* name; + char* command; + char* type; + char* caption; + char* uiName; +} _flex_meter; + +_flex_meter meter_list[METERS_LIST_SIZE]; + +static int meters_count = 0; + +static const int DateMeter_attributes[] = { + FLEX +}; + +MeterClass* FlexMeter_class = NULL; + +static int check_for_meters(void); + +static bool parse_input(_flex_meter *meter, char* line) +{ + switch(line[0]) + { + case 'n': + if (String_startsWith(line, "name=")) { + xAsprintf(&meter->uiName, "Flex: %s", line + 5); + } + break; + case 'c': + if (String_startsWith(line, "command=")) { + meter->command = xStrdup(line + 8); + } else if (String_startsWith(line, "caption=")) { + meter->caption = xStrdup(line + 8); + } + break; + case 't': + if (String_startsWith(line, "type=")) { + meter->type = xStrdup(line + 6); + } + break; + default: + return false; + } + + return true; +} + +static bool load_config(_flex_meter *meter, char* file) +{ + bool ret = false; + FILE* fp = fopen(file, "r"); + + if (fp != NULL) { + char* buff; + while ((buff = String_readLine(fp)) != NULL) { + ret = parse_input(meter, buff); + if (!ret) { + break; + } + } + free(buff); + buff = NULL; + } + + fclose(fp); + return ret; +} + +static int check_for_meters(void) +{ + char* path; + struct dirent* dir; + struct passwd* pw = getpwuid(getuid()); + const char* homedir = pw->pw_dir; + char* home = NULL; + bool ret; + + const char* xdgConfigHome = getenv("XDG_CONFIG_HOME"); + const char* homedirEnv = getenv("HOME"); + + if (xdgConfigHome) { + xAsprintf(&home, "%s/%s", xdgConfigHome, "htop/FlexMeter"); + } else if (homedirEnv) { + xAsprintf(&home, "%s/%s", homedirEnv, FLEX_CFG_FOLDER); + } else { + xAsprintf(&home, "%s/%s", homedir, FLEX_CFG_FOLDER); + } + + struct stat fileStat; + + if (stat(home, &fileStat) < 0) { + return -1; + } + + uint32_t uid = getuid(); + + if ((fileStat.st_uid == uid) && S_ISDIR(fileStat.st_mode) && + ((fileStat.st_mode & 0777) == 0700)) { + DIR* d = opendir(home); + if (d) { + while ((dir = readdir(d)) != NULL) { + if ( dir->d_name[0] == '.') { + /* We are ignoring all files starting with . like ".Template" + * and "." ".." directories + */ + continue; + } + + meter_list[meters_count].name = xStrdup(dir->d_name); + xAsprintf(&path, "%s/%s", home, dir->d_name); + + if (stat(path, &fileStat) < 0) { + return -1; + } + + if ((fileStat.st_uid == uid) && ((fileStat.st_mode & 0777) == 0700)) { + ret = load_config(&meter_list[meters_count], path); + + if (ret && (meters_count < MAX_METERS_COUNT)) { + meters_count++; + } + } + + free(path); + path=NULL; + + } + closedir(d); + } + } + + free(home); + home = NULL; + + return meters_count; +} + +static void FlexMeter_updateValues(Meter* this) +{ + for (size_t i = 0 ; i < (size_t)meters_count; i++) { + if (this->m_ptr == &FlexMeter_class[i] ) { + char* buff = NULL; + int ret = -1; + if (meter_list[i].command) { + FILE* fd = popen(meter_list[i].command, "r"); + if (fd) { + buff = String_readLine(fd); + ret = pclose(fd); + } + } + + if (buff && !ret) { + xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%s", buff); + } else { + // Once fail, free command pointer and every time print Error message + if (meter_list[i].command != NULL) { + free(meter_list[i].command); + meter_list[i].command = NULL; + } + xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%s", "[ERR] Check command"); + } + } + } +} + +const MeterClass FlexMeter_class_template = { + .super = { + .extends = Class(Meter), + .delete = Meter_delete + }, + .updateValues = FlexMeter_updateValues, + .defaultMode = TEXT_METERMODE, + .maxItems = 1, + .total = 100, + .attributes = DateMeter_attributes, + .name = NULL, + .uiName = NULL, + .caption = NULL, +}; + +int load_flex_modules(void) +{ + size_t meters_num = check_for_meters(); + if (!FlexMeter_class && meters_num > 0) { + FlexMeter_class = (MeterClass*) xCalloc(meters_num, sizeof(MeterClass)); + for (size_t i = 0 ; i < meters_num; i++) { + memcpy(&FlexMeter_class[i], &FlexMeter_class_template, sizeof(MeterClass)); + FlexMeter_class[i].name = (const char*) xStrdup(meter_list[i].name); + FlexMeter_class[i].uiName = (const char*) xStrdup(meter_list[i].uiName); + FlexMeter_class[i].caption = (const char*) xStrdup(meter_list[i].caption); + } + } + return meters_num; +} diff --git a/FlexMeter.h b/FlexMeter.h new file mode 100644 index 000000000..8d1f4c0bf --- /dev/null +++ b/FlexMeter.h @@ -0,0 +1,22 @@ +#ifndef HEADER_FlexMeter +#define HEADER_FlexMeter +/* +htop - FlexMeter.c +(C) 2024 Stoyan Bogdanov +Released under the GNU GPLv2+, see the COPYING file +in the source distribution for its full text. +*/ +#include + +#include "Meter.h" + + +#define METERS_LIST_SIZE 30 + +#define MAX_METERS_COUNT METERS_LIST_SIZE-1 + +extern MeterClass *FlexMeter_class ; + +int load_flex_modules(void); + +#endif diff --git a/Header.c b/Header.c index 8a9eae34d..34c111fe5 100644 --- a/Header.c +++ b/Header.c @@ -20,6 +20,7 @@ in the source distribution for its full text. #include "CRT.h" #include "CPUMeter.h" #include "DynamicMeter.h" +#include "FlexMeter.h" #include "Macros.h" #include "Object.h" #include "Platform.h" @@ -27,7 +28,6 @@ in the source distribution for its full text. #include "Settings.h" #include "XUtils.h" - Header* Header_new(Machine* host, HeaderLayout hLayout) { Header* this = xCalloc(1, sizeof(Header)); this->columns = xMallocArray(HeaderLayout_getColumns(hLayout), sizeof(Vector*)); @@ -121,6 +121,14 @@ void Header_populateFromSettings(Header* this) { const Settings* settings = this->host->settings; Header_setLayout(this, settings->hLayout); + int num = load_flex_modules(); + int platform_size = 0; + + for (platform_size = 0; Platform_meterTypes[platform_size] != NULL; platform_size++); + for (int i = 0; i < num; i++) Platform_meterTypes[platform_size+i]=FlexMeter_class+i; + + Platform_meterTypes[platform_size+num]=NULL; + Header_forEachColumn(this, col) { const MeterColumnSetting* colSettings = &settings->hColumns[col]; Vector_prune(this->columns[col]); diff --git a/Makefile.am b/Makefile.am index 2580252b8..0d8c3ab9d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,6 +52,7 @@ myhtopsources = \ DynamicScreen.c \ EnvScreen.c \ FileDescriptorMeter.c \ + FlexMeter.c \ FunctionBar.c \ Hashtable.c \ Header.c \ @@ -93,6 +94,7 @@ myhtopsources = \ Vector.c \ XUtils.c + myhtopheaders = \ Action.h \ Affinity.h \ @@ -118,6 +120,7 @@ myhtopheaders = \ DynamicScreen.h \ EnvScreen.h \ FileDescriptorMeter.h \ + FlexMeter.h \ FunctionBar.h \ Hashtable.h \ Header.h \ @@ -165,6 +168,7 @@ myhtopheaders = \ Vector.h \ XUtils.h + # Linux # ----- diff --git a/Meter.c b/Meter.c index 3dbdfcc66..25c0940cb 100644 --- a/Meter.c +++ b/Meter.c @@ -377,6 +377,7 @@ Meter* Meter_new(const Machine* host, unsigned int param, const MeterClass* type this->values = type->maxItems ? xCalloc(type->maxItems, sizeof(double)) : NULL; this->total = type->total; this->caption = xStrdup(type->caption); + this->m_ptr = type; if (Meter_initFn(this)) { Meter_init(this); } diff --git a/Meter.h b/Meter.h index 0d93759f6..be4fe28b2 100644 --- a/Meter.h +++ b/Meter.h @@ -67,9 +67,9 @@ typedef struct MeterClass_ { const MeterModeId defaultMode; const double total; const int* const attributes; - const char* const name; /* internal name of the meter, must not contain any space */ - const char* const uiName; /* display name in header setup menu */ - const char* const caption; /* prefix in the actual header */ + const char* name; /* internal name of the meter, must not contain any space */ + const char* uiName; /* display name in header setup menu */ + const char* caption; /* prefix in the actual header */ const char* const description; /* optional meter description in header setup menu */ const uint8_t maxItems; const bool isMultiColumn; /* whether the meter draws multiple sub-columns (defaults to false) */ @@ -102,8 +102,9 @@ typedef struct GraphData_ { struct Meter_ { Object super; Meter_Draw draw; - const Machine* host; + const Machine* host; + const MeterClass* m_ptr; char* caption; MeterModeId mode; unsigned int param; diff --git a/configure.ac b/configure.ac index 81836e8e7..13d1ee0c9 100644 --- a/configure.ac +++ b/configure.ac @@ -25,6 +25,7 @@ AM_INIT_AUTOMAKE([-Wall std-options subdir-objects]) # ---------------------------------------------------------------------- +AC_DEFINE([MAX_PLATFORM_METERS], [100], [Set max meters for number]) # ---------------------------------------------------------------------- # Checks for platform. diff --git a/darwin/Platform.c b/darwin/Platform.c index ba31a59f8..5dbf5f3eb 100644 --- a/darwin/Platform.c +++ b/darwin/Platform.c @@ -38,6 +38,7 @@ in the source distribution for its full text. #include "DateMeter.h" #include "DateTimeMeter.h" #include "FileDescriptorMeter.h" +#include "FlexMeter.h" #include "HostnameMeter.h" #include "LoadAverageMeter.h" #include "Macros.h" @@ -112,7 +113,7 @@ const SignalItem Platform_signals[] = { const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); -const MeterClass* const Platform_meterTypes[] = { +const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS] = { &CPUMeter_class, &ClockMeter_class, &DateMeter_class, diff --git a/darwin/Platform.h b/darwin/Platform.h index f67db8ff4..bac3187fc 100644 --- a/darwin/Platform.h +++ b/darwin/Platform.h @@ -34,7 +34,7 @@ extern const SignalItem Platform_signals[]; extern const unsigned int Platform_numberOfSignals; -extern const MeterClass* const Platform_meterTypes[]; +extern const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS]; bool Platform_init(void); diff --git a/docs/FlexMeter/Template b/docs/FlexMeter/Template new file mode 100644 index 000000000..c4170838e --- /dev/null +++ b/docs/FlexMeter/Template @@ -0,0 +1,4 @@ +name=template +command=echo "`uptime`" +type=TEXT_METERMODE +caption="UPTIME" diff --git a/dragonflybsd/Platform.c b/dragonflybsd/Platform.c index f3412ef9e..cd7623850 100644 --- a/dragonflybsd/Platform.c +++ b/dragonflybsd/Platform.c @@ -27,6 +27,7 @@ in the source distribution for its full text. #include "DateMeter.h" #include "DateTimeMeter.h" #include "FileDescriptorMeter.h" +#include "FlexMeter.h" #include "HostnameMeter.h" #include "LoadAverageMeter.h" #include "Macros.h" @@ -43,7 +44,6 @@ in the source distribution for its full text. #include "dragonflybsd/DragonFlyBSDProcessTable.h" #include "generic/fdstat_sysctl.h" - const ScreenDefaults Platform_defaultScreens[] = { { .name = "Main", @@ -93,7 +93,7 @@ const SignalItem Platform_signals[] = { const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); -const MeterClass* const Platform_meterTypes[] = { +const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS] = { &CPUMeter_class, &ClockMeter_class, &DateMeter_class, diff --git a/dragonflybsd/Platform.h b/dragonflybsd/Platform.h index 606b004c0..343f67849 100644 --- a/dragonflybsd/Platform.h +++ b/dragonflybsd/Platform.h @@ -37,7 +37,7 @@ extern const SignalItem Platform_signals[]; extern const unsigned int Platform_numberOfSignals; -extern const MeterClass* const Platform_meterTypes[]; +extern const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS]; bool Platform_init(void); diff --git a/freebsd/Platform.c b/freebsd/Platform.c index 9be7195e5..da321bf6c 100644 --- a/freebsd/Platform.c +++ b/freebsd/Platform.c @@ -32,6 +32,7 @@ in the source distribution for its full text. #include "DateTimeMeter.h" #include "DiskIOMeter.h" #include "FileDescriptorMeter.h" +#include "FlexMeter.h" #include "HostnameMeter.h" #include "LoadAverageMeter.h" #include "Machine.h" @@ -100,7 +101,7 @@ const SignalItem Platform_signals[] = { const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); -const MeterClass* const Platform_meterTypes[] = { +const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS] = { &CPUMeter_class, &ClockMeter_class, &DateMeter_class, diff --git a/freebsd/Platform.h b/freebsd/Platform.h index c358d85d3..5604b8111 100644 --- a/freebsd/Platform.h +++ b/freebsd/Platform.h @@ -33,7 +33,7 @@ extern const SignalItem Platform_signals[]; extern const unsigned int Platform_numberOfSignals; -extern const MeterClass* const Platform_meterTypes[]; +extern const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS]; bool Platform_init(void); diff --git a/linux/Platform.c b/linux/Platform.c index 3316d1dba..e8e4732d1 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -31,6 +31,7 @@ in the source distribution for its full text. #include "DateTimeMeter.h" #include "DiskIOMeter.h" #include "FileDescriptorMeter.h" +#include "FlexMeter.h" #include "HostnameMeter.h" #include "HugePageMeter.h" #include "LoadAverageMeter.h" @@ -209,7 +210,7 @@ void Platform_setBindings(Htop_Action* keys) { keys[KEY_F(20)] = Platform_actionHigherAutogroupPriority; // Shift-F8 } -const MeterClass* const Platform_meterTypes[] = { +const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS] = { &CPUMeter_class, &ClockMeter_class, &DateMeter_class, diff --git a/linux/Platform.h b/linux/Platform.h index e99d1a226..a8fcb1594 100644 --- a/linux/Platform.h +++ b/linux/Platform.h @@ -47,7 +47,8 @@ extern const SignalItem Platform_signals[]; extern const unsigned int Platform_numberOfSignals; -extern const MeterClass* const Platform_meterTypes[]; +extern const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS]; + bool Platform_init(void); void Platform_done(void); diff --git a/netbsd/Platform.c b/netbsd/Platform.c index f458c239f..27efd2ac8 100644 --- a/netbsd/Platform.c +++ b/netbsd/Platform.c @@ -41,6 +41,7 @@ in the source distribution for its full text. #include "DateMeter.h" #include "DateTimeMeter.h" #include "FileDescriptorMeter.h" +#include "FlexMeter.h" #include "HostnameMeter.h" #include "LoadAverageMeter.h" #include "Macros.h" @@ -152,7 +153,7 @@ const SignalItem Platform_signals[] = { const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); -const MeterClass* const Platform_meterTypes[] = { +const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS] = { &CPUMeter_class, &ClockMeter_class, &DateMeter_class, diff --git a/netbsd/Platform.h b/netbsd/Platform.h index a543f52dd..509e324e8 100644 --- a/netbsd/Platform.h +++ b/netbsd/Platform.h @@ -43,7 +43,7 @@ extern const SignalItem Platform_signals[]; extern const unsigned int Platform_numberOfSignals; -extern const MeterClass* const Platform_meterTypes[]; +extern const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS]; bool Platform_init(void); diff --git a/openbsd/Platform.c b/openbsd/Platform.c index a8b5d212d..54158d27e 100644 --- a/openbsd/Platform.c +++ b/openbsd/Platform.c @@ -31,6 +31,7 @@ in the source distribution for its full text. #include "DateMeter.h" #include "DateTimeMeter.h" #include "FileDescriptorMeter.h" +#include "FlexMeter.h" #include "HostnameMeter.h" #include "LoadAverageMeter.h" #include "Macros.h" @@ -47,7 +48,6 @@ in the source distribution for its full text. #include "openbsd/OpenBSDMachine.h" #include "openbsd/OpenBSDProcess.h" - const ScreenDefaults Platform_defaultScreens[] = { { .name = "Main", @@ -100,7 +100,7 @@ const SignalItem Platform_signals[] = { const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); -const MeterClass* const Platform_meterTypes[] = { +const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS] = { &CPUMeter_class, &ClockMeter_class, &DateMeter_class, diff --git a/openbsd/Platform.h b/openbsd/Platform.h index 339616c11..3e8527201 100644 --- a/openbsd/Platform.h +++ b/openbsd/Platform.h @@ -35,7 +35,7 @@ extern const SignalItem Platform_signals[]; extern const unsigned int Platform_numberOfSignals; -extern const MeterClass* const Platform_meterTypes[]; +extern const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS]; bool Platform_init(void); diff --git a/pcp/Platform.c b/pcp/Platform.c index d50edd254..f9ef2db89 100644 --- a/pcp/Platform.c +++ b/pcp/Platform.c @@ -27,6 +27,7 @@ in the source distribution for its full text. #include "DynamicMeter.h" #include "DynamicScreen.h" #include "FileDescriptorMeter.h" +#include "FlexMeter.h" #include "HostnameMeter.h" #include "LoadAverageMeter.h" #include "Macros.h" @@ -55,7 +56,6 @@ in the source distribution for its full text. #include "zfs/ZfsArcStats.h" #include "zfs/ZfsCompressedArcMeter.h" - Platform* pcp; const ScreenDefaults Platform_defaultScreens[] = { @@ -79,7 +79,7 @@ const SignalItem Platform_signals[] = { const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); -const MeterClass* const Platform_meterTypes[] = { +const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS] = { &CPUMeter_class, &DynamicMeter_class, &ClockMeter_class, diff --git a/pcp/Platform.h b/pcp/Platform.h index f43ed54f2..53dfcce25 100644 --- a/pcp/Platform.h +++ b/pcp/Platform.h @@ -68,7 +68,7 @@ extern const SignalItem Platform_signals[]; extern const unsigned int Platform_numberOfSignals; -extern const MeterClass* const Platform_meterTypes[]; +extern const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS]; bool Platform_init(void); diff --git a/solaris/Platform.c b/solaris/Platform.c index 3934f7896..40ec1343b 100644 --- a/solaris/Platform.c +++ b/solaris/Platform.c @@ -33,6 +33,7 @@ in the source distribution for its full text. #include "ClockMeter.h" #include "DateMeter.h" #include "DateTimeMeter.h" +#include "FlexMeter.h" #include "HostnameMeter.h" #include "SysArchMeter.h" #include "UptimeMeter.h" @@ -43,7 +44,6 @@ in the source distribution for its full text. #include "zfs/ZfsArcMeter.h" #include "zfs/ZfsCompressedArcMeter.h" - const ScreenDefaults Platform_defaultScreens[] = { { .name = "Default", @@ -101,7 +101,7 @@ const SignalItem Platform_signals[] = { const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); -const MeterClass* const Platform_meterTypes[] = { +const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS] = { &CPUMeter_class, &ClockMeter_class, &DateMeter_class, diff --git a/solaris/Platform.h b/solaris/Platform.h index 1a31c2e7a..a2008c4ab 100644 --- a/solaris/Platform.h +++ b/solaris/Platform.h @@ -58,7 +58,7 @@ extern const SignalItem Platform_signals[]; extern const unsigned int Platform_numberOfSignals; -extern const MeterClass* const Platform_meterTypes[]; +extern const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS]; bool Platform_init(void); diff --git a/unsupported/Platform.c b/unsupported/Platform.c index dbfddd916..eadfbcd76 100644 --- a/unsupported/Platform.c +++ b/unsupported/Platform.c @@ -17,6 +17,7 @@ in the source distribution for its full text. #include "DateMeter.h" #include "DateTimeMeter.h" #include "FileDescriptorMeter.h" +#include "FlexMeter.h" #include "HostnameMeter.h" #include "LoadAverageMeter.h" #include "Macros.h" @@ -27,7 +28,6 @@ in the source distribution for its full text. #include "TasksMeter.h" #include "UptimeMeter.h" - const ScreenDefaults Platform_defaultScreens[] = { { .name = "Main", @@ -44,7 +44,7 @@ const SignalItem Platform_signals[] = { const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); -const MeterClass* const Platform_meterTypes[] = { +const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS] = { &CPUMeter_class, &ClockMeter_class, &DateMeter_class, diff --git a/unsupported/Platform.h b/unsupported/Platform.h index c4cd06a04..c36de74d4 100644 --- a/unsupported/Platform.h +++ b/unsupported/Platform.h @@ -31,7 +31,7 @@ extern const SignalItem Platform_signals[]; extern const unsigned int Platform_numberOfSignals; -extern const MeterClass* const Platform_meterTypes[]; +extern const MeterClass* Platform_meterTypes[MAX_PLATFORM_METERS]; bool Platform_init(void);