Platform.h 3.6 KB

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