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

Diff for /pegasus/src/Pegasus/Common/CommonUTF.cpp between version 1.14 and 1.22

version 1.14, 2005/04/07 19:56:09 version 1.22, 2006/11/30 10:15:17
Line 1 
Line 1 
 //%2005////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // 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 8 
Line 8 
 // 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.; // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 // EMC Corporation; VERITAS Software Corporation; The Open Group. // EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; Symantec 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 25 
Line 27 
 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // 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. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // //
 //==============================================================================  //=============================================================================
 // //
 // Author: Dave Rosckes   (rosckes@us.ibm.com)  //%////////////////////////////////////////////////////////////////////////////
 //  
 // Modified By: David Dillard, VERITAS Software Corp.  
 //                  (david.dillard@veritas.com)  
 //  
 //%/////////////////////////////////////////////////////////////////////////////  
  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #include <Pegasus/Common/Array.h> #include <Pegasus/Common/Array.h>
   #include <Pegasus/Common/Logger.h>
 #include "CommonUTF.h" #include "CommonUTF.h"
 #include <cstdio> #include <cstdio>
 #include <cstring> #include <cstring>
   #include <cctype>
  
 PEGASUS_NAMESPACE_BEGIN  #ifdef PEGASUS_HAS_ICU
   #include <unicode/uclean.h>
   #endif
  
   PEGASUS_NAMESPACE_BEGIN
  
   const Uint32 halfBase = 0x0010000UL;
   const Uint32 halfMask = 0x3FFUL;
   const int halfShift  = 10;
   const Uint8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
   
   const Uint32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
                0x03C82080UL, 0xFA082080UL, 0x82082080UL };
   
   const char trailingBytesForUTF8[256] = {
       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
       2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
   };
 inline Uint8 _hexCharToNumeric(Char16 c) inline Uint8 _hexCharToNumeric(Char16 c)
 { {
     Uint8 n;     Uint8 n;
Line 134 
Line 154 
     Uint8* tgt = *tgtHead;     Uint8* tgt = *tgtHead;
     while (src < srcEnd)     while (src < srcEnd)
     {     {
           if (*src < 128)
           {
               if (tgt == tgtEnd)
               {
                   returnCode = -1;
                   break;
               }
   
               *tgt++ = (Uint8)*src++;
               continue;
           }
   
     Uint32 tempchar;     Uint32 tempchar;
     Uint16 numberOfBytes = 0;     Uint16 numberOfBytes = 0;
     const Uint16* oldsrc = src;     const Uint16* oldsrc = src;
Line 284 
Line 316 
     return returnCode;     return returnCode;
 } }
  
 Boolean isUTF8(const char *legal)  Boolean isUTF8Aux(const char *legal)
 { {
     char numBytes = UTF_8_COUNT_TRAIL_BYTES(*legal)+1;     char numBytes = UTF_8_COUNT_TRAIL_BYTES(*legal)+1;
  
Line 298 
Line 330 
         }         }
     }     }
  
     return (isValid_U8((const Uint8 *)legal, numBytes));      return isValid_U8((const Uint8 *)legal, numBytes);
 } }
  
 Boolean isUTF8Str(const char *legal) Boolean isUTF8Str(const char *legal)
Line 314 
Line 346 
     while(count<size)     while(count<size)
     {     {
 //      printf("count = %d\n",count); //      printf("count = %d\n",count);
         if(isUTF8(&legal[count]) == true){          if (isUTF8(&legal[count]) == true)
           {
             UTF8_NEXT(legal,count);             UTF8_NEXT(legal,count);
         }else{          }
           else
           {
 //          printf("bad string\n"); //          printf("bad string\n");
             return false;             return false;
         }         }
Line 332 
Line 367 
         while(count<size-1)         while(count<size-1)
         {         {
         printf("count = %d\n", count);         printf("count = %d\n", count);
                 if(isUTF8((char*)&legal[count]) == true){          if (isUTF8((char*)&legal[count]) == true)
           {
                     UTF8_NEXT(legal,trailingBytes);                     UTF8_NEXT(legal,trailingBytes);
             count += trailingBytes;             count += trailingBytes;
         } else{          }
           else
           {
             printf("CommonUTF8:: returning false; position[%d]",count);             printf("CommonUTF8:: returning false; position[%d]",count);
              return false;              return false;
         }         }
Line 364 
Line 402 
             escapeStr.append(hexencoding);             escapeStr.append(hexencoding);
     }     }
     }     }
     return(escapeStr);      return escapeStr;
 } }
  
 String escapeStringDecoder(const String& Str) String escapeStringDecoder(const String& Str)
Line 405 
Line 443 
     }     }
 } }
  
   #ifdef PEGASUS_HAS_ICU
   
   Boolean InitializeICU::_initAttempted = false;
   Boolean InitializeICU::_initSuccessful = false;
   Mutex InitializeICU::_initMutex;
   
   Boolean InitializeICU::initICUSuccessful()
   {
       if (!_initAttempted)
       {
           {
               AutoMutex lock(_initMutex);
   
               if (!_initAttempted)
               {
                   UErrorCode _status = U_ZERO_ERROR;
   
                   // Initialize ICU
                   u_init(&_status);
   
                   if (U_FAILURE(_status))
                   {
                       _initSuccessful = false;
                       Logger::put(
                           Logger::STANDARD_LOG , System::CIMSERVER,
                           Logger::WARNING,
                           "ICU initialization failed with error: $0.",
                           _status);
                   }
                   else
                   {
                       _initSuccessful = true;
                   }
                   _initAttempted = true;
               }
           }
       }
   
       return _initSuccessful;
   }
   
   #endif
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.14  
changed lines
  Added in v.1.22

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2