// Spectre Samba Mounter // // Douglas Thrift // // Configurator.cpp #include "Configurator.h" Configurator::Configurator(const string& host) { this->host = host; configurate(); } void Configurator::configurate() { if (config.hosts.count(host) < 2) { cerr << program << ": No configuration for host: " << host << "\n"; exit(1); } for (multimap::iterator itor = config.hosts.lower_bound(host); itor != config.hosts.upper_bound(host); itor++) { string entry = itor->second; if (entry.find("passwd=") == 0) { istringstream sin(entry.substr(7)); do { string item; getline(sin, item, ','); if (item == "file") { passwd.push_back(file); } else if (item == "prompt") { passwd.push_back(prompt); } } while (sin.good()); } else if (entry.find("folder=") == 0) { istringstream sin(entry.substr(7)); string folder; getline(sin, folder, ':'); string local; getline(sin, local, ':'); string remote; getline(sin, remote); if (folder == "*") { regular.local = local; regular.remote = remote; } else { Folder special; special.local = local; special.remote = remote; folders.insert(pair(folder, special)); } } else { cerr << program << ": Unknown configuration entry: \"" << entry << "\", ignored\n"; } } }