ready to start using Config
git-svn-id: http://apu.dw.local/svnusers/JoshHoltrop/pppc/trunk@54 8131a0b2-b21c-1c47-bd6a-f003126495bd
This commit is contained in:
parent
3c22f00c7d
commit
90f46c2917
12
Config.cc
12
Config.cc
@ -26,7 +26,7 @@ void Config::read(const char * file)
|
|||||||
ifstream ifs(file);
|
ifstream ifs(file);
|
||||||
if (ifs.is_open())
|
if (ifs.is_open())
|
||||||
{
|
{
|
||||||
int entry_num = -1;
|
int entry_num = -1; /* start in "global" section (-1) */
|
||||||
string line;
|
string line;
|
||||||
while (!ifs.eof())
|
while (!ifs.eof())
|
||||||
{
|
{
|
||||||
@ -36,7 +36,7 @@ void Config::read(const char * file)
|
|||||||
if (line == "") /* skip blank lines */
|
if (line == "") /* skip blank lines */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (line[0] == ';' || line[0] == '#') /* skip comments */
|
if (line[0] == ';') /* skip comments */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Look for the beginning of a new entry section */
|
/* Look for the beginning of a new entry section */
|
||||||
@ -54,8 +54,10 @@ void Config::read(const char * file)
|
|||||||
if (parts.first == "port")
|
if (parts.first == "port")
|
||||||
{
|
{
|
||||||
if (parts.second != "")
|
if (parts.second != "")
|
||||||
|
{
|
||||||
port = parts.second;
|
port = parts.second;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "Warning: Unrecognized global command: "
|
cerr << "Warning: Unrecognized global command: "
|
||||||
@ -110,13 +112,19 @@ Config::Action Config::parseAction(const string & str)
|
|||||||
{
|
{
|
||||||
string s = str;
|
string s = str;
|
||||||
Action res = NONE;
|
Action res = NONE;
|
||||||
|
|
||||||
|
/* lowercase the string */
|
||||||
for (int sz = s.size(), i = 0; i < sz; i++)
|
for (int sz = s.size(), i = 0; i < sz; i++)
|
||||||
|
{
|
||||||
s[i] = tolower(s[i]);
|
s[i] = tolower(s[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (s == "on")
|
if (s == "on")
|
||||||
res = ON;
|
res = ON;
|
||||||
else if (s == "off")
|
else if (s == "off")
|
||||||
res = OFF;
|
res = OFF;
|
||||||
else if (s == "previous")
|
else if (s == "previous")
|
||||||
res = PREVIOUS;
|
res = PREVIOUS;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
|
; Global options
|
||||||
port = LPT1
|
port = LPT1
|
||||||
|
|
||||||
[Light]
|
[Light]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user