// Spectre Samba Mounter // // Douglas Thrift // // Spectre.cpp #include "Spectre.h" #include "Maker.h" #include "Mounter.h" string program; string programName = "Spectre Samba Mounter"; string programVersion = "1.0alpha"; bool debug = false; Config config; int main(int argc, char* argv[]) { program = argv[0]; #include "configure.h" bool make = false; bool mount = false; set makes; set mounts; for (int index = 1; index < argc; index++) { string arg = argv[index]; if (arg == "-help") { usage(); return 0; } else if (arg == "-version") { version(); return 0; } else if (arg == "-make") { if (!make) make = true; if (++index < argc) { makes.insert(argv[index]); } else { cerr << program << ": Bad arguments\n"; usage(); return 1; } } else if (arg == "-mount") { if (!mount) mount = true; if (++index < argc) { mounts.insert(argv[index]); } else { cerr << program << ": Bad arguments\n"; usage(); return 1; } } else if (arg == "-D") { if (!debug) { debug = true; cerr.setf(ios_base::boolalpha); } } } if (!make && !mount) { usage(); return 0; } if (debug) { cerr << "make = " << make << "\n" << (make ? "makes = {\n" : ""); for (set::iterator itor = makes.begin(); itor != makes.end(); itor++) { cerr << " " << *itor << "\n"; } cerr << (make ? "}\n" : "") << "mount = " << mount << "\n" << (mount ? "mounts = {\n" : ""); for (set::iterator itor = mounts.begin(); itor != mounts.end(); itor++) { cerr << " " << *itor << "\n"; } cerr << (mount ? "}\n" : "") << "config.install = " << config.install << "\n"; } // configure(); if (debug) { cerr << "config.smbclient = " << config.smbclient << "\n"; cerr << "config.mount_smbfs = " << config.mount_smbfs << "\n" << (!config.hosts.empty() ? "config.hosts = {\n" : ""); for (multimap::iterator itor = config.hosts.begin(); itor != config.hosts.end(); itor++) { cerr << " " << itor->first << " = " << itor->second << "\n"; } cerr << (!config.hosts.empty() ? "}\n" : ""); } return 0; } string platform() { utsname* computer = new utsname; uname(computer); string os = computer->sysname; string version = computer->release; string architecture = computer->machine; delete computer; string platform = "(" + os + " " + version + " " + architecture + ")"; return platform; } void usage() { cout << "Usage: " << program << " [-make host ...] [-mount host ...] [-D] " << "[-version] [-help]\n" << "Options:\n" << " -make host Make the mount tree for host\n" << " -mount host Mount the shares on host to its tree\n" << " -D Display debug information\n" << " -version Display version information and exit\n" << " -help Display this message and exit\n"; } void version() { cout << programName << " " << programVersion << " "<< platform() << "\n\n" << " Copyright (C) 2003, Douglas Thrift. All Rights Reserved.\n\n" << " This product includes software developed by Douglas Thrift\n" << " (http://computers.douglasthrift.net/).\n"; }