From 90f46c291788150e5d0d96b785d109db6dc2cd16 Mon Sep 17 00:00:00 2001 From: joshholtrop Date: Wed, 19 Aug 2009 17:49:12 +0000 Subject: [PATCH] ready to start using Config git-svn-id: http://apu.dw.local/svnusers/JoshHoltrop/pppc/trunk@54 8131a0b2-b21c-1c47-bd6a-f003126495bd --- Config.cc | 14 +++++++++++--- pppc-sample.ini | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Config.cc b/Config.cc index 7680e94..499cce8 100644 --- a/Config.cc +++ b/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; } diff --git a/pppc-sample.ini b/pppc-sample.ini index 8bdae44..ae9c9ce 100644 --- a/pppc-sample.ini +++ b/pppc-sample.ini @@ -1,4 +1,5 @@ +; Global options port = LPT1 [Light]