Use sane constexpr var names
This commit is contained in:
parent
3db4a8fcaa
commit
146d31efea
@ -7,7 +7,7 @@
|
|||||||
#include "memory.hpp"
|
#include "memory.hpp"
|
||||||
|
|
||||||
bool memory::getProcMem(crow::json::wvalue& ret){
|
bool memory::getProcMem(crow::json::wvalue& ret){
|
||||||
std::ifstream f (procmempath);
|
std::ifstream f (PROC_MEM_PATH);
|
||||||
std::string line;
|
std::string line;
|
||||||
if(f.is_open()){
|
if(f.is_open()){
|
||||||
while(std::getline(f, line)){
|
while(std::getline(f, line)){
|
||||||
@ -36,7 +36,7 @@ bool memory::getProcMem(crow::json::wvalue& ret){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool memory::getRawProcMem(std::string& ret){
|
bool memory::getRawProcMem(std::string& ret){
|
||||||
std::ifstream f (procmempath);
|
std::ifstream f (PROC_MEM_PATH);
|
||||||
std::string line;
|
std::string line;
|
||||||
if(f.is_open()){
|
if(f.is_open()){
|
||||||
while(std::getline(f, line)){
|
while(std::getline(f, line)){
|
||||||
@ -53,7 +53,7 @@ bool memory::getRawProcMem(std::string& ret){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool memory::getEasyMem(crow::json::wvalue& ret){
|
bool memory::getEasyMem(crow::json::wvalue& ret){
|
||||||
std::ifstream f (procmempath);
|
std::ifstream f (PROC_MEM_PATH);
|
||||||
std::string line;
|
std::string line;
|
||||||
if(f.is_open()){
|
if(f.is_open()){
|
||||||
for(int j = 0; j < 3; ++j){
|
for(int j = 0; j < 3; ++j){
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
constexpr char procmempath[] = "/proc/meminfo";
|
constexpr char PROC_MEM_PATH[] = "/proc/meminfo";
|
||||||
|
|
||||||
namespace memory{
|
namespace memory{
|
||||||
bool getProcMem(crow::json::wvalue&);
|
bool getProcMem(crow::json::wvalue&);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "state.hpp"
|
#include "state.hpp"
|
||||||
|
|
||||||
bool state::getUptime(crow::json::wvalue& ret){
|
bool state::getUptime(crow::json::wvalue& ret){
|
||||||
std::ifstream f (procuptimepath);
|
std::ifstream f (PROC_UPTIME_PATH);
|
||||||
std::string line;
|
std::string line;
|
||||||
if(f.is_open()){
|
if(f.is_open()){
|
||||||
int space = -1;
|
int space = -1;
|
||||||
@ -34,7 +34,7 @@ bool state::getUptime(crow::json::wvalue& ret){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool state::getRawUptime(std::string& ret){
|
bool state::getRawUptime(std::string& ret){
|
||||||
std::ifstream f (procuptimepath);
|
std::ifstream f (PROC_UPTIME_PATH);
|
||||||
if(f.is_open()){
|
if(f.is_open()){
|
||||||
std::getline(f, ret);
|
std::getline(f, ret);
|
||||||
ret += '\n';
|
ret += '\n';
|
||||||
@ -48,7 +48,7 @@ bool state::getRawUptime(std::string& ret){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool state::getLoadAvg(crow::json::wvalue& ret){
|
bool state::getLoadAvg(crow::json::wvalue& ret){
|
||||||
std::ifstream f (procloadavgpath);
|
std::ifstream f (PROC_LOADAVG_PATH);
|
||||||
std::string line;
|
std::string line;
|
||||||
if(f.is_open()){
|
if(f.is_open()){
|
||||||
int spaces[4];
|
int spaces[4];
|
||||||
@ -78,7 +78,7 @@ bool state::getLoadAvg(crow::json::wvalue& ret){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool state::getRawLoadAvg(std::string& ret){
|
bool state::getRawLoadAvg(std::string& ret){
|
||||||
std::ifstream f (procloadavgpath);
|
std::ifstream f (PROC_LOADAVG_PATH);
|
||||||
if(f.is_open()){
|
if(f.is_open()){
|
||||||
std::getline(f, ret);
|
std::getline(f, ret);
|
||||||
ret += '\n';
|
ret += '\n';
|
||||||
@ -92,7 +92,7 @@ bool state::getRawLoadAvg(std::string& ret){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool state::getHostname(crow::json::wvalue& ret){
|
bool state::getHostname(crow::json::wvalue& ret){
|
||||||
std::ifstream f (prochostnamepath);
|
std::ifstream f (PROC_HOSTNAME_PATH);
|
||||||
std::string line;
|
std::string line;
|
||||||
if(f.is_open()){
|
if(f.is_open()){
|
||||||
std::getline(f, line);
|
std::getline(f, line);
|
||||||
@ -108,7 +108,7 @@ bool state::getHostname(crow::json::wvalue& ret){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool state::getRawHostname(std::string& ret){
|
bool state::getRawHostname(std::string& ret){
|
||||||
std::ifstream f (prochostnamepath);
|
std::ifstream f (PROC_HOSTNAME_PATH);
|
||||||
if(f.is_open()){
|
if(f.is_open()){
|
||||||
std::getline(f, ret);
|
std::getline(f, ret);
|
||||||
ret += '\n';
|
ret += '\n';
|
||||||
|
@ -11,9 +11,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
constexpr char procuptimepath[] = "/proc/uptime";
|
constexpr char PROC_UPTIME_PATH[] = "/proc/uptime";
|
||||||
constexpr char procloadavgpath[] = "/proc/loadavg";
|
constexpr char PROC_LOADAVG_PATH[] = "/proc/loadavg";
|
||||||
constexpr char prochostnamepath[] = "/proc/sys/kernel/hostname";
|
constexpr char PROC_HOSTNAME_PATH[] = "/proc/sys/kernel/hostname";
|
||||||
|
|
||||||
namespace state{
|
namespace state{
|
||||||
bool getUptime(crow::json::wvalue&);
|
bool getUptime(crow::json::wvalue&);
|
||||||
|
Loading…
Reference in New Issue
Block a user