diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-05-23 16:06:24 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-05-23 16:06:24 +0000 |
commit | ed997c458e0d884a87211929523b02779080ef2a (patch) | |
tree | 53c4b12dff939ffba8efc9596536f31b742753fb /cpp/src/IceGrid/FileUserAccountMapperI.cpp | |
parent | Added IceGrid properties (diff) | |
download | ice-ed997c458e0d884a87211929523b02779080ef2a.tar.bz2 ice-ed997c458e0d884a87211929523b02779080ef2a.tar.xz ice-ed997c458e0d884a87211929523b02779080ef2a.zip |
Fix
Diffstat (limited to 'cpp/src/IceGrid/FileUserAccountMapperI.cpp')
-rw-r--r-- | cpp/src/IceGrid/FileUserAccountMapperI.cpp | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/cpp/src/IceGrid/FileUserAccountMapperI.cpp b/cpp/src/IceGrid/FileUserAccountMapperI.cpp index 91ab12e6c14..9d29e56582a 100644 --- a/cpp/src/IceGrid/FileUserAccountMapperI.cpp +++ b/cpp/src/IceGrid/FileUserAccountMapperI.cpp @@ -22,24 +22,46 @@ FileUserAccountMapperI::FileUserAccountMapperI(const string& filename) throw "cannot open `" + filename + "' for reading: " + strerror(errno); } + const string delim = " \t\r\n"; while(true) { - string user; - file >> user; + string line; + getline(file, line); if(!file) { break; } - - string account; - file >> account; - if(!file) + + string::size_type idx = line.find('#'); + if(idx != string::npos) { - break; + line.erase(idx); } + idx = line.find_last_not_of(delim); + if(idx != string::npos && idx + 1 < line.length()) + { + line.erase(idx + 1); + } + + string::size_type beg = line.find_first_not_of(delim); + if(beg == string::npos) + { + continue; + } + + string::size_type end = line.find_last_of(delim); + if(end == string::npos || end <= beg) + { + continue; + } + + string user = line.substr(beg, end - beg); + string account = line.substr(end + 1); + assert(!user.empty()); assert(!account.empty()); + _accounts.insert(make_pair(user, account)); } } |