10 |
|
|
11 |
|
string program; |
12 |
|
string programName = "Spectre Samba Mounter"; |
13 |
< |
string programVersion = "1.0beta"; |
13 |
> |
string programVersion = "1.0rc1"; |
14 |
|
bool debug = false; |
15 |
|
|
16 |
|
Config config; |
239 |
|
|
240 |
|
if (debug) cerr << "findsmb = {\n"; |
241 |
|
|
242 |
< |
for (unsigned index = 0; index < 5; index++) |
242 |
> |
do |
243 |
|
{ |
244 |
+ |
if (isdigit(findsmb.peek())) break; |
245 |
+ |
|
246 |
|
string line; |
247 |
|
|
248 |
|
getline(findsmb, line); |
249 |
|
|
250 |
|
if (debug) cerr << line << "\n"; |
251 |
|
} |
252 |
+ |
while (findsmb.good()); |
253 |
|
|
254 |
|
automake(makes, findsmb); |
255 |
|
|
278 |
|
if (!isdigit(pin.peek())) break; |
279 |
|
|
280 |
|
char ip[17]; |
281 |
< |
char host[16]; |
281 |
> |
string tab; |
282 |
> |
char host[15]; |
283 |
|
string info; |
284 |
|
|
285 |
|
pin.get(ip, 17); |
286 |
< |
pin.ignore(); |
287 |
< |
pin.get(host, 16); |
286 |
> |
|
287 |
> |
while (isspace(pin.peek())) |
288 |
> |
{ |
289 |
> |
tab += pin.get(); |
290 |
> |
} |
291 |
> |
|
292 |
> |
pin.get(host, 15); |
293 |
|
getline(pin, info); |
294 |
|
|
295 |
< |
if (debug) cerr << ip << "\t" << host << info << "\n"; |
295 |
> |
if (debug) cerr << ip << tab << host << info << "\n"; |
296 |
|
|
297 |
|
strip(host); |
298 |
|
|
313 |
|
|
314 |
|
void automount(set<string>& mounts) |
315 |
|
{ |
316 |
+ |
vector<string> args; |
317 |
+ |
|
318 |
+ |
args.push_back("spectre"); |
319 |
+ |
|
320 |
+ |
ipstream findsmb(config.findsmb, args); |
321 |
+ |
|
322 |
+ |
if (debug) cerr << "findsmb = {\n"; |
323 |
+ |
|
324 |
+ |
do |
325 |
+ |
{ |
326 |
+ |
if (isdigit(findsmb.peek())) break; |
327 |
+ |
|
328 |
+ |
string line; |
329 |
+ |
|
330 |
+ |
getline(findsmb, line); |
331 |
+ |
|
332 |
+ |
if (debug) cerr << line << "\n"; |
333 |
+ |
} |
334 |
+ |
while (findsmb.good()); |
335 |
+ |
|
336 |
+ |
set<string> hosts; |
337 |
+ |
|
338 |
+ |
automake(hosts, findsmb); |
339 |
+ |
|
340 |
+ |
if (debug) cerr << "}\n"; |
341 |
+ |
|
342 |
+ |
findsmb.close(); |
343 |
+ |
|
344 |
|
DIR* dir = opendir(config.root.c_str()); |
345 |
|
dirent* file; |
346 |
|
|
355 |
|
{ |
356 |
|
string folder = file->d_name; |
357 |
|
|
358 |
< |
if (folder == "." || folder == "..") continue; |
358 |
> |
if (folder == "." || folder == ".." || hosts.find(folder) == |
359 |
> |
hosts.end()) continue; |
360 |
|
|
361 |
|
mounts.insert(folder); |
362 |
|
} |