summaryrefslogtreecommitdiffstats
path: root/Header.c
AgeCommit message (Collapse)Author
2021-12-09Do not leave empty last column in headerChristian Göttsche
Do not leave empty last column in header meters by refactoring the width and separator logic. Closes: #784
2021-12-07Introduce screen tabsHisham Muhammad
This is a forward port (by nathans) of Hisham's original code.
2021-10-15Header: allocate memory for terminating entryChristian Göttsche
The names array is terminated by a NULL entry, thus allocate space for one more than entries. Fixes: #844 ==6708==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6060000045b8 at pc 0x000000589ee1 bp 0x7ffcd1dee220 sp 0x7ffcd1dee218 READ of size 8 at 0x6060000045b8 thread T0 #0 0x589ee0 in String_freeArray ./XUtils.c:157:23 #1 0x56c9af in Settings_delete ./Settings.c:31:7 #2 0x4ee44b in CommandLine_run ./CommandLine.c:395:4 #3 0x4d6fb2 in main ./htop.c:15:11 #4 0x7ff3b8154e49 in __libc_start_main csu/../csu/libc-start.c:314:16 #5 0x428aa9 in _start (./htop+0x428aa9) 0x6060000045b8 is located 0 bytes to the right of 56-byte region [0x606000004580,0x6060000045b8) allocated by thread T0 here: #0 0x4a53f2 in __interceptor_calloc (./htop+0x4a53f2) #1 0x5890ba in xCalloc ./XUtils.c:55:17 #2 0x50a044 in Header_writeBackToSettings ./Header.c:148:34 #3 0x4de861 in Action_runSetup ./Action.c:91:7 #4 0x4de861 in actionSetup ./Action.c:386:4 #5 0x515caf in MainPanel_eventHandler ./MainPanel.c:106:19 #6 0x56a5c1 in ScreenManager_run ./ScreenManager.c:235:19 #7 0x4ee13b in CommandLine_run ./CommandLine.c:364:4 #8 0x4d6fb2 in main ./htop.c:15:11 #9 0x7ff3b8154e49 in __libc_start_main csu/../csu/libc-start.c:314:16
2021-09-22Update license headers to explicitly say GPLv2+Daniel Lange
2021-09-18Header: do not let multi-column meters expand to empty neighborsChristian Göttsche
Extending to right neighbors is intended for text meters with an overlong content, so the whole text is shown if possible. Multi column meters, like the combined memory and swap meter, position its text depending on the given total width; keep the position to the original assigned header slot. Short term resolution for #796
2021-09-04Header: use upper case floating point suffixChristian Göttsche
2021-09-04Reduce variable scopeChristian Göttsche
Also avoid declaring variables of different type, pointer and array, in the same line.
2021-08-25IWYU updateChristian Göttsche
2021-08-23Tiny cleanup from review commentsDaniel Lange
2021-08-22Add option to change Header layoutChristian Göttsche
2021-08-10Add assert to improve backtraces on NULL function pointerChristian Göttsche
2021-07-14Ensure PCP dynamic metric configuration definition uniquenessNathan Scott
It can happen that pcp-htop is presented multiple definitions of the same dynamic meter, e.g. if /etc/pcp/htop/meters has a definition matching one in ~/.config/htop/meters - instead of exiting with a duplicate metric error provide more meaningful diagnostics (on close) and also just skip over such entries. System files override home directories which overrides those found below the current working directory. Also fix the derived metric error diagnostic; because this is using CRT_fatalError, which is like perror(3), we must give a meaningful prefix (like program name) at the string end.
2021-07-14Ensure we do not attempt to add a DynamicMeter via theNathan Scott
htoprc that we didn't find during start up. This just leaves blank sections of the display as @smalinux found. Related to https://github.com/htop-dev/htop/pull/682
2021-07-07Add a new DynamicMeter class for runtime Meter extensionNathan Scott
This commit is based on exploratory work by Sohaib Mohamed. The end goal is two-fold - to support addition of Meters we build via configuration files for both the PCP platform and for scripts ( https://github.com/htop-dev/htop/issues/526 ) Here, we focus on generic code and the PCP support. A new class DynamicMeter is introduced - it uses the special case 'param' field handling that previously was used only by the CPUMeter, such that every runtime-configured Meter is given a unique identifier. Unlike with the CPUMeter this is used internally only. When reading/writing to htoprc instead of CPU(N) - where N is an integer param (CPU number) - we use the string name for each meter. For example, if we have a configuration for a DynamicMeter for some Redis metrics, we might read and write "Dynamic(redis)". This identifier is subsequently matched (back) up to the configuration file so we're able to re-create arbitrary user configurations. The PCP platform configuration file format is fairly simple. We expand configs from several directories, including the users homedir alongside htoprc (below htop/meters/) and also /etc/pcp/htop/meters. The format will be described via a new pcp-htop(5) man page, but its basically ini-style and each Meter has one or more metric expressions associated, as well as specifications for labels, color and so on via a dot separated notation for individual metrics within the Meter. A few initial sample configuration files are provided below ./pcp/meters that give the general idea. The PCP "derived" metric specification - see pmRegisterDerived(3) - is used as the syntax for specifying metrics in PCP DynamicMeters.
2021-03-19Use unsigned types for CPU counts and associated variablesChristian Göttsche
2021-03-04Separate data-update and drawing of headerChristian Göttsche
2021-02-02Leave less right margin next to long (text) metersDaniel Lange
2021-01-26Use typedef names instead of raw struct onesChristian Göttsche
2021-01-23Allow meters in text mode to span empty neighbors to the rightChristian Göttsche
Closes: #484
2021-01-11Mark several non-modified pointer variables constChristian Göttsche
2020-12-06Remove unused function Header_readMeterNameChristian Göttsche
2020-11-28Update even more snprintfsChristian Göttsche
Use size of actual buffers instead of magic numbers
2020-11-02Embracing branchesBenny Baumann
2020-11-02Spacing around operatorsBenny Baumann
2020-10-18Make all required includes explicitBenny Baumann
Information as seen by IWYU 0.12 + clang 9 on Linux
2020-10-16Rename StringUtils.[ch] to XUtils.[ch]Benny Baumann
2020-10-07Mark Object instances constChristian Göttsche
2020-10-05Update License consistently to GPLv2 as per COPYING fileDaniel Lange
2020-09-12Clean up some code duplication in the header filesHugo Musso Gualandi
PR htop-dev/htop#70 got rid of the infrastructure for generating header files, but it left behind some code duplication. Some of cases are things that belong in the header file and don't need to be repeated in the C file. Other cases are things that belong in the C file and don't need to be in the header file. In this commit I tried to fix all of these that I could find. When given a choice I preferred keeping things out of the header file, unless they were being used by someone else.
2020-09-09Consolidate repeated macro definitions into one headerNathan Scott
The MIN, MAX, CLAMP, MINIMUM, and MAXIMUM macros appear throughout the codebase with many re-definitions. Make a single copy of each in a common header file, and use the BSD variants of MINIMUM/MAXIMUM due to conflicts in the system <sys/param.h> headers.
2020-09-03Axe automated header generation.Zev Weiss
Reasoning: - implementation was unsound -- broke down when I added a fairly basic macro definition expanding to a struct initializer in a *.c file. - made it way too easy (e.g. via otherwise totally innocuous git commands) to end up with timestamps such that it always ran MakeHeader.py but never used its output, leading to overbuild noise when running what should be a null 'make'. - but mostly: it's just an awkward way of dealing with C code.
2020-08-25Avoid string overflow warningChristian Göttsche
Enough memory is allocated. Header.c: In function ‘Header_readMeterName’: Header.c:157:4: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] 157 | strncpy(name, Meter_name(meter), nameLen); | ^ Header.c:154:18: note: length computed here 154 | int nameLen = strlen(Meter_name(meter)); | ^
2020-08-20Merge branch 'hishamhm-pull-960'Nathan Scott
2019-10-31Clean up existing whitespaceDaniel Flanagan
2019-02-12Restore meter name after used in Header_addMeterByName()wangqr
Fix #852
2017-07-27Security review: check results of snprintf.Hisham Muhammad
Calls marked with xSnprintf shouldn't fail. Abort program cleanly if any of them does.
2016-05-07Fix macro Header_forEachColumnExplorer09
The (this_) token was not expanded properly, but the bug was not caught because all uses of this macro specifies (this_)=this . Also parenthesize macro tokens to prevent further problems.
2016-02-02Check for failure in allocations.Hisham
2015-09-07fix calloc() callsChristian Hesse
* size_t nmemb (number of elements) first, then size_t size * do not assume char is size 1 but use sizeof() * allocate for char, not pointer to char (found by Michael McConville, fixes #261)
2015-08-19Rename String to StringUtils.David Hunt
Fixes building on case-insensitive filesystems where String.h gets confused with <string.h>. From d734dacea0a10d0465dad4e95b3421511e7da112 Mon Sep 17 00:00:00 2001 From: David Hunt <dhunt@iolanthe.attlocal.net> Date: Sat, 11 Jul 2015 20:56:31 -0500 Subject: [PATCH 1/8] Rename String to StringUtils
2015-06-12write header length (number of columns) back to configurationChristian Hesse
2015-03-16Fix saving of header states, motion in Setup screen.Hisham Muhammad
2015-01-23Another mega-patch for the refactoring process.Hisham Muhammad
Kinda runs, but functionality from the original main loop is still missing. Patience.
2015-01-21Sorry about the mega-patch.Hisham Muhammad
This is a work-in-progress, code is currently broken. (Some actions, and notably, the header, are missing.)
2014-11-27Move UptimeMeter into platform-dependent area.Hisham Muhammad
Set up environment to move other meters.
2014-11-27Decouple Header from Meter classes.Hisham Muhammad
(Yes, that's dynamic typing!)
2014-04-21Restrict size of read.Hisham Muhammad
2014-02-27alignment improvementsHisham Muhammad
2014-01-16Fix order of calloc arguments.Hisham Muhammad
(Patch by Dawid Gajownik)
2012-12-05Changes in object model: separate class objects to store vtable. Also, nicer ↵Hisham Muhammad
UTF-8 display of big numbers.