mirror of https://github.com/xzeldon/htop.git
Move generic (shared) code into its own sub-directory
Code that is shared across some (but not all) platforms is moved into a 'generic' home. Makefile.am cleanups to match plus some minor alphabetic reordering/formatting. As discussed in https://github.com/htop-dev/htop/pull/553
This commit is contained in:
parent
5b50ae3aa3
commit
61ef1134d9
116
Makefile.am
116
Makefile.am
|
@ -42,7 +42,6 @@ myhtopsources = \
|
||||||
DisplayOptionsPanel.c \
|
DisplayOptionsPanel.c \
|
||||||
EnvScreen.c \
|
EnvScreen.c \
|
||||||
FunctionBar.c \
|
FunctionBar.c \
|
||||||
Generic.c \
|
|
||||||
Hashtable.c \
|
Hashtable.c \
|
||||||
Header.c \
|
Header.c \
|
||||||
HostnameMeter.c \
|
HostnameMeter.c \
|
||||||
|
@ -97,7 +96,6 @@ myhtopheaders = \
|
||||||
DisplayOptionsPanel.h \
|
DisplayOptionsPanel.h \
|
||||||
EnvScreen.h \
|
EnvScreen.h \
|
||||||
FunctionBar.h \
|
FunctionBar.h \
|
||||||
Generic.h \
|
|
||||||
Hashtable.h \
|
Hashtable.h \
|
||||||
Header.h \
|
Header.h \
|
||||||
HostnameMeter.h \
|
HostnameMeter.h \
|
||||||
|
@ -136,6 +134,8 @@ myhtopheaders = \
|
||||||
# -----
|
# -----
|
||||||
|
|
||||||
linux_platform_headers = \
|
linux_platform_headers = \
|
||||||
|
generic/hostname.h \
|
||||||
|
generic/uname.h \
|
||||||
linux/HugePageMeter.h \
|
linux/HugePageMeter.h \
|
||||||
linux/IOPriority.h \
|
linux/IOPriority.h \
|
||||||
linux/IOPriorityPanel.h \
|
linux/IOPriorityPanel.h \
|
||||||
|
@ -153,9 +153,9 @@ linux_platform_headers = \
|
||||||
zfs/ZfsArcStats.h \
|
zfs/ZfsArcStats.h \
|
||||||
zfs/ZfsCompressedArcMeter.h
|
zfs/ZfsCompressedArcMeter.h
|
||||||
|
|
||||||
if HTOP_LINUX
|
linux_platform_sources = \
|
||||||
AM_LDFLAGS += -rdynamic
|
generic/hostname.c \
|
||||||
myhtopplatsources = \
|
generic/uname.c \
|
||||||
linux/HugePageMeter.c \
|
linux/HugePageMeter.c \
|
||||||
linux/IOPriorityPanel.c \
|
linux/IOPriorityPanel.c \
|
||||||
linux/LibSensors.c \
|
linux/LibSensors.c \
|
||||||
|
@ -169,7 +169,10 @@ myhtopplatsources = \
|
||||||
zfs/ZfsArcMeter.c \
|
zfs/ZfsArcMeter.c \
|
||||||
zfs/ZfsCompressedArcMeter.c
|
zfs/ZfsCompressedArcMeter.c
|
||||||
|
|
||||||
|
if HTOP_LINUX
|
||||||
|
AM_LDFLAGS += -rdynamic
|
||||||
myhtopplatheaders = $(linux_platform_headers)
|
myhtopplatheaders = $(linux_platform_headers)
|
||||||
|
myhtopplatsources = $(linux_platform_sources)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# FreeBSD
|
# FreeBSD
|
||||||
|
@ -180,17 +183,26 @@ freebsd_platform_headers = \
|
||||||
freebsd/FreeBSDProcess.h \
|
freebsd/FreeBSDProcess.h \
|
||||||
freebsd/Platform.h \
|
freebsd/Platform.h \
|
||||||
freebsd/ProcessField.h \
|
freebsd/ProcessField.h \
|
||||||
|
generic/hostname.h \
|
||||||
|
generic/openzfs_sysctl.h \
|
||||||
|
generic/uname.h \
|
||||||
zfs/ZfsArcMeter.h \
|
zfs/ZfsArcMeter.h \
|
||||||
zfs/ZfsCompressedArcMeter.h \
|
|
||||||
zfs/ZfsArcStats.h \
|
zfs/ZfsArcStats.h \
|
||||||
zfs/openzfs_sysctl.h
|
zfs/ZfsCompressedArcMeter.h
|
||||||
|
|
||||||
|
freebsd_platform_sources = \
|
||||||
|
freebsd/Platform.c \
|
||||||
|
freebsd/FreeBSDProcessList.c \
|
||||||
|
freebsd/FreeBSDProcess.c \
|
||||||
|
generic/hostname.c \
|
||||||
|
generic/openzfs_sysctl.c \
|
||||||
|
generic/uname.c \
|
||||||
|
zfs/ZfsArcMeter.c \
|
||||||
|
zfs/ZfsCompressedArcMeter.c
|
||||||
|
|
||||||
if HTOP_FREEBSD
|
if HTOP_FREEBSD
|
||||||
myhtopplatsources = freebsd/Platform.c freebsd/FreeBSDProcessList.c \
|
|
||||||
freebsd/FreeBSDProcess.c \
|
|
||||||
zfs/ZfsArcMeter.c zfs/ZfsCompressedArcMeter.c zfs/openzfs_sysctl.c
|
|
||||||
|
|
||||||
myhtopplatheaders = $(freebsd_platform_headers)
|
myhtopplatheaders = $(freebsd_platform_headers)
|
||||||
|
myhtopplatsources = $(freebsd_platform_sources)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# DragonFlyBSD
|
# DragonFlyBSD
|
||||||
|
@ -200,31 +212,43 @@ dragonflybsd_platform_headers = \
|
||||||
dragonflybsd/DragonFlyBSDProcessList.h \
|
dragonflybsd/DragonFlyBSDProcessList.h \
|
||||||
dragonflybsd/DragonFlyBSDProcess.h \
|
dragonflybsd/DragonFlyBSDProcess.h \
|
||||||
dragonflybsd/Platform.h \
|
dragonflybsd/Platform.h \
|
||||||
dragonflybsd/ProcessField.h
|
dragonflybsd/ProcessField.h \
|
||||||
|
generic/hostname.h \
|
||||||
|
generic/uname.h
|
||||||
|
|
||||||
|
dragonflybsd_platform_sources = \
|
||||||
|
dragonflybsd/DragonFlyBSDProcessList.c \
|
||||||
|
dragonflybsd/DragonFlyBSDProcess.c \
|
||||||
|
dragonflybsd/Platform.c \
|
||||||
|
generic/hostname.c \
|
||||||
|
generic/uname.c
|
||||||
|
|
||||||
if HTOP_DRAGONFLYBSD
|
if HTOP_DRAGONFLYBSD
|
||||||
myhtopplatsources = \
|
|
||||||
dragonflybsd/Platform.c \
|
|
||||||
dragonflybsd/DragonFlyBSDProcessList.c \
|
|
||||||
dragonflybsd/DragonFlyBSDProcess.c
|
|
||||||
|
|
||||||
myhtopplatheaders = $(dragonflybsd_platform_headers)
|
myhtopplatheaders = $(dragonflybsd_platform_headers)
|
||||||
|
myhtopplatsources = $(dragonflybsd_platform_sources)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# OpenBSD
|
# OpenBSD
|
||||||
# -------
|
# -------
|
||||||
|
|
||||||
openbsd_platform_headers = \
|
openbsd_platform_headers = \
|
||||||
|
generic/hostname.h \
|
||||||
|
generic/uname.h \
|
||||||
openbsd/OpenBSDProcessList.h \
|
openbsd/OpenBSDProcessList.h \
|
||||||
openbsd/OpenBSDProcess.h \
|
openbsd/OpenBSDProcess.h \
|
||||||
openbsd/Platform.h \
|
openbsd/Platform.h \
|
||||||
openbsd/ProcessField.h
|
openbsd/ProcessField.h
|
||||||
|
|
||||||
if HTOP_OPENBSD
|
openbsd_platform_sources = \
|
||||||
myhtopplatsources = openbsd/Platform.c openbsd/OpenBSDProcessList.c \
|
generic/hostname.c \
|
||||||
openbsd/OpenBSDProcess.c
|
generic/uname.c \
|
||||||
|
openbsd/OpenBSDProcessList.c \
|
||||||
|
openbsd/OpenBSDProcess.c \
|
||||||
|
openbsd/Platform.c
|
||||||
|
|
||||||
|
if HTOP_OPENBSD
|
||||||
myhtopplatheaders = $(openbsd_platform_headers)
|
myhtopplatheaders = $(openbsd_platform_headers)
|
||||||
|
myhtopplatsources = $(openbsd_platform_sources)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Darwin
|
# Darwin
|
||||||
|
@ -235,38 +259,55 @@ darwin_platform_headers = \
|
||||||
darwin/DarwinProcessList.h \
|
darwin/DarwinProcessList.h \
|
||||||
darwin/Platform.h \
|
darwin/Platform.h \
|
||||||
darwin/ProcessField.h \
|
darwin/ProcessField.h \
|
||||||
|
generic/hostname.h \
|
||||||
|
generic/openzfs_sysctl.h \
|
||||||
|
generic/uname.h \
|
||||||
zfs/ZfsArcMeter.h \
|
zfs/ZfsArcMeter.h \
|
||||||
zfs/ZfsCompressedArcMeter.h \
|
|
||||||
zfs/ZfsArcStats.h \
|
zfs/ZfsArcStats.h \
|
||||||
zfs/openzfs_sysctl.h
|
zfs/ZfsCompressedArcMeter.h
|
||||||
|
|
||||||
|
darwin_platform_sources = \
|
||||||
|
darwin/Platform.c \
|
||||||
|
darwin/DarwinProcess.c \
|
||||||
|
darwin/DarwinProcessList.c \
|
||||||
|
generic/hostname.c \
|
||||||
|
generic/openzfs_sysctl.c \
|
||||||
|
generic/uname.c \
|
||||||
|
zfs/ZfsArcMeter.c \
|
||||||
|
zfs/ZfsCompressedArcMeter.c
|
||||||
|
|
||||||
if HTOP_DARWIN
|
if HTOP_DARWIN
|
||||||
AM_LDFLAGS += -framework IOKit -framework CoreFoundation
|
AM_LDFLAGS += -framework IOKit -framework CoreFoundation
|
||||||
myhtopplatsources = darwin/Platform.c darwin/DarwinProcess.c \
|
|
||||||
darwin/DarwinProcessList.c \
|
|
||||||
zfs/ZfsArcMeter.c zfs/ZfsCompressedArcMeter.c zfs/openzfs_sysctl.c
|
|
||||||
|
|
||||||
myhtopplatheaders = $(darwin_platform_headers)
|
myhtopplatheaders = $(darwin_platform_headers)
|
||||||
|
myhtopplatsources = $(darwin_platform_sources)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Solaris
|
# Solaris
|
||||||
# -------
|
# -------
|
||||||
|
|
||||||
solaris_platform_headers = \
|
solaris_platform_headers = \
|
||||||
solaris/Platform.h \
|
generic/hostname.h \
|
||||||
|
generic/uname.h \
|
||||||
solaris/ProcessField.h \
|
solaris/ProcessField.h \
|
||||||
|
solaris/Platform.h \
|
||||||
solaris/SolarisProcess.h \
|
solaris/SolarisProcess.h \
|
||||||
solaris/SolarisProcessList.h \
|
solaris/SolarisProcessList.h \
|
||||||
zfs/ZfsArcMeter.h \
|
zfs/ZfsArcMeter.h \
|
||||||
zfs/ZfsCompressedArcMeter.h \
|
zfs/ZfsArcStats.h \
|
||||||
zfs/ZfsArcStats.h
|
zfs/ZfsCompressedArcMeter.h
|
||||||
|
|
||||||
|
solaris_platform_sources = \
|
||||||
|
generic/hostname.c \
|
||||||
|
generic/uname.c \
|
||||||
|
solaris/Platform.c \
|
||||||
|
solaris/SolarisProcess.c \
|
||||||
|
solaris/SolarisProcessList.c \
|
||||||
|
zfs/ZfsArcMeter.c \
|
||||||
|
zfs/ZfsCompressedArcMeter.c
|
||||||
|
|
||||||
if HTOP_SOLARIS
|
if HTOP_SOLARIS
|
||||||
myhtopplatsources = solaris/Platform.c \
|
|
||||||
solaris/SolarisProcess.c solaris/SolarisProcessList.c \
|
|
||||||
zfs/ZfsArcMeter.c zfs/ZfsCompressedArcMeter.c
|
|
||||||
|
|
||||||
myhtopplatheaders = $(solaris_platform_headers)
|
myhtopplatheaders = $(solaris_platform_headers)
|
||||||
|
myhtopplatsources = $(solaris_platform_sources)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Unsupported
|
# Unsupported
|
||||||
|
@ -278,10 +319,13 @@ unsupported_platform_headers = \
|
||||||
unsupported/UnsupportedProcess.h \
|
unsupported/UnsupportedProcess.h \
|
||||||
unsupported/UnsupportedProcessList.h
|
unsupported/UnsupportedProcessList.h
|
||||||
|
|
||||||
if HTOP_UNSUPPORTED
|
unsupported_platform_sources = \
|
||||||
myhtopplatsources = unsupported/Platform.c \
|
unsupported/Platform.c \
|
||||||
unsupported/UnsupportedProcess.c unsupported/UnsupportedProcessList.c
|
unsupported/UnsupportedProcess.c \
|
||||||
|
unsupported/UnsupportedProcessList.c
|
||||||
|
|
||||||
|
if HTOP_UNSUPPORTED
|
||||||
|
myhtopplatsources = $(unsupported_platform_sources)
|
||||||
myhtopplatheaders = $(unsupported_platform_headers)
|
myhtopplatheaders = $(unsupported_platform_headers)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,9 @@ in the source distribution for its full text.
|
||||||
|
|
||||||
#include "CRT.h"
|
#include "CRT.h"
|
||||||
#include "DarwinProcess.h"
|
#include "DarwinProcess.h"
|
||||||
|
#include "generic/openzfs_sysctl.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "ProcessList.h"
|
#include "ProcessList.h"
|
||||||
#include "zfs/openzfs_sysctl.h"
|
|
||||||
#include "zfs/ZfsArcStats.h"
|
#include "zfs/ZfsArcStats.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ in the source distribution for its full text.
|
||||||
#include "CPUMeter.h"
|
#include "CPUMeter.h"
|
||||||
#include "DarwinProcess.h"
|
#include "DarwinProcess.h"
|
||||||
#include "DiskIOMeter.h"
|
#include "DiskIOMeter.h"
|
||||||
#include "Generic.h"
|
#include "generic/hostname.h"
|
||||||
|
#include "generic/uname.h"
|
||||||
#include "NetworkIOMeter.h"
|
#include "NetworkIOMeter.h"
|
||||||
#include "ProcessLocksScreen.h"
|
#include "ProcessLocksScreen.h"
|
||||||
#include "SignalsPanel.h"
|
#include "SignalsPanel.h"
|
||||||
|
@ -69,11 +70,11 @@ bool Platform_getNetworkIO(NetworkIOData* data);
|
||||||
void Platform_getBattery(double *percent, ACPresence *isOnAC);
|
void Platform_getBattery(double *percent, ACPresence *isOnAC);
|
||||||
|
|
||||||
static inline void Platform_getHostname(char* buffer, size_t size) {
|
static inline void Platform_getHostname(char* buffer, size_t size) {
|
||||||
Generic_Hostname(buffer, size);
|
Generic_hostname(buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Platform_getRelease(char** string) {
|
static inline void Platform_getRelease(char** string) {
|
||||||
*string = Generic_OSRelease();
|
*string = Generic_uname();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,7 +14,8 @@ in the source distribution for its full text.
|
||||||
#include "Action.h"
|
#include "Action.h"
|
||||||
#include "BatteryMeter.h"
|
#include "BatteryMeter.h"
|
||||||
#include "DiskIOMeter.h"
|
#include "DiskIOMeter.h"
|
||||||
#include "Generic.h"
|
#include "generic/hostname.h"
|
||||||
|
#include "generic/uname.h"
|
||||||
#include "NetworkIOMeter.h"
|
#include "NetworkIOMeter.h"
|
||||||
#include "ProcessLocksScreen.h"
|
#include "ProcessLocksScreen.h"
|
||||||
#include "SignalsPanel.h"
|
#include "SignalsPanel.h"
|
||||||
|
@ -59,11 +60,11 @@ bool Platform_getNetworkIO(NetworkIOData* data);
|
||||||
void Platform_getBattery(double* percent, ACPresence* isOnAC);
|
void Platform_getBattery(double* percent, ACPresence* isOnAC);
|
||||||
|
|
||||||
static inline void Platform_getHostname(char* buffer, size_t size) {
|
static inline void Platform_getHostname(char* buffer, size_t size) {
|
||||||
Generic_Hostname(buffer, size);
|
Generic_hostname(buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Platform_getRelease(char** string) {
|
static inline void Platform_getRelease(char** string) {
|
||||||
*string = Generic_OSRelease();
|
*string = Generic_uname();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,6 +30,7 @@ in the source distribution for its full text.
|
||||||
#include "CRT.h"
|
#include "CRT.h"
|
||||||
#include "Compat.h"
|
#include "Compat.h"
|
||||||
#include "FreeBSDProcess.h"
|
#include "FreeBSDProcess.h"
|
||||||
|
#include "generic/openzfs_sysctl.h"
|
||||||
#include "Macros.h"
|
#include "Macros.h"
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
|
@ -37,7 +38,6 @@ in the source distribution for its full text.
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "XUtils.h"
|
#include "XUtils.h"
|
||||||
#include "zfs/ZfsArcStats.h"
|
#include "zfs/ZfsArcStats.h"
|
||||||
#include "zfs/openzfs_sysctl.h"
|
|
||||||
|
|
||||||
|
|
||||||
static int MIB_hw_physmem[2];
|
static int MIB_hw_physmem[2];
|
||||||
|
|
|
@ -13,7 +13,8 @@ in the source distribution for its full text.
|
||||||
#include "Action.h"
|
#include "Action.h"
|
||||||
#include "BatteryMeter.h"
|
#include "BatteryMeter.h"
|
||||||
#include "DiskIOMeter.h"
|
#include "DiskIOMeter.h"
|
||||||
#include "Generic.h"
|
#include "generic/hostname.h"
|
||||||
|
#include "generic/uname.h"
|
||||||
#include "Meter.h"
|
#include "Meter.h"
|
||||||
#include "NetworkIOMeter.h"
|
#include "NetworkIOMeter.h"
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
|
@ -64,11 +65,11 @@ bool Platform_getNetworkIO(NetworkIOData* data);
|
||||||
void Platform_getBattery(double* percent, ACPresence* isOnAC);
|
void Platform_getBattery(double* percent, ACPresence* isOnAC);
|
||||||
|
|
||||||
static inline void Platform_getHostname(char* buffer, size_t size) {
|
static inline void Platform_getHostname(char* buffer, size_t size) {
|
||||||
Generic_Hostname(buffer, size);
|
Generic_hostname(buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Platform_getRelease(char** string) {
|
static inline void Platform_getRelease(char** string) {
|
||||||
*string = Generic_OSRelease();
|
*string = Generic_uname();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
htop - generic/hostname.c
|
||||||
|
(C) 2021 htop dev team
|
||||||
|
Released under the GNU GPLv2, see the COPYING file
|
||||||
|
in the source distribution for its full text.
|
||||||
|
*/
|
||||||
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
|
#include "generic/hostname.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
|
void Generic_hostname(char* buffer, size_t size) {
|
||||||
|
gethostname(buffer, size - 1);
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef HEADER_Generic
|
#ifndef HEADER_hostname
|
||||||
#define HEADER_Generic
|
#define HEADER_hostname
|
||||||
/*
|
/*
|
||||||
htop - Generic.h
|
htop - generic/hostname.h
|
||||||
(C) 2021 htop dev team
|
(C) 2021 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
|
@ -9,8 +9,6 @@ in the source distribution for its full text.
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
void Generic_Hostname(char* buffer, size_t size);
|
void Generic_hostname(char* buffer, size_t size);
|
||||||
|
|
||||||
char* Generic_OSRelease(void);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
htop - zfs/openzfs_sysctl.c
|
htop - generic/openzfs_sysctl.c
|
||||||
(C) 2014 Hisham H. Muhammad
|
(C) 2014 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "zfs/openzfs_sysctl.h"
|
#include "generic/openzfs_sysctl.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/types.h> // IWYU pragma: keep
|
#include <sys/types.h> // IWYU pragma: keep
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef HEADER_openzfs_sysctl
|
#ifndef HEADER_openzfs_sysctl
|
||||||
#define HEADER_openzfs_sysctl
|
#define HEADER_openzfs_sysctl
|
||||||
/*
|
/*
|
||||||
htop - zfs/openzfs_sysctl.h
|
htop - generic/openzfs_sysctl.h
|
||||||
(C) 2014 Hisham H. Muhammad
|
(C) 2014 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
|
@ -1,26 +1,20 @@
|
||||||
/*
|
/*
|
||||||
htop - Generic.c
|
htop - generic/uname.c
|
||||||
(C) 2021 htop dev team
|
(C) 2021 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include "Generic.h"
|
#include "generic/uname.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifdef HAVE_SYS_UTSNAME_H
|
#ifdef HAVE_SYS_UTSNAME_H
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#endif
|
#endif
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "XUtils.h"
|
#include "XUtils.h"
|
||||||
|
|
||||||
void Generic_Hostname(char* buffer, size_t size) {
|
|
||||||
gethostname(buffer, size - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_UTSNAME_H
|
|
||||||
|
|
||||||
#ifndef OSRELEASEFILE
|
#ifndef OSRELEASEFILE
|
||||||
#define OSRELEASEFILE "/etc/os-release"
|
#define OSRELEASEFILE "/etc/os-release"
|
||||||
|
@ -68,9 +62,7 @@ static void parseOSRelease(char* buffer, size_t bufferLen) {
|
||||||
snprintf(buffer, bufferLen, "%s%s%s", name[0] ? name : "", name[0] && version[0] ? " " : "", version);
|
snprintf(buffer, bufferLen, "%s%s%s", name[0] ? name : "", name[0] && version[0] ? " " : "", version);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* Generic_OSRelease(void) {
|
char* Generic_uname(void) {
|
||||||
static struct utsname uname_info;
|
|
||||||
|
|
||||||
static char savedString[
|
static char savedString[
|
||||||
/* uname structure fields - manpages recommend sizeof */
|
/* uname structure fields - manpages recommend sizeof */
|
||||||
sizeof(uname_info.sysname) +
|
sizeof(uname_info.sysname) +
|
||||||
|
@ -99,4 +91,3 @@ char* Generic_OSRelease(void) {
|
||||||
|
|
||||||
return savedString;
|
return savedString;
|
||||||
}
|
}
|
||||||
#endif
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef HEADER_uname
|
||||||
|
#define HEADER_uname
|
||||||
|
/*
|
||||||
|
htop - generic/uname.h
|
||||||
|
(C) 2021 htop dev team
|
||||||
|
Released under the GNU GPLv2, see the COPYING file
|
||||||
|
in the source distribution for its full text.
|
||||||
|
*/
|
||||||
|
|
||||||
|
char* Generic_uname(void);
|
||||||
|
|
||||||
|
#endif
|
|
@ -14,7 +14,8 @@ in the source distribution for its full text.
|
||||||
#include "Action.h"
|
#include "Action.h"
|
||||||
#include "BatteryMeter.h"
|
#include "BatteryMeter.h"
|
||||||
#include "DiskIOMeter.h"
|
#include "DiskIOMeter.h"
|
||||||
#include "Generic.h"
|
#include "generic/hostname.h"
|
||||||
|
#include "generic/uname.h"
|
||||||
#include "Meter.h"
|
#include "Meter.h"
|
||||||
#include "NetworkIOMeter.h"
|
#include "NetworkIOMeter.h"
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
|
@ -74,11 +75,11 @@ bool Platform_getNetworkIO(NetworkIOData* data);
|
||||||
void Platform_getBattery(double *percent, ACPresence *isOnAC);
|
void Platform_getBattery(double *percent, ACPresence *isOnAC);
|
||||||
|
|
||||||
static inline void Platform_getHostname(char* buffer, size_t size) {
|
static inline void Platform_getHostname(char* buffer, size_t size) {
|
||||||
Generic_Hostname(buffer, size);
|
Generic_hostname(buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Platform_getRelease(char** string) {
|
static inline void Platform_getRelease(char** string) {
|
||||||
*string = Generic_OSRelease();
|
*string = Generic_uname();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,7 +14,8 @@ in the source distribution for its full text.
|
||||||
#include "Action.h"
|
#include "Action.h"
|
||||||
#include "BatteryMeter.h"
|
#include "BatteryMeter.h"
|
||||||
#include "DiskIOMeter.h"
|
#include "DiskIOMeter.h"
|
||||||
#include "Generic.h"
|
#include "generic/hostname.h"
|
||||||
|
#include "generic/uname.h"
|
||||||
#include "Meter.h"
|
#include "Meter.h"
|
||||||
#include "NetworkIOMeter.h"
|
#include "NetworkIOMeter.h"
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
|
@ -62,11 +63,11 @@ bool Platform_getNetworkIO(NetworkIOData* data);
|
||||||
void Platform_getBattery(double* percent, ACPresence* isOnAC);
|
void Platform_getBattery(double* percent, ACPresence* isOnAC);
|
||||||
|
|
||||||
static inline void Platform_getHostname(char* buffer, size_t size) {
|
static inline void Platform_getHostname(char* buffer, size_t size) {
|
||||||
Generic_Hostname(buffer, size);
|
Generic_hostname(buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Platform_getRelease(char** string) {
|
static inline void Platform_getRelease(char** string) {
|
||||||
*string = Generic_OSRelease();
|
*string = Generic_uname();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,7 +19,8 @@ in the source distribution for its full text.
|
||||||
#include "Action.h"
|
#include "Action.h"
|
||||||
#include "BatteryMeter.h"
|
#include "BatteryMeter.h"
|
||||||
#include "DiskIOMeter.h"
|
#include "DiskIOMeter.h"
|
||||||
#include "Generic.h"
|
#include "generic/hostname.h"
|
||||||
|
#include "generic/uname.h"
|
||||||
#include "NetworkIOMeter.h"
|
#include "NetworkIOMeter.h"
|
||||||
#include "ProcessLocksScreen.h"
|
#include "ProcessLocksScreen.h"
|
||||||
#include "SignalsPanel.h"
|
#include "SignalsPanel.h"
|
||||||
|
@ -81,11 +82,11 @@ bool Platform_getNetworkIO(NetworkIOData* data);
|
||||||
void Platform_getBattery(double* percent, ACPresence* isOnAC);
|
void Platform_getBattery(double* percent, ACPresence* isOnAC);
|
||||||
|
|
||||||
static inline void Platform_getHostname(char* buffer, size_t size) {
|
static inline void Platform_getHostname(char* buffer, size_t size) {
|
||||||
Generic_Hostname(buffer, size);
|
Generic_hostname(buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Platform_getRelease(char** string) {
|
static inline void Platform_getRelease(char** string) {
|
||||||
*string = Generic_OSRelease();
|
*string = Generic_uname();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue