Platform.h 3.6 KB

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