(file) Return to cimserver.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Server

Diff for /pegasus/src/Server/cimserver.cpp between version 1.1 and 1.13

version 1.1, 2001/04/15 17:58:58 version 1.13, 2001/06/02 02:25:33
Line 1 
Line 1 
 //BEGIN_LICENSE  //%/////////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
 // //
Line 17 
Line 17 
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
 // //
 //END_LICENSE  //==============================================================================
 //BEGIN_HISTORY  
 // //
 // Author: Mike Brasher  // Author: Mike Brasher (mbrasher@bmc.com)
 // //
 //END_HISTORY  // Modified By:
   //
   //%/////////////////////////////////////////////////////////////////////////////
  
 #include <iostream> #include <iostream>
   #include <cstdlib>
 #include <Pegasus/Common/FileSystem.h> #include <Pegasus/Common/FileSystem.h>
 #include <Pegasus/Common/Selector.h> #include <Pegasus/Common/Selector.h>
 #include <Pegasus/Common/OptionManager.h> #include <Pegasus/Common/OptionManager.h>
 #include <Pegasus/Server/CIMServer.h> #include <Pegasus/Server/CIMServer.h>
   #include <Pegasus/Common/PegasusVersion.h>
   #include <Pegasus/Protocol/Handler.h>
   #include <Pegasus/Common/Logger.h>
   
   PEGASUS_USING_PEGASUS;
   PEGASUS_USING_STD;
  
 using namespace Pegasus;  
 using namespace std;  
  
 const char PEGASUS_VERSION[]  = "Pegasus CIM Server - Version 0.7";  
  
 void GetEnvironmentVariables( void GetEnvironmentVariables(
     const char* arg0,     const char* arg0,
Line 53 
Line 58 
     FileSystem::translateSlashes(pegasusHome);     FileSystem::translateSlashes(pegasusHome);
 } }
  
   /** GetOptions function - This function defines the Options Table
       and sets up the options from that table using the option manager.
   */
 void GetOptions( void GetOptions(
     OptionManager& om,     OptionManager& om,
     int& argc,     int& argc,
Line 62 
Line 70 
     static struct OptionRow options[] =     static struct OptionRow options[] =
     {     {
         {"port", "8888", false, Option::WHOLE_NUMBER, 0, 0, "port"},         {"port", "8888", false, Option::WHOLE_NUMBER, 0, 0, "port"},
         {"trace", "false", false, Option::BOOLEAN, 0, 0, "trace"},          {"trace", "false", false, Option::BOOLEAN, 0, 0, "t"},
           {"severity", "ALL", false, Option::STRING, 0, 0, "s"},
           {"logs", "ALL", false, Option::STRING, 0, 0, "L"},
           {"daemon", "false", false, Option::STRING, 0, 0, "d"},
         {"version", "false", false, Option::BOOLEAN, 0, 0, "v"},         {"version", "false", false, Option::BOOLEAN, 0, 0, "v"},
         {"help", "false", false, Option::BOOLEAN, 0, 0, "h"}          {"help", "false", false, Option::BOOLEAN, 0, 0, "h"},
           {"debug", "false", false, Option::BOOLEAN, 0, 0, "d"}
     };     };
     const Uint32 NUM_OPTIONS = sizeof(options) / sizeof(options[0]);     const Uint32 NUM_OPTIONS = sizeof(options) / sizeof(options[0]);
  
Line 72 
Line 84 
  
     String configFile = pegasusHome + "/cimserver.conf";     String configFile = pegasusHome + "/cimserver.conf";
  
     if (!FileSystem::exists(configFile))      if (FileSystem::exists(configFile))
     {  
         cerr << argv[0] << ": cannot open " << configFile << endl;  
         exit(1);  
     }  
   
     om.mergeFile(configFile);     om.mergeFile(configFile);
  
     om.mergeCommandLine(argc, argv);     om.mergeCommandLine(argc, argv);
Line 85 
Line 92 
     om.checkRequiredOptions();     om.checkRequiredOptions();
 } }
  
   /* PrintHelp - This is temporary until we expand the options manager to allow
      options help to be defined with the OptionRow entries and presented from
      those entries.
   */
   void PrintHelp(const char* arg0)
   {
       cout << '\n';
       cout << PEGASUS_NAME << PEGASUS_VERSION << endl;
       cout << '\n';
       cout << "Usage: " << arg0 << " [-port <port_num> -t -h -v]\n";
       cout << '\n';
       cout << "    -h - prints this help message\n";
       cout << "    -port - specifies port number to listen on\n";
       cout << "    -v - prints out the version number\n";
       cout << "    -t - turns on trace mode\n";
       cout << "    -d - turns on debug mode\n";
       cout << endl;
   }
   
   //////////////////////////////////////////////////////////////////////////
   //  MAIN
   //////////////////////////////////////////////////////////////////////////
 int main(int argc, char** argv) int main(int argc, char** argv)
 { {
     // Get environment variables:     // Get environment variables:
Line 116 
Line 145 
     {     {
         cerr << argv[0] << ": unrecognized options: ";         cerr << argv[0] << ": unrecognized options: ";
  
         for (Uint32 i = 1; i < argc; i++)          for (int i = 1; i < argc; i++)
             cerr << argv[i] << ' ';             cerr << argv[i] << ' ';
         cout << endl;         cout << endl;
         exit(1);         exit(1);
Line 138 
Line 167 
  
     if (om.lookupValue("help", helpOption) && helpOption == "true")     if (om.lookupValue("help", helpOption) && helpOption == "true")
     {     {
         cerr << "No help yet!" << endl;          PrintHelp(argv[0]);
         exit(0);         exit(0);
     }     }
  
       // Check the trace options and set global variable
       Boolean pegasusIOTrace = false;
       if (om.valueEquals("trace", "true"))
       {
            Handler::sethandlerTrace(true);
            pegasusIOTrace = true;
            cout << "Trace Set" << endl;
       }
   
     // Grab the port otpion:     // Grab the port otpion:
  
     String portOption;     String portOption;
     om.lookupValue("port", portOption);     om.lookupValue("port", portOption);
  
       char* address = portOption.allocateCString();
   
       // Put out startup up message.
       // Put to cout if not daemon
       // ATTN: modify when we add daemon
       cout << PEGASUS_NAME << PEGASUS_VERSION <<
            " on port " << address << endl;
       cout << "Built " << __DATE__ << " " << __TIME__ << endl;
       cout <<"Started..."
            << (pegasusIOTrace ? " Tracing": " ") << endl;
   
       // Set up the Logger
       Logger::setHomeDirectory("./logs");
   
       // Put server start message to the logger
       Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION,
           "Start $0 %1 port $2 $3 ", 88, PEGASUS_NAME, PEGASUS_VERSION,
                   address, (pegasusIOTrace ? " Tracing": " "));
   
       // try loop to bind the address, and run the server
     try     try
     {     {
         Selector selector;         Selector selector;
         CIMServer server(&selector, pegasusHome);         CIMServer server(&selector, pegasusHome);
  
         char* address = portOption.allocateCString();  
         server.bind(address);         server.bind(address);
         delete [] address;         delete [] address;
         server.runForever();         server.runForever();
     }     }
     catch(Exception& e)     catch(Exception& e)
     {     {
         std::cerr << "Error: " << e.getMessage() << std::endl;          PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl);
     }     }
  
     return 0;     return 0;


Legend:
Removed from v.1.1  
changed lines
  Added in v.1.13

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2