59 lines
891 B
C++
59 lines
891 B
C++
#include "cfg.h"
|
|
#include "libconfig.h++"
|
|
#include <iostream>
|
|
|
|
using namespace libconfig;
|
|
|
|
Config cfg;
|
|
|
|
void CfgReadConfig() {
|
|
try {
|
|
/* Load the configuration.. */
|
|
cfg.readFile(WRENCHBOARD_CONFIG\
|
|
"/wrenchboard_api.conf");
|
|
} catch (...) {
|
|
// failure
|
|
}
|
|
}
|
|
|
|
long CfgReadLong(const char* key) {
|
|
if (key!=NULL) {
|
|
try {
|
|
Setting& s = cfg.lookup(key);
|
|
long ret = s;
|
|
return ret;
|
|
} catch (...) {
|
|
// failure
|
|
std::cout << "missing: " << key << std::endl;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
/*
|
|
std::string CfgReadString(const char* key) {
|
|
if (key!=NULL) {
|
|
try {
|
|
return (std::string)cfg.lookup(key);
|
|
} catch (...) {
|
|
// failure
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
*/
|
|
const char* CfgReadChar(const char* key) {
|
|
if (key!=NULL) {
|
|
try {
|
|
return (const char*)cfg.lookup(key);
|
|
} catch (...) {
|
|
// failure
|
|
std::cout << "missing: " << key << std::endl;
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
/*
|
|
vi:ts=2
|
|
*/
|
|
|