Use sane constexpr var names

This commit is contained in:
Tyler Perkins 2022-04-29 15:54:37 -04:00
parent 3db4a8fcaa
commit 146d31efea
4 changed files with 13 additions and 13 deletions

View File

@ -7,7 +7,7 @@
#include "memory.hpp"
bool memory::getProcMem(crow::json::wvalue& ret){
std::ifstream f (procmempath);
std::ifstream f (PROC_MEM_PATH);
std::string line;
if(f.is_open()){
while(std::getline(f, line)){
@ -36,7 +36,7 @@ bool memory::getProcMem(crow::json::wvalue& ret){
}
bool memory::getRawProcMem(std::string& ret){
std::ifstream f (procmempath);
std::ifstream f (PROC_MEM_PATH);
std::string line;
if(f.is_open()){
while(std::getline(f, line)){
@ -53,7 +53,7 @@ bool memory::getRawProcMem(std::string& ret){
}
bool memory::getEasyMem(crow::json::wvalue& ret){
std::ifstream f (procmempath);
std::ifstream f (PROC_MEM_PATH);
std::string line;
if(f.is_open()){
for(int j = 0; j < 3; ++j){

View File

@ -11,7 +11,7 @@
#include <string>
#include <fstream>
constexpr char procmempath[] = "/proc/meminfo";
constexpr char PROC_MEM_PATH[] = "/proc/meminfo";
namespace memory{
bool getProcMem(crow::json::wvalue&);

View File

@ -7,7 +7,7 @@
#include "state.hpp"
bool state::getUptime(crow::json::wvalue& ret){
std::ifstream f (procuptimepath);
std::ifstream f (PROC_UPTIME_PATH);
std::string line;
if(f.is_open()){
int space = -1;
@ -34,7 +34,7 @@ bool state::getUptime(crow::json::wvalue& ret){
}
bool state::getRawUptime(std::string& ret){
std::ifstream f (procuptimepath);
std::ifstream f (PROC_UPTIME_PATH);
if(f.is_open()){
std::getline(f, ret);
ret += '\n';
@ -48,7 +48,7 @@ bool state::getRawUptime(std::string& ret){
}
bool state::getLoadAvg(crow::json::wvalue& ret){
std::ifstream f (procloadavgpath);
std::ifstream f (PROC_LOADAVG_PATH);
std::string line;
if(f.is_open()){
int spaces[4];
@ -78,7 +78,7 @@ bool state::getLoadAvg(crow::json::wvalue& ret){
}
bool state::getRawLoadAvg(std::string& ret){
std::ifstream f (procloadavgpath);
std::ifstream f (PROC_LOADAVG_PATH);
if(f.is_open()){
std::getline(f, ret);
ret += '\n';
@ -92,7 +92,7 @@ bool state::getRawLoadAvg(std::string& ret){
}
bool state::getHostname(crow::json::wvalue& ret){
std::ifstream f (prochostnamepath);
std::ifstream f (PROC_HOSTNAME_PATH);
std::string line;
if(f.is_open()){
std::getline(f, line);
@ -108,7 +108,7 @@ bool state::getHostname(crow::json::wvalue& ret){
}
bool state::getRawHostname(std::string& ret){
std::ifstream f (prochostnamepath);
std::ifstream f (PROC_HOSTNAME_PATH);
if(f.is_open()){
std::getline(f, ret);
ret += '\n';

View File

@ -11,9 +11,9 @@
#include <string>
#include <fstream>
constexpr char procuptimepath[] = "/proc/uptime";
constexpr char procloadavgpath[] = "/proc/loadavg";
constexpr char prochostnamepath[] = "/proc/sys/kernel/hostname";
constexpr char PROC_UPTIME_PATH[] = "/proc/uptime";
constexpr char PROC_LOADAVG_PATH[] = "/proc/loadavg";
constexpr char PROC_HOSTNAME_PATH[] = "/proc/sys/kernel/hostname";
namespace state{
bool getUptime(crow::json::wvalue&);