(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.17 and 1.30

version 1.17, 2001/06/07 12:24:21 version 1.30, 2001/07/04 14:16:48
Line 1 
Line 1 
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM  // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a  // Permission is hereby granted, free of charge, to any person obtaining a copy
 // copy of this software and associated documentation files (the "Software"),  // of this software and associated documentation files (the "Software"), to
 // to deal in the Software without restriction, including without limitation  // deal in the Software without restriction, including without limitation the
 // the rights to use, copy, modify, merge, publish, distribute, sublicense,  // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 // and/or sell copies of the Software, and to permit persons to whom the  // sell copies of the Software, and to permit persons to whom the Software is
 // Software is furnished to do so, subject to the following conditions:  // furnished to do so, subject to the following conditions:
 //  //
 // The above copyright notice and this permission notice shall be included in  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 // all copies or substantial portions of the Software.  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 //  // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 //  // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING  
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER  
 // DEALINGS IN THE SOFTWARE.  
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: Mike Brasher (mbrasher@bmc.com) // Author: Mike Brasher (mbrasher@bmc.com)
 // //
 // Modified By: Mike Day (mdday@us.ibm.com) // Modified By: Mike Day (mdday@us.ibm.com)
 =======  // =======
 // Modified By: Karl Schopmeyer (k.schopmeyer@opengroup.org) // Modified By: Karl Schopmeyer (k.schopmeyer@opengroup.org)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
Line 78 
Line 75 
 #include <Pegasus/Protocol/Handler.h> #include <Pegasus/Protocol/Handler.h>
 #include <Pegasus/Common/Logger.h> #include <Pegasus/Common/Logger.h>
 #include <Pegasus/Common/System.h> #include <Pegasus/Common/System.h>
   #include <slp/slp.h>
   
  
  
 #if defined(PEGASUS_OS_TYPE_WINDOWS) #if defined(PEGASUS_OS_TYPE_WINDOWS)
Line 120 
Line 119 
 { {
     static struct OptionRow optionsTable[] =     static struct OptionRow optionsTable[] =
     {     {
         {"port", "8888", false, Option::WHOLE_NUMBER, 0, 0, "port",          {"home", "/etc/pegasus", false, Option::STRING, 0, 0, "D",
                       "Sets the pegasus home directory"},
           {"port", "5988", false, Option::WHOLE_NUMBER, 0, 0, "port",
                         "specifies port number to listen on" },                         "specifies port number to listen on" },
         {"trace", "false", false, Option::BOOLEAN, 0, 0, "t",         {"trace", "false", false, Option::BOOLEAN, 0, 0, "t",
                         "turns on trace of Client IO to console "},                         "turns on trace of Client IO to console "},
Line 139 
Line 140 
                         "Directory for log files"},                         "Directory for log files"},
         {"cleanlogs", "false", false, Option::BOOLEAN, 0, 0, "clean",         {"cleanlogs", "false", false, Option::BOOLEAN, 0, 0, "clean",
                         "Clears the log files at startup"},                         "Clears the log files at startup"},
         {"daemon", "false", false, Option::BOOLEAN, 0, 0, "d",  
                         "Not Used "},  
         {"version", "false", false, Option::BOOLEAN, 0, 0, "v",         {"version", "false", false, Option::BOOLEAN, 0, 0, "v",
                         "Displays Pegasus Version "},                         "Displays Pegasus Version "},
         {"help", "false", false, Option::BOOLEAN, 0, 0, "h",         {"help", "false", false, Option::BOOLEAN, 0, 0, "h",
Line 150 
Line 149 
         {"remove", "false", false, Option::BOOLEAN, 0, 0, "remove",         {"remove", "false", false, Option::BOOLEAN, 0, 0, "remove",
                     "Removes Pegasus as a Windows NT Service "},                     "Removes Pegasus as a Windows NT Service "},
         {"debug", "false", false, Option::BOOLEAN, 0, 0, "d",         {"debug", "false", false, Option::BOOLEAN, 0, 0, "d",
                         "Not Used "}                          "Not Used "},
           {"slp", "false", false, Option::BOOLEAN, 0, 0, "slp",
                           "Register Pegasus as a Service with SLP"}
     };     };
     const Uint32 NUM_OPTIONS = sizeof(optionsTable) / sizeof(optionsTable[0]);     const Uint32 NUM_OPTIONS = sizeof(optionsTable) / sizeof(optionsTable[0]);
  
     om.registerOptions(optionsTable, NUM_OPTIONS);     om.registerOptions(optionsTable, NUM_OPTIONS);
  
     String configFile = pegasusHome + "/cimserver.conf";      String configFile = pegasusHome + "/testclient.conf";
  
     cout << "Config file from " << configFile << endl;     cout << "Config file from " << configFile << endl;
  
Line 186 
Line 187 
 ////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
 int main(int argc, char** argv) int main(int argc, char** argv)
 { {
   
     // on Windows NT if there are no command-line options, run as a service     // on Windows NT if there are no command-line options, run as a service
   
     if (argc == 1 )     if (argc == 1 )
       cim_server_service(argc, argv) ;       cim_server_service(argc, argv) ;
  
     // Get environment variables:      // Get environment variables
  
     String pegasusHome;     String pegasusHome;
  
       for (int i=0; i < argc; i++) {
           if (!strcmp(argv[i],"-D")) {
               i++;
               if (i < argc) pegasusHome = argv[i];
               break;
           }
       }
       if (pegasusHome.size() == 0)
     GetEnvironmentVariables(argv[0], pegasusHome);     GetEnvironmentVariables(argv[0], pegasusHome);
  
     // Get options (from command line and from configuration file); this     // Get options (from command line and from configuration file); this
Line 305 
Line 314 
         Logger::clean(logsDirectory);;         Logger::clean(logsDirectory);;
     }     }
  
       // Option to Display the options table.  Primarily
       // a diagnostic tool.
       if (om.valueEquals("options", "true"))
           om.print();
   
     // Leave this in until people get familiar with the logs.     // Leave this in until people get familiar with the logs.
     cout << "Logs Directory = " << logsDirectory << endl;     cout << "Logs Directory = " << logsDirectory << endl;
  
       Boolean useSLP = (om.valueEquals("slp", "true")) ? true: false;
  
     char* address = portOption.allocateCString();     char* address = portOption.allocateCString();
  
Line 318 
Line 333 
     cout <<"Started..."     cout <<"Started..."
          << (pegasusIOTrace ? " Tracing to Display ": " ")          << (pegasusIOTrace ? " Tracing to Display ": " ")
          << (pegasusIOLog ? " Tracing to Log ": " ")          << (pegasusIOLog ? " Tracing to Log ": " ")
            << (useSLP ? " SLP reg. " : " No SLP ")
         << endl;         << endl;
  
     // Option to Display the options table.  Primarily  
     // a diagnostic tool.  
     if (om.valueEquals("options", "true"))  
         om.print();  
   
     // Put server start message to the logger     // Put server start message to the logger
     Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION,     Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION,
         "Start $0 $1 port $2 $3 ",          "Start $0 $1 port $2 $3 $4",
                 PEGASUS_NAME,                 PEGASUS_NAME,
                 PEGASUS_VERSION,                 PEGASUS_VERSION,
                 address,                 address,
                 (pegasusIOTrace ? " Tracing": " "));                  (pegasusIOTrace ? " Tracing": " "),
                   (useSLP ? " SLP on " : " SLP off "));
  
     // do we need to run as a daemon ?     // do we need to run as a daemon ?
     String daemonOption;     String daemonOption;
Line 345 
Line 357 
     // try loop to bind the address, and run the server     // try loop to bind the address, and run the server
     try     try
     {     {
           slp_client *discovery = new slp_client() ;;
           String serviceURL;
           serviceURL.assign("service:cim.pegasus://");
           String host_name = slp_get_host_name();
           serviceURL += host_name;
           serviceURL += ":";
           serviceURL += address;
           char *url = serviceURL.allocateCString();
           //      free(host_name);
   
         Selector selector;         Selector selector;
         CIMServer server(&selector, pegasusHome);         CIMServer server(&selector, pegasusHome);
  
         // bind throws an exception of the bind fails         // bind throws an exception of the bind fails
         server.bind(address);         server.bind(address);
         delete [] address;         delete [] address;
   
   
   
           time_t last = 0;
           while( 1 )
           {
             if(useSLP  )
             {
               if(  (time(NULL) - last ) > 60 )
               {
                 if( discovery != NULL && url != NULL )
                   discovery->srv_reg_all(url,
                                          "(namespace=root/cimv20)",
                                          "service:cim.pegasus",
                                          "DEFAULT",
                                          70) ;
                 time(&last);
               }
   
               discovery->service_listener();
             }
         server.runForever();         server.runForever();
           }
  
         Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION,         Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION,
             "Normal Termination");             "Normal Termination");
   
     }     }
     catch(Exception& e)     catch(Exception& e)
     {     {
Line 367 
Line 410 
  
     return 0;     return 0;
 } }
   


Legend:
Removed from v.1.17  
changed lines
  Added in v.1.30

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2