ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/Spectre/Spectre.cpp
Revision: 155
Committed: 2003-06-09T01:10:31-07:00 (22 years ago) by douglas
File size: 3263 byte(s)
Log Message:
Did some crazy stuff!

File Contents

# Content
1 // Spectre Samba Mounter
2 //
3 // Douglas Thrift
4 //
5 // Spectre.cpp
6
7 #include "Spectre.h"
8 #include "Maker.h"
9 #include "Mounter.h"
10
11 string program;
12 string programName = "Spectre Samba Mounter";
13 string programVersion = "1.0alpha";
14 bool debug = false;
15
16 Config config;
17
18 int main(int argc, char* argv[])
19 {
20 program = argv[0];
21
22 #include "configure.h"
23
24 bool make = false;
25 bool mount = false;
26
27 set<string> makes;
28 set<string> mounts;
29
30 for (int index = 1; index < argc; index++)
31 {
32 string arg = argv[index];
33
34 if (arg == "-help")
35 {
36 usage();
37 return 0;
38 }
39 else if (arg == "-version")
40 {
41 version();
42 return 0;
43 }
44 else if (arg == "-make")
45 {
46 if (!make) make = true;
47
48 if (++index < argc)
49 {
50 makes.insert(argv[index]);
51 }
52 else
53 {
54 cerr << program << ": Bad arguments\n";
55 usage();
56 return 1;
57 }
58 }
59 else if (arg == "-mount")
60 {
61 if (!mount) mount = true;
62
63 if (++index < argc)
64 {
65 mounts.insert(argv[index]);
66 }
67 else
68 {
69 cerr << program << ": Bad arguments\n";
70 usage();
71 return 1;
72 }
73 }
74 else if (arg == "-D")
75 {
76 if (!debug)
77 {
78 debug = true;
79 cerr.setf(ios_base::boolalpha);
80 }
81 }
82 }
83
84 if (!make && !mount)
85 {
86 usage();
87 return 0;
88 }
89
90 if (debug)
91 {
92 cerr << "make = " << make << "\n"
93 << (make ? "makes = {\n" : "");
94
95 for (set<string>::iterator itor = makes.begin(); itor != makes.end();
96 itor++)
97 {
98 cerr << " " << *itor << "\n";
99 }
100
101 cerr << (make ? "}\n" : "")
102 << "mount = " << mount << "\n"
103 << (mount ? "mounts = {\n" : "");
104
105 for (set<string>::iterator itor = mounts.begin(); itor != mounts.end();
106 itor++)
107 {
108 cerr << " " << *itor << "\n";
109 }
110
111 cerr << (mount ? "}\n" : "")
112 << "config.install = " << config.install << "\n";
113 }
114
115 // configure();
116
117 if (debug)
118 {
119 cerr << "config.smbclient = " << config.smbclient << "\n";
120 cerr << "config.mount_smbfs = " << config.mount_smbfs << "\n"
121 << (!config.hosts.empty() ? "config.hosts = {\n" : "");
122
123 for (multimap<string, string>::iterator itor = config.hosts.begin();
124 itor != config.hosts.end(); itor++)
125 {
126 cerr << " " << itor->first << " = " << itor->second << "\n";
127 }
128
129 cerr << (!config.hosts.empty() ? "}\n" : "");
130 }
131
132 return 0;
133 }
134
135 string platform()
136 {
137 utsname* computer = new utsname;
138 uname(computer);
139
140 string os = computer->sysname;
141 string version = computer->release;
142 string architecture = computer->machine;
143
144 delete computer;
145
146 string platform = "(" + os + " " + version + " " + architecture + ")";
147
148 return platform;
149 }
150
151 void usage()
152 {
153 cout << "Usage: " << program << " [-make host ...] [-mount host ...] [-D] "
154 << "[-version] [-help]\n"
155 << "Options:\n"
156 << " -make host Make the mount tree for host\n"
157 << " -mount host Mount the shares on host to its tree\n"
158 << " -D Display debug information\n"
159 << " -version Display version information and exit\n"
160 << " -help Display this message and exit\n";
161 }
162
163 void version()
164 {
165 cout << programName << " " << programVersion << " "<< platform() << "\n\n"
166 << " Copyright (C) 2003, Douglas Thrift. All Rights Reserved.\n\n"
167 << " This product includes software developed by Douglas Thrift\n"
168 << " (http://computers.douglasthrift.net/).\n";
169 }