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

Diff for /pegasus/src/Pegasus/Common/XmlReader.cpp between version 1.122 and 1.144.2.1

version 1.122, 2006/11/10 18:14:58 version 1.144.2.1, 2012/12/13 14:29:21
Line 1 
Line 1 
 //%2006////////////////////////////////////////////////////////////////////////  //%LICENSE////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development  // Licensed to The Open Group (TOG) under one or more contributor license
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.  // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;  // this work for additional information regarding copyright ownership.
 // IBM Corp.; EMC Corporation, The Open Group.  // Each contributor licenses this file to you under the OpenPegasus Open
 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;  // Source License; you may not use this file except in compliance with the
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.  // License.
 // 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
 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;  // copy of this software and associated documentation files (the "Software"),
 // EMC Corporation; Symantec Corporation; The Open Group.  // to deal in the Software without restriction, including without limitation
 //  // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 // Permission is hereby granted, free of charge, to any person obtaining a copy  // and/or sell copies of the Software, and to permit persons to whom the
 // of this software and associated documentation files (the "Software"), to  // Software is furnished to do so, subject to the following conditions:
 // deal in the Software without restriction, including without limitation the  //
 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  // The above copyright notice and this permission notice shall be included
 // sell copies of the Software, and to permit persons to whom the Software is  // in all copies or substantial portions of the Software.
 // furnished to do so, subject to the following conditions:  //
 //  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT  // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR  // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT  // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN  // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // 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.  
 // //
 //==============================================================================  //////////////////////////////////////////////////////////////////////////
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
   #include <Pegasus/Common/Constants.h>
 #include <errno.h> #include <errno.h>
 #include <cctype> #include <cctype>
 #include <cstdio> #include <cstdio>
Line 39 
Line 38 
 # include <errno.h> # include <errno.h>
 #endif #endif
 #include "CIMName.h" #include "CIMName.h"
   #include "CIMNameCast.h"
 #include "XmlReader.h" #include "XmlReader.h"
 #include "XmlWriter.h" #include "XmlWriter.h"
 #include "CIMQualifier.h" #include "CIMQualifier.h"
Line 49 
Line 49 
 #include "CIMParamValue.h" #include "CIMParamValue.h"
 #include "System.h" #include "System.h"
 #include "XmlConstants.h" #include "XmlConstants.h"
 #ifdef PEGASUS_PLATFORM_OS400_ISERIES_IBM  
 # include "EBCDIC_OS400.h"  
 #endif  
  
 #include <Pegasus/Common/MessageLoader.h> #include <Pegasus/Common/MessageLoader.h>
   #include <Pegasus/Common/StringConversion.h>
 #include <Pegasus/Common/AutoPtr.h> #include <Pegasus/Common/AutoPtr.h>
 #include "CIMNameUnchecked.h"  
   
 #define PEGASUS_SINT64_MIN (PEGASUS_SINT64_LITERAL(0x8000000000000000))  
 #define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL(0xFFFFFFFFFFFFFFFF)  
  
 PEGASUS_USING_STD; PEGASUS_USING_STD;
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
Line 210 
Line 204 
     {     {
         MessageLoaderParms mlParms(         MessageLoaderParms mlParms(
             "Common.XmlReader.EXPECTED_CDATA",             "Common.XmlReader.EXPECTED_CDATA",
             "Expected content of CDATA");              "Expected content or CDATA");
         throw XmlValidationError(parser.getLine(), mlParms);         throw XmlValidationError(parser.getLine(), mlParms);
     }     }
  
Line 271 
Line 265 
     XmlEntry& entry,     XmlEntry& entry,
     const char* tagName)     const char* tagName)
 { {
     if (!parser.next(entry) ||      if (!parser.next(entry))
        (entry.type != XmlEntry::START_TAG &&      {
           return false;
       }
       if ((entry.type != XmlEntry::START_TAG &&
         entry.type != XmlEntry::EMPTY_TAG) ||         entry.type != XmlEntry::EMPTY_TAG) ||
         strcmp(entry.text, tagName) != 0)         strcmp(entry.text, tagName) != 0)
     {     {
Line 375 
Line 372 
     const char* elementName,     const char* elementName,
     Boolean acceptNull)     Boolean acceptNull)
 { {
     String name;      const char* name;
  
     if (!entry.getAttributeValue("NAME", name))     if (!entry.getAttributeValue("NAME", name))
     {     {
Line 389 
Line 386 
         throw XmlValidationError(lineNumber, mlParms);         throw XmlValidationError(lineNumber, mlParms);
     }     }
  
     if (acceptNull && name.size() == 0)      if (acceptNull && *name == '\0')
         return CIMName ();         return CIMName ();
  
       Uint32 size = CIMNameLegalASCII(name);
   
       if (size)
       {
           String tmp(name, size);
           return CIMName(CIMNameCast(tmp));
       }
   
     if (!CIMName::legal(name))     if (!CIMName::legal(name))
     {     {
 #ifdef PEGASUS_SNIA_INTEROP_TEST #ifdef PEGASUS_SNIA_INTEROP_TEST
Line 412 
Line 417 
  
 #endif #endif
     }     }
     return CIMNameUnchecked(name);  
       return CIMNameCast(name);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 476 
Line 482 
     if (!entry.getAttributeValue("CLASSORIGIN", name))     if (!entry.getAttributeValue("CLASSORIGIN", name))
         return CIMName();         return CIMName();
  
       /* Interoperability hack to make the C++ client of OpenPegasus able
          to deal with the wbemservices CIMOM delivered with Sun Solaris.
          The issue is that the wbemservices delivers Xml responses with
          CLASSORIGIN=""
          Originally this had been reported with Bug#537.
       */
       if (name.size()==0)
       {
           return CIMName();
       }
   
     if (!CIMName::legal(name))     if (!CIMName::legal(name))
     {     {
         char buffer[MESSAGE_SIZE];         char buffer[MESSAGE_SIZE];
Line 487 
Line 504 
             buffer);             buffer);
         throw XmlSemanticError(lineNumber, mlParms);         throw XmlSemanticError(lineNumber, mlParms);
     }     }
       // The CIMName was already checked with legal() + String()
     return name;      return CIMNameCast(name);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // getEmbeddedObjectAttribute() // getEmbeddedObjectAttribute()
 // //
 //     <!ENTITY % EmbeddedObject "EMBEDDEDOBJECT (object | instance) #IMPLIED">  //     <!ENTITY % EmbeddedObject "EmbeddedObject (object | instance) #IMPLIED">
   //
   //     EmbeddedObjectAttributeType:
   //        NO_EMBEDDED_OBJECT     = 0,
   //        EMBEDDED_OBJECT_ATTR   = 1,
   //        EMBEDDED_INSTANCE_ATTR = 2
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 String XmlReader::getEmbeddedObjectAttribute(  XmlReader::EmbeddedObjectAttributeType XmlReader::getEmbeddedObjectAttribute(
     Uint32 lineNumber,     Uint32 lineNumber,
     const XmlEntry& entry,     const XmlEntry& entry,
     const char* elementName)      const char* tagName)
 { {
     String embeddedObject;      const char* embeddedObject;
  
     if (!entry.getAttributeValue("EMBEDDEDOBJECT", embeddedObject))      // Check for both upper case and mixed case "EmbeddedObject"
         return String();      // because of an error in an earlier pegasus version  where we
       // used upper case in the generation of the attribute name
       // whereas the DMTF spec calls for mixed case.
       if (!entry.getAttributeValue("EmbeddedObject", embeddedObject) &&
           !entry.getAttributeValue("EMBEDDEDOBJECT", embeddedObject))
           return NO_EMBEDDED_OBJECT;
  
     // The embeddedObject attribute, if present, must have the string     // The embeddedObject attribute, if present, must have the string
     // value "object" or "instance".     // value "object" or "instance".
     if (!(String::equal(embeddedObject, "object") ||      if (strcmp(embeddedObject, "object") == 0)
           String::equal(embeddedObject, "instance")))  
     {     {
           return EMBEDDED_OBJECT_ATTR;
       }
   
       if (strcmp(embeddedObject, "instance") == 0)
       {
           return EMBEDDED_INSTANCE_ATTR;
       }
   
         char buffer[MESSAGE_SIZE];         char buffer[MESSAGE_SIZE];
         sprintf(buffer, "%s.EMBEDDEDOBJECT", elementName);      sprintf(buffer, "%s.EmbeddedObject", tagName);
  
         MessageLoaderParms mlParms(         MessageLoaderParms mlParms(
             "Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE",             "Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE",
             "Illegal value for $0 attribute",             "Illegal value for $0 attribute",
             buffer);             buffer);
         throw XmlSemanticError(lineNumber, mlParms);         throw XmlSemanticError(lineNumber, mlParms);
     }  
  
     return embeddedObject;      return NO_EMBEDDED_OBJECT;
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 561 
Line 594 
             buffer);             buffer);
         throw XmlSemanticError(lineNumber, mlParms);         throw XmlSemanticError(lineNumber, mlParms);
     }     }
       // The CIMName was already checked with legal() + String()
     return name;      return CIMNameCast(name);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 594 
Line 627 
             buffer);             buffer);
         throw XmlSemanticError(lineNumber, mlParms);         throw XmlSemanticError(lineNumber, mlParms);
     }     }
       // The CIMName was already checked with legal() + String()
     return superClass;      return CIMNameCast(superClass);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 724 
Line 757 
         if (!required)         if (!required)
             return defaultValue;             return defaultValue;
  
         char buffer[62];          char buffer[MESSAGE_SIZE];
         sprintf(buffer, "%s.%s", attributeName, tagName);         sprintf(buffer, "%s.%s", attributeName, tagName);
  
         MessageLoaderParms mlParms(         MessageLoaderParms mlParms(
Line 739 
Line 772 
     else if (strcmp(tmp, "false") == 0)     else if (strcmp(tmp, "false") == 0)
         return false;         return false;
  
     char buffer[62];      char buffer[MESSAGE_SIZE];
     sprintf(buffer, "%s.%s", attributeName, tagName);     sprintf(buffer, "%s.%s", attributeName, tagName);
  
     MessageLoaderParms mlParms(     MessageLoaderParms mlParms(
Line 752 
Line 785 
     return false;     return false;
 } }
  
 //------------------------------------------------------------------------------  
 //  
 // SringToReal()  
 //  
 //      [ "+" | "-" ] *decimalDigit "." 1*decimalDigit  
 //          [ ( "e" | "E" ) [ "+" | "-" ] 1*decimalDigit ]  
 //  
 //------------------------------------------------------------------------------  
   
 Boolean XmlReader::stringToReal(const char* stringValue, Real64& x)  
 {  
     //  
     // Check the string against the DMTF-defined grammar  
     //  
     const char* p = stringValue;  
   
     if (!*p)  
         return false;  
   
     // Skip optional sign:  
   
     if (*p == '+' || *p  == '-')  
         p++;  
   
     // Skip optional first set of digits:  
   
     while (isdigit(*p))  
         p++;  
   
     // Test required dot:  
   
     if (*p++ != '.')  
         return false;  
   
     // One or more digits required:  
   
     if (!isdigit(*p++))  
         return false;  
   
     while (isdigit(*p))  
         p++;  
   
     // If there is an exponent now:  
   
     if (*p)  
     {  
         // Test exponent:  
   
         if (*p != 'e' && *p != 'E')  
             return false;  
   
         p++;  
   
         // Skip optional sign:  
   
         if (*p == '+' || *p  == '-')  
             p++;  
   
         // One or more digits required:  
   
         if (!isdigit(*p++))  
             return false;  
   
         while (isdigit(*p))  
             p++;  
     }  
   
     if (*p)  
         return false;  
   
     //  
     // Do the conversion  
     //  
     char* end;  
     errno = 0;  
     x = strtod(stringValue, &end);  
     if (*end || (errno == ERANGE))  
     {  
         return false;  
     }  
   
     return true;  
 }  
   
 inline Uint8 _xmlReader_hexCharToNumeric(const char c)  
 {  
     Uint8 n;  
   
     if (isdigit(c))  
         n = (c - '0');  
     else if (isupper(c))  
         n = (c - 'A' + 10);  
     else // if (islower(c))  
         n = (c - 'a' + 10);  
   
     return n;  
 }  
   
 // See http://www.ietf.org/rfc/rfc2396.txt section 2 // See http://www.ietf.org/rfc/rfc2396.txt section 2
 // //
 // Also see the "CIM Operations over HTTP" spec, section 3.3.2 and // Also see the "CIM Operations over HTTP" spec, section 3.3.2 and
Line 858 
Line 793 
 { {
     Uint32 i;     Uint32 i;
  
     Array<Uint8> utf8Chars;      Buffer utf8Chars;
  
     for (i=0; i<uriString.size(); i++)     for (i=0; i<uriString.size(); i++)
     {     {
Line 872 
Line 807 
                 throw ParseError(MessageLoader::getMessage(mlParms));                 throw ParseError(MessageLoader::getMessage(mlParms));
             }             }
  
             Uint8 digit1 = _xmlReader_hexCharToNumeric(char(uriString[++i]));              Uint8 digit1 =
             Uint8 digit2 = _xmlReader_hexCharToNumeric(char(uriString[++i]));                  StringConversion::hexCharToNumeric(char(uriString[++i]));
               Uint8 digit2 =
                   StringConversion::hexCharToNumeric(char(uriString[++i]));
             if ( (digit1 > 15) || (digit2 > 15) )             if ( (digit1 > 15) || (digit2 > 15) )
             {             {
                 MessageLoaderParms mlParms(                 MessageLoaderParms mlParms(
Line 883 
Line 820 
             }             }
  
             Uint16 decodedChar = Uint16(digit1<<4) + Uint16(digit2);             Uint16 decodedChar = Uint16(digit1<<4) + Uint16(digit2);
             utf8Chars.append((Uint8)decodedChar);              utf8Chars.append((char)decodedChar);
         }         }
         else         else
         {         {
             utf8Chars.append((Uint8)uriString[i]);              utf8Chars.append((char)uriString[i]);
         }         }
     }     }
  
Line 895 
Line 832 
     if (uriString.size() > 0)     if (uriString.size() > 0)
     {     {
         // Convert UTF-8 to UTF-16 and return the String         // Convert UTF-8 to UTF-16 and return the String
         utf8Chars.append('\0');          return String(utf8Chars.getData(), utf8Chars.size());
         return String((char *)utf8Chars.getData());  
     }     }
     else     else
     {     {
Line 906 
Line 842 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // stringToSignedInteger  
 //  
 //      [ "+" | "-" ] ( positiveDecimalDigit *decimalDigit | "0" )  
 //    or  
 //      [ "+" | "-" ] ( "0x" | "0X" ) 1*hexDigit  
 //  
 //------------------------------------------------------------------------------  
   
 Boolean XmlReader::stringToSignedInteger(  
     const char* stringValue,  
     Sint64& x)  
 {  
     x = 0;  
     const char* p = stringValue;  
   
     if (!p || !*p)  
         return false;  
   
     // Skip optional sign:  
   
     Boolean negative = *p == '-';  
   
     if (negative || *p == '+')  
         p++;  
   
     if (*p == '0')  
     {  
         if ( (p[1] == 'x') || (p[1] == 'X') )  
         {  
             // Convert a hexadecimal string  
   
             // Skip over the "0x"  
             p+=2;  
   
             // At least one hexadecimal digit is required  
             if (!isxdigit(*p))  
                 return false;  
   
             // Build the Sint64 as a negative number, regardless of the  
             // eventual sign (negative numbers can be bigger than positive ones)  
   
             // Add on each digit, checking for overflow errors  
             while (isxdigit(*p))  
             {  
                 // Make sure we won't overflow when we multiply by 16  
                 if (x < PEGASUS_SINT64_MIN/16)  
                 {  
                     return false;  
                 }  
                 x = x << 4;  
   
                 // Make sure we don't overflow when we add the next digit  
                 Sint64 newDigit = Sint64(_xmlReader_hexCharToNumeric(*p++));  
                 if (PEGASUS_SINT64_MIN - x > -newDigit)  
                 {  
                     return false;  
                 }  
                 x = x - newDigit;  
             }  
   
             // If we found a non-hexadecimal digit, report an error  
             if (*p)  
                 return false;  
   
             // Return the integer to positive, if necessary, checking for an  
             // overflow error  
             if (!negative)  
             {  
                 if (x == PEGASUS_SINT64_MIN)  
                 {  
                     return false;  
                 }  
                 x = -x;  
             }  
             return true;  
         }  
         else  
         {  
             // A decimal string that starts with '0' must be exactly "0".  
             return p[1] == '\0';  
         }  
     }  
   
     // Expect a positive decimal digit:  
   
     // At least one decimal digit is required  
     if (!isdigit(*p))  
         return false;  
   
     // Build the Sint64 as a negative number, regardless of the  
     // eventual sign (negative numbers can be bigger than positive ones)  
   
     // Add on each digit, checking for overflow errors  
     while (isdigit(*p))  
     {  
         // Make sure we won't overflow when we multiply by 10  
         if (x < PEGASUS_SINT64_MIN/10)  
         {  
             return false;  
         }  
         x = 10 * x;  
   
         // Make sure we won't overflow when we add the next digit  
         Sint64 newDigit = (*p++ - '0');  
         if (PEGASUS_SINT64_MIN - x > -newDigit)  
         {  
             return false;  
         }  
         x = x - newDigit;  
     }  
   
     // If we found a non-decimal digit, report an error  
     if (*p)  
         return false;  
   
     // Return the integer to positive, if necessary, checking for an  
     // overflow error  
     if (!negative)  
     {  
         if (x == PEGASUS_SINT64_MIN)  
         {  
             return false;  
         }  
         x = -x;  
     }  
     return true;  
 }  
   
 //------------------------------------------------------------------------------  
 //  
 // stringToUnsignedInteger  
 //  
 //      ( positiveDecimalDigit *decimalDigit | "0" )  
 //    or  
 //      ( "0x" | "0X" ) 1*hexDigit  
 //  
 //------------------------------------------------------------------------------  
   
 Boolean XmlReader::stringToUnsignedInteger(  
     const char* stringValue,  
     Uint64& x)  
 {  
     x = 0;  
     const char* p = stringValue;  
   
     if (!p || !*p)  
         return false;  
   
     if (*p == '0')  
     {  
         if ( (p[1] == 'x') || (p[1] == 'X') )  
         {  
             // Convert a hexadecimal string  
   
             // Skip over the "0x"  
             p+=2;  
   
             // At least one hexadecimal digit is required  
             if (!*p)  
                 return false;  
   
             // Add on each digit, checking for overflow errors  
             while (isxdigit(*p))  
             {  
                 // Make sure we won't overflow when we multiply by 16  
                 if (x > PEGASUS_UINT64_MAX/16)  
                 {  
                     return false;  
                 }  
                 x = x << 4;  
   
                 // We can't overflow when we add the next digit  
                 Uint64 newDigit = Uint64(_xmlReader_hexCharToNumeric(*p++));  
                 if (PEGASUS_UINT64_MAX - x < newDigit)  
                 {  
                     return false;  
                 }  
                 x = x + newDigit;  
             }  
   
             // If we found a non-hexadecimal digit, report an error  
             if (*p)  
                 return false;  
   
             return true;  
         }  
         else  
         {  
             // A decimal string that starts with '0' must be exactly "0".  
             return p[1] == '\0';  
         }  
     }  
   
     // Expect a positive decimal digit:  
   
     // Add on each digit, checking for overflow errors  
     while (isdigit(*p))  
     {  
         // Make sure we won't overflow when we multiply by 10  
         if (x > PEGASUS_UINT64_MAX/10)  
         {  
             return false;  
         }  
         x = 10 * x;  
   
         // Make sure we won't overflow when we add the next digit  
         Uint64 newDigit = (*p++ - '0');  
         if (PEGASUS_UINT64_MAX - x < newDigit)  
         {  
             return false;  
         }  
         x = x + newDigit;  
     }  
   
     // If we found a non-decimal digit, report an error  
     if (*p)  
         return false;  
   
     return true;  
 }  
   
 //------------------------------------------------------------------------------  
 //  
 // stringToValue() // stringToValue()
 // //
 // Return: CIMValue. If the string input is zero length creates a CIMValue // Return: CIMValue. If the string input is zero length creates a CIMValue
Line 1143 
Line 856 
     const char* valueString,     const char* valueString,
     CIMType type)     CIMType type)
 { {
       return stringToValue(lineNumber, valueString, strlen(valueString), type);
   }
   
   CIMValue XmlReader::stringToValue(
       Uint32 lineNumber,
       const char* valueString,
       Uint32 valueStringLen,
       CIMType type)
   {
     // ATTN-B: accepting only UTF-8 for now! (affects string and char16):     // ATTN-B: accepting only UTF-8 for now! (affects string and char16):
  
       // Char string must have been null terminated.
       PEGASUS_ASSERT (!valueString[valueStringLen]);
   
     // Create value per type     // Create value per type
     switch (type)     switch (type)
     {     {
Line 1165 
Line 890 
  
         case CIMTYPE_STRING:         case CIMTYPE_STRING:
         {         {
             return CIMValue(String(valueString));              return CIMValue(String(valueString, valueStringLen));
         }         }
  
         case CIMTYPE_CHAR16:         case CIMTYPE_CHAR16:
         {         {
   
 // remove this test, utf-8 can be up to 6 bytes per char  
 /*  
             if (strlen(valueString) != 1)  
             {  
                 MessageLoaderParms mlParms(  
                     "Common.XmlReader.INVALID_CHAR16_VALUE",  
                     "Invalid char16 value");  
                 throw XmlSemanticError(lineNumber, mlParms);  
             }  
 */  
             // Converts UTF-8 to UTF-16             // Converts UTF-8 to UTF-16
             String tmp(valueString);              String tmp(valueString, valueStringLen);
             if (tmp.size() != 1)             if (tmp.size() != 1)
             {             {
                 MessageLoaderParms mlParms(                 MessageLoaderParms mlParms(
Line 1201 
Line 915 
         {         {
             Uint64 x;             Uint64 x;
  
             if (!stringToUnsignedInteger(valueString, x))              if (!StringConversion::stringToUnsignedInteger(valueString, x))
             {             {
                 MessageLoaderParms mlParms(                 MessageLoaderParms mlParms(
                     "Common.XmlReader.INVALID_UI_VALUE",                     "Common.XmlReader.INVALID_UI_VALUE",
Line 1213 
Line 927 
             {             {
                 case CIMTYPE_UINT8:                 case CIMTYPE_UINT8:
                 {                 {
                     if (x >= (Uint64(1)<<8))                      if (!StringConversion::checkUintBounds(x, type))
                     {                     {
                         MessageLoaderParms mlParms(                         MessageLoaderParms mlParms(
                             "Common.XmlReader.U8_VALUE_OUT_OF_RANGE",                             "Common.XmlReader.U8_VALUE_OUT_OF_RANGE",
Line 1224 
Line 938 
                 }                 }
                 case CIMTYPE_UINT16:                 case CIMTYPE_UINT16:
                 {                 {
                     if (x >= (Uint64(1)<<16))                      if (!StringConversion::checkUintBounds(x, type))
                     {                     {
                         MessageLoaderParms mlParms(                         MessageLoaderParms mlParms(
                             "Common.XmlReader.U16_VALUE_OUT_OF_RANGE",                             "Common.XmlReader.U16_VALUE_OUT_OF_RANGE",
Line 1235 
Line 949 
                 }                 }
                 case CIMTYPE_UINT32:                 case CIMTYPE_UINT32:
                 {                 {
                     if (x >= (Uint64(1)<<32))                      if (!StringConversion::checkUintBounds(x, type))
                     {                     {
                         MessageLoaderParms mlParms(                         MessageLoaderParms mlParms(
                             "Common.XmlReader.U32_VALUE_OUT_OF_RANGE",                             "Common.XmlReader.U32_VALUE_OUT_OF_RANGE",
Line 1256 
Line 970 
         {         {
             Sint64 x;             Sint64 x;
  
             if (!stringToSignedInteger(valueString, x))              if (!StringConversion::stringToSignedInteger(valueString, x))
             {             {
                 MessageLoaderParms mlParms(                 MessageLoaderParms mlParms(
                     "Common.XmlReader.INVALID_SI_VALUE",                     "Common.XmlReader.INVALID_SI_VALUE",
Line 1268 
Line 982 
             {             {
                 case CIMTYPE_SINT8:                 case CIMTYPE_SINT8:
                 {                 {
                     if ((x >= (Sint64(1)<<7)) || (x < (-(Sint64(1)<<7))))                      if (!StringConversion::checkSintBounds(x, type))
                     {                     {
                         MessageLoaderParms mlParms(                         MessageLoaderParms mlParms(
                             "Common.XmlReader.S8_VALUE_OUT_OF_RANGE",                             "Common.XmlReader.S8_VALUE_OUT_OF_RANGE",
Line 1279 
Line 993 
                 }                 }
                 case CIMTYPE_SINT16:                 case CIMTYPE_SINT16:
                 {                 {
                     if ((x >= (Sint64(1)<<15)) || (x < (-(Sint64(1)<<15))))                      if (!StringConversion::checkSintBounds(x, type))
                     {                     {
                         MessageLoaderParms mlParms(                         MessageLoaderParms mlParms(
                             "Common.XmlReader.S16_VALUE_OUT_OF_RANGE",                             "Common.XmlReader.S16_VALUE_OUT_OF_RANGE",
Line 1290 
Line 1004 
                 }                 }
                 case CIMTYPE_SINT32:                 case CIMTYPE_SINT32:
                 {                 {
                     if ((x >= (Sint64(1)<<31)) || (x < (-(Sint64(1)<<31))))                      if (!StringConversion::checkSintBounds(x, type))
                     {                     {
                         MessageLoaderParms mlParms(                         MessageLoaderParms mlParms(
                             "Common.XmlReader.S32_VALUE_OUT_OF_RANGE",                             "Common.XmlReader.S32_VALUE_OUT_OF_RANGE",
Line 1315 
Line 1029 
                 // Bugzilla 137  Adds the following if line.                 // Bugzilla 137  Adds the following if line.
                 // Expect this to become permanent but test only for now                 // Expect this to become permanent but test only for now
 #ifdef PEGASUS_SNIA_INTEROP_TEST #ifdef PEGASUS_SNIA_INTEROP_TEST
                 if (strlen(valueString) != 0)                  if (valueStringLen != 0)
 #endif #endif
                     tmp.set(valueString);                     tmp.set(valueString);
             }             }
Line 1334 
Line 1048 
         {         {
             Real64 x;             Real64 x;
  
             if (!stringToReal(valueString, x))              if (!StringConversion::stringToReal64(valueString, x))
             {             {
                 MessageLoaderParms mlParms(                 MessageLoaderParms mlParms(
                     "Common.XmlReader.INVALID_RN_VALUE",                     "Common.XmlReader.INVALID_RN_VALUE",
Line 1348 
Line 1062 
         {         {
             Real64 x;             Real64 x;
  
             if (!stringToReal(valueString, x))              if (!StringConversion::stringToReal64(valueString, x))
             {             {
                 MessageLoaderParms mlParms(                 MessageLoaderParms mlParms(
                     "Common.XmlReader.INVALID_RN_VALUE",                     "Common.XmlReader.INVALID_RN_VALUE",
Line 1363 
Line 1077 
 //  just a Pegasus internal representation of an embedded object. However, //  just a Pegasus internal representation of an embedded object. However,
 //  this case is used when decoding string representations of embedded objects. //  this case is used when decoding string representations of embedded objects.
         case CIMTYPE_OBJECT:         case CIMTYPE_OBJECT:
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         case CIMTYPE_INSTANCE:         case CIMTYPE_INSTANCE:
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         {         {
             CIMObject x;             CIMObject x;
  
Line 1382 
Line 1094 
                 // just the value of the Embedded Object in String                 // just the value of the Embedded Object in String
                 // representation.                 // representation.
                 AutoArrayPtr<char> tmp_buffer(                 AutoArrayPtr<char> tmp_buffer(
                     new char[strlen(valueString) + 1]);                      new char[valueStringLen + 1]);
                 strcpy(tmp_buffer.get(), valueString);                  memcpy(tmp_buffer.get(), valueString, valueStringLen + 1);
                 XmlParser tmp_parser(tmp_buffer.get());                 XmlParser tmp_parser(tmp_buffer.get());
  
                 // The next bit of logic constructs a CIMObject from the                 // The next bit of logic constructs a CIMObject from the
Line 1394 
Line 1106 
  
                 if (XmlReader::getInstanceElement(tmp_parser, cimInstance))                 if (XmlReader::getInstanceElement(tmp_parser, cimInstance))
                 {                 {
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
                     if (type == CIMTYPE_INSTANCE)                     if (type == CIMTYPE_INSTANCE)
                         return CIMValue(cimInstance);                         return CIMValue(cimInstance);
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
                     x = CIMObject(cimInstance);                     x = CIMObject(cimInstance);
                 }                 }
                 else if (XmlReader::getClassElement(tmp_parser, cimClass))                 else if (XmlReader::getClassElement(tmp_parser, cimClass))
Line 1406 
Line 1116 
                 }                 }
                 else                 else
                 {                 {
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
                     if (type == CIMTYPE_OBJECT)                     if (type == CIMTYPE_OBJECT)
                     {                     {
                         // change "element" to "embedded object"                         // change "element" to "embedded object"
Line 1424 
Line 1133 
                             "Expected INSTANCE element");                             "Expected INSTANCE element");
                         throw XmlValidationError(lineNumber, mlParms);                         throw XmlValidationError(lineNumber, mlParms);
                     }                     }
 #else  
                     // change "element" to "embedded object"  
                     MessageLoaderParms mlParms(  
                         "Common.XmlReader.EXPECTED_INSTANCE_OR_CLASS_ELEMENT",  
                         "Expected INSTANCE or CLASS element");  
                     throw XmlValidationError(lineNumber, mlParms);  
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
                 }                 }
                 // Ok, now we can delete the storage for the temporary                 // Ok, now we can delete the storage for the temporary
                 // XmlParser.                 // XmlParser.
Line 1507 
Line 1209 
     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
  
     const char* valueString = "";     const char* valueString = "";
       Uint32 valueStringLen = 0;
     if (!empty)     if (!empty)
     {     {
         if (testContentOrCData(parser, entry))         if (testContentOrCData(parser, entry))
         {         {
             valueString = entry.text;             valueString = entry.text;
               valueStringLen = entry.textLen;
         }         }
  
         expectEndTag(parser, "VALUE");         expectEndTag(parser, "VALUE");
Line 1524 
Line 1227 
     // Bugzilla tbd     // Bugzilla tbd
     if (!empty)     if (!empty)
 #endif #endif
         value = stringToValue(parser.getLine(), valueString,type);          value = stringToValue(
               parser.getLine(),
               valueString,
               valueStringLen,
               type);
  
     return true;     return true;
 } }
Line 1559 
Line 1266 
     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
  
     const char* valueString = "";     const char* valueString = "";
       Uint32 valueStringLen = 0;
  
     if (!empty)     if (!empty)
     {     {
         if (testContentOrCData(parser, entry))         if (testContentOrCData(parser, entry))
           {
             valueString = entry.text;             valueString = entry.text;
               valueStringLen = entry.textLen;
           }
  
         expectEndTag(parser, "VALUE");         expectEndTag(parser, "VALUE");
     }     }
  
     str = String(valueString);      str = String(valueString, valueStringLen);
     return true;     return true;
 } }
  
Line 1637 
Line 1348 
 template<class T> template<class T>
 CIMValue StringArrayToValueAux( CIMValue StringArrayToValueAux(
     Uint32 lineNumber,     Uint32 lineNumber,
     const Array<const char*>& stringArray,      const Array<CharString>& stringArray,
     CIMType type,     CIMType type,
     T*)     T*)
 { {
Line 1646 
Line 1357 
     for (Uint32 i = 0, n = stringArray.size(); i < n; i++)     for (Uint32 i = 0, n = stringArray.size(); i < n; i++)
     {     {
         CIMValue value = XmlReader::stringToValue(         CIMValue value = XmlReader::stringToValue(
             lineNumber, stringArray[i], type);              lineNumber,
               stringArray[i].value,
               stringArray[i].length,
               type);
  
         T x;         T x;
         value.get(x);         value.get(x);
Line 1661 
Line 1375 
     const Array<const char*>& array,     const Array<const char*>& array,
     CIMType type)     CIMType type)
 { {
       Array<CharString> strArray;
   
       for (Uint32 i = 0, n = array.size() ; i < n ; ++i)
       {
           strArray.append(CharString(array[i], strlen(array[i])));
       }
   
       return _stringArrayToValue(lineNumber, strArray, type);
   }
   
   CIMValue XmlReader::_stringArrayToValue(
       Uint32 lineNumber,
       const Array<CharString> &array,
       CIMType type)
   {
     switch (type)     switch (type)
     {     {
         case CIMTYPE_BOOLEAN:         case CIMTYPE_BOOLEAN:
Line 1713 
Line 1442 
         case CIMTYPE_OBJECT:         case CIMTYPE_OBJECT:
             return StringArrayToValueAux(             return StringArrayToValueAux(
                 lineNumber, array, type, (CIMObject*)0);                 lineNumber, array, type, (CIMObject*)0);
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         case CIMTYPE_INSTANCE:         case CIMTYPE_INSTANCE:
             return StringArrayToValueAux(             return StringArrayToValueAux(
                 lineNumber, array, type, (CIMInstance*)0);                 lineNumber, array, type, (CIMInstance*)0);
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
   
         default:         default:
             break;             break;
     }     }
Line 1748 
Line 1474 
     // Get VALUE.ARRAY open tag:     // Get VALUE.ARRAY open tag:
  
     XmlEntry entry;     XmlEntry entry;
     Array<const char*> stringArray;      Array<CharString> stringArray;
  
     // If no VALUE.ARRAY start tag, return false     // If no VALUE.ARRAY start tag, return false
     if (!testStartTagOrEmptyTag(parser, entry, "VALUE.ARRAY"))     if (!testStartTagOrEmptyTag(parser, entry, "VALUE.ARRAY"))
Line 1760 
Line 1486 
  
         while (testStartTagOrEmptyTag(parser, entry, "VALUE"))         while (testStartTagOrEmptyTag(parser, entry, "VALUE"))
         {         {
               // ATTN: NULL values in array will have VALUE.NULL subelement
               // See DSP0201 Version 2.3.0, Section 5.2.3.2
             if (entry.type == XmlEntry::EMPTY_TAG)             if (entry.type == XmlEntry::EMPTY_TAG)
             {             {
                 stringArray.append("");                  stringArray.append(CharString("", 0));
                 continue;                 continue;
             }             }
  
             if (testContentOrCData(parser, entry))             if (testContentOrCData(parser, entry))
                 stringArray.append(entry.text);              {
                   stringArray.append(CharString(entry.text, entry.textLen));
               }
             else             else
                 stringArray.append("");              {
                   stringArray.append(CharString("", 0));
               }
             expectEndTag(parser, "VALUE");             expectEndTag(parser, "VALUE");
         }         }
  
         expectEndTag(parser, "VALUE.ARRAY");         expectEndTag(parser, "VALUE.ARRAY");
     }     }
  
     value = stringArrayToValue(parser.getLine(), stringArray, type);      value = _stringArrayToValue(parser.getLine(), stringArray, type);
     return true;     return true;
 } }
  
Line 2042 
Line 1773 
     Boolean propagated = getCimBooleanAttribute(     Boolean propagated = getCimBooleanAttribute(
         parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false);         parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false);
  
     // Get PROPERTY.EMBEDDEDOBJECT attribute:      // Get PROPERTY.EmbeddedObject attribute:
  
     String embeddedObject = getEmbeddedObjectAttribute(      EmbeddedObjectAttributeType embeddedObject =
         parser.getLine(), entry, "PROPERTY");          getEmbeddedObjectAttribute(parser.getLine(), entry, "PROPERTY");
  
     // Get PROPERTY.TYPE attribute:     // Get PROPERTY.TYPE attribute:
  
Line 2066 
Line 1797 
     }     }
  
     Boolean embeddedObjectQualifierValue = false;     Boolean embeddedObjectQualifierValue = false;
     Uint32 ix = property.findQualifier(CIMName("EmbeddedObject"));      Uint32 ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT);
     if (ix != PEG_NOT_FOUND)     if (ix != PEG_NOT_FOUND)
     {     {
         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);
     }     }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     String embeddedInstanceQualifierValue;     String embeddedInstanceQualifierValue;
     ix = property.findQualifier(CIMName("EmbeddedInstance"));      ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE);
     if (ix != PEG_NOT_FOUND)     if (ix != PEG_NOT_FOUND)
     {     {
         property.getQualifier(ix).getValue().get(         property.getQualifier(ix).getValue().get(
             embeddedInstanceQualifierValue);             embeddedInstanceQualifierValue);
     }     }
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT      // If the EmbeddedObject attribute is present with value "object"
     // If the EMBEDDEDOBJECT attribute is present with value "object"  
     // or the EmbeddedObject qualifier exists on this property with value "true"     // or the EmbeddedObject qualifier exists on this property with value "true"
     // then      // then convert the EmbeddedObject-encoded string into a CIMObject
     //     Convert the EmbeddedObject-encoded string into a CIMObject      Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) ||
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     Boolean isEmbeddedObject = String::equal(embeddedObject, "object") ||  
         embeddedObjectQualifierValue;         embeddedObjectQualifierValue;
     Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance") ||      Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) ||
         embeddedInstanceQualifierValue.size() > 0;         embeddedInstanceQualifierValue.size() > 0;
     if (isEmbeddedObject || isEmbeddedInstance)     if (isEmbeddedObject || isEmbeddedInstance)
     {     {
         // The EMBEDDEDOBJECT attribute is only valid on Properties of type          // The EmbeddedObject attribute is only valid on Properties of type
         // string         // string
         if (type == CIMTYPE_STRING)         if (type == CIMTYPE_STRING)
         {         {
Line 2105 
Line 1832 
  
             // Copy the qualifiers from the String property to the CIMObject             // Copy the qualifiers from the String property to the CIMObject
             // property.             // property.
             for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix)              for (Uint32 i = 0; i < property.getQualifierCount(); ++i)
             {  
                 // All properties are copied, including the EmbeddedObject  
                 // qualifier.  This way we don't have to keep track to know  
                 // that the EmbeddedObject qualifier needs to be added back  
                 // during the encode step.  
                 new_property.addQualifier(property.getQualifier(ix));  
             }  
   
             value = new_value;  
             property = new_property;  
         }  
         else  
         {  
             MessageLoaderParms mlParms(  
                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",  
                 "The EMBEDDEDOBJECT attribute is only valid on string types.");  
             throw XmlValidationError(parser.getLine(), mlParms);  
         }  
     }  
 #else  
     if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue)  
     {  
         // The EMBEDDEDOBJECT attribute is only valid on Properties of type  
         // string  
         if (type == CIMTYPE_STRING)  
         {  
             type = CIMTYPE_OBJECT;  
             CIMValue new_value(type, false);  
             CIMProperty new_property = CIMProperty(  
                 name, new_value, 0, CIMName(), classOrigin, propagated);  
   
             // Copy the qualifiers from the String property to the CIMObject  
             // property.  
             for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix)  
             {             {
                 // All properties are copied, including the EmbeddedObject                 // All properties are copied, including the EmbeddedObject
                 // qualifier.  This way we don't have to keep track to know                 // qualifier.  This way we don't have to keep track to know
                 // that the EmbeddedObject qualifier needs to be added back                 // that the EmbeddedObject qualifier needs to be added back
                 // during the encode step.                 // during the encode step.
                 new_property.addQualifier(property.getQualifier(ix));                  new_property.addQualifier(property.getQualifier(i));
             }             }
  
             value = new_value;             value = new_value;
Line 2155 
Line 1848 
         {         {
             MessageLoaderParms mlParms(             MessageLoaderParms mlParms(
                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",
                 "The EMBEDDEDOBJECT attribute is only valid on string types.");                  "The EmbeddedObject attribute is only valid on string types.");
             throw XmlValidationError(parser.getLine(), mlParms);             throw XmlValidationError(parser.getLine(), mlParms);
         }         }
     }     }
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     // Continue on to get property value, if not empty.     // Continue on to get property value, if not empty.
     if (!empty)     if (!empty)
     {     {
Line 2195 
Line 1887 
  
     Uint64 arraySize;     Uint64 arraySize;
  
     if (!stringToUnsignedInteger(tmp, arraySize) || arraySize == 0)      if (!StringConversion::stringToUnsignedInteger(tmp, arraySize) ||
           (arraySize == 0) ||
           !StringConversion::checkUintBounds(arraySize, CIMTYPE_UINT32))
     {     {
         char message[128];         char message[128];
         sprintf(message, "%s.%s", tagName, "ARRAYSIZE");         sprintf(message, "%s.%s", tagName, "ARRAYSIZE");
Line 2269 
Line 1963 
         false,         false,
         false);         false);
  
     // Get PROPERTY.EMBEDDEDOBJECT attribute:      // Get PROPERTY.EmbeddedObject attribute:
  
     String embeddedObject = getEmbeddedObjectAttribute(      EmbeddedObjectAttributeType embeddedObject = getEmbeddedObjectAttribute(
         parser.getLine(), entry, "PROPERTY.ARRAY");         parser.getLine(), entry, "PROPERTY.ARRAY");
  
     // Create property:     // Create property:
Line 2287 
Line 1981 
     }     }
  
     Boolean embeddedObjectQualifierValue = false;     Boolean embeddedObjectQualifierValue = false;
     Uint32 ix = property.findQualifier(CIMName("EmbeddedObject"));      Uint32 ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT);
     if (ix != PEG_NOT_FOUND)     if (ix != PEG_NOT_FOUND)
     {     {
         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);
     }     }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     String embeddedInstanceQualifierValue;     String embeddedInstanceQualifierValue;
     ix = property.findQualifier(CIMName("EmbeddedInstance"));      ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE);
     if (ix != PEG_NOT_FOUND)     if (ix != PEG_NOT_FOUND)
     {     {
         property.getQualifier(ix).getValue().get(         property.getQualifier(ix).getValue().get(
             embeddedInstanceQualifierValue);             embeddedInstanceQualifierValue);
     }     }
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT      // If the EmbeddedObject attribute is present with value "object"
     // If the EMBEDDEDOBJECT attribute is present with value "object"  
     // or the EmbeddedObject qualifier exists on this property with value "true"     // or the EmbeddedObject qualifier exists on this property with value "true"
     // then     // then
     //     Convert the EmbeddedObject-encoded string into a CIMObject     //     Convert the EmbeddedObject-encoded string into a CIMObject
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT      Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) ||
     Boolean isEmbeddedObject = String::equal(embeddedObject, "object") ||  
         embeddedObjectQualifierValue;         embeddedObjectQualifierValue;
     Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance") ||      Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) ||
         embeddedInstanceQualifierValue.size() > 0;         embeddedInstanceQualifierValue.size() > 0;
     if (isEmbeddedObject || isEmbeddedInstance)     if (isEmbeddedObject || isEmbeddedInstance)
     {     {
         // The EMBEDDEDOBJECT attribute is only valid on Properties of type          // The EmbeddedObject attribute is only valid on Properties of type
         // string         // string
         if (type == CIMTYPE_STRING)         if (type == CIMTYPE_STRING)
         {         {
Line 2326 
Line 2017 
  
             // Copy the qualifiers from the String property to the CIMObject             // Copy the qualifiers from the String property to the CIMObject
             // property.             // property.
             for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix)              for (Uint32 i = 0; i < property.getQualifierCount(); ++i)
             {             {
                 // All properties are copied, including the EmbeddedObject                 // All properties are copied, including the EmbeddedObject
                 // qualifier.  This way we don't have to keep track to know                 // qualifier.  This way we don't have to keep track to know
                 // that the EmbeddedObject qualifier needs to be added back                 // that the EmbeddedObject qualifier needs to be added back
                 // during the encode step.                 // during the encode step.
                 new_property.addQualifier(property.getQualifier(ix));                  new_property.addQualifier(property.getQualifier(i));
             }             }
  
             value = new_value;             value = new_value;
Line 2342 
Line 2033 
         {         {
             MessageLoaderParms mlParms(             MessageLoaderParms mlParms(
                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",
                 "The EMBEDDEDOBJECT attribute is only valid on string types.");                  "The EmbeddedObject attribute is only valid on string types.");
             throw XmlValidationError(parser.getLine(), mlParms);             throw XmlValidationError(parser.getLine(), mlParms);
         }         }
     }     }
 #else  
     if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue)  
     {  
         // The EMBEDDEDOBJECT attribute is only valid on Properties of type  
         // string  
         if (type == CIMTYPE_STRING)  
         {  
             type = CIMTYPE_OBJECT;  
             CIMValue new_value(type, true, arraySize);  
             CIMProperty new_property = CIMProperty(  
                 name, new_value, arraySize, CIMName(), classOrigin, propagated);  
   
             // Copy the qualifiers from the String property to the CIMObject  
             // property.  
             for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix)  
             {  
                 // All properties are copied, including the EmbeddedObject  
                 // qualifier.  This way we don't have to keep track to know  
                 // that the EmbeddedObject qualifier needs to be added back  
                 // during the encode step.  
                 new_property.addQualifier(property.getQualifier(ix));  
             }  
   
             value = new_value;  
             property = new_property;  
         }  
         else  
         {  
             MessageLoaderParms mlParms(  
                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",  
                 "The EMBEDDEDOBJECT attribute is only valid on string types.");  
             throw XmlValidationError(parser.getLine(), mlParms);  
         }  
     }  
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     // Continue on to get property array value, if not empty.     // Continue on to get property array value, if not empty.
     // Else not an embedded object, if not empty, get the property array value.     // Else not an embedded object, if not empty, get the property array value.
     if (!empty)     if (!empty)
Line 2613 
Line 2269 
     const XmlEntry& entry,     const XmlEntry& entry,
     const char* elementName)     const char* elementName)
 { {
     String tmp;      const char* tmp;
  
     if (!entry.getAttributeValue("VALUETYPE", tmp))     if (!entry.getAttributeValue("VALUETYPE", tmp))
         return CIMKeyBinding::STRING;         return CIMKeyBinding::STRING;
  
     if (String::equal(tmp, "string"))      if (strcmp(tmp, "string") == 0)
         return CIMKeyBinding::STRING;         return CIMKeyBinding::STRING;
     else if (String::equal(tmp, "boolean"))      else if (strcmp(tmp, "boolean") == 0)
         return CIMKeyBinding::BOOLEAN;         return CIMKeyBinding::BOOLEAN;
     else if (String::equal(tmp, "numeric"))      else if (strcmp(tmp, "numeric") == 0)
         return CIMKeyBinding::NUMERIC;         return CIMKeyBinding::NUMERIC;
  
     char buffer[MESSAGE_SIZE];     char buffer[MESSAGE_SIZE];
Line 2778 
Line 2434 
     else     else
     {     {
         while (getKeyBindingElement(parser, name, value, type))         while (getKeyBindingElement(parser, name, value, type))
           {
             keyBindings.append(CIMKeyBinding(name, value, type));             keyBindings.append(CIMKeyBinding(name, value, type));
               if (keyBindings.size() > PEGASUS_MAXELEMENTS_NUM)
               {
                   MessageLoaderParms mlParms(
                       "Common.XmlReader.TOO_MANY_KEYBINDINGS",
                       "More than $0 key-value pairs per object path"
                           " are not supported.",
                       PEGASUS_MAXELEMENTS_NUM);
                   throw XmlValidationError(parser.getLine(), mlParms);
               }
           }
     }     }
  
     expectEndTag(parser, "INSTANCENAME");     expectEndTag(parser, "INSTANCENAME");
Line 3549 
Line 3216 
  
     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
  
     CIMName name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY");      CIMName name = getCimNameAttribute(parser.getLine(), entry, "METHOD");
  
     CIMType type;     CIMType type;
     getCimTypeAttribute(parser.getLine(), entry, type, "PROPERTY");      getCimTypeAttribute(parser.getLine(), entry, type, "METHOD");
  
     CIMName classOrigin =     CIMName classOrigin =
         getClassOriginAttribute(parser.getLine(), entry, "PROPERTY");          getClassOriginAttribute(parser.getLine(), entry, "METHOD");
  
     Boolean propagated = getCimBooleanAttribute(     Boolean propagated = getCimBooleanAttribute(
         parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false);          parser.getLine(), entry, "METHOD", "PROPAGATED", false, false);
  
     method = CIMMethod(name, type, classOrigin, propagated);     method = CIMMethod(name, type, classOrigin, propagated);
  
Line 4251 
Line 3918 
         objectName.set(String(), CIMNamespaceName(), className);         objectName.set(String(), CIMNamespaceName(), className);
         return true;         return true;
     }     }
     else if (getInstanceNameElement(parser, objectName))  
         return true;      if (!getInstanceNameElement(parser, objectName))
     else  
     {     {
         MessageLoaderParms mlParms(         MessageLoaderParms mlParms(
             "Common.XmlReader.EXPECTED_CLASSNAME_OR_INSTANCENAME_ELEMENT",             "Common.XmlReader.EXPECTED_CLASSNAME_OR_INSTANCENAME_ELEMENT",
Line 4261 
Line 3927 
         throw XmlValidationError(parser.getLine(), mlParms);         throw XmlValidationError(parser.getLine(), mlParms);
     }     }
  
     PEGASUS_UNREACHABLE( return false; )      return true;
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 4279 
Line 3945 
     if (!testStartTag(parser, entry, "OBJECTPATH"))     if (!testStartTag(parser, entry, "OBJECTPATH"))
         return false;         return false;
  
     if (getClassPathElement(parser, objectPath))      if (!getClassPathElement(parser, objectPath) &&
     {          !getInstancePathElement(parser, objectPath))
         expectEndTag(parser, "OBJECTPATH");  
         return true;  
     }  
     else if (getInstancePathElement(parser, objectPath))  
     {  
         expectEndTag(parser, "OBJECTPATH");  
         return true;  
     }  
     else  
     {     {
         MessageLoaderParms mlParms(         MessageLoaderParms mlParms(
             "Common.XmlReader.EXPECTED_INSTANCEPATH_OR_CLASSPATH_ELEMENT",             "Common.XmlReader.EXPECTED_INSTANCEPATH_OR_CLASSPATH_ELEMENT",
Line 4297 
Line 3954 
         throw XmlValidationError(parser.getLine(), mlParms);         throw XmlValidationError(parser.getLine(), mlParms);
     }     }
  
     PEGASUS_UNREACHABLE(return false;)      expectEndTag(parser, "OBJECTPATH");
       return true;
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 4490 
Line 4148 
         throw XmlValidationError(parser.getLine(), mlParms);         throw XmlValidationError(parser.getLine(), mlParms);
     }     }
  
     // Get PROPERTY.EMBEDDEDOBJECT      // Get PROPERTY.EmbeddedObject
  
     String embeddedObject = getEmbeddedObjectAttribute(      EmbeddedObjectAttributeType embeddedObject = getEmbeddedObjectAttribute(
         parser.getLine(), entry, "PARAMVALUE");         parser.getLine(), entry, "PARAMVALUE");
  
     // Get PARAMVALUE.PARAMTYPE attribute:     // Get PARAMVALUE.PARAMTYPE attribute:
Line 4521 
Line 4179 
                 type = CIMTYPE_REFERENCE;                 type = CIMTYPE_REFERENCE;
                 gotType = true;                 gotType = true;
             }             }
             // If type==reference but no VALUE.REFERENCE found, use null value              else
               {
                   gotType = false; // Can't distinguish array and non-array types
               }
         }         }
  
         // Parse non-reference value         // Parse non-reference value
Line 4538 
Line 4199 
                 effectiveType = type;                 effectiveType = type;
             }             }
  
             // If the EMBEDDEDOBJECT attribute is present with value "object"              // If the EmbeddedObject attribute is present with value "object"
             // then             // then
             //     Convert the EmbeddedObject-encoded string into a CIMObject             //     Convert the EmbeddedObject-encoded string into a CIMObject
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT              if (embeddedObject != NO_EMBEDDED_OBJECT)
             Boolean isEmbeddedObject = String::equal(embeddedObject, "object");  
             Boolean isEmbeddedInstance =  
                 String::equal(embeddedObject, "instance");  
             if (isEmbeddedObject || isEmbeddedInstance)  
             {             {
                 // The EMBEDDEDOBJECT attribute is only valid on Parameters                  // The EmbeddedObject attribute is only valid on Parameters
                 // of type string                 // of type string
                 // The type must have been specified.                 // The type must have been specified.
                 if (gotType && (type == CIMTYPE_STRING))                 if (gotType && (type == CIMTYPE_STRING))
                 {                 {
                   if (isEmbeddedObject)                    if (embeddedObject == EMBEDDED_OBJECT_ATTR)
                       // Used below by getValueElement() or                       // Used below by getValueElement() or
                       // getValueArrayElement()                       // getValueArrayElement()
                       effectiveType = CIMTYPE_OBJECT;                       effectiveType = CIMTYPE_OBJECT;
Line 4563 
Line 4220 
                 {                 {
                     MessageLoaderParms mlParms(                     MessageLoaderParms mlParms(
                         "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",                         "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",
                         "The EMBEDDEDOBJECT attribute is only valid on "                          "The EmbeddedObject attribute is only valid on "
                             "string types.");                             "string types.");
                     throw XmlValidationError(parser.getLine(), mlParms);                     throw XmlValidationError(parser.getLine(), mlParms);
                 }                 }
             }             }
 #else  
             if (String::equal(embeddedObject, "object"))  
             {  
                 // The EMBEDDEDOBJECT attribute is only valid on Parameters  
                 // of type string  
                 // The type must have been specified.  
                 if (gotType && (type == CIMTYPE_STRING))  
                 {  
                     // Used below by getValueElement() or getValueArrayElement()  
                     effectiveType = CIMTYPE_OBJECT;  
                 }  
                 else  
                 {  
                     MessageLoaderParms mlParms(  
                         "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",  
                         "The EMBEDDEDOBJECT attribute is only valid on "  
                             "string types.");  
                     throw XmlValidationError(parser.getLine(), mlParms);  
                 }  
             }  
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
  
             if (!XmlReader::getValueArrayElement(parser, effectiveType, value)             if (!XmlReader::getValueArrayElement(parser, effectiveType, value)
                 && !XmlReader::getValueElement(parser, effectiveType, value))                 && !XmlReader::getValueElement(parser, effectiveType, value))
Line 4628 
Line 4264 
     if (!testStartTag(parser, entry, "RETURNVALUE"))     if (!testStartTag(parser, entry, "RETURNVALUE"))
         return false;         return false;
  
     // Get PROPERTY.EMBEDDEDOBJECT      // Get PROPERTY.EmbeddedObject
  
     String embeddedObject = getEmbeddedObjectAttribute(      EmbeddedObjectAttributeType embeddedObject = getEmbeddedObjectAttribute(
         parser.getLine(), entry, "RETURNVALUE");         parser.getLine(), entry, "RETURNVALUE");
  
     // Get RETURNVALUE.PARAMTYPE attribute:     // Get RETURNVALUE.PARAMTYPE attribute:
Line 4666 
Line 4302 
             // If we don't know what type the value is, read it as a String             // If we don't know what type the value is, read it as a String
             type = CIMTYPE_STRING;             type = CIMTYPE_STRING;
         }         }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT          if (embeddedObject != NO_EMBEDDED_OBJECT)
         Boolean isEmbeddedObject = String::equal(embeddedObject, "object");  
         Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance");  
         if (isEmbeddedObject || isEmbeddedInstance)  
         {         {
             if (gotType && (type == CIMTYPE_STRING))             if (gotType && (type == CIMTYPE_STRING))
             {             {
                 if (isEmbeddedObject)                  if (embeddedObject == EMBEDDED_OBJECT_ATTR)
                     // Used below by getValueElement() or getValueArrayElement()                     // Used below by getValueElement() or getValueArrayElement()
                     type = CIMTYPE_OBJECT;                     type = CIMTYPE_OBJECT;
                 else                 else
Line 4683 
Line 4316 
             {             {
                 MessageLoaderParms mlParms(                 MessageLoaderParms mlParms(
                     "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",                     "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",
                     "The EMBEDDEDOBJECT attribute is only valid on string "                      "The EmbeddedObject attribute is only valid on string "
                         "types.");                         "types.");
                 throw XmlValidationError(parser.getLine(), mlParms);                 throw XmlValidationError(parser.getLine(), mlParms);
             }             }
         }         }
 #else  
         if (String::equal(embeddedObject, "object"))  
         {  
             if (gotType && (type == CIMTYPE_STRING))  
             {  
                 type = CIMTYPE_OBJECT;  // Used below by getValueElement()  
             }  
             else  
             {  
                 MessageLoaderParms mlParms(  
                     "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",  
                     "The EMBEDDEDOBJECT attribute is only valid on string "  
                         "types.");  
                 throw XmlValidationError(parser.getLine(), mlParms);  
             }  
         }  
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         if ( !XmlReader::getValueElement(parser, type, returnValue) )         if ( !XmlReader::getValueElement(parser, type, returnValue) )
         {         {
             MessageLoaderParms mlParms(             MessageLoaderParms mlParms(
Line 4719 
Line 4335 
     return true;     return true;
 } }
  
   //-----------------------------------------------------------------------------
   //
   // The following is a common set of version tests used by the different
   // Pegasus Request and Response Decoders
   //
   //------------------------------------------------------------------------------
   //
   // isSupportedCIMVersion()
   // tests for valid CIMVersion number
   //
   // Reject cimVersion not in 2.[0-9]+
   //
   // CIMXML Secification, Version 2.2 Final, Sect 3.2.1.1
   // The CIMVERSION attribute defines the version of the CIM Specification to
   // which the XML Document conforms.  It MUST be in the form of "M.N".  Where
   // M is the Major Version of the specification in numeric form and N is the
   // minor version of the specification in numeric form.  For example, "2.0",
   // "2.1".  Implementations must only validate the major version as all minor
   // versions are backward compatible.  Implementations may look at the minor
   // version to determine additional capabilites.
   //
   //------------------------------------------------------------------------------
   Boolean XmlReader::isSupportedCIMVersion(
       const char* cimVersion)
   {
       Boolean cimVersionAccepted = false;
       //printf("testCIMVersion %s \n", cimVersion);
       if ((cimVersion[0] == '2') &&
           (cimVersion[1] == '.') &&
           (cimVersion[2] != 0))
       {
           // Verify that all characters after the '.' are digits
           Uint32 index = 2;
           while (isdigit(cimVersion[index]))
           {
               index++;
           }
   
           if (cimVersion[index] == 0)
           {
              cimVersionAccepted = true;
           }
       }
       return cimVersionAccepted;
   }
   
   //------------------------------------------------------------------------------
   //
   // isSupportedProtocolVersion()
   // tests for valid ProtocolVersion number
   //
   // Reject ProtocolVersion not 1.[0-9]
   //
   // cimxml spec 2.2 Final Section 3261
   // The PROTOCOLVERSION attribute defines the version of the CIM Operations to
   // which this message conforms.  It MUST be in the form of  "M.N". Where M is
   // the Major Version of the specification in numeric form and N is the minor
   // version of the specification in numeric form.  For example, "1.0", "1.1".
   // Implementations must only validate the major version as all minor versions
   // are backward compatible. Implementations may look at the minor version to
   // determine additional capabilites.
   //
   //------------------------------------------------------------------------------
   Boolean XmlReader::isSupportedProtocolVersion(
       const String& protocolVersion)
   {
       Boolean protocolVersionAccepted = false;
   
       //cout << "testProtocolVersion " << protocolVersion << endl;
       if ((protocolVersion.size() >= 3) &&
           (protocolVersion[0] == '1') &&
           (protocolVersion[1] == '.'))
       {
           // Verify that all characters after the '.' are digits
           Uint32 index = 2;
           while ((index < protocolVersion.size()) &&
                  (protocolVersion[index] >= '0') &&
                  (protocolVersion[index] <= '9'))
           {
               index++;
           }
   
           if (index == protocolVersion.size())
           {
               protocolVersionAccepted = true;
           }
       }
       return protocolVersionAccepted;
   }
   
   //------------------------------------------------------------------------------
   //
   // isSupportedDTDVersion()
   // Tests for Valid dtdVersion number
   // We accept DTD version 2.[0-9]+ (see Bugzilla 1556)//
   //
   // CIM/XML Specification, V 2.2 Final, Section 3.2.1.1
   // The DTDVERSION attribute defines the version of the CIM XML Mapping to
   // which the XML Document conforms.  It MUST be in the form of "M.N".  Where
   // M is the Major Version of the specification in numeric form and N is the
   // minor version of the specification in numeric form.  For example, "2.0",
   // "2.1".  Implementations must only validate the major version as all minor
   // versions are backward compatible.  Implementations may look at the minor
   // version to determine additional capabilites.
   //
   //------------------------------------------------------------------------------
   Boolean XmlReader::isSupportedDTDVersion(
       const char* dtdVersion)
   {
       Boolean dtdVersionAccepted = false;
   
       //printf("testDTDVersion %s \n", dtdVersion);
       if ((dtdVersion[0] == '2') &&
           (dtdVersion[1] == '.') &&
           (dtdVersion[2] != 0))
       {
           // Verify that all characters after the '.' are digits
           Uint32 index = 2;
           while (isdigit(dtdVersion[index]))
           {
               index++;
           }
   
           if (dtdVersion[index] == 0)
           {
              dtdVersionAccepted = true;
           }
       }
       return dtdVersionAccepted;
   }
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.122  
changed lines
  Added in v.1.144.2.1

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2