From ea9622b8c9444d92007f24fc54597f83c498f11d Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Tue, 17 Nov 2020 18:12:38 +1100 Subject: Merge individual Battery.[ch] files into Platform.[ch] Consistent with everything else involving platform-specific calls from core htop code. --- freebsd/Battery.c | 29 ----------------------------- freebsd/Battery.h | 14 -------------- freebsd/Platform.c | 16 ++++++++++++++++ freebsd/Platform.h | 2 ++ 4 files changed, 18 insertions(+), 43 deletions(-) delete mode 100644 freebsd/Battery.c delete mode 100644 freebsd/Battery.h (limited to 'freebsd') diff --git a/freebsd/Battery.c b/freebsd/Battery.c deleted file mode 100644 index 26b42da9..00000000 --- a/freebsd/Battery.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -htop - freebsd/Battery.c -(C) 2015 Hisham H. Muhammad -Released under the GNU GPLv2, see the COPYING file -in the source distribution for its full text. -*/ - -#include "Battery.h" - -#include -#include - -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/freebsd/Battery.h b/freebsd/Battery.h deleted file mode 100644 index 98adb6ee..00000000 --- a/freebsd/Battery.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef HEADER_Battery -#define HEADER_Battery -/* -htop - freebsd/Battery.h -(C) 2015 Hisham H. Muhammad -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/freebsd/Platform.c b/freebsd/Platform.c index 2fc9ccc9..8efa4e68 100644 --- a/freebsd/Platform.c +++ b/freebsd/Platform.c @@ -338,3 +338,19 @@ bool Platform_getNetworkIO(unsigned long int* bytesReceived, *packetsTransmitted = packetsTransmittedSum; return true; } + +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/freebsd/Platform.h b/freebsd/Platform.h index 72e964aa..5e3b29fb 100644 --- a/freebsd/Platform.h +++ b/freebsd/Platform.h @@ -59,4 +59,6 @@ bool Platform_getNetworkIO(unsigned long int* bytesReceived, unsigned long int* bytesTransmitted, unsigned long int* packetsTransmitted); +void Platform_getBattery(double* level, ACPresence* isOnAC); + #endif -- cgit v1.2.3