sysinfo.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef FOUNDATION_SETTINGS_SYSINFO_H
  2. #define FOUNDATION_SETTINGS_SYSINFO_H
  3. namespace settings {
  4. namespace sysinfo {
  5. #define MAXBUFSIZE 1024
  6. #define WAIT_SECOND 3 // 暂停时间,单位为“秒”
  7. typedef struct occupy {
  8. char name[20];
  9. unsigned int user;
  10. unsigned int nice;
  11. unsigned int system;
  12. unsigned int idle;
  13. } CPU_OCCUPY;
  14. typedef struct PACKED {
  15. char name[20];
  16. long total;
  17. char name2[20];
  18. long free;
  19. } MEM_OCCUPY;
  20. double cal_occupy(CPU_OCCUPY *o, CPU_OCCUPY *n);
  21. void get_occupy(CPU_OCCUPY *o);
  22. void get_mem_occupy(MEM_OCCUPY *mem);
  23. float get_io_occupy();
  24. void get_disk_occupy(char **reused);
  25. void getCurrentDownloadRates(long int *save_rate);
  26. /**
  27. * 设置IP
  28. */
  29. int SetIfAddr(const char *ifname, const char *Ipaddr, const char *mask, const char *gateway);
  30. /*
  31. * 获取IP
  32. */
  33. int GetIfAddr(const char *iface, char ipaddr[], char mask[], char gateway[]);
  34. /*
  35. * 获取IP
  36. */
  37. bool GetLocalIp(const char *iface, char ipaddr[]);
  38. /*
  39. * 修改本机IP地址的函数
  40. */
  41. int SetLocalIp(const char *iface, const char *ipaddr);
  42. /*
  43. *获取子网掩码的函数
  44. */
  45. bool GetLocalNetMask(const char *ifname, char netmask_addr[]);
  46. /*
  47. * 修改子NETMASK的函数
  48. */
  49. bool SetLocalNetMask(const char *iface, const char *szNetMask);
  50. /*
  51. * 获去GateWay
  52. */
  53. bool GetGateWay(char gateway[]);
  54. /*
  55. * 设置网关
  56. */
  57. int SetGateWay(const char *szGateWay);
  58. /*
  59. *获取本机MAC地址函数
  60. */
  61. bool GetLocalMac(const char *eth, char mac_addr[30]);
  62. } // namespace sysinfo
  63. } // namespace settings
  64. #endif