Platform.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #ifndef HEADER_Platform
  2. #define HEADER_Platform
  3. /*
  4. htop - netbsd/Platform.h
  5. (C) 2014 Hisham H. Muhammad
  6. (C) 2015 Michael McConville
  7. (C) 2021 Santhosh Raju
  8. (C) 2021 htop dev team
  9. Released under the GNU GPLv2+, see the COPYING file
  10. in the source distribution for its full text.
  11. */
  12. #include <stdbool.h>
  13. #include <stddef.h>
  14. #include <stdint.h>
  15. #include <sys/time.h>
  16. #include <sys/types.h>
  17. #include "Action.h"
  18. #include "BatteryMeter.h"
  19. #include "DiskIOMeter.h"
  20. #include "Meter.h"
  21. #include "NetworkIOMeter.h"
  22. #include "Process.h"
  23. #include "ProcessLocksScreen.h"
  24. #include "SignalsPanel.h"
  25. #include "CommandLine.h"
  26. #include "generic/gettime.h"
  27. #include "generic/hostname.h"
  28. #include "generic/uname.h"
  29. /* There are no Long Options for NetBSD as of now. */
  30. #define PLATFORM_LONG_OPTIONS \
  31. // End of list
  32. extern const ScreenDefaults Platform_defaultScreens[];
  33. extern const unsigned int Platform_numberOfDefaultScreens;
  34. /* see /usr/include/sys/signal.h */
  35. extern const SignalItem Platform_signals[];
  36. extern const unsigned int Platform_numberOfSignals;
  37. extern const MeterClass* const Platform_meterTypes[];
  38. bool Platform_init(void);
  39. void Platform_done(void);
  40. void Platform_setBindings(Htop_Action* keys);
  41. int Platform_getUptime(void);
  42. void Platform_getLoadAverage(double* one, double* five, double* fifteen);
  43. pid_t Platform_getMaxPid(void);
  44. double Platform_setCPUValues(Meter* this, int cpu);
  45. void Platform_setMemoryValues(Meter* this);
  46. void Platform_setSwapValues(Meter* this);
  47. char* Platform_getProcessEnv(pid_t pid);
  48. FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid);
  49. void Platform_getFileDescriptors(double* used, double* max);
  50. bool Platform_getDiskIO(DiskIOData* data);
  51. bool Platform_getNetworkIO(NetworkIOData* data);
  52. void Platform_getBattery(double* percent, ACPresence* isOnAC);
  53. static inline void Platform_getHostname(char* buffer, size_t size) {
  54. Generic_hostname(buffer, size);
  55. }
  56. static inline void Platform_getRelease(char** string) {
  57. *string = Generic_uname();
  58. }
  59. static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { }
  60. static inline CommandLineStatus Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
  61. return STATUS_ERROR_EXIT;
  62. }
  63. static inline void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) {
  64. Generic_gettime_realtime(tv, msec);
  65. }
  66. static inline void Platform_gettime_monotonic(uint64_t* msec) {
  67. Generic_gettime_monotonic(msec);
  68. }
  69. static inline Hashtable* Platform_dynamicMeters(void) {
  70. return NULL;
  71. }
  72. static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable* table) { }
  73. static inline void Platform_dynamicMeterInit(ATTR_UNUSED Meter* meter) { }
  74. static inline void Platform_dynamicMeterUpdateValues(ATTR_UNUSED Meter* meter) { }
  75. static inline void Platform_dynamicMeterDisplay(ATTR_UNUSED const Meter* meter, ATTR_UNUSED RichString* out) { }
  76. static inline Hashtable* Platform_dynamicColumns(void) {
  77. return NULL;
  78. }
  79. static inline void Platform_dynamicColumnsDone(ATTR_UNUSED Hashtable* table) { }
  80. static inline const char* Platform_dynamicColumnName(ATTR_UNUSED unsigned int key) {
  81. return NULL;
  82. }
  83. static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) {
  84. return false;
  85. }
  86. static inline Hashtable* Platform_dynamicScreens(void) {
  87. return NULL;
  88. }
  89. static inline void Platform_defaultDynamicScreens(ATTR_UNUSED Settings* settings) { }
  90. static inline void Platform_addDynamicScreen(ATTR_UNUSED ScreenSettings* ss) { }
  91. static inline void Platform_addDynamicScreenAvailableColumns(ATTR_UNUSED Panel* availableColumns, ATTR_UNUSED const char* screen) { }
  92. static inline void Platform_dynamicScreensDone(ATTR_UNUSED Hashtable* screens) { }
  93. #endif