diff options
author | Nathan Scott <nathans@redhat.com> | 2020-11-17 18:12:38 +1100 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2020-11-18 10:17:33 +1100 |
commit | ea9622b8c9444d92007f24fc54597f83c498f11d (patch) | |
tree | 13cb45909d2c873b7b09ec59580d6a8db4676b0b /dragonflybsd | |
parent | e3af8d0d0851dd6ce25446a7f9a99e2127795a78 (diff) |
Merge individual Battery.[ch] files into Platform.[ch]
Consistent with everything else involving platform-specific
calls from core htop code.
Diffstat (limited to 'dragonflybsd')
-rw-r--r-- | dragonflybsd/Battery.c | 30 | ||||
-rw-r--r-- | dragonflybsd/Battery.h | 15 | ||||
-rw-r--r-- | dragonflybsd/Platform.c | 16 | ||||
-rw-r--r-- | dragonflybsd/Platform.h | 2 |
4 files changed, 18 insertions, 45 deletions
diff --git a/dragonflybsd/Battery.c b/dragonflybsd/Battery.c deleted file mode 100644 index 1a690ee3..00000000 --- a/dragonflybsd/Battery.c +++ /dev/null @@ -1,30 +0,0 @@ -/* -htop - dragonflybsd/Battery.c -(C) 2015 Hisham H. Muhammad -(C) 2017 Diederik de Groot -Released under the GNU GPLv2, see the COPYING file -in the source distribution for its full text. -*/ - -#include "Battery.h" - -#include <math.h> -#include <sys/sysctl.h> - -void Battery_getData(double* level, ACPresence* isOnAC) { - int life; - size_t life_len = sizeof(life); - if (sysctlbyname("hw.acpi.battery.life", &life, &life_len, NULL, 0) == -1) { - *level = NAN; - } else { - *level = life; - } - - int acline; - size_t acline_len = sizeof(acline); - if (sysctlbyname("hw.acpi.acline", &acline, &acline_len, NULL, 0) == -1) { - *isOnAC = AC_ERROR; - } else { - *isOnAC = acline == 0 ? AC_ABSENT : AC_PRESENT; - } -} diff --git a/dragonflybsd/Battery.h b/dragonflybsd/Battery.h deleted file mode 100644 index eed0f630..00000000 --- a/dragonflybsd/Battery.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef HEADER_Battery -#define HEADER_Battery -/* -htop - dragonflybsd/Battery.h -(C) 2015 Hisham H. Muhammad -(C) 2017 Diederik de Groot -Released under the GNU GPLv2, see the COPYING file -in the source distribution for its full text. -*/ - -#include "BatteryMeter.h" - -void Battery_getData(double* level, ACPresence* isOnAC); - -#endif diff --git a/dragonflybsd/Platform.c b/dragonflybsd/Platform.c index dd36bf0a..c6966c11 100644 --- a/dragonflybsd/Platform.c +++ b/dragonflybsd/Platform.c @@ -234,3 +234,19 @@ bool Platform_getNetworkIO(unsigned long int* bytesReceived, *packetsTransmitted = 0; return false; } + +void Platform_getBattery(double* level, ACPresence* isOnAC) { + int life; + size_t life_len = sizeof(life); + if (sysctlbyname("hw.acpi.battery.life", &life, &life_len, NULL, 0) == -1) + *level = NAN; + else + *level = life; + + int acline; + size_t acline_len = sizeof(acline); + if (sysctlbyname("hw.acpi.acline", &acline, &acline_len, NULL, 0) == -1) + *isOnAC = AC_ERROR; + else + *isOnAC = acline == 0 ? AC_ABSENT : AC_PRESENT; +} diff --git a/dragonflybsd/Platform.h b/dragonflybsd/Platform.h index 1da8811b..267b8f37 100644 --- a/dragonflybsd/Platform.h +++ b/dragonflybsd/Platform.h @@ -56,4 +56,6 @@ bool Platform_getNetworkIO(unsigned long int* bytesReceived, unsigned long int* bytesTransmitted, unsigned long int* packetsTransmitted); +void Platform_getBattery(double* level, ACPresence* isOnAC); + #endif |