1 |
+ |
/* ============================================================================ |
2 |
+ |
* Spectre Samba Mounter |
3 |
+ |
* |
4 |
+ |
* Copyright © 2003-2004, Douglas Thrift. All Rights Reserved. |
5 |
+ |
* |
6 |
+ |
* Redistribution and use in source and binary forms, with or without |
7 |
+ |
* modification, are permitted provided that the following conditions are met: |
8 |
+ |
* |
9 |
+ |
* 1. Redistributions of source code must retain the above copyright notice, |
10 |
+ |
* this list of conditions and the following disclaimer. |
11 |
+ |
* |
12 |
+ |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
13 |
+ |
* this list of conditions and the following disclaimer in the documentation |
14 |
+ |
* and/or other materials provided with the distribution. |
15 |
+ |
* |
16 |
+ |
* 3. The end-user documentation included with the redistribution, if any, must |
17 |
+ |
* include the following acknowledgment: |
18 |
+ |
* |
19 |
+ |
* "This product includes software developed by Douglas Thrift |
20 |
+ |
* (http://computers.douglasthrift.net/spectre.xml)." |
21 |
+ |
* |
22 |
+ |
* Alternately, this acknowledgment may appear in the software itself, if |
23 |
+ |
* and wherever such third-party acknowledgments normally appear. |
24 |
+ |
* |
25 |
+ |
* 4. The names "Douglas Thrift" and "Spectre Samba Mounter" must not be used |
26 |
+ |
* to endorse or promote products derived from this software without |
27 |
+ |
* specific prior written permission. For written permission, please visit |
28 |
+ |
* http://www.douglasthrift.net/contact.cgi for contact information. |
29 |
+ |
* |
30 |
+ |
* 5. Products derived from this software may not be called "Spectre Samba |
31 |
+ |
* Mounter", nor may "Spectre Samba Mounter" appear in their name, without |
32 |
+ |
* prior written permission. |
33 |
+ |
* |
34 |
+ |
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
35 |
+ |
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
36 |
+ |
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
37 |
+ |
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
38 |
+ |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
39 |
+ |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, |
40 |
+ |
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
41 |
+ |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
42 |
+ |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
43 |
+ |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
44 |
+ |
* ============================================================================ |
45 |
+ |
*/ |
46 |
|
// Spectre Samba Mounter |
47 |
|
// |
48 |
|
// Douglas Thrift |
49 |
|
// |
50 |
< |
// Spectre.h |
50 |
> |
// $Id: Spectre.h,v 1.9 2004/03/23 04:22:17 douglas Exp $ |
51 |
|
|
52 |
|
#ifndef _Spectre_h_ |
53 |
|
#define _Spectre_h_ |
54 |
|
|
55 |
|
#include <iostream> |
56 |
|
#include <fstream> |
57 |
+ |
#include <string> |
58 |
+ |
#include <sstream> |
59 |
|
#include <vector> |
60 |
|
#include <set> |
61 |
|
#include <map> |
62 |
|
#include <cstdlib> |
63 |
|
#include <cstdio> |
64 |
< |
#include <string> |
64 |
> |
#include <cctype> |
65 |
|
|
66 |
|
#include <pstream.h> |
67 |
|
#include <sys/utsname.h> |
77 |
|
struct Config |
78 |
|
{ |
79 |
|
string install; |
80 |
+ |
string findsmb; |
81 |
|
string smbclient; |
82 |
|
string mount; |
83 |
+ |
string umount; |
84 |
|
string root; |
85 |
|
multimap<string, string> hosts; |
86 |
|
}; |
95 |
|
string platform(); |
96 |
|
void usage(); |
97 |
|
void version(); |
98 |
< |
void configure(); |
98 |
> |
|
99 |
> |
inline string toupper(const string& lower) |
100 |
> |
{ |
101 |
> |
string upper; |
102 |
> |
|
103 |
> |
for (unsigned index = 0; index < lower.length(); index++) |
104 |
> |
{ |
105 |
> |
upper += toupper(lower[index]); |
106 |
> |
} |
107 |
> |
|
108 |
> |
return upper; |
109 |
> |
} |
110 |
> |
|
111 |
> |
inline string tolower(const string& upper) |
112 |
> |
{ |
113 |
> |
string lower; |
114 |
> |
|
115 |
> |
for (unsigned index = 0; index < upper.length(); index++) |
116 |
> |
{ |
117 |
> |
lower += tolower(upper[index]); |
118 |
> |
} |
119 |
> |
|
120 |
> |
return lower; |
121 |
> |
} |
122 |
> |
|
123 |
> |
inline void strip(char* name) |
124 |
> |
{ |
125 |
> |
for (unsigned index = strlen(name); index > 0; index--) |
126 |
> |
{ |
127 |
> |
if (name[index - 1] == ' ') |
128 |
> |
{ |
129 |
> |
name[index - 1] = '\0'; |
130 |
> |
} |
131 |
> |
else |
132 |
> |
{ |
133 |
> |
break; |
134 |
> |
} |
135 |
> |
} |
136 |
> |
} |
137 |
|
|
138 |
|
#endif // _Spectre_h_ |