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

Diff for /pegasus/src/Pegasus/Common/System.cpp between version 1.24 and 1.30

version 1.24, 2005/01/17 15:41:44 version 1.30, 2005/10/05 20:45:21
Line 1 
Line 1 
 //%2004////////////////////////////////////////////////////////////////////////  //%2005////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
Line 6 
Line 6 
 // IBM Corp.; EMC Corporation, The Open Group. // IBM Corp.; EMC Corporation, The Open Group.
 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; VERITAS Software Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 34 
Line 36 
 //                                      PEGASUS_OR_IOS_BINARY //                                      PEGASUS_OR_IOS_BINARY
 //              Robert Kieninger, IBM (kieningr@de.ibm.com) for Bug#667 //              Robert Kieninger, IBM (kieningr@de.ibm.com) for Bug#667
 //              Dave Sudlik, IBM (dsudlik@us.ibm.com) for Bug#1462 //              Dave Sudlik, IBM (dsudlik@us.ibm.com) for Bug#1462
   //              Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 62 
Line 65 
 # include "SystemUnix.cpp" # include "SystemUnix.cpp"
 #elif defined(PEGASUS_OS_TYPE_NSK) #elif defined(PEGASUS_OS_TYPE_NSK)
 # include "SystemNsk.cpp" # include "SystemNsk.cpp"
   #elif defined(PEGASUS_OS_VMS)
   # include "SystemVms.cpp"
 #else #else
 # error "Unsupported platform" # error "Unsupported platform"
 #endif #endif
Line 164 
Line 169 
     struct hostent * phostent;     struct hostent * phostent;
     struct in_addr   inaddr;     struct in_addr   inaddr;
     String ipAddress = String::EMPTY;     String ipAddress = String::EMPTY;
       CString csName = hostName.getCString();
     if ((phostent = ::gethostbyname((const char *)hostName.getCString())) != NULL)      const char * ccName = csName;
   #ifndef PEGASUS_OS_OS400
       if ((phostent = ::gethostbyname(ccName)) != NULL)
   #else
       char ebcdicHost[PEGASUS_MAXHOSTNAMELEN];
       if (strlen(ccName) < PEGASUS_MAXHOSTNAMELEN)
           strcpy(ebcdicHost, ccName);
       else
           return ipAddress;
       AtoE(ebcdicHost);
       if ((phostent = ::gethostbyname(ebcdicHost)) != NULL)
   #endif
     {     {
         ::memcpy( &inaddr, phostent->h_addr,4);         ::memcpy( &inaddr, phostent->h_addr,4);
 #ifdef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM #ifdef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM
Line 239 
Line 255 
 #elif defined(PEGASUS_OS_OS400) #elif defined(PEGASUS_OS_OS400)
                 entry = gethostbyname(ebcdicHost);                 entry = gethostbyname(ebcdicHost);
 #elif defined(PEGASUS_OS_ZOS) #elif defined(PEGASUS_OS_ZOS)
                 char hostName[ PEGASUS_MAXHOSTNAMELEN ];                  char hostName[PEGASUS_MAXHOSTNAMELEN + 1];
                 if (String::equalNoCase("localhost",String(hostname)))                 if (String::equalNoCase("localhost",String(hostname)))
                 {                 {
                         gethostname( hostName, PEGASUS_MAXHOSTNAMELEN );                         gethostname( hostName, PEGASUS_MAXHOSTNAMELEN );
                           hostName[sizeof(hostName)-1] = 0;
                         entry = gethostbyname(hostName);                         entry = gethostbyname(hostName);
                 } else                 } else
                 {                 {
Line 270 
Line 287 
         {         {
                 // resolve hostaddr to a real host entry                 // resolve hostaddr to a real host entry
                 // casting to (const char *) as (char *) will work as (void *) too, those it fits all platforms                 // casting to (const char *) as (char *) will work as (void *) too, those it fits all platforms
   #ifndef PEGASUS_OS_OS400
                 entry = gethostbyaddr((const char *) &tmp_addr, sizeof(tmp_addr), AF_INET);                 entry = gethostbyaddr((const char *) &tmp_addr, sizeof(tmp_addr), AF_INET);
   #else
                   entry = gethostbyaddr((char *) &tmp_addr, sizeof(tmp_addr), AF_INET);
   #endif
                 if (entry == 0)                 if (entry == 0)
                 {                 {
                         // error, couldn't resolve the ip                         // error, couldn't resolve the ip
Line 295 
Line 315 
         return ip;         return ip;
 } }
  
   Boolean System::sameHost (const String & hostName)
   {
       //
       //  If a port is included, return false
       //
       if (hostName.find (":") != PEG_NOT_FOUND)
       {
           return false;
       }
   
       //
       //  Retrieve IP addresses for both hostnames
       //
       Uint32 hostNameIP, systemHostIP = 0xFFFFFFFF;
       hostNameIP = System::_acquireIP ((const char *) hostName.getCString ());
       if (hostNameIP == 0x7F000001)
       {
           //
           //  localhost or IP address of 127.0.0.1
           //  real IP address needed for compare
           //
           hostNameIP = System::_acquireIP
               ((const char *) System::getHostName ().getCString ());
       }
       if (hostNameIP == 0xFFFFFFFF)
       {
           //
           //  Malformed IP address or not resolveable
           //
           return false;
       }
   
       systemHostIP = System::_acquireIP
           ((const char *) System::getFullyQualifiedHostName ().getCString ());
   
       if (systemHostIP == 0x7F000001)
       {
           //
           //  localhost or IP address of 127.0.0.1
           //  real IP address needed for compare
           //
           systemHostIP = System::_acquireIP
               ((const char *) System::getHostName ().getCString ());
       }
       if (systemHostIP == 0xFFFFFFFF)
       {
           //
           //  Malformed IP address or not resolveable
           //
           return false;
       }
   
       if (hostNameIP != systemHostIP)
       {
           return false;
       }
   
       return true;
   }
   
 // System ID constants for Logger::put and Logger::trace // System ID constants for Logger::put and Logger::trace
 const String System::CIMLISTENER = "cimlistener"; // Listener systme ID const String System::CIMLISTENER = "cimlistener"; // Listener systme ID
  


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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2