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
14
Config.cc
14
Config.cc
@ -26,7 +26,7 @@ void Config::read(const char * file)
|
||||
ifstream ifs(file);
|
||||
if (ifs.is_open())
|
||||
{
|
||||
int entry_num = -1;
|
||||
int entry_num = -1; /* start in "global" section (-1) */
|
||||
string line;
|
||||
while (!ifs.eof())
|
||||
{
|
||||
@ -36,7 +36,7 @@ void Config::read(const char * file)
|
||||
if (line == "") /* skip blank lines */
|
||||
continue;
|
||||
|
||||
if (line[0] == ';' || line[0] == '#') /* skip comments */
|
||||
if (line[0] == ';') /* skip comments */
|
||||
continue;
|
||||
|
||||
/* Look for the beginning of a new entry section */
|
||||
@ -54,7 +54,9 @@ void Config::read(const char * file)
|
||||
if (parts.first == "port")
|
||||
{
|
||||
if (parts.second != "")
|
||||
{
|
||||
port = parts.second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -110,13 +112,19 @@ Config::Action Config::parseAction(const string & str)
|
||||
{
|
||||
string s = str;
|
||||
Action res = NONE;
|
||||
|
||||
/* lowercase the string */
|
||||
for (int sz = s.size(), i = 0; i < sz; i++)
|
||||
{
|
||||
s[i] = tolower(s[i]);
|
||||
if (s == "on")
|
||||
}
|
||||
|
||||
if (s == "on")
|
||||
res = ON;
|
||||
else if (s == "off")
|
||||
res = OFF;
|
||||
else if (s == "previous")
|
||||
res = PREVIOUS;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
|
||||
; Global options
|
||||
port = LPT1
|
||||
|
||||
[Light]
|
||||
|
Loading…
x
Reference in New Issue
Block a user