1 mike 1.1 //BEGIN_LICENSE
2 //
3 // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 // DEALINGS IN THE SOFTWARE.
19 //
20 //END_LICENSE
21 //BEGIN_HISTORY
22 mike 1.1 //
23 // Author: Mike Brasher
24 //
25 //END_HISTORY
26
27 #include <iostream>
28 #include <Pegasus/Common/FileSystem.h>
29 #include <Pegasus/Common/Selector.h>
30 #include <Pegasus/Common/OptionManager.h>
31 #include <Pegasus/Server/CIMServer.h>
32
33 using namespace Pegasus;
34 using namespace std;
35
36 const char PEGASUS_VERSION[] = "Pegasus CIM Server - Version 0.7";
37
38 void GetEnvironmentVariables(
39 const char* arg0,
40 String& pegasusHome)
41 {
42 // Get environment variables:
43 mike 1.1
44 const char* tmp = getenv("PEGASUS_HOME");
45
46 if (!tmp)
47 {
48 cerr << arg0 << ": PEGASUS_HOME environment variable undefined" << endl;
49 exit(1);
50 }
51
52 pegasusHome = tmp;
53 FileSystem::translateSlashes(pegasusHome);
54 }
55
56 void GetOptions(
57 OptionManager& om,
58 int& argc,
59 char** argv,
60 const String& pegasusHome)
61 {
62 static struct OptionRow options[] =
63 {
64 mike 1.1 {"port", "8888", false, Option::WHOLE_NUMBER, 0, 0, "port"},
65 {"trace", "false", false, Option::BOOLEAN, 0, 0, "trace"},
66 {"version", "false", false, Option::BOOLEAN, 0, 0, "v"},
67 {"help", "false", false, Option::BOOLEAN, 0, 0, "h"}
68 };
69 const Uint32 NUM_OPTIONS = sizeof(options) / sizeof(options[0]);
70
71 om.registerOptions(options, NUM_OPTIONS);
72
73 String configFile = pegasusHome + "/cimserver.conf";
74
|
97 mike 1.1 int main(int argc, char** argv)
98 {
99 // Get environment variables:
100
101 String pegasusHome;
102 GetEnvironmentVariables(argv[0], pegasusHome);
103
104 // Get options (from command line and from configuration file); this
105 // removes corresponding options and their arguments fromt he command
106 // line.
107
108 OptionManager om;
109
110 try
111 {
112 GetOptions(om, argc, argv, pegasusHome);
113 // om.print();
114 }
115 catch (Exception& e)
116 {
117 cerr << argv[0] << ": " << e.getMessage() << endl;
118 mike 1.1 exit(1);
119 }
120
121 // At this point, all options should have been extracted; print an
122 // error if there are any remaining:
123
124 if (argc != 1)
125 {
126 cerr << argv[0] << ": unrecognized options: ";
127
128 for (Uint32 i = 1; i < argc; i++)
129 cerr << argv[i] << ' ';
130 cout << endl;
131 exit(1);
132 }
133
134 // Check to see if user asked for the version (-v otpion):
135
136 String versionOption;
137
138 if (om.lookupValue("version", versionOption) && versionOption == "true")
139 mike 1.1 {
140 cerr << PEGASUS_VERSION << endl;
141 exit(0);
142 }
143
144 // Check to see if user asked for help (-h otpion):
145
146 String helpOption;
147
148 if (om.lookupValue("help", helpOption) && helpOption == "true")
149 {
|