summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/FileUserAccountMapperI.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2006-05-23 16:06:24 +0000
committerBenoit Foucher <benoit@zeroc.com>2006-05-23 16:06:24 +0000
commited997c458e0d884a87211929523b02779080ef2a (patch)
tree53c4b12dff939ffba8efc9596536f31b742753fb /cpp/src/IceGrid/FileUserAccountMapperI.cpp
parentAdded IceGrid properties (diff)
downloadice-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.cpp36
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));
}
}