1 |
douglas |
161 |
// Spectre Samba Mounter |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// Configurator.cpp |
6 |
|
|
|
7 |
|
|
#include "Configurator.h" |
8 |
|
|
|
9 |
|
|
Configurator::Configurator(const string& host) |
10 |
|
|
{ |
11 |
|
|
this->host = host; |
12 |
|
|
|
13 |
|
|
configurate(); |
14 |
|
|
} |
15 |
|
|
|
16 |
|
|
void Configurator::configurate() |
17 |
|
|
{ |
18 |
douglas |
162 |
if (config.hosts.count(host) < 2) |
19 |
|
|
{ |
20 |
douglas |
163 |
cerr << program << ": No configuration for host: " << host << "\n"; |
21 |
douglas |
162 |
exit(1); |
22 |
|
|
} |
23 |
|
|
|
24 |
|
|
for (multimap<string, string>::iterator itor = |
25 |
|
|
config.hosts.lower_bound(host); itor != config.hosts.upper_bound(host); |
26 |
|
|
itor++) |
27 |
|
|
{ |
28 |
|
|
string entry = itor->second; |
29 |
douglas |
163 |
|
30 |
douglas |
162 |
if (entry.find("passwd=") == 0) |
31 |
|
|
{ |
32 |
douglas |
163 |
istringstream sin(entry.substr(7)); |
33 |
|
|
|
34 |
|
|
do |
35 |
|
|
{ |
36 |
|
|
string item; |
37 |
|
|
getline(sin, item, ','); |
38 |
|
|
|
39 |
|
|
if (item == "file") |
40 |
|
|
{ |
41 |
|
|
passwd.push_back(file); |
42 |
|
|
} |
43 |
|
|
else if (item == "prompt") |
44 |
|
|
{ |
45 |
|
|
passwd.push_back(prompt); |
46 |
|
|
} |
47 |
|
|
} |
48 |
|
|
while (sin.good()); |
49 |
douglas |
162 |
} |
50 |
|
|
else if (entry.find("folder=") == 0) |
51 |
|
|
{ |
52 |
douglas |
163 |
istringstream sin(entry.substr(7)); |
53 |
|
|
|
54 |
|
|
string folder; |
55 |
|
|
getline(sin, folder, ':'); |
56 |
|
|
|
57 |
|
|
string local; |
58 |
|
|
getline(sin, local, ':'); |
59 |
|
|
|
60 |
|
|
string remote; |
61 |
|
|
getline(sin, remote); |
62 |
|
|
|
63 |
|
|
if (folder == "*") |
64 |
|
|
{ |
65 |
|
|
regular.local = local; |
66 |
|
|
regular.remote = remote; |
67 |
|
|
} |
68 |
|
|
else |
69 |
|
|
{ |
70 |
|
|
Folder special; |
71 |
|
|
|
72 |
|
|
special.local = local; |
73 |
|
|
special.remote = remote; |
74 |
|
|
|
75 |
|
|
folders.insert(pair<string, Folder>(folder, special)); |
76 |
|
|
} |
77 |
douglas |
162 |
} |
78 |
|
|
else |
79 |
|
|
{ |
80 |
douglas |
163 |
cerr << program << ": Unknown configuration entry: \"" << entry |
81 |
|
|
<< "\", ignored\n"; |
82 |
douglas |
162 |
} |
83 |
|
|
} |
84 |
douglas |
161 |
} |