summaryrefslogtreecommitdiffstats
path: root/freebsd
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2020-11-17 18:12:38 +1100
committerNathan Scott <nathans@redhat.com>2020-11-18 10:17:33 +1100
commitea9622b8c9444d92007f24fc54597f83c498f11d (patch)
tree13cb45909d2c873b7b09ec59580d6a8db4676b0b /freebsd
parente3af8d0d0851dd6ce25446a7f9a99e2127795a78 (diff)
Merge individual Battery.[ch] files into Platform.[ch]
Consistent with everything else involving platform-specific calls from core htop code.
Diffstat (limited to 'freebsd')
-rw-r--r--freebsd/Battery.c29
-rw-r--r--freebsd/Battery.h14
-rw-r--r--freebsd/Platform.c16
-rw-r--r--freebsd/Platform.h2
4 files changed, 18 insertions, 43 deletions
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 <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/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

© 2014-2024 Faster IT GmbH | imprint | privacy policy