(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.22 and 1.29.2.1

version 1.22, 2004/09/02 02:58:20 version 1.29.2.1, 2005/09/29 03:25:00
Line 1 
Line 1 
 //%2003////////////////////////////////////////////////////////////////////////  //%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.
 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
 // 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.;
   // 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 32 
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 45 
Line 50 
 #include <cstring> #include <cstring>
 #include "System.h" #include "System.h"
 #include "Socket.h" #include "Socket.h"
   #include "CharSet.h"
  
 #ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC #ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC
 # include <windows.h> # include <windows.h>
Line 60 
Line 66 
 # 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 90 
Line 98 
     return true;     return true;
 } }
  
 // ATTN: Move to platform-specific System implementation files and call  
 // strcasecmp where it is available.  
 Sint32 System::strcasecmp(const char* s1, const char* s2) Sint32 System::strcasecmp(const char* s1, const char* s2)
 { {
     while (*s1 && *s2)      // Note: this is faster than glibc strcasecmp().
     {  
         int r = tolower(*s1++) - tolower(*s2++);  
  
         if (r)      Uint8* p = (Uint8*)s1;
             return r;      Uint8* q = (Uint8*)s2;
     }      int r;
   
       for (;;)
       {
           if ((r = CharSet::to_lower(p[0]) - CharSet::to_lower(q[0])) || !p[0] ||
               (r = CharSet::to_lower(p[1]) - CharSet::to_lower(q[1])) || !p[1] ||
               (r = CharSet::to_lower(p[2]) - CharSet::to_lower(q[2])) || !p[2] ||
               (r = CharSet::to_lower(p[3]) - CharSet::to_lower(q[3])) || !p[3])
               break;
  
     if (*s2)          p += 4;
         return -1;          q += 4;
     else if (*s1)      }
         return 1;  
  
     return 0;      return r;
 } }
  
 // Return the just the file name from the path into basename // Return the just the file name from the path into basename
Line 157 
Line 168 
   return dirname;   return dirname;
 } }
  
   String System::getHostIP(const String &hostName)
   {
       struct hostent * phostent;
       struct in_addr   inaddr;
       String ipAddress = String::EMPTY;
       CString csName = hostName.getCString();
       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);
   #ifdef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM
           char * gottenIPAdress = NULL;
           gottenIPAdress = ::inet_ntoa( inaddr );
           __etoa(gottenIPAdress);
           if (gottenIPAdress != NULL)
           {
               ipAddress.assign(gottenIPAdress);
           }
   #else
           ipAddress = ::inet_ntoa( inaddr );
   #endif
       }
       return ipAddress;
   }
  
 // ------------------------------------------------------------------------ // ------------------------------------------------------------------------
 // Convert a hostname into a a single host unique integer representation // Convert a hostname into a a single host unique integer representation
Line 245 
Line 290 
         {         {
                 // 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 270 
Line 318 
         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.22  
changed lines
  Added in v.1.29.2.1

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2