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

Diff for /pegasus/src/Pegasus/Common/XmlWriter.cpp between version 1.124.2.4 and 1.169.4.1

version 1.124.2.4, 2005/10/02 02:16:42 version 1.169.4.1, 2011/01/15 21:26:53
Line 1 
Line 1 
 //%2005////////////////////////////////////////////////////////////////////////  //%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
 //  // copy of this software and associated documentation files (the "Software"),
 // Permission is hereby granted, free of charge, to any person obtaining a copy  // to deal in the Software without restriction, including without limitation
 // of this software and associated documentation files (the "Software"), to  // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 // deal in the Software without restriction, including without limitation the  // and/or sell copies of the Software, and to permit persons to whom the
 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  // Software is furnished to do so, subject to the following conditions:
 // sell copies of the Software, and to permit persons to whom the Software is  //
 // furnished to do so, subject to the following conditions:  // The above copyright notice and this permission notice shall be included
 //  // in all copies or substantial portions of the Software.
 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN  //
 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT  // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN  // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //  //
 //==============================================================================  //////////////////////////////////////////////////////////////////////////
 //  
 // Author: Mike Brasher (mbrasher@bmc.com)  
 //  
 // Modified By: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)  
 //              Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)  
 //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)  
 //              Carol Ann Krug Graves, Hewlett-Packard Company  
 //                  (carolann_graves@hp.com)  
 //              Amit K Arora, IBM (amita@in.ibm.com) for PEP#101  
 //         Brian G. Campbell, EMC (campbell_brian@emc.com) - PEP140/phase1  
 //                               Willis White (whiwill@us.ibm.com) PEP 127 and 128  
 //         Brian G. Campbell, EMC (campbell_brian@emc.com) - PEP140/phase2  
 //              Dave Sudlik, IBM (dsudlik@us.ibm.com)  
 //              David Dillard, VERITAS Software Corp.  
 //                  (david.dillard@veritas.com)  
 //              Vijay Eli, vijayeli@in.ibm.com, fix for #2571  
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 67 
Line 51 
 #include "CIMQualifierDeclRep.h" #include "CIMQualifierDeclRep.h"
 #include "CIMValue.h" #include "CIMValue.h"
 #include "XmlWriter.h" #include "XmlWriter.h"
 #include "XmlParser.h"  
 #include "Tracer.h" #include "Tracer.h"
 #include <Pegasus/Common/StatisticalData.h> #include <Pegasus/Common/StatisticalData.h>
 #include "CommonUTF.h" #include "CommonUTF.h"
   #include "Buffer.h"
   #include "StrLit.h"
   #include "IDFactory.h"
   #include "StringConversion.h"
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 // This is a shortcut macro for outputing content length. This  
 // pads the output number to the max characters representing a Uint32 number  
 // so that it can be overwritten easily with a transfer encoding line later  
 // on in HTTPConnection if required. This is strictly for performance since  
 // messages can be very large. This overwriting shortcut allows us to NOT have  
 // to repackage a large message later.  
   
 #define OUTPUT_CONTENTLENGTH                                            \  
 {                                                                       \  
     char contentLengthP[11];                                            \  
     sprintf(contentLengthP,"%.10u", contentLength);                     \  
     out << LIT("content-length: ") << contentLengthP << LIT("\r\n");    \  
 }  
   
 ////////////////////////////////////////////////////////////////////////////////  
 //  
 // SpecialChar and table.  
 //  
 ////////////////////////////////////////////////////////////////////////////////  
   
 struct SpecialChar  
 {  
     const char* str;  
     size_t size;  
 };  
   
 // Defines encodings of special characters. Just use a 7-bit ASCII character  
 // as an index into this array to retrieve its string encoding and encoding  
 // length in bytes.  
 static const SpecialChar _specialChars[] =  
 {  
     { "&#0;", 4 },  
     { "&#1;", 4 },  
     { "&#2;", 4 },  
     { "&#3;", 4 },  
     { "&#4;", 4 },  
     { "&#5;", 4 },  
     { "&#6;", 4 },  
     { "&#7;", 4 },  
     { "&#8;", 4 },  
     { "&#9;", 4 },  
     { "&#10;", 5 },  
     { "&#11;", 5 },  
     { "&#12;", 5 },  
     { "&#13;", 5 },  
     { "&#14;", 5 },  
     { "&#15;", 5 },  
     { "&#16;", 5 },  
     { "&#17;", 5 },  
     { "&#18;", 5 },  
     { "&#19;", 5 },  
     { "&#20;", 5 },  
     { "&#21;", 5 },  
     { "&#22;", 5 },  
     { "&#23;", 5 },  
     { "&#24;", 5 },  
     { "&#25;", 5 },  
     { "&#26;", 5 },  
     { "&#27;", 5 },  
     { "&#28;", 5 },  
     { "&#29;", 5 },  
     { "&#30;", 5 },  
     { "&#31;", 5 },  
     { " ", 1 },  
     { "!", 1 },  
     { "&quot;", 6 },  
     { "#", 1 },  
     { "$", 1 },  
     { "%", 1 },  
     { "&amp;", 5 },  
     { "&apos;", 6 },  
     { "(", 1 },  
     { ")", 1 },  
     { "*", 1 },  
     { "+", 1 },  
     { ",", 1 },  
     { "-", 1 },  
     { ".", 1 },  
     { "/", 1 },  
     { "0", 1 },  
     { "1", 1 },  
     { "2", 1 },  
     { "3", 1 },  
     { "4", 1 },  
     { "5", 1 },  
     { "6", 1 },  
     { "7", 1 },  
     { "8", 1 },  
     { "9", 1 },  
     { ":", 1 },  
     { ";", 1 },  
     { "&lt;", 4 },  
     { "=", 1 },  
     { "&gt;", 4 },  
     { "?", 1 },  
     { "@", 1 },  
     { "A", 1 },  
     { "B", 1 },  
     { "C", 1 },  
     { "D", 1 },  
     { "E", 1 },  
     { "F", 1 },  
     { "G", 1 },  
     { "H", 1 },  
     { "I", 1 },  
     { "J", 1 },  
     { "K", 1 },  
     { "L", 1 },  
     { "M", 1 },  
     { "N", 1 },  
     { "O", 1 },  
     { "P", 1 },  
     { "Q", 1 },  
     { "R", 1 },  
     { "S", 1 },  
     { "T", 1 },  
     { "U", 1 },  
     { "V", 1 },  
     { "W", 1 },  
     { "X", 1 },  
     { "Y", 1 },  
     { "Z", 1 },  
     { "[", 1 },  
     { "\\", 1 },  
     { "]", 1 },  
     { "^", 1 },  
     { "_", 1 },  
     { "`", 1 },  
     { "a", 1 },  
     { "b", 1 },  
     { "c", 1 },  
     { "d", 1 },  
     { "e", 1 },  
     { "f", 1 },  
     { "g", 1 },  
     { "h", 1 },  
     { "i", 1 },  
     { "j", 1 },  
     { "k", 1 },  
     { "l", 1 },  
     { "m", 1 },  
     { "n", 1 },  
     { "o", 1 },  
     { "p", 1 },  
     { "q", 1 },  
     { "r", 1 },  
     { "s", 1 },  
     { "t", 1 },  
     { "u", 1 },  
     { "v", 1 },  
     { "w", 1 },  
     { "x", 1 },  
     { "y", 1 },  
     { "z", 1 },  
     { "{", 1 },  
     { "|", 1 },  
     { "}", 1 },  
     { "~", 1 },  
     { "&#127;", 6 },  
 };  
   
 // If _isSpecialChar7[ch] is true, then ch is a special character, which must  
 // have a special encoding in XML. But only use 7-bit ASCII characters to  
 // index this array.  
 static const int _isSpecialChar7[] =  
 {  
     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,0,0,1,0,0,  
     0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,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,  
 };  
   
 ////////////////////////////////////////////////////////////////////////////////  
   
 Buffer& operator<<(Buffer& out, const char* x)  
 {  
     XmlWriter::append(out, x);  
     return out;  
 }  
   
 Buffer& operator<<(Buffer& out, char x)  
 {  
     XmlWriter::append(out, x);  
     return out;  
 }  
   
 Buffer& operator<<(Buffer& out, const Char16& x)  
 {  
     XmlWriter::append(out, x);  
     return out;  
 }  
   
 Buffer& operator<<(Buffer& out, const String& x)  
 {  
     XmlWriter::append(out, x);  
     return out;  
 }  
   
 Buffer& operator<<(Buffer& out, const Indentor& x)  
 {  
     XmlWriter::append(out, x);  
     return out;  
 }  
   
 Buffer& operator<<(Buffer& out, const Buffer& x)  
 {  
     out.append(x.getData(), x.size());  
     return out;  
 }  
   
 Buffer& operator<<(Buffer& out, Uint32 x)  
 {  
     XmlWriter::append(out, x);  
     return out;  
 }  
   
 Buffer& operator<<(Buffer& out, const CIMName& name)  
 {  
     XmlWriter::append(out, name.getString ());  
     return out;  
 }  
   
   
 // l10n  
 Buffer& operator<<(Buffer& out, const AcceptLanguages& al)  
 {  
     XmlWriter::append(out, al.toString ());  
     return out;  
 }  
   
 // l10n  
 Buffer& operator<<(Buffer& out, const ContentLanguages& cl)  
 {  
     XmlWriter::append(out, cl.toString ());  
     return out;  
 }  
   
   
 PEGASUS_STD(ostream)& operator<<(PEGASUS_STD(ostream)& os, const CIMDateTime& x)  
 {  
     return os << x.toString();  
 }  
   
 PEGASUS_STD(ostream)& operator<<(PEGASUS_STD(ostream)& os, const CIMName& name)  
 {  
     os << name.getString();  
     return os;  
 }  
   
 PEGASUS_STD(ostream)& operator<<(PEGASUS_STD(ostream)& os,  
     const CIMNamespaceName& name)  
 {  
     os << name.getString();  
     return os;  
 }  
   
 inline void _xmlWritter_appendChar(Buffer& out, const Char16& c)  
 {  
     // We need to convert the Char16 to UTF8 then append the UTF8  
     // character into the array.  
     // NOTE: The UTF8 character could be several bytes long.  
     // WARNING: This function will put in replacement character for  
     // all characters that have surogate pairs.  
     char str[6];  
     memset(str,0x00,sizeof(str));  
     Uint8* charIN = (Uint8 *)&c;  
   
     const Uint16 *strsrc = (Uint16 *)charIN;  
     Uint16 *endsrc = (Uint16 *)&charIN[1];  
   
     Uint8 *strtgt = (Uint8 *)str;  
     Uint8 *endtgt = (Uint8 *)&str[5];  
   
     UTF16toUTF8(&strsrc,  
                 endsrc,  
                 &strtgt,  
                 endtgt);  
   
     out.append(str, UTF_8_COUNT_TRAIL_BYTES(str[0]) + 1);  
 }  
   
 inline void _xmlWritter_appendSpecialChar(Buffer& out, const Char16& c)  
 {  
     if ( ((c < Char16(0x20)) && (c >= Char16(0x00))) || (c == Char16(0x7f)) )  
     {  
         char charref[7];  
         sprintf(charref, "&#%u;", (Uint16)c);  
         out.append(charref, static_cast<Uint32>(strlen(charref)));  
     }  
     else  
     {  
         switch (c)  
         {  
             case '&':  
                 out.append("&amp;", 5);  
                 break;  
   
             case '<':  
                 out.append("&lt;", 4);  
                 break;  
   
             case '>':  
                 out.append("&gt;", 4);  
                 break;  
   
             case '"':  
                 out.append("&quot;", 6);  
                 break;  
   
             case '\'':  
                 out.append("&apos;", 6);  
                 break;  
   
             default:  
                 {  
                     // We need to convert the Char16 to UTF8 then append the UTF8  
                     // character into the array.  
                     // NOTE: The UTF8 character could be several bytes long.  
                     // WARNING: This function will put in replacement character for  
                     // all characters that have surogate pairs.  
             char str[6];  
                     memset(str,0x00,sizeof(str));  
                     const char* charIN = reinterpret_cast<const char *>(&c);  
   
                     const Uint16 *strsrc = (const Uint16 *)charIN;  
                     const Uint16 *endsrc = (const Uint16 *)&charIN[1];  
   
                     Uint8 *strtgt = (Uint8 *)str;  
                     Uint8 *endtgt = (Uint8 *)&str[5];  
   
                     UTF16toUTF8(&strsrc,  
                                 endsrc,  
                                 &strtgt,  
                                 endtgt);  
   
                     Uint32 number1 = UTF_8_COUNT_TRAIL_BYTES(str[0]) + 1;  
   
                     out.append(str,number1);  
                 }  
         }  
     }  
 }  
   
 inline void _appendSpecialChar7(Buffer& out, char c)  
 {  
     if (_isSpecialChar7[int(c)])  
         out.append(_specialChars[int(c)].str, _specialChars[int(c)].size);  
     else  
         out.append(c);  
 }  
   
 inline void _xmlWritter_appendSpecialChar(PEGASUS_STD(ostream)& os, char c)  
 {  
     if ( ((c < 0x20) && (c >= 0)) || (c == 0x7f) )  
     {  
         char charref[7];  
         sprintf(charref, "&#%u;", static_cast<Uint8>(c));  
         os << charref;  
     }  
     else  
     {  
         switch (c)  
         {  
             case '&':  
                 os << "&amp;";  
                 break;  
   
             case '<':  
                 os << "&lt;";  
                 break;  
   
             case '>':  
                 os << "&gt;";  
                 break;  
   
             case '"':  
                 os << "&quot;";  
                 break;  
   
             case '\'':  
                 os << "&apos;";  
                 break;  
   
             default:  
                 os << c;  
         }  
     }  
 }  
   
 void _xmlWritter_appendSurrogatePair(Buffer& out, Uint16 high, Uint16 low)  
 {  
     char str[6];  
     Uint8 charIN[5];  
     memset(str,0x00,sizeof(str));  
     memcpy(&charIN,&high,2);  
     memcpy(&charIN[2],&low,2);  
     const Uint16 *strsrc = (Uint16 *)charIN;  
     Uint16 *endsrc = (Uint16 *)&charIN[3];  
   
     Uint8 *strtgt = (Uint8 *)str;  
     Uint8 *endtgt = (Uint8 *)&str[5];  
   
     UTF16toUTF8(&strsrc,  
                 endsrc,  
                 &strtgt,  
                 endtgt);  
   
     Uint32 number1 = UTF_8_COUNT_TRAIL_BYTES(str[0]) + 1;  
     out.append(str,number1);  
 }  
   
 inline void _xmlWritter_appendSpecial(PEGASUS_STD(ostream)& os, const char* str)  
 {  
     while (*str)  
         _xmlWritter_appendSpecialChar(os, *str++);  
 }  
   
 void XmlWriter::append(Buffer& out, const Char16& x)  
 {  
     _xmlWritter_appendChar(out, x);  
 }  
   
 void XmlWriter::append(Buffer& out, Boolean x)  
 {  
     append(out, (x ? "TRUE" : "FALSE"));  
 }  
   
 void XmlWriter::append(Buffer& out, Uint32 x)  
 {  
     char buffer[32];  
     sprintf(buffer, "%u", x);  
     append(out, buffer);  
 }  
   
 void XmlWriter::append(Buffer& out, Sint32 x)  
 {  
     char buffer[32];  
     sprintf(buffer, "%d", x);  
     append(out, buffer);  
 }  
   
 void XmlWriter::append(Buffer& out, Uint64 x)  
 {  
     char buffer[32];  // Should need 21 chars max  
     sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", x);  
     append(out, buffer);  
 }  
   
 void XmlWriter::append(Buffer& out, Sint64 x)  
 {  
     char buffer[32];  // Should need 21 chars max  
     sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "d", x);  
     append(out, buffer);  
 }  
   
 void XmlWriter::append(Buffer& out, Real32 x)  
 {  
     char buffer[128];  
     // %.7e gives '[-]m.ddddddde+/-xx', which seems compatible with the format  
     // given in the CIM/XML spec, and the precision required by the CIM 2.2 spec  
     // (4 byte IEEE floating point)  
     sprintf(buffer, "%.7e", x);  
     append(out, buffer);  
 }  
   
 void XmlWriter::append(Buffer& out, Real64 x)  
 {  
     char buffer[128];  
     // %.16e gives '[-]m.dddddddddddddddde+/-xx', which seems compatible with the format  
     // given in the CIM/XML spec, and the precision required by the CIM 2.2 spec  
     // (8 byte IEEE floating point)  
     sprintf(buffer, "%.16e", x);  
     append(out, buffer);  
 }  
   
 void XmlWriter::append(Buffer& out, const char* str)  
 {  
     while (*str)  
       XmlWriter::append(out, *str++);  
 }  
   
 void XmlWriter::append(Buffer& out, const String& str)  
 {  
     for (Uint32 i = 0; i < str.size(); i++)  
     {  
         Uint16 c = str[i];  
         if(((c >= FIRST_HIGH_SURROGATE) && (c <= LAST_HIGH_SURROGATE)) ||  
            ((c >= FIRST_LOW_SURROGATE) && (c <= LAST_LOW_SURROGATE)))  
         {  
             Char16 highSurrogate = str[i];  
             Char16 lowSurrogate = str[++i];  
   
             _xmlWritter_appendSurrogatePair(out, Uint16(highSurrogate),Uint16(lowSurrogate));  
         }  
         else  
         {  
             _xmlWritter_appendChar(out, str[i]);  
         }  
     }  
 }  
   
 void XmlWriter::append(Buffer& out, const Indentor& x)  
 {  
     for (Uint32 i = 0; i < 4 * x.getLevel(); i++)  
         out.append(' ');  
 }  
   
 void XmlWriter::appendSpecial(Buffer& out, const Char16& x)  
 {  
     _xmlWritter_appendSpecialChar(out, x);  
 }  
   
 void XmlWriter::appendSpecial(Buffer& out, char x)  
 {  
     _appendSpecialChar7(out, x);  
 }  
   
 void XmlWriter::appendSpecial(Buffer& out, const char* str)  
 {  
     while (*str)  
         _appendSpecialChar7(out, *str++);  
 }  
   
 void XmlWriter::appendSpecial(Buffer& out, const String& str)  
 {  
     const Uint16* p = (const Uint16*)str.getChar16Data();  
     size_t n = str.size();  
   
     // Handle leading ASCII 7 characers in these next two loos (use unrolling).  
   
     while (n >= 8)  
     {  
         // The following condition is equivalent to this:  
         //     (p[0] < 128 && p[1] < 128 && p[2] < 128 && p[3] < 128 &&  
         //      p[4] < 128 && p[5] < 128 && p[6] < 128 && p[7] < 128)  
   
         if (((p[0]|p[1]|p[2]|p[3]|p[4]|p[5]|p[6]|p[7]) & 0xFF80) == 0)  
         {  
             // Note: "|" is faster than "||" and achieves the same effect  
             // since p[i] is either 0 or 1.  
   
             if (_isSpecialChar7[p[0]] | _isSpecialChar7[p[1]] |  
                 _isSpecialChar7[p[2]] | _isSpecialChar7[p[3]] |  
                 _isSpecialChar7[p[4]] | _isSpecialChar7[p[5]] |  
                 _isSpecialChar7[p[6]] | _isSpecialChar7[p[7]])  
             {  
                 // Rare case.  
                 _appendSpecialChar7(out, p[0]);  
                 _appendSpecialChar7(out, p[1]);  
                 _appendSpecialChar7(out, p[2]);  
                 _appendSpecialChar7(out, p[3]);  
                 _appendSpecialChar7(out, p[4]);  
                 _appendSpecialChar7(out, p[5]);  
                 _appendSpecialChar7(out, p[6]);  
                 _appendSpecialChar7(out, p[7]);  
             }  
             else  
             {  
                 // Common case.  
                 out.append(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);  
             }  
             p += 8;  
             n -= 8;  
         }  
         else  
             break;  
     }  
   
     while (n >= 4)  
     {  
         // The following condition is equivalent to this:  
         //     (p[0] < 128 && p[1] < 128 && p[2] < 128 && p[3] < 128)  
   
         if (((p[0]|p[1]|p[2]|p[3]) & 0xFF80) == 0)  
         {  
             if (_isSpecialChar7[p[0]] | _isSpecialChar7[p[1]] |  
                 _isSpecialChar7[p[2]] | _isSpecialChar7[p[3]])  
             {  
                 // Rare case:  
                 _appendSpecialChar7(out, p[0]);  
                 _appendSpecialChar7(out, p[1]);  
                 _appendSpecialChar7(out, p[2]);  
                 _appendSpecialChar7(out, p[3]);  
             }  
             else  
             {  
                 // Common case:  
                 out.append(p[0], p[1], p[2], p[3]);  
             }  
   
             p += 4;  
             n -= 4;  
         }  
         else  
             break;  
     }  
   
     // Process remaining characters. A UTF8 character must have been  
     // encountered or this would have never been reached.  
   
     while (n--)  
     {  
         Uint16 c = *p++;  
   
         // Special processing for UTF8 case:  
   
         if (c < 128)  
         {  
             _appendSpecialChar7(out, c);  
             continue;  
         }  
   
         // Hanlde UTF8 case (if reached).  
   
         if(((c >= FIRST_HIGH_SURROGATE) && (c <= LAST_HIGH_SURROGATE)) ||  
            ((c >= FIRST_LOW_SURROGATE) && (c <= LAST_LOW_SURROGATE)))  
         {  
             Char16 highSurrogate = p[-1];  
             Char16 lowSurrogate = p[0];  
             p++;  
             n--;  
   
             _xmlWritter_appendSurrogatePair(  
                 out, Uint16(highSurrogate),Uint16(lowSurrogate));  
         }  
         else  
         {  
             _xmlWritter_appendSpecialChar(out, c);  
         }  
     }  
 }  
   
 // See http://www.ietf.org/rfc/rfc2396.txt section 2  
 // Reserved characters = ';' '/' '?' ':' '@' '&' '=' '+' '$' ','  
 // Excluded characters:  
 //   Control characters = 0x00-0x1f, 0x7f  
 //   Space character = 0x20  
 //   Delimiters = '<' '>' '#' '%' '"'  
 //   Unwise = '{' '}' '|' '\\' '^' '[' ']' '`'  
 //  
   
 inline void _xmlWritter_encodeURIChar(String& outString, Sint8 char8)  
 {  
     Uint8 c = (Uint8)char8;  
   
 #ifndef PEGASUS_DO_NOT_IMPLEMENT_URI_ENCODING  
     if ( (c <= 0x20) ||                     // Control characters + space char  
          ( (c >= 0x22) && (c <= 0x26) ) ||  // '"' '#' '$' '%' '&'  
          (c == 0x2b) ||                     // '+'  
          (c == 0x2c) ||                     // ','  
          (c == 0x2f) ||                     // '/'  
          ( (c >= 0x3a) && (c <= 0x40) ) ||  // ':' ';' '<' '=' '>' '?' '@'  
          ( (c >= 0x5b) && (c <= 0x5e) ) ||  // '[' '\\' ']' '^'  
          (c == 0x60) ||                     // '`'  
          ( (c >= 0x7b) && (c <= 0x7d) ) ||  // '{' '|' '}'  
          (c >= 0x7f) )                      // Control character or non US-ASCII (UTF-8)  
     {  
         char hexencoding[4];  
   
         sprintf(hexencoding, "%%%X%X", c/16, c%16);  
         outString.append(hexencoding);  
     }  
     else  
 #endif  
     {  
         outString.append((Uint16)c);  
     }  
 }  
   
 String XmlWriter::encodeURICharacters(const Buffer& uriString)  
 {  
     String encodedString;  
   
     for (Uint32 i=0; i<uriString.size(); i++)  
     {  
         _xmlWritter_encodeURIChar(encodedString, uriString[i]);  
     }  
   
     return encodedString;  
 }  
   
 String XmlWriter::encodeURICharacters(const String& uriString)  
 {  
     String encodedString;  
   
 /* i18n remove - did not handle surrogate pairs  
     for (Uint32 i=0; i<uriString.size(); i++)  
     {  
         _xmlWritter_encodeURIChar(encodedString, uriString[i]);  
     }  
 */  
   
     // See the "CIM Operations over HTTP" spec, section 3.3.2 and  
     // 3.3.3, for the treatment of non US-ASCII (UTF-8) chars  
   
     // First, convert to UTF-8 (include handling of surrogate pairs)  
     Buffer utf8;  
     for (Uint32 i = 0; i < uriString.size(); i++)  
     {  
         Uint16 c = uriString[i];  
   
         if(((c >= FIRST_HIGH_SURROGATE) && (c <= LAST_HIGH_SURROGATE)) ||  
            ((c >= FIRST_LOW_SURROGATE) && (c <= LAST_LOW_SURROGATE)))  
         {  
             Char16 highSurrogate = uriString[i];  
             Char16 lowSurrogate = uriString[++i];  
   
             _xmlWritter_appendSurrogatePair(utf8, Uint16(highSurrogate),Uint16(lowSurrogate));  
         }  
         else  
         {  
             _xmlWritter_appendChar(utf8, uriString[i]);  
         }  
     }  
   
     // Second, escape the non HTTP-safe chars  
     for (Uint32 i=0; i<utf8.size(); i++)  
     {  
         _xmlWritter_encodeURIChar(encodedString, utf8[i]);  
     }  
   
     return encodedString;  
 }  
   
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // appendLocalNameSpacePathElement() // appendLocalNameSpacePathElement()
Line 810 
Line 73 
     Buffer& out,     Buffer& out,
     const CIMNamespaceName& nameSpace)     const CIMNamespaceName& nameSpace)
 { {
     out << LIT("<LOCALNAMESPACEPATH>\n");      out << STRLIT("<LOCALNAMESPACEPATH>\n");
  
     char* nameSpaceCopy = strdup(nameSpace.getString().getCString());     char* nameSpaceCopy = strdup(nameSpace.getString().getCString());
  
 #if defined(PEGASUS_PLATFORM_SOLARIS_SPARC_CC) || \  #if !defined(PEGASUS_COMPILER_MSVC) && !defined(PEGASUS_OS_ZOS)
     defined(PEGASUS_OS_HPUX) || \  
     defined(PEGASUS_OS_LINUX)  
     char *last;     char *last;
     for (const char* p = strtok_r(nameSpaceCopy, "/", &last); p;     for (const char* p = strtok_r(nameSpaceCopy, "/", &last); p;
          p = strtok_r(NULL, "/", &last))          p = strtok_r(NULL, "/", &last))
Line 824 
Line 85 
     for (const char* p = strtok(nameSpaceCopy, "/"); p; p = strtok(NULL, "/"))     for (const char* p = strtok(nameSpaceCopy, "/"); p; p = strtok(NULL, "/"))
 #endif #endif
     {     {
         out << LIT("<NAMESPACE NAME=\"") << p << LIT("\"/>\n");          out << STRLIT("<NAMESPACE NAME=\"") << p << STRLIT("\"/>\n");
     }     }
     free(nameSpaceCopy);     free(nameSpaceCopy);
  
     out << LIT("</LOCALNAMESPACEPATH>\n");      out << STRLIT("</LOCALNAMESPACEPATH>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 844 
Line 105 
     const String& host,     const String& host,
     const CIMNamespaceName& nameSpace)     const CIMNamespaceName& nameSpace)
 { {
     out << LIT("<NAMESPACEPATH>\n");      out << STRLIT("<NAMESPACEPATH>\n"
     out << LIT("<HOST>") << host << LIT("</HOST>\n");                    "<HOST>") << host << STRLIT("</HOST>\n");
     appendLocalNameSpacePathElement(out, nameSpace);     appendLocalNameSpacePathElement(out, nameSpace);
     out << LIT("</NAMESPACEPATH>\n");      out << STRLIT("</NAMESPACEPATH>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 864 
Line 125 
     Buffer& out,     Buffer& out,
     const CIMName& className)     const CIMName& className)
 { {
     out << LIT("<CLASSNAME NAME=\"") << className << LIT("\"/>\n");      out << STRLIT("<CLASSNAME NAME=\"") << className << STRLIT("\"/>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 881 
Line 142 
     Buffer& out,     Buffer& out,
     const CIMObjectPath& instanceName)     const CIMObjectPath& instanceName)
 { {
     out << LIT("<INSTANCENAME CLASSNAME=\"");      out << STRLIT("<INSTANCENAME CLASSNAME=\"");
     out << instanceName.getClassName() << LIT("\">\n");      out << instanceName.getClassName() << STRLIT("\">\n");
  
     Array<CIMKeyBinding> keyBindings = instanceName.getKeyBindings();      const Array<CIMKeyBinding>& keyBindings = instanceName.getKeyBindings();
     for (Uint32 i = 0, n = keyBindings.size(); i < n; i++)     for (Uint32 i = 0, n = keyBindings.size(); i < n; i++)
     {     {
         out << LIT("<KEYBINDING NAME=\"");          out << STRLIT("<KEYBINDING NAME=\"");
         out << keyBindings[i].getName() << LIT("\">\n");          out << keyBindings[i].getName() << STRLIT("\">\n");
  
         if (keyBindings[i].getType() == CIMKeyBinding::REFERENCE)         if (keyBindings[i].getType() == CIMKeyBinding::REFERENCE)
         {         {
             CIMObjectPath ref = keyBindings[i].getValue();             CIMObjectPath ref = keyBindings[i].getValue();
             appendValueReferenceElement(out, ref, true);             appendValueReferenceElement(out, ref, true);
         }         }
         else {          else
             out << LIT("<KEYVALUE VALUETYPE=\"");          {
               out << STRLIT("<KEYVALUE VALUETYPE=\"");
             out << keyBindingTypeToString(keyBindings[i].getType());             out << keyBindingTypeToString(keyBindings[i].getType());
             out << LIT("\">");              out << STRLIT("\">");
  
             // fixed the special character problem - Markus             // fixed the special character problem - Markus
  
             appendSpecial(out, keyBindings[i].getValue());             appendSpecial(out, keyBindings[i].getValue());
             out << LIT("</KEYVALUE>\n");              out << STRLIT("</KEYVALUE>\n");
         }         }
         out << LIT("</KEYBINDING>\n");          out << STRLIT("</KEYBINDING>\n");
     }     }
     out << LIT("</INSTANCENAME>\n");      out << STRLIT("</INSTANCENAME>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 922 
Line 184 
     Buffer& out,     Buffer& out,
     const CIMObjectPath& classPath)     const CIMObjectPath& classPath)
 { {
     out << LIT("<CLASSPATH>\n");      out << STRLIT("<CLASSPATH>\n");
     appendNameSpacePathElement(out,     appendNameSpacePathElement(out,
                                classPath.getHost(),                                classPath.getHost(),
                                classPath.getNameSpace());                                classPath.getNameSpace());
     appendClassNameElement(out, classPath.getClassName());     appendClassNameElement(out, classPath.getClassName());
     out << LIT("</CLASSPATH>\n");      out << STRLIT("</CLASSPATH>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 942 
Line 204 
     Buffer& out,     Buffer& out,
     const CIMObjectPath& instancePath)     const CIMObjectPath& instancePath)
 { {
     out << LIT("<INSTANCEPATH>\n");      out << STRLIT("<INSTANCEPATH>\n");
     appendNameSpacePathElement(out,     appendNameSpacePathElement(out,
                                instancePath.getHost(),                                instancePath.getHost(),
                                instancePath.getNameSpace());                                instancePath.getNameSpace());
     appendInstanceNameElement(out, instancePath);     appendInstanceNameElement(out, instancePath);
     out << LIT("</INSTANCEPATH>\n");      out << STRLIT("</INSTANCEPATH>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 962 
Line 224 
     Buffer& out,     Buffer& out,
     const CIMObjectPath& classPath)     const CIMObjectPath& classPath)
 { {
     out << LIT("<LOCALCLASSPATH>\n");      out << STRLIT("<LOCALCLASSPATH>\n");
     appendLocalNameSpacePathElement(out, classPath.getNameSpace());     appendLocalNameSpacePathElement(out, classPath.getNameSpace());
     appendClassNameElement(out, classPath.getClassName());     appendClassNameElement(out, classPath.getClassName());
     out << LIT("</LOCALCLASSPATH>\n");      out << STRLIT("</LOCALCLASSPATH>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 980 
Line 242 
     Buffer& out,     Buffer& out,
     const CIMObjectPath& instancePath)     const CIMObjectPath& instancePath)
 { {
     out << LIT("<LOCALINSTANCEPATH>\n");      out << STRLIT("<LOCALINSTANCEPATH>\n");
     appendLocalNameSpacePathElement(out, instancePath.getNameSpace());     appendLocalNameSpacePathElement(out, instancePath.getNameSpace());
     appendInstanceNameElement(out, instancePath);     appendInstanceNameElement(out, instancePath);
     out << LIT("</LOCALINSTANCEPATH>\n");      out << STRLIT("</LOCALINSTANCEPATH>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 1088 
Line 350 
  
 inline void _xmlWritter_appendValue(Buffer& out, const CIMDateTime& x) inline void _xmlWritter_appendValue(Buffer& out, const CIMDateTime& x)
 { {
     out << x.toString();  //ATTN: append() method?      // It is not necessary to use XmlWriter::appendSpecial(), because
       // CIMDateTime values do not contain special characters.
       out << x.toString();
 } }
  
 inline void _xmlWritter_appendValue(Buffer& out, const CIMObjectPath& x) inline void _xmlWritter_appendValue(Buffer& out, const CIMObjectPath& x)
Line 1102 
Line 366 
     _xmlWritter_appendValue(out, myStr);     _xmlWritter_appendValue(out, myStr);
 } }
  
 void _xmlWritter_appendValueArray(Buffer& out, const CIMObjectPath* p, Uint32 size)  void _xmlWritter_appendValueArray(
       Buffer& out, const CIMObjectPath* p, Uint32 size)
 { {
     out << LIT("<VALUE.REFARRAY>\n");      out << STRLIT("<VALUE.REFARRAY>\n");
     while (size--)     while (size--)
     {     {
         _xmlWritter_appendValue(out, *p++);         _xmlWritter_appendValue(out, *p++);
     }     }
     out << LIT("</VALUE.REFARRAY>\n");      out << STRLIT("</VALUE.REFARRAY>\n");
 } }
  
 template<class T> template<class T>
 void _xmlWritter_appendValueArray(Buffer& out, const T* p, Uint32 size) void _xmlWritter_appendValueArray(Buffer& out, const T* p, Uint32 size)
 { {
     out << LIT("<VALUE.ARRAY>\n");      out << STRLIT("<VALUE.ARRAY>\n");
  
     while (size--)     while (size--)
     {     {
         out << LIT("<VALUE>");          out << STRLIT("<VALUE>");
         _xmlWritter_appendValue(out, *p++);         _xmlWritter_appendValue(out, *p++);
         out << LIT("</VALUE>\n");          out << STRLIT("</VALUE>\n");
     }     }
  
     out << LIT("</VALUE.ARRAY>\n");      out << STRLIT("</VALUE.ARRAY>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 1250 
Line 515 
  
             case CIMTYPE_STRING:             case CIMTYPE_STRING:
             {             {
                 Array<String> a;                  const String* data;
                 value.get(a);                  Uint32 size;
                 _xmlWritter_appendValueArray(out, a.getData(), a.size());                  value._get(data, size);
                   _xmlWritter_appendValueArray(out, data, size);
                 break;                 break;
             }             }
  
Line 1279 
Line 545 
                 _xmlWritter_appendValueArray(out, a.getData(), a.size());                 _xmlWritter_appendValueArray(out, a.getData(), a.size());
                 break;                 break;
             }             }
               case CIMTYPE_INSTANCE:
               {
                   Array<CIMInstance> a;
                   value.get(a);
                   _xmlWritter_appendValueArray(out, a.getData(), a.size());
                   break;
               }
             default:             default:
                 PEGASUS_ASSERT(false);                 PEGASUS_ASSERT(false);
         }         }
Line 1293 
Line 565 
     }     }
     else     else
     {     {
         out << LIT("<VALUE>");          out << STRLIT("<VALUE>");
  
         switch (value.getType())         switch (value.getType())
         {         {
Line 1416 
Line 688 
                 _xmlWritter_appendValue(out, v);                 _xmlWritter_appendValue(out, v);
                 break;                 break;
             }             }
               case CIMTYPE_INSTANCE:
               {
                   CIMInstance v;
                   value.get(v);
                   _xmlWritter_appendValue(out, v);
                   break;
               }
             default:             default:
                 PEGASUS_ASSERT(false);                 PEGASUS_ASSERT(false);
         }         }
  
         out << LIT("</VALUE>\n");          out << STRLIT("</VALUE>\n");
     }     }
 } }
  
Line 1431 
Line 709 
 { {
     Buffer tmp;     Buffer tmp;
     appendValueElement(tmp, value);     appendValueElement(tmp, value);
     tmp.append('\0');  
     os << tmp.getData() << PEGASUS_STD(endl);     os << tmp.getData() << PEGASUS_STD(endl);
 } }
  
Line 1448 
Line 725 
     Buffer& out,     Buffer& out,
     const CIMObject& objectWithPath)     const CIMObject& objectWithPath)
 { {
     out << LIT("<VALUE.OBJECTWITHPATH>\n");      out << STRLIT("<VALUE.OBJECTWITHPATH>\n");
  
     appendValueReferenceElement(out, objectWithPath.getPath (), false);     appendValueReferenceElement(out, objectWithPath.getPath (), false);
     appendObjectElement(out, objectWithPath);     appendObjectElement(out, objectWithPath);
  
     out << LIT("</VALUE.OBJECTWITHPATH>\n");      out << STRLIT("</VALUE.OBJECTWITHPATH>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 1472 
Line 749 
     Boolean putValueWrapper)     Boolean putValueWrapper)
 { {
     if (putValueWrapper)     if (putValueWrapper)
         out << LIT("<VALUE.REFERENCE>\n");          out << STRLIT("<VALUE.REFERENCE>\n");
  
     // See if it is a class or instance reference (instance references have     // See if it is a class or instance reference (instance references have
     // key-bindings; class references do not).     // key-bindings; class references do not).
Line 1483 
Line 760 
     //  key bindings     //  key bindings
     //     //
  
     Array<CIMKeyBinding> kbs = reference.getKeyBindings();      const Array<CIMKeyBinding>& kbs = reference.getKeyBindings();
  
     if (kbs.size())     if (kbs.size())
     {     {
Line 1517 
Line 794 
     }     }
  
     if (putValueWrapper)     if (putValueWrapper)
         out << LIT("</VALUE.REFERENCE>\n");          out << STRLIT("</VALUE.REFERENCE>\n");
 } }
  
 void XmlWriter::printValueReferenceElement( void XmlWriter::printValueReferenceElement(
Line 1526 
Line 803 
 { {
     Buffer tmp;     Buffer tmp;
     appendValueReferenceElement(tmp, reference, true);     appendValueReferenceElement(tmp, reference, true);
     tmp.append('\0');  
     indentedPrint(os, tmp.getData());     indentedPrint(os, tmp.getData());
 } }
  
Line 1542 
Line 818 
     Buffer& out,     Buffer& out,
     const CIMInstance& namedInstance)     const CIMInstance& namedInstance)
 { {
     out << LIT("<VALUE.NAMEDINSTANCE>\n");      out << STRLIT("<VALUE.NAMEDINSTANCE>\n");
  
     appendInstanceNameElement(out, namedInstance.getPath ());     appendInstanceNameElement(out, namedInstance.getPath ());
     appendInstanceElement(out, namedInstance);     appendInstanceElement(out, namedInstance);
  
     out << LIT("</VALUE.NAMEDINSTANCE>\n");      out << STRLIT("</VALUE.NAMEDINSTANCE>\n");
 } }
  
   //EXP_PULL
   //------------------------------------------------------------------------------
   //
   // appendValueInstanceWithPathElement()
   //
   //     <!ELEMENT VALUE.INSTANCEWITHPATH (INSTANCEPATH,INSTANCE)>
   //
   //------------------------------------------------------------------------------
   // EXP_PULL_TBD checkout the INSTANCEPATH vs NAMEDINSTANCE
   void XmlWriter::appendValueInstanceWithPathElement(
       Buffer& out,
       const CIMInstance& namedInstance)
   {
       out << STRLIT("<VALUE.INSTANCEWITHPATH>\n");
   
       appendInstancePathElement(out, namedInstance.getPath ());
       appendInstanceElement(out, namedInstance);
   
       out << STRLIT("</VALUE.INSTANCEWITHPATH>\n");
   }
   //EXP_PULL_END
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // appendClassElement() // appendClassElement()
Line 1564 
Line 861 
  
 void XmlWriter::appendClassElement( void XmlWriter::appendClassElement(
     Buffer& out,     Buffer& out,
     const CIMConstClass& cimclass)      const CIMConstClass& cimClass)
 { {
     cimclass._checkRep();      CheckRep(cimClass._rep);
     cimclass._rep->toXml(out);      const CIMClassRep* rep = cimClass._rep;
   
       // Class opening element:
   
       out << STRLIT("<CLASS NAME=\"")
           << rep->getClassName()
           << STRLIT("\" ");
   
       if (!rep->getSuperClassName().isNull())
       {
           out << STRLIT(" SUPERCLASS=\"")
               << rep->getSuperClassName()
               << STRLIT("\" ");
       }
   
       out << STRLIT(">\n");
   
       // Append Class Qualifiers:
   
       for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
           XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
   
       // Append Property definitions:
   
       for (Uint32 i = 0, n = rep->getPropertyCount(); i < n; i++)
           XmlWriter::appendPropertyElement(out, rep->getProperty(i));
   
       // Append Method definitions:
   
       for (Uint32 i = 0, n = rep->getMethodCount(); i < n; i++)
           XmlWriter::appendMethodElement(out, rep->getMethod(i));
   
       // Class closing element:
   
       out << STRLIT("</CLASS>\n");
 } }
  
 void XmlWriter::printClassElement( void XmlWriter::printClassElement(
Line 1576 
Line 907 
 { {
     Buffer tmp;     Buffer tmp;
     appendClassElement(tmp, cimclass);     appendClassElement(tmp, cimclass);
     tmp.append('\0');  
     indentedPrint(os, tmp.getData(), 4);     indentedPrint(os, tmp.getData(), 4);
 } }
  
Line 1595 
Line 925 
     Buffer& out,     Buffer& out,
     const CIMConstInstance& instance)     const CIMConstInstance& instance)
 { {
     instance._checkRep();      CheckRep(instance._rep);
     instance._rep->toXml(out);      const CIMInstanceRep* rep = instance._rep;
   
       // Class opening element:
   
       out << STRLIT("<INSTANCE CLASSNAME=\"")
           << rep->getClassName()
           << STRLIT("\" >\n");
   
       // Append Instance Qualifiers:
   
       for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
           XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
   
       // Append Properties:
   
       for (Uint32 i = 0, n = rep->getPropertyCount(); i < n; i++)
           XmlWriter::appendPropertyElement(out, rep->getProperty(i));
   
       // Instance closing element:
   
       out << STRLIT("</INSTANCE>\n");
 } }
  
 void XmlWriter::printInstanceElement( void XmlWriter::printInstanceElement(
Line 1605 
Line 955 
 { {
     Buffer tmp;     Buffer tmp;
     appendInstanceElement(tmp, instance);     appendInstanceElement(tmp, instance);
     tmp.append('\0');  
     os << tmp.getData() << PEGASUS_STD(endl);     os << tmp.getData() << PEGASUS_STD(endl);
 } }
  
Line 1666 
Line 1015 
     Buffer& out,     Buffer& out,
     const CIMConstProperty& property)     const CIMConstProperty& property)
 { {
     property._checkRep();      CheckRep(property._rep);
     property._rep->toXml(out);      const CIMPropertyRep* rep = property._rep;
   
       if (rep->getValue().isArray())
       {
           out << STRLIT("<PROPERTY.ARRAY NAME=\"")
               << rep->getName()
               << STRLIT("\" ");
   
           if (rep->getValue().getType() == CIMTYPE_OBJECT)
           {
               // If the property array type is CIMObject, then
               //     encode the property in CIM-XML as a string array with the
               //     EmbeddedObject attribute (there is not currently a CIM-XML
               //     "object" datatype)
   
               Array<CIMObject> a;
               rep->getValue().get(a);
               out << STRLIT(" TYPE=\"string\"");
               // If the Embedded Object is an instance, always add the
               // EmbeddedObject attribute.
               if (a.size() > 0 && a[0].isInstance())
               {
                   out << STRLIT(" EmbeddedObject=\"object\""
                                 " EMBEDDEDOBJECT=\"object\"");
               }
   #ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY
               else
   #endif
               {
                   // Else the Embedded Object is a class, always add the
                   // EmbeddedObject qualifier.  Note that if the macro
                   // PEGASUS_SNIA_INTEROP_COMPATIBILITY is defined, then
                   // the EmbeddedObject qualifier will always be added,
                   // whether it's a class or an instance.
                   if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT) ==
                           PEG_NOT_FOUND)
                   {
                       // Note that addQualifiers() cannot be called on a const
                       // CIMQualifierRep.  In this case we really do want to add
                       // the EmbeddedObject qualifier, so we cast away the
                       // constness.
                       CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);
                       tmpRep->addQualifier(
                           CIMQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT,
                                        true));
                   }
               }
           }
           else if (rep->getValue().getType() == CIMTYPE_INSTANCE)
           {
               // If the property array type is CIMInstance, then
               //   encode the property in CIM-XML as a string array with the
               //   EmbeddedObject attribute (there is not currently a CIM-XML
               //   "instance" datatype)
   
               Array<CIMInstance> a;
               rep->getValue().get(a);
               out << STRLIT(" TYPE=\"string\"");
   
               // add the EmbeddedObject attribute
               if (a.size() > 0)
               {
                   out << STRLIT(" EmbeddedObject=\"instance\""
                                 " EMBEDDEDOBJECT=\"instance\"");
   
                   // Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY is
                   // defined, then the EmbeddedInstance qualifier will be added
   # ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY
                   if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE ==
                           PEG_NOT_FOUND)
                   {
                       // Note that addQualifiers() cannot be called on a const
                       // CIMQualifierRep.  In this case we really do want to add
                       // the EmbeddedInstance qualifier, so we cast away the
                       // constness.
   
                       // For now, we assume that all the embedded instances in
                       // the array are of the same type
                       CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);
                       tmpRep->addQualifier(CIMQualifier(
                           PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE,
                           a[0].getClassName().getString()));
                   }
   # endif
               }
           }
           else
           {
               out.append(' ');
               out << xmlWriterTypeStrings(rep->getValue().getType());
           }
   
           if (rep->getArraySize())
           {
               char buffer[32];
               sprintf(buffer, "%u", rep->getArraySize());
               out << STRLIT(" ARRAYSIZE=\"") << buffer;
               out.append('"');
           }
   
           if (!rep->getClassOrigin().isNull())
           {
               out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin();
               out.append('"');
           }
   
           if (rep->getPropagated())
           {
               out << STRLIT(" PROPAGATED=\"true\"");
           }
   
           out << STRLIT(">\n");
   
           for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
               XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
   
           XmlWriter::appendValueElement(out, rep->getValue());
   
           out << STRLIT("</PROPERTY.ARRAY>\n");
       }
       else if (rep->getValue().getType() == CIMTYPE_REFERENCE)
       {
           out << STRLIT("<PROPERTY.REFERENCE"
                         " NAME=\"") << rep->getName() << STRLIT("\" ");
   
           if (!rep->getReferenceClassName().isNull())
           {
               out << STRLIT(" REFERENCECLASS=\"") << rep->getReferenceClassName();
               out.append('"');
           }
   
           if (!rep->getClassOrigin().isNull())
           {
               out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin();
               out.append('"');
           }
   
           if (rep->getPropagated())
           {
               out << STRLIT(" PROPAGATED=\"true\"");
           }
   
           out << STRLIT(">\n");
   
           for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
               XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
   
           XmlWriter::appendValueElement(out, rep->getValue());
   
           out << STRLIT("</PROPERTY.REFERENCE>\n");
       }
       else
       {
           out << STRLIT("<PROPERTY NAME=\"") << rep->getName() << STRLIT("\" ");
   
           if (!rep->getClassOrigin().isNull())
           {
               out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin();
               out.append('"');
           }
   
           if (rep->getPropagated())
           {
               out << STRLIT(" PROPAGATED=\"true\"");
           }
   
           if (rep->getValue().getType() == CIMTYPE_OBJECT)
           {
               // If the property type is CIMObject, then
               //   encode the property in CIM-XML as a string with the
               //   EmbeddedObject attribute (there is not currently a CIM-XML
               //   "object" datatype)
   
               CIMObject a;
               rep->getValue().get(a);
               out << STRLIT(" TYPE=\"string\"");
   
               // If the Embedded Object is an instance, always add the
               // EmbeddedObject attribute.
               if (a.isInstance())
               {
                   out << STRLIT(" EmbeddedObject=\"object\""
                                 " EMBEDDEDOBJECT=\"object\"");
               }
               // Else the Embedded Object is a class, always add the
               // EmbeddedObject qualifier.
   #ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY
               else
   #endif
               {
                   // Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY
                   // is defined, then the EmbeddedObject qualifier will always
                   // be added, whether it's a class or an instance.
                   if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT) ==
                           PEG_NOT_FOUND)
                   {
                       // Note that addQualifiers() cannot be called on a const
                       // CIMQualifierRep.  In this case we really do want to add
                       // the EmbeddedObject qualifier, so we cast away the
                       // constness.
                       CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);
                       tmpRep->addQualifier(
                           CIMQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT,
                                        true));
                   }
               }
           }
           else if (rep->getValue().getType() == CIMTYPE_INSTANCE)
           {
               CIMInstance a;
               rep->getValue().get(a);
               out << STRLIT(" TYPE=\"string\""
                             " EmbeddedObject=\"instance\""
                             " EMBEDDEDOBJECT=\"instance\"");
   
   # ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY
               if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT)
                   == PEG_NOT_FOUND)
               {
                   // Note that addQualifiers() cannot be called on a const
                   // CIMQualifierRep.  In this case we really do want to add
                   // the EmbeddedInstance qualifier, so we cast away the
                   // constness.
                   CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);
                   tmpRep->addQualifier(CIMQualifier(
                       PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE,
                       a.getClassName().getString()));
               }
   # endif
           }
           else
           {
               out.append(' ');
               out << xmlWriterTypeStrings(rep->getValue().getType());
           }
   
           out << STRLIT(">\n");
   
           for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
               XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
   
           XmlWriter::appendValueElement(out, rep->getValue());
   
           out << STRLIT("</PROPERTY>\n");
       }
 } }
  
 void XmlWriter::printPropertyElement( void XmlWriter::printPropertyElement(
Line 1676 
Line 1269 
 { {
     Buffer tmp;     Buffer tmp;
     appendPropertyElement(tmp, property);     appendPropertyElement(tmp, property);
     tmp.append('\0');  
     os << tmp.getData() << PEGASUS_STD(endl);     os << tmp.getData() << PEGASUS_STD(endl);
 } }
  
Line 1698 
Line 1290 
     Buffer& out,     Buffer& out,
     const CIMConstMethod& method)     const CIMConstMethod& method)
 { {
     method._checkRep();      CheckRep(method._rep);
     method._rep->toXml(out);      const CIMMethodRep* rep = method._rep;
   
       out << STRLIT("<METHOD NAME=\"") << rep->getName();
       out << STRLIT("\" ");
   
       out << xmlWriterTypeStrings(rep->getType());
   
       if (!rep->getClassOrigin().isNull())
       {
           out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin();
           out.append('"');
       }
   
       if (rep->getPropagated())
       {
           out << STRLIT(" PROPAGATED=\"true\"");
       }
   
       out << STRLIT(">\n");
   
       for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
           XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
   
       for (Uint32 i = 0, n = rep->getParameterCount(); i < n; i++)
           XmlWriter::appendParameterElement(out, rep->getParameter(i));
   
       out << STRLIT("</METHOD>\n");
 } }
  
 void XmlWriter::printMethodElement( void XmlWriter::printMethodElement(
Line 1708 
Line 1326 
 { {
     Buffer tmp;     Buffer tmp;
     appendMethodElement(tmp, method);     appendMethodElement(tmp, method);
     tmp.append('\0');  
     os << tmp.getData() << PEGASUS_STD(endl);     os << tmp.getData() << PEGASUS_STD(endl);
 } }
  
Line 1744 
Line 1361 
     Buffer& out,     Buffer& out,
     const CIMConstParameter& parameter)     const CIMConstParameter& parameter)
 { {
     parameter._checkRep();      CheckRep(parameter._rep);
     parameter._rep->toXml(out);      const CIMParameterRep* rep = parameter._rep;
   
       if (rep->isArray())
       {
           if (rep->getType() == CIMTYPE_REFERENCE)
           {
               out << STRLIT("<PARAMETER.REFARRAY NAME=\"") << rep->getName();
               out.append('"');
   
               if (!rep->getReferenceClassName().isNull())
               {
                   out << STRLIT(" REFERENCECLASS=\"");
                   out << rep->getReferenceClassName().getString();
                   out.append('"');
               }
   
               if (rep->getArraySize())
               {
                   char buffer[32];
                   int n = sprintf(buffer, "%u", rep->getArraySize());
                   out << STRLIT(" ARRAYSIZE=\"");
                   out.append(buffer, n);
                   out.append('"');
               }
   
               out << STRLIT(">\n");
   
               for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
                   XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
   
               out << STRLIT("</PARAMETER.REFARRAY>\n");
           }
           else
           {
               out << STRLIT("<PARAMETER.ARRAY"
                             " NAME=\"") << rep->getName();
               out << STRLIT("\" ") << xmlWriterTypeStrings(rep->getType());
   
               if (rep->getArraySize())
               {
                   char buffer[32];
                   sprintf(buffer, "%u", rep->getArraySize());
                   out << STRLIT(" ARRAYSIZE=\"") << buffer;
                   out.append('"');
               }
   
               out << STRLIT(">\n");
   
               for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
                   XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
   
               out << STRLIT("</PARAMETER.ARRAY>\n");
           }
       }
       else if (rep->getType() == CIMTYPE_REFERENCE)
       {
           out << STRLIT("<PARAMETER.REFERENCE"
                         " NAME=\"") << rep->getName();
           out.append('"');
   
           if (!rep->getReferenceClassName().isNull())
           {
               out << STRLIT(" REFERENCECLASS=\"");
               out << rep->getReferenceClassName().getString();
               out.append('"');
           }
           out << STRLIT(">\n");
   
           for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
               XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
   
           out << STRLIT("</PARAMETER.REFERENCE>\n");
       }
       else
       {
           out << STRLIT("<PARAMETER"
                         " NAME=\"") << rep->getName();
           out << STRLIT("\" ") << xmlWriterTypeStrings(rep->getType());
   
           out << STRLIT(">\n");
   
           for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
               XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
   
           out << STRLIT("</PARAMETER>\n");
       }
 } }
  
 void XmlWriter::printParameterElement( void XmlWriter::printParameterElement(
Line 1754 
Line 1456 
 { {
     Buffer tmp;     Buffer tmp;
     appendParameterElement(tmp, parameter);     appendParameterElement(tmp, parameter);
     tmp.append('\0');  
     os << tmp.getData() << PEGASUS_STD(endl);     os << tmp.getData() << PEGASUS_STD(endl);
 } }
  
Line 1764 
Line 1465 
 // //
 //     <!ELEMENT PARAMVALUE (VALUE|VALUE.REFERENCE|VALUE.ARRAY|VALUE.REFARRAY)?> //     <!ELEMENT PARAMVALUE (VALUE|VALUE.REFERENCE|VALUE.ARRAY|VALUE.REFARRAY)?>
 //     <!ATTLIST PARAMVALUE //     <!ATTLIST PARAMVALUE
 //              %CIMName;>  //         %CIMName;
   //         %EmbeddedObject; #IMPLIED
   //         %ParamType;>
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
Line 1772 
Line 1475 
     Buffer& out,     Buffer& out,
     const CIMParamValue& paramValue)     const CIMParamValue& paramValue)
 { {
     paramValue._checkRep();      CheckRep(paramValue._rep);
     paramValue._rep->toXml(out);      const CIMParamValueRep* rep = paramValue._rep;
   
       out << STRLIT("<PARAMVALUE NAME=\"") << rep->getParameterName();
       out.append('"');
   
       CIMType type = rep->getValue().getType();
   
       if (rep->isTyped())
       {
           XmlWriter::appendParamTypeAndEmbeddedObjAttrib(out, type);
       }
   
       out << STRLIT(">\n");
       XmlWriter::appendValueElement(out, rep->getValue());
   
       out << STRLIT("</PARAMVALUE>\n");
 } }
  
 void XmlWriter::printParamValueElement( void XmlWriter::printParamValueElement(
Line 1782 
Line 1500 
 { {
     Buffer tmp;     Buffer tmp;
     appendParamValueElement(tmp, paramValue);     appendParamValueElement(tmp, paramValue);
     tmp.append('\0');  
     os << tmp.getData() << PEGASUS_STD(endl);     os << tmp.getData() << PEGASUS_STD(endl);
 } }
  
Line 1803 
Line 1520 
     Buffer& out,     Buffer& out,
     const CIMConstQualifier& qualifier)     const CIMConstQualifier& qualifier)
 { {
     qualifier._checkRep();      CheckRep(qualifier._rep);
     qualifier._rep->toXml(out);      const CIMQualifierRep* rep = qualifier._rep;
   
       out << STRLIT("<QUALIFIER NAME=\"") << rep->getName();
       out << STRLIT("\" ") << xmlWriterTypeStrings(rep->getValue().getType());
   
       if (rep->getPropagated())
       {
           out << STRLIT(" PROPAGATED=\"true\"");
       }
   
       XmlWriter::appendQualifierFlavorEntity(out, rep->getFlavor());
   
       out << STRLIT(">\n");
   
       XmlWriter::appendValueElement(out, rep->getValue());
   
       out << STRLIT("</QUALIFIER>\n");
 } }
  
 void XmlWriter::printQualifierElement( void XmlWriter::printQualifierElement(
Line 1813 
Line 1546 
 { {
     Buffer tmp;     Buffer tmp;
     appendQualifierElement(tmp, qualifier);     appendQualifierElement(tmp, qualifier);
     tmp.append('\0');  
     os << tmp.getData() << PEGASUS_STD(endl);     os << tmp.getData() << PEGASUS_STD(endl);
 } }
  
Line 1835 
Line 1567 
     Buffer& out,     Buffer& out,
     const CIMConstQualifierDecl& qualifierDecl)     const CIMConstQualifierDecl& qualifierDecl)
 { {
     qualifierDecl._checkRep();      CheckRep(qualifierDecl._rep);
     qualifierDecl._rep->toXml(out);      const CIMQualifierDeclRep* rep = qualifierDecl._rep;
   
       out << STRLIT("<QUALIFIER.DECLARATION NAME=\"") << rep->getName();
       out << STRLIT("\" ") << xmlWriterTypeStrings(rep->getValue().getType());
   
       if (rep->getValue().isArray())
       {
           out << STRLIT(" ISARRAY=\"true\"");
   
           if (rep->getArraySize())
           {
               char buffer[64];
               int n = sprintf(buffer, " ARRAYSIZE=\"%u\"", rep->getArraySize());
               out.append(buffer, n);
           }
       }
   
       XmlWriter::appendQualifierFlavorEntity(out, rep->getFlavor());
   
       out << STRLIT(">\n");
   
       XmlWriter::appendScopeElement(out, rep->getScope());
       XmlWriter::appendValueElement(out, rep->getValue());
   
       out << STRLIT("</QUALIFIER.DECLARATION>\n");
 } }
  
 void XmlWriter::printQualifierDeclElement( void XmlWriter::printQualifierDeclElement(
Line 1845 
Line 1601 
 { {
     Buffer tmp;     Buffer tmp;
     appendQualifierDeclElement(tmp, qualifierDecl);     appendQualifierDeclElement(tmp, qualifierDecl);
     tmp.append('\0');  
     os << tmp.getData() << PEGASUS_STD(endl);     os << tmp.getData() << PEGASUS_STD(endl);
 } }
  
Line 1858 
Line 1613 
 //                                 TOINSTANCE   (true|false)   'false' //                                 TOINSTANCE   (true|false)   'false'
 //                                 TRANSLATABLE (true|false)   'false'"> //                                 TRANSLATABLE (true|false)   'false'">
 // //
   //     DEPRECATION NOTE:  The attribute TOINSTANCE is DEPRECATED and MAY be
   //     removed from the QualifierFlavor entity in a future version of this
   //     document.  Use of this qualifier is discouraged.
   //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 void XmlWriter::appendQualifierFlavorEntity( void XmlWriter::appendQualifierFlavorEntity(
Line 1865 
Line 1624 
     const CIMFlavor & flavor)     const CIMFlavor & flavor)
 { {
     if (!(flavor.hasFlavor (CIMFlavor::OVERRIDABLE)))     if (!(flavor.hasFlavor (CIMFlavor::OVERRIDABLE)))
         out << LIT(" OVERRIDABLE=\"false\"");          out << STRLIT(" OVERRIDABLE=\"false\"");
  
     if (!(flavor.hasFlavor (CIMFlavor::TOSUBCLASS)))     if (!(flavor.hasFlavor (CIMFlavor::TOSUBCLASS)))
         out << LIT(" TOSUBCLASS=\"false\"");          out << STRLIT(" TOSUBCLASS=\"false\"");
  
     if (flavor.hasFlavor (CIMFlavor::TOINSTANCE))      //if (flavor.hasFlavor (CIMFlavor::TOINSTANCE))
         out << LIT(" TOINSTANCE=\"true\"");      //    out << STRLIT(" TOINSTANCE=\"true\"");
  
     if (flavor.hasFlavor (CIMFlavor::TRANSLATABLE))     if (flavor.hasFlavor (CIMFlavor::TRANSLATABLE))
         out << LIT(" TRANSLATABLE=\"true\"");          out << STRLIT(" TRANSLATABLE=\"true\"");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 1899 
Line 1658 
 { {
     if (!(scope.equal (CIMScope ())))     if (!(scope.equal (CIMScope ())))
     {     {
         out << LIT("<SCOPE");          out << STRLIT("<SCOPE");
  
         if (scope.hasScope (CIMScope::CLASS))         if (scope.hasScope (CIMScope::CLASS))
             out << LIT(" CLASS=\"true\"");              out << STRLIT(" CLASS=\"true\"");
  
         if (scope.hasScope (CIMScope::ASSOCIATION))         if (scope.hasScope (CIMScope::ASSOCIATION))
             out << LIT(" ASSOCIATION=\"true\"");              out << STRLIT(" ASSOCIATION=\"true\"");
  
         if (scope.hasScope (CIMScope::REFERENCE))         if (scope.hasScope (CIMScope::REFERENCE))
             out << LIT(" REFERENCE=\"true\"");              out << STRLIT(" REFERENCE=\"true\"");
  
         if (scope.hasScope (CIMScope::PROPERTY))         if (scope.hasScope (CIMScope::PROPERTY))
             out << LIT(" PROPERTY=\"true\"");              out << STRLIT(" PROPERTY=\"true\"");
  
         if (scope.hasScope (CIMScope::METHOD))         if (scope.hasScope (CIMScope::METHOD))
             out << LIT(" METHOD=\"true\"");              out << STRLIT(" METHOD=\"true\"");
  
         if (scope.hasScope (CIMScope::PARAMETER))         if (scope.hasScope (CIMScope::PARAMETER))
             out << LIT(" PARAMETER=\"true\"");              out << STRLIT(" PARAMETER=\"true\"");
  
         if (scope.hasScope (CIMScope::INDICATION))         if (scope.hasScope (CIMScope::INDICATION))
             out << LIT(" INDICATION=\"true\"");              out << STRLIT(" INDICATION=\"true\"");
  
         out << LIT("/>");          out << STRLIT("/>");
     }     }
 } }
  
Line 1944 
Line 1703 
     const String& cimObject,     const String& cimObject,
     const String& authenticationHeader,     const String& authenticationHeader,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const AcceptLanguages & acceptLanguages,      const AcceptLanguageList& acceptLanguages,
     const ContentLanguages & contentLanguages,      const ContentLanguageList& contentLanguages,
     Uint32 contentLength)      Uint32 contentLength,
       bool binaryRequest,
       bool binaryResponse)
 { {
     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };
  
Line 1958 
Line 1719 
     // installed.  Required because of change to wbemservices cimom     // installed.  Required because of change to wbemservices cimom
     if (httpMethod == HTTP_METHOD_M_POST)     if (httpMethod == HTTP_METHOD_M_POST)
     {     {
         out << LIT("M-POST /cimom HTTP/1.1\r\n");          out << STRLIT("M-POST /cimom HTTP/1.1\r\n");
       }
       else
       {
           out << STRLIT("POST /cimom HTTP/1.1\r\n");
       }
       out << STRLIT("HOST: ") << host << STRLIT("\r\n");
   
       if (binaryRequest)
       {
           // Tell the server that the payload is encoded in the OpenPegasus
           // binary protocol.
           out << STRLIT("Content-Type: application/x-openpegasus\r\n");
     }     }
     else     else
     {     {
         out << LIT("POST /cimom HTTP/1.1\r\n");          out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n");
     }     }
     out << LIT("HOST: ") << host << LIT("\r\n");  
     out << LIT("Content-Type: application/xml; charset=\"utf-8\"\r\n");      if (binaryResponse)
     OUTPUT_CONTENTLENGTH;      {
           // Tell the server that this client accepts the OpenPegasus binary
           // protocol.
           out << STRLIT("Accept: application/x-openpegasus\r\n");
       }
   
       OUTPUT_CONTENTLENGTH(out, contentLength);
     if (acceptLanguages.size() > 0)     if (acceptLanguages.size() > 0)
     {     {
         out << LIT("Accept-Language: ") << acceptLanguages << LIT("\r\n");          out << STRLIT("Accept-Language: ") << acceptLanguages << STRLIT("\r\n");
     }     }
     if (contentLanguages.size() > 0)     if (contentLanguages.size() > 0)
     {     {
         out << LIT("Content-Language: ") << contentLanguages << LIT("\r\n");          out << STRLIT("Content-Language: ") << contentLanguages <<
               STRLIT("\r\n");
     }     }
  
 #ifdef PEGASUS_DEBUG #ifdef PEGASUS_DEBUG
Line 1984 
Line 1764 
  
                 static const char *clientTransferEncodingOff =                 static const char *clientTransferEncodingOff =
                         getenv("PEGASUS_HTTP_TRANSFER_ENCODING_REQUEST");                         getenv("PEGASUS_HTTP_TRANSFER_ENCODING_REQUEST");
                 if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0')  
       // EXP_PULL_TEMP DELETE
       // KS_TODO - Remove this. Temp to insure no chunking during testing
       //  if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0')
 #endif #endif
  
                         out << LIT("TE: chunked, trailers\r\n");      // EXP_PULL TEMP DELETE out << STRLIT("TE: chunked, trailers\r\n");
   
       if (!binaryResponse)
       {
           // The binary protocol does not allow chunking.
           out << STRLIT("TE: chunked, trailers\r\n");
       }
  
     if (httpMethod == HTTP_METHOD_M_POST)     if (httpMethod == HTTP_METHOD_M_POST)
     {     {
         out << LIT("Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");          out << STRLIT("Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");
         out << nn << LIT("\r\n");          out << nn << STRLIT("\r\n");
         out << nn << LIT("-CIMOperation: MethodCall\r\n");          out << nn << STRLIT("-CIMOperation: MethodCall\r\n");
         out << nn << LIT("-CIMMethod: ")          out << nn << STRLIT("-CIMMethod: ")
             << encodeURICharacters(cimMethod.getString()) << LIT("\r\n");              << encodeURICharacters(cimMethod.getString()) << STRLIT("\r\n");
         out << nn << LIT("-CIMObject: ") << encodeURICharacters(cimObject)          out << nn << STRLIT("-CIMObject: ")
             << LIT("\r\n");              << encodeURICharacters(cimObject) << STRLIT("\r\n");
     }     }
     else     else
     {     {
         out << LIT("CIMOperation: MethodCall\r\n");          out << STRLIT("CIMOperation: MethodCall\r\n");
         out << LIT("CIMMethod: ") << encodeURICharacters(cimMethod.getString())          out << STRLIT("CIMMethod: ")
             << LIT("\r\n");              << encodeURICharacters(cimMethod.getString()) << STRLIT("\r\n");
         out << LIT("CIMObject: ") << encodeURICharacters(cimObject)          out << STRLIT("CIMObject: ") << encodeURICharacters(cimObject)
             << LIT("\r\n");              << STRLIT("\r\n");
     }     }
  
     if (authenticationHeader.size())     if (authenticationHeader.size())
     {     {
         out << authenticationHeader << LIT("\r\n");          out << authenticationHeader << STRLIT("\r\n");
     }     }
  
     out << LIT("\r\n");      out << STRLIT("\r\n");
 } }
  
  
 void XmlWriter::appendMethodResponseHeader( void XmlWriter::appendMethodResponseHeader(
      Buffer& out,      Buffer& out,
      HttpMethod httpMethod,      HttpMethod httpMethod,
      const ContentLanguages & contentLanguages,       const ContentLanguageList& contentLanguages,
      Uint32 contentLength,      Uint32 contentLength,
      Uint32 serverResponseTime)       Uint64 serverResponseTime,
        bool binaryResponse)
 { {
      char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };      // Optimize the typical case for binary messages, circumventing the
      out << LIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n");      // more expensive logic below.
      STAT_SERVERTIME      if (binaryResponse &&
      out << LIT("Content-Type: application/xml; charset=\"utf-8\"\r\n");          contentLength == 0 &&
      OUTPUT_CONTENTLENGTH;          httpMethod != HTTP_METHOD_M_POST &&
           contentLanguages.size() == 0)
       {
           static const char HEADERS[] =
               "HTTP/1.1 200 OK\r\n"
               "Content-Type: application/x-openpegasus\r\n"
               "content-length: 0000000000\r\n"
               "CIMOperation: MethodResponse\r\n"
               "\r\n";
   
           // The HTTP processor fills in the content-length value later.
           // It searches for a field matching "content-length" (so the first
           // character must be lower case).
           out.append(HEADERS, sizeof(HEADERS) - 1);
           return;
       }
   
        out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n");
   
   #ifndef PEGASUS_DISABLE_PERFINST
        if (StatisticalData::current()->copyGSD)
        {
            out << STRLIT("WBEMServerResponseTime: ") <<
                CIMValue(serverResponseTime).toString() << STRLIT("\r\n");
        }
   #endif
   
        if (binaryResponse)
        {
           // According to MIME RFC, the "x-" prefix should be used for all
           // non-registered values.
            out << STRLIT("Content-Type: application/x-openpegasus\r\n");
        }
        else
        {
            out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n");
        }
   
        OUTPUT_CONTENTLENGTH(out, contentLength);
  
      if (contentLanguages.size() > 0)      if (contentLanguages.size() > 0)
      {      {
          out << LIT("Content-Language: ") << contentLanguages << LIT("\r\n");           out << STRLIT("Content-Language: ") << contentLanguages <<
                STRLIT("\r\n");
      }      }
      if (httpMethod == HTTP_METHOD_M_POST)      if (httpMethod == HTTP_METHOD_M_POST)
      {      {
          out << LIT("Ext:\r\n");           char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };
          out << LIT("Cache-Control: no-cache\r\n");  
          out << LIT("Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");           out << STRLIT("Ext:\r\n"
          out << nn << LIT("\r\n");                         "Cache-Control: no-cache\r\n"
          out << nn << LIT("-CIMOperation: MethodResponse\r\n\r\n");                         "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");
            out << nn << STRLIT("\r\n");
            out << nn << STRLIT("-CIMOperation: MethodResponse\r\n\r\n");
      }      }
      else      else
      {      {
          out << LIT("CIMOperation: MethodResponse\r\n\r\n");           out << STRLIT("CIMOperation: MethodResponse\r\n\r\n");
      }      }
 } }
  
Line 2069 
Line 1900 
     const String& cimError,     const String& cimError,
     const String& errorDetail)     const String& errorDetail)
 { {
     out << LIT("HTTP/1.1 ") << status << LIT("\r\n");      out << STRLIT("HTTP/1.1 ") << status << STRLIT("\r\n");
     if (cimError != String::EMPTY)     if (cimError != String::EMPTY)
     {     {
         out << LIT("CIMError: ") << cimError << LIT("\r\n");          out << STRLIT("CIMError: ") << cimError << STRLIT("\r\n");
     }     }
     if (errorDetail != String::EMPTY)     if (errorDetail != String::EMPTY)
     {     {
         // ATTN-RK-P3-20020404: It is critical that this text not contain '\n'          out << STRLIT(PEGASUS_HTTPHEADERTAG_ERRORDETAIL ": ")
         // ATTN-RK-P3-20020404: Need to encode this value properly.  (See              << encodeURICharacters(errorDetail) << STRLIT("\r\n");
         // CIM/HTTP Specification section 3.3.2  
         out << LIT(PEGASUS_HTTPHEADERTAG_ERRORDETAIL ": ")  
             << encodeURICharacters(errorDetail) << LIT("\r\n");  
     }     }
     out << LIT("\r\n");      out << STRLIT("\r\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 2094 
Line 1922 
 //     Returns unauthorized message in the following format: //     Returns unauthorized message in the following format:
 // //
 //        HTTP/1.1 401 Unauthorized //        HTTP/1.1 401 Unauthorized
 //        WWW-Authenticate: Basic "hostname:80"  //        WWW-Authenticate: Basic realm="HostName"
 //        <HTML><HEAD> //        <HTML><HEAD>
 //        <TITLE>401 Unauthorized</TITLE> //        <TITLE>401 Unauthorized</TITLE>
 //        </HEAD><BODY BGCOLOR="#99cc99"> //        </HEAD><BODY BGCOLOR="#99cc99">
Line 2108 
Line 1936 
     Buffer& out,     Buffer& out,
     const String& content)     const String& content)
 { {
     out << LIT("HTTP/1.1 " HTTP_STATUS_UNAUTHORIZED "\r\n");      out << STRLIT("HTTP/1.1 " HTTP_STATUS_UNAUTHORIZED "\r\n");
     out << content << LIT("\r\n");      OUTPUT_CONTENTLENGTH(out, 0);
     out << LIT("\r\n");      out << content << STRLIT("\r\n\r\n");
  
 //ATTN: We may need to include the following line, so that the browsers //ATTN: We may need to include the following line, so that the browsers
 //      can display the error message. //      can display the error message.
Line 2147 
Line 1975 
     Buffer& out,     Buffer& out,
     const String& content)     const String& content)
 { {
     out << LIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n");      out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n");
     // Content-Length header needs to be added because 200 OK record     // Content-Length header needs to be added because 200 OK record
     // is usually intended to have content.  But, for Kerberos this     // is usually intended to have content.  But, for Kerberos this
     // may not always be the case so we need to indicate that there     // may not always be the case so we need to indicate that there
     // is no content     // is no content
                 Uint32 contentLength = 0;      OUTPUT_CONTENTLENGTH(out, 0);
                 OUTPUT_CONTENTLENGTH;      out << content << STRLIT("\r\n\r\n");
     out << content << LIT("\r\n");  
     out << LIT("\r\n");  
  
 //ATTN: We may need to include the following line, so that the browsers //ATTN: We may need to include the following line, so that the browsers
 //      can display the error message. //      can display the error message.
Line 2184 
Line 2010 
     Buffer& out,     Buffer& out,
     const String& messageId)     const String& messageId)
 { {
     out << LIT("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");      out << STRLIT("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
     out << LIT("<CIM CIMVERSION=\"2.0\" DTDVERSION=\"2.0\">\n");                    "<CIM CIMVERSION=\"2.0\" DTDVERSION=\"2.0\">\n"
     out << LIT("<MESSAGE ID=\"") << messageId;                    "<MESSAGE ID=\"") << messageId;
     out << LIT("\" PROTOCOLVERSION=\"1.0\">\n");      out << STRLIT("\" PROTOCOLVERSION=\"1.0\">\n");
 } }
  
 void XmlWriter::_appendMessageElementEnd( void XmlWriter::_appendMessageElementEnd(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("</MESSAGE>\n");      out << STRLIT("</MESSAGE>\n</CIM>\n");
     out << LIT("</CIM>\n");  
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 2209 
Line 2034 
 void XmlWriter::_appendSimpleReqElementBegin( void XmlWriter::_appendSimpleReqElementBegin(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("<SIMPLEREQ>\n");      out << STRLIT("<SIMPLEREQ>\n");
 } }
  
 void XmlWriter::_appendSimpleReqElementEnd( void XmlWriter::_appendSimpleReqElementEnd(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("</SIMPLEREQ>\n");      out << STRLIT("</SIMPLEREQ>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 2232 
Line 2057 
     Buffer& out,     Buffer& out,
     const CIMName& name)     const CIMName& name)
 { {
     out << LIT("<METHODCALL NAME=\"") << name << LIT("\">\n");      out << STRLIT("<METHODCALL NAME=\"") << name << STRLIT("\">\n");
 } }
  
 void XmlWriter::_appendMethodCallElementEnd( void XmlWriter::_appendMethodCallElementEnd(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("</METHODCALL>\n");      out << STRLIT("</METHODCALL>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 2255 
Line 2080 
     Buffer& out,     Buffer& out,
     const CIMName& name)     const CIMName& name)
 { {
     out << LIT("<IMETHODCALL NAME=\"") << name << LIT("\">\n");      out << STRLIT("<IMETHODCALL NAME=\"") << name << STRLIT("\">\n");
 } }
  
 void XmlWriter::_appendIMethodCallElementEnd( void XmlWriter::_appendIMethodCallElementEnd(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("</IMETHODCALL>\n");      out << STRLIT("</IMETHODCALL>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 2280 
Line 2105 
     Buffer& out,     Buffer& out,
     const char* name)     const char* name)
 { {
     out << LIT("<IPARAMVALUE NAME=\"") << name << LIT("\">\n");      out << STRLIT("<IPARAMVALUE NAME=\"") << name << STRLIT("\">\n");
 } }
  
 void XmlWriter::_appendIParamValueElementEnd( void XmlWriter::_appendIParamValueElementEnd(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("</IPARAMVALUE>\n");      out << STRLIT("</IPARAMVALUE>\n");
   }
   
   //------------------------------------------------------------------------------
   //
   // _appendParamValueElementBegin()
   // _appendParamValueElementEnd()
   //
   //     <!ELEMENT IPARAMVALUE (VALUE|VALUE.ARRAY|VALUE.REFERENCE
   //         |INSTANCENAME|CLASSNAME|QUALIFIER.DECLARATION
   //         |CLASS|INSTANCE|VALUE.NAMEDINSTANCE)?>
   //     <!ATTLIST IPARAMVALUE %CIMName;>
   //
   //------------------------------------------------------------------------------
   
   void XmlWriter::_appendParamValueElementBegin(
       Buffer& out,
       const char* name)
   {
       out << STRLIT("<PARAMVALUE NAME=\"") << name << STRLIT("\">\n");
 } }
  
   void XmlWriter::_appendParamValueElementEnd(
       Buffer& out)
   {
       out << STRLIT("</PARAMVALUE>\n");
   }
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // _appendSimpleRspElementBegin() // _appendSimpleRspElementBegin()
Line 2301 
Line 2150 
 void XmlWriter::_appendSimpleRspElementBegin( void XmlWriter::_appendSimpleRspElementBegin(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("<SIMPLERSP>\n");      out << STRLIT("<SIMPLERSP>\n");
 } }
  
 void XmlWriter::_appendSimpleRspElementEnd( void XmlWriter::_appendSimpleRspElementEnd(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("</SIMPLERSP>\n");      out << STRLIT("</SIMPLERSP>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 2324 
Line 2173 
     Buffer& out,     Buffer& out,
     const CIMName& name)     const CIMName& name)
 { {
     out << LIT("<METHODRESPONSE NAME=\"") << name << LIT("\">\n");      out << STRLIT("<METHODRESPONSE NAME=\"") << name << STRLIT("\">\n");
 } }
  
 void XmlWriter::_appendMethodResponseElementEnd( void XmlWriter::_appendMethodResponseElementEnd(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("</METHODRESPONSE>\n");      out << STRLIT("</METHODRESPONSE>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 2347 
Line 2196 
     Buffer& out,     Buffer& out,
     const CIMName& name)     const CIMName& name)
 { {
     out << LIT("<IMETHODRESPONSE NAME=\"") << name << LIT("\">\n");      out << STRLIT("<IMETHODRESPONSE NAME=\"") << name << STRLIT("\">\n");
 } }
  
 void XmlWriter::_appendIMethodResponseElementEnd( void XmlWriter::_appendIMethodResponseElementEnd(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("</IMETHODRESPONSE>\n");      out << STRLIT("</IMETHODRESPONSE>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 2366 
Line 2215 
     Buffer& out,     Buffer& out,
     const CIMException& cimException)     const CIMException& cimException)
 { {
     Tracer::traceCIMException(TRC_XML_WRITER, Tracer::LEVEL2, cimException);      Tracer::traceCIMException(TRC_XML, Tracer::LEVEL2, cimException);
  
     out << LIT("<ERROR");      out << STRLIT("<ERROR CODE=\"") << Uint32(cimException.getCode());
     out << LIT(" CODE=\"") << Uint32(cimException.getCode());  
     out.append('"');     out.append('"');
   
     String description = TraceableCIMException(cimException).getDescription();     String description = TraceableCIMException(cimException).getDescription();
   
     if (description != String::EMPTY)     if (description != String::EMPTY)
     {     {
         out << LIT(" DESCRIPTION=\"");          out << STRLIT(" DESCRIPTION=\"");
         appendSpecial(out, description);         appendSpecial(out, description);
         out.append('"');         out.append('"');
     }     }
     out << LIT("/>");  
       if (cimException.getErrorCount())
       {
           out << STRLIT(">");
   
           for (Uint32 i = 0, n = cimException.getErrorCount(); i < n; i++)
               appendInstanceElement(out, cimException.getError(i));
   
           out << STRLIT("</ERROR>");
       }
       else
           out << STRLIT("/>");
 } }
  
 //------------------------------------------------------------------------------  //----------------------------------------------------------------------
 //  
 // appendReturnValueElement()  
 // //
 // <!ELEMENT RETURNVALUE (VALUE|VALUE.REFERENCE)>  // appendParamTypeAndEmbeddedObjAttrib
 // <!ATTLIST RETURNVALUE  // Appends the Param type and EmbeddedObject Info to the buffer
 //     %EmbeddedObject; #IMPLIED //     %EmbeddedObject; #IMPLIED
 //     %ParamType;> //     %ParamType;>
 // //
 //------------------------------------------------------------------------------  //---------------------------------------------------------------------
  
 void XmlWriter::appendReturnValueElement(  void XmlWriter::appendParamTypeAndEmbeddedObjAttrib(
     Buffer& out,     Buffer& out,
     const CIMValue& value)      const CIMType& type)
 { {
     out << LIT("<RETURNVALUE");  
  
     CIMType type = value.getType();  
     // If the property type is CIMObject, then     // If the property type is CIMObject, then
     //   encode the property in CIM-XML as a string with the EMBEDDEDOBJECT attribute      //   encode the property in CIM-XML as a string with the EmbeddedObject
     //   (there is not currently a CIM-XML "object" datatype)      //   attribute (there is not currently a CIM-XML "object"
       //   datatype).
       //   Because of an error in Pegasus we were earlier outputting
       //   upper case "EMBEDDEDOBJECT" as the attribute name. The
       //   spec calls for mixed case "EmbeddedObject. Fixed in
       //   bug 7131 to output EmbeddedObject  attribute in upper
       //   case and mixed case. Receiver will ignore one or the
       //   other.
     // else     // else
     //   output the real type     //   output the real type
     if (type == CIMTYPE_OBJECT)     if (type == CIMTYPE_OBJECT)
     {     {
         out << LIT(" PARAMTYPE=\"string\"");  
         out << LIT(" EMBEDDEDOBJECT=\"object\"");          out << STRLIT(" PARAMTYPE=\"string\""
                         " EmbeddedObject=\"object\""
                         " EMBEDDEDOBJECT=\"object\"");
       }
       else if (type == CIMTYPE_INSTANCE)
       {
           out << STRLIT(" PARAMTYPE=\"string\""
                         " EmbeddedObject=\"instance\""
                         " EMBEDDEDOBJECT=\"instance\"");
     }     }
     else     else
     {     {
         out << LIT(" PARAMTYPE=\"") << cimTypeToString (type);          out << STRLIT(" PARAM") << xmlWriterTypeStrings(type);
         out.append('"');      }
     }     }
  
     out << LIT(">\n");  //------------------------------------------------------------------------------
   //
   // appendReturnValueElement()
   //
   // <!ELEMENT RETURNVALUE (VALUE|VALUE.REFERENCE)>
   // <!ATTLIST RETURNVALUE
   //     %EmbeddedObject; #IMPLIED
   //     %ParamType;>
   //
   //------------------------------------------------------------------------------
   
   void XmlWriter::appendReturnValueElement(
       Buffer& out,
       const CIMValue& value)
   {
       out << STRLIT("<RETURNVALUE");
   
       CIMType type = value.getType();
   
       appendParamTypeAndEmbeddedObjAttrib(out, type);
   
       out << STRLIT(">\n");
  
     // Add value.     // Add value.
     appendValueElement(out, value);     appendValueElement(out, value);
     out << LIT("</RETURNVALUE>\n");      out << STRLIT("</RETURNVALUE>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 2437 
Line 2330 
 void XmlWriter::_appendIReturnValueElementBegin( void XmlWriter::_appendIReturnValueElementBegin(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("<IRETURNVALUE>\n");      out << STRLIT("<IRETURNVALUE>\n");
 } }
  
 void XmlWriter::_appendIReturnValueElementEnd( void XmlWriter::_appendIReturnValueElementEnd(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("</IRETURNVALUE>\n");      out << STRLIT("</IRETURNVALUE>\n");
   }
   
   //EXP_PULL_BEGIN
   void XmlWriter::_appendIReturnValueElementWithNameBegin(
       Buffer& out,
       const char* name)
   {
       out << STRLIT("<IRETURNVALUE NAME=\"") << name << STRLIT("\">\n");
 } }
   //EXP_PULL_END
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
Line 2458 
Line 2360 
     Boolean flag)     Boolean flag)
 { {
     _appendIParamValueElementBegin(out, name);     _appendIParamValueElementBegin(out, name);
     out << LIT("<VALUE>");      out << STRLIT("<VALUE>");
       append(out, flag);
       out << STRLIT("</VALUE>\n");
       _appendIParamValueElementEnd(out);
   }
   
   //EXP_PULL_BEGIN
   void XmlWriter::appendBooleanParameter(
       Buffer& out,
       const char* name,
       Boolean flag)
   {
       _appendParamValueElementBegin(out, name);
       out << STRLIT("<VALUE>");
       append(out, flag);
       out << STRLIT("</VALUE>\n");
       _appendParamValueElementEnd(out);
   }
   
   void XmlWriter::appendBooleanIReturnValue(
       Buffer& out,
       const char* name,
       Boolean flag)
   {
       _appendIReturnValueElementWithNameBegin(out, name);
       out << STRLIT("<VALUE>");
     append(out, flag);     append(out, flag);
     out << LIT("</VALUE>\n");      out << STRLIT("</VALUE>\n");
       _appendIReturnValueElementEnd(out);
   }
   
   // Can be used to generate either parameters with value,
   // parameters with NULL (i.e. no value element) or
   // no parameters output at all.
   void XmlWriter::appendUint32IParameter(
       Buffer& out,
       const char* name,
       const Uint32Arg& val,
       const Boolean required)
   {
       if (!required && val.isNull())
       {
           return;
       }
   
       _appendIParamValueElementBegin(out, name);
       if (!val.isNull())
       {
           out << STRLIT("<VALUE>");
           append(out, val.getValue());
           out << STRLIT("</VALUE>\n");
       }
     _appendIParamValueElementEnd(out);     _appendIParamValueElementEnd(out);
 } }
  
   /* Output return value from Uint64Arg object as
      Value inside IRETURNVALUE
      If the state of the object is NULL output
      the parameter without value.  Else
      output the value
   */
   void XmlWriter::appendUint64ReturnValue(
       Buffer& out,
       const char* name,
       const Uint64Arg& val)
   {
       _appendIReturnValueElementBegin(out);
       out << STRLIT("<VALUE>");
       if (!val.isNull())
       {
           append(out, val.getValue());
       }
       out << STRLIT("</VALUE>\n");
       _appendIReturnValueElementEnd(out);
   }
   //EXP_PULL_END
   
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // appendStringIParameter() // appendStringIParameter()
Line 2476 
Line 2449 
     const String& str)     const String& str)
 { {
     _appendIParamValueElementBegin(out, name);     _appendIParamValueElementBegin(out, name);
     out << LIT("<VALUE>");      out << STRLIT("<VALUE>");
     appendSpecial(out, str);     appendSpecial(out, str);
     out << LIT("</VALUE>\n");      out << STRLIT("</VALUE>\n");
     _appendIParamValueElementEnd(out);     _appendIParamValueElementEnd(out);
 } }
  
   // EXP_PULL
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // appendQualifierNameIParameter()  // appendStringIParameterIfNotEmpty()
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 void XmlWriter::appendQualifierNameIParameter(  void XmlWriter::appendStringIParameterIfNotEmpty(
     Buffer& out,     Buffer& out,
     const char* name,     const char* name,
     const String& qualifierName)      const String& str)
 { {
     // <!ELEMENT IPARAMVALUE (VALUE|VALUE.ARRAY|VALUE.REFERENCE      if (str != String::EMPTY)
     //     |INSTANCENAME|CLASSNAME|QUALIFIER.DECLARATION      {
     //     |CLASS|INSTANCE|VALUE.NAMEDINSTANCE)?>          appendStringIParameter(out,name,str);
       }
   }
   
   //------------------------------------------------------------------------------
   //
   // appendStringParameter()
     //     //
     // ATTN: notice that there is really no way to pass a qualifier name  //------------------------------------------------------------------------------
     // as an IPARAMVALUE element according to the spec (look above). So we  
     // just pass it as a class name. An answer must be obtained later.  
  
     _appendIParamValueElementBegin(out, name);  void XmlWriter::appendStringParameter(
     appendClassNameElement(out, qualifierName);      Buffer& out,
     _appendIParamValueElementEnd(out);      const char* name,
       const String& str)
   {
       _appendParamValueElementBegin(out, name);
       out << STRLIT("<VALUE>");
       appendSpecial(out, str);
       out << STRLIT("</VALUE>\n");
       _appendParamValueElementEnd(out);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
   // appendStringIReturnValue()
   //
   //------------------------------------------------------------------------------
   
   void XmlWriter::appendStringIReturnValue(
       Buffer& out,
       const char* name,
       const String& str)
   {
       _appendIReturnValueElementWithNameBegin(out, name);
       out << STRLIT("<VALUE>");
       appendSpecial(out, str);
       out << STRLIT("</VALUE>\n");
       _appendIReturnValueElementEnd(out);
   }
   //EXP_PULL_END
   //------------------------------------------------------------------------------
   //
 // appendClassNameIParameter() // appendClassNameIParameter()
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 2632 
Line 2635 
     const CIMName& propertyName)     const CIMName& propertyName)
 { {
     _appendIParamValueElementBegin(out, "PropertyName");     _appendIParamValueElementBegin(out, "PropertyName");
     out << LIT("<VALUE>") << propertyName << LIT("</VALUE>\n");      out << STRLIT("<VALUE>") << propertyName << STRLIT("</VALUE>\n");
     _appendIParamValueElementEnd(out);     _appendIParamValueElementEnd(out);
 } }
  
Line 2670 
Line 2673 
     //     //
     if (!propertyList.isNull ())     if (!propertyList.isNull ())
     {     {
         out << LIT("<VALUE.ARRAY>\n");          out << STRLIT("<VALUE.ARRAY>\n");
         for (Uint32 i = 0; i < propertyList.size(); i++)         for (Uint32 i = 0; i < propertyList.size(); i++)
         {         {
             out << LIT("<VALUE>") << propertyList[i] << LIT("</VALUE>\n");              out << STRLIT("<VALUE>") << propertyList[i] << STRLIT("</VALUE>\n");
         }         }
         out << LIT("</VALUE.ARRAY>\n");          out << STRLIT("</VALUE.ARRAY>\n");
     }     }
  
     _appendIParamValueElementEnd(out);     _appendIParamValueElementEnd(out);
Line 2733 
Line 2736 
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const String& authenticationHeader,     const String& authenticationHeader,
     const AcceptLanguages& httpAcceptLanguages,      const AcceptLanguageList& httpAcceptLanguages,
     const ContentLanguages& httpContentLanguages)      const ContentLanguageList& httpContentLanguages,
       bool binaryResponse)
 { {
     Buffer out;     Buffer out;
     Buffer tmp;     Buffer tmp;
Line 2763 
Line 2767 
         httpMethod,         httpMethod,
         httpAcceptLanguages,         httpAcceptLanguages,
         httpContentLanguages,         httpContentLanguages,
         out.size());          out.size(),
           false,
           binaryResponse);
     tmp << out;     tmp << out;
  
     return tmp;     return tmp;
 } }
  
 //PEP 128 adding serverRsponseTime to header  
 Buffer XmlWriter::formatSimpleMethodRspMessage( Buffer XmlWriter::formatSimpleMethodRspMessage(
     const CIMName& methodName,     const CIMName& methodName,
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const ContentLanguages & httpContentLanguages,      const ContentLanguageList& httpContentLanguages,
       const Buffer& bodyParams,
     const Buffer& body,     const Buffer& body,
                 Uint32 serverResponseTime,      Uint64 serverResponseTime,
                 Boolean isFirst,                 Boolean isFirst,
                 Boolean isLast)                 Boolean isLast)
 { {
Line 2786 
Line 2792 
         {         {
                 // NOTE: temporarily put zero for content length. the http code                 // NOTE: temporarily put zero for content length. the http code
                 // will later decide to fill in the length or remove it altogether                 // will later decide to fill in the length or remove it altogether
                 appendMethodResponseHeader(out, httpMethod, httpContentLanguages, 0,          appendMethodResponseHeader(
                                                                                                                          serverResponseTime);              out, httpMethod, httpContentLanguages, 0, serverResponseTime);
                 _appendMessageElementBegin(out, messageId);                 _appendMessageElementBegin(out, messageId);
                 _appendSimpleRspElementBegin(out);                 _appendSimpleRspElementBegin(out);
                 _appendMethodResponseElementBegin(out, methodName);                 _appendMethodResponseElementBegin(out, methodName);
Line 2809 
Line 2815 
 } }
  
  
   
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // XmlWriter::formatSimpleMethodErrorRspMessage() // XmlWriter::formatSimpleMethodErrorRspMessage()
Line 2833 
Line 2838 
     _appendSimpleRspElementEnd(out);     _appendSimpleRspElementEnd(out);
     _appendMessageElementEnd(out);     _appendMessageElementEnd(out);
  
 // l10n      appendMethodResponseHeader(
     appendMethodResponseHeader(tmp,          tmp,
         httpMethod,         httpMethod,
         cimException.getContentLanguages(),         cimException.getContentLanguages(),
         out.size());          out.size(),
           false);
     tmp << out;     tmp << out;
  
     return tmp;     return tmp;
Line 2856 
Line 2862 
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const String& authenticationHeader,     const String& authenticationHeader,
     const AcceptLanguages& httpAcceptLanguages,      const AcceptLanguageList& httpAcceptLanguages,
     const ContentLanguages& httpContentLanguages,      const ContentLanguageList& httpContentLanguages,
     const Buffer& body)      const Buffer& body,
       bool binaryResponse)
 { {
     Buffer out;     Buffer out;
     Buffer tmp;     Buffer tmp;
Line 2881 
Line 2888 
         httpMethod,         httpMethod,
         httpAcceptLanguages,         httpAcceptLanguages,
         httpContentLanguages,         httpContentLanguages,
         out.size());          out.size(),
           false,
           binaryResponse);
     tmp << out;     tmp << out;
  
     return tmp;     return tmp;
Line 2893 
Line 2902 
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
   /*
       Formats a IMethod Response Message.  Note that this function formats
       messages for chunking based on the isFirst and isLast parameters.
       If isFirst is set, it outputs headers and ResponseElement begin.
       It always sends the body.  If isLast is set,  it sends the rtnParams
       and the ResponseElement end followed by any parameter in the rtnParams.
       KS_PULL_TBD_TODO - Determine what we want to do with chunking. Since this
       This whole thing is based on the concept of each message sending a  single
       chunk and we will want in the future to modify so we can chose easily
       whether we want to chunk or not and send the chunks.
   */
 Buffer XmlWriter::formatSimpleIMethodRspMessage( Buffer XmlWriter::formatSimpleIMethodRspMessage(
     const CIMName& iMethodName,     const CIMName& iMethodName,
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const ContentLanguages & httpContentLanguages,      const ContentLanguageList& httpContentLanguages,
       const Buffer& rtnParams,
     const Buffer& body,     const Buffer& body,
     Uint32 serverResponseTime,      Uint64 serverResponseTime,
     Boolean isFirst,     Boolean isFirst,
     Boolean isLast)     Boolean isLast)
 { {
Line 2909 
Line 2930 
                 {                 {
                         // NOTE: temporarily put zero for content length. the http code                         // NOTE: temporarily put zero for content length. the http code
                         // will later decide to fill in the length or remove it altogether                         // will later decide to fill in the length or remove it altogether
                         appendMethodResponseHeader(out, httpMethod, httpContentLanguages, 0,          appendMethodResponseHeader(
                                                                                                                                  serverResponseTime);              out, httpMethod, httpContentLanguages, 0, serverResponseTime);
                         _appendMessageElementBegin(out, messageId);                         _appendMessageElementBegin(out, messageId);
                         _appendSimpleRspElementBegin(out);                         _appendSimpleRspElementBegin(out);
                         _appendIMethodResponseElementBegin(out, iMethodName);                         _appendIMethodResponseElementBegin(out, iMethodName);
  
                         // output the start of the return tag. Test if there is response data by:          // output the start of the return tag. Test if there is response data
           // by:
                         // 1. there is data on the first chunk OR                         // 1. there is data on the first chunk OR
                         // 2. there is no data on the first chunk but isLast is false implying                         // 2. there is no data on the first chunk but isLast is false implying
                         //    there is more non-empty data to come. If all subsequent chunks                         //    there is more non-empty data to come. If all subsequent chunks
Line 2933 
Line 2955 
                 {                 {
                         if (body.size() != 0 || isFirst == false)                         if (body.size() != 0 || isFirst == false)
                                 _appendIReturnValueElementEnd(out);                                 _appendIReturnValueElementEnd(out);
           // EXP_PULL
           // If there are any parameters include them here.
           // Assumes that it is prebuilt with all components
           //
           if (rtnParams.size() != 0)
           {
               out << rtnParams;
           }
           //
           // //EXP_PULL_END
                         _appendIMethodResponseElementEnd(out);                         _appendIMethodResponseElementEnd(out);
                         _appendSimpleRspElementEnd(out);                         _appendSimpleRspElementEnd(out);
                         _appendMessageElementEnd(out);                         _appendMessageElementEnd(out);
Line 2965 
Line 2997 
     _appendSimpleRspElementEnd(out);     _appendSimpleRspElementEnd(out);
     _appendMessageElementEnd(out);     _appendMessageElementEnd(out);
  
 // l10n  
     appendMethodResponseHeader(tmp,     appendMethodResponseHeader(tmp,
          httpMethod,          httpMethod,
          cimException.getContentLanguages(),          cimException.getContentLanguages(),
          out.size());          out.size(), false);
     tmp << out;     tmp << out;
  
     return tmp;     return tmp;
Line 2996 
Line 3027 
     const CIMName& cimMethod,     const CIMName& cimMethod,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const String& authenticationHeader,     const String& authenticationHeader,
     const AcceptLanguages& acceptLanguages,      const AcceptLanguageList& acceptLanguages,
     const ContentLanguages& contentLanguages,      const ContentLanguageList& contentLanguages,
     Uint32 contentLength)     Uint32 contentLength)
 { {
     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };
  
     if (httpMethod == HTTP_METHOD_M_POST)     if (httpMethod == HTTP_METHOD_M_POST)
     {     {
       out << LIT("M-POST ") << requestUri << LIT(" HTTP/1.1\r\n");        out << STRLIT("M-POST ") << requestUri << STRLIT(" HTTP/1.1\r\n");
     }     }
     else     else
     {     {
       out << LIT("POST ") << requestUri << LIT(" HTTP/1.1\r\n");        out << STRLIT("POST ") << requestUri << STRLIT(" HTTP/1.1\r\n");
     }     }
     out << LIT("HOST: ") << host << LIT("\r\n");      out << STRLIT("HOST: ") << host << STRLIT("\r\n"
     out << LIT("Content-Type: application/xml; charset=\"utf-8\"\r\n");                    "Content-Type: application/xml; charset=\"utf-8\"\r\n");
     OUTPUT_CONTENTLENGTH;      OUTPUT_CONTENTLENGTH(out, contentLength);
  
     if (acceptLanguages.size() > 0)     if (acceptLanguages.size() > 0)
     {     {
         out << LIT("Accept-Language: ") << acceptLanguages << LIT("\r\n");          out << STRLIT("Accept-Language: ") << acceptLanguages << STRLIT("\r\n");
     }     }
     if (contentLanguages.size() > 0)     if (contentLanguages.size() > 0)
     {     {
         out << LIT("Content-Language: ") << contentLanguages << LIT("\r\n");          out << STRLIT("Content-Language: ") << contentLanguages <<
               STRLIT("\r\n");
     }     }
  
 #ifdef PEGASUS_DEBUG #ifdef PEGASUS_DEBUG
Line 3033 
Line 3065 
                         getenv("PEGASUS_HTTP_TRANSFER_ENCODING_REQUEST");                         getenv("PEGASUS_HTTP_TRANSFER_ENCODING_REQUEST");
                 if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0')                 if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0')
 #endif #endif
                         out << LIT("TE: chunked, trailers\r\n");      out << STRLIT("TE: chunked, trailers\r\n");
  
     if (httpMethod == HTTP_METHOD_M_POST)     if (httpMethod == HTTP_METHOD_M_POST)
     {     {
         out << LIT("Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");          out << STRLIT("Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");
         out << nn << LIT("\r\n");          out << nn << STRLIT("\r\n");
         out << nn << LIT("-CIMExport: MethodRequest\r\n");          out << nn << STRLIT("-CIMExport: MethodRequest\r\n");
         out << nn << LIT("-CIMExportMethod: ") << cimMethod << LIT("\r\n");          out << nn << STRLIT("-CIMExportMethod: ") << cimMethod <<
               STRLIT("\r\n");
     }     }
     else     else
     {     {
         out << LIT("CIMExport: MethodRequest\r\n");          out << STRLIT("CIMExport: MethodRequest\r\n"
         out << LIT("CIMExportMethod: ") << cimMethod << LIT("\r\n");                        "CIMExportMethod: ") << cimMethod << STRLIT("\r\n");
     }     }
  
     if (authenticationHeader.size())     if (authenticationHeader.size())
     {     {
         out << authenticationHeader << LIT("\r\n");          out << authenticationHeader << STRLIT("\r\n");
     }     }
  
     out << LIT("\r\n");      out << STRLIT("\r\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 3067 
Line 3100 
 void XmlWriter::appendEMethodResponseHeader( void XmlWriter::appendEMethodResponseHeader(
     Buffer& out,     Buffer& out,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const ContentLanguages& contentLanguages,      const ContentLanguageList& contentLanguages,
     Uint32 contentLength)     Uint32 contentLength)
 { {
     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };
  
     out << LIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n");      out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n"
     out << LIT("Content-Type: application/xml; charset=\"utf-8\"\r\n");                    "Content-Type: application/xml; charset=\"utf-8\"\r\n");
     OUTPUT_CONTENTLENGTH;      OUTPUT_CONTENTLENGTH(out, contentLength);
  
     if (contentLanguages.size() > 0)     if (contentLanguages.size() > 0)
     {     {
         out << LIT("Content-Language: ") << contentLanguages << LIT("\r\n");          out << STRLIT("Content-Language: ") << contentLanguages <<
               STRLIT("\r\n");
     }     }
     if (httpMethod == HTTP_METHOD_M_POST)     if (httpMethod == HTTP_METHOD_M_POST)
     {     {
         out << LIT("Ext:\r\n");          out << STRLIT("Ext:\r\n"
         out << LIT("Cache-Control: no-cache\r\n");                        "Cache-Control: no-cache\r\n"
         out << LIT("Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");                        "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");
         out << nn << LIT("\r\n");          out << nn << STRLIT("\r\n");
         out << nn << LIT("-CIMExport: MethodResponse\r\n\r\n");          out << nn << STRLIT("-CIMExport: MethodResponse\r\n\r\n");
     }     }
     else     else
     {     {
         out << LIT("CIMExport: MethodResponse\r\n\r\n");          out << STRLIT("CIMExport: MethodResponse\r\n\r\n");
     }     }
 } }
  
Line 3106 
Line 3140 
 void XmlWriter::_appendSimpleExportReqElementBegin( void XmlWriter::_appendSimpleExportReqElementBegin(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("<SIMPLEEXPREQ>\n");      out << STRLIT("<SIMPLEEXPREQ>\n");
 } }
  
 void XmlWriter::_appendSimpleExportReqElementEnd( void XmlWriter::_appendSimpleExportReqElementEnd(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("</SIMPLEEXPREQ>\n");      out << STRLIT("</SIMPLEEXPREQ>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 3129 
Line 3163 
     Buffer& out,     Buffer& out,
     const CIMName& name)     const CIMName& name)
 { {
     out << LIT("<EXPMETHODCALL NAME=\"") << name << LIT("\">\n");      out << STRLIT("<EXPMETHODCALL NAME=\"") << name << STRLIT("\">\n");
 } }
  
 void XmlWriter::_appendEMethodCallElementEnd( void XmlWriter::_appendEMethodCallElementEnd(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("</EXPMETHODCALL>\n");      out << STRLIT("</EXPMETHODCALL>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 3153 
Line 3187 
     Buffer& out,     Buffer& out,
     const char* name)     const char* name)
 { {
     out << LIT("<EXPPARAMVALUE NAME=\"") << name << LIT("\">\n");      out << STRLIT("<EXPPARAMVALUE NAME=\"") << name << STRLIT("\">\n");
 } }
  
 void XmlWriter::_appendEParamValueElementEnd( void XmlWriter::_appendEParamValueElementEnd(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("</EXPPARAMVALUE>\n");      out << STRLIT("</EXPPARAMVALUE>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 3190 
Line 3224 
 void XmlWriter::_appendSimpleExportRspElementBegin( void XmlWriter::_appendSimpleExportRspElementBegin(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("<SIMPLEEXPRSP>\n");      out << STRLIT("<SIMPLEEXPRSP>\n");
 } }
  
 void XmlWriter::_appendSimpleExportRspElementEnd( void XmlWriter::_appendSimpleExportRspElementEnd(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("</SIMPLEEXPRSP>\n");      out << STRLIT("</SIMPLEEXPRSP>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 3213 
Line 3247 
     Buffer& out,     Buffer& out,
     const CIMName& name)     const CIMName& name)
 { {
     out << LIT("<EXPMETHODRESPONSE NAME=\"") << name << LIT("\">\n");      out << STRLIT("<EXPMETHODRESPONSE NAME=\"") << name << STRLIT("\">\n");
 } }
  
 void XmlWriter::_appendEMethodResponseElementEnd( void XmlWriter::_appendEMethodResponseElementEnd(
     Buffer& out)     Buffer& out)
 { {
     out << LIT("</EXPMETHODRESPONSE>\n");      out << STRLIT("</EXPMETHODRESPONSE>\n");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 3235 
Line 3269 
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const String& authenticationHeader,     const String& authenticationHeader,
     const AcceptLanguages& httpAcceptLanguages,      const AcceptLanguageList& httpAcceptLanguages,
     const ContentLanguages& httpContentLanguages,      const ContentLanguageList& httpContentLanguages,
     const Buffer& body)     const Buffer& body)
 { {
     Buffer out;     Buffer out;
Line 3275 
Line 3309 
     const CIMName& eMethodName,     const CIMName& eMethodName,
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const ContentLanguages& httpContentLanguages,      const ContentLanguageList& httpContentLanguages,
     const Buffer& body)     const Buffer& body)
 { {
     Buffer out;     Buffer out;
Line 3321 
Line 3355 
     _appendSimpleExportRspElementEnd(out);     _appendSimpleExportRspElementEnd(out);
     _appendMessageElementEnd(out);     _appendMessageElementEnd(out);
  
 // l10n      appendEMethodResponseHeader(
     appendEMethodResponseHeader(tmp,          tmp,
          httpMethod,          httpMethod,
          cimException.getContentLanguages(),          cimException.getContentLanguages(),
                  out.size());                  out.size());
Line 3333 
Line 3367 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // _xmlWritter_printAttributes()  
 //  
 //------------------------------------------------------------------------------  
   
 void _xmlWritter_printAttributes(  
     PEGASUS_STD(ostream)& os,  
     const XmlAttribute* attributes,  
     Uint32 attributeCount)  
 {  
     for (Uint32 i = 0; i < attributeCount; i++)  
     {  
         os << attributes[i].name << "=";  
   
         os << '"';  
         _xmlWritter_appendSpecial(os, attributes[i].value);  
         os << '"';  
   
         if (i + 1 != attributeCount)  
             os << ' ';  
     }  
 }  
   
 //------------------------------------------------------------------------------  
 //  
 // _xmlWritter_indent()  
 //  
 //------------------------------------------------------------------------------  
   
 void _xmlWritter_indent(PEGASUS_STD(ostream)& os, Uint32 level, Uint32 indentChars)  
 {  
     Uint32 n = level * indentChars;  
   
     for (Uint32 i = 0; i < n; i++)  
         os << ' ';  
 }  
   
 //------------------------------------------------------------------------------  
 //  
 // indentedPrint()  
 //  
 //------------------------------------------------------------------------------  
   
 void XmlWriter::indentedPrint(  
     PEGASUS_STD(ostream)& os,  
     const char* text,  
     Uint32 indentChars)  
 {  
     AutoArrayPtr<char> tmp(strcpy(new char[strlen(text) + 1], text));  
   
     XmlParser parser(tmp.get());  
     XmlEntry entry;  
     Stack<const char*> stack;  
   
     while (parser.next(entry))  
     {  
         switch (entry.type)  
         {  
             case XmlEntry::XML_DECLARATION:  
             {  
                 _xmlWritter_indent(os, stack.size(), indentChars);  
   
                 os << "<?" << entry.text << " ";  
                 _xmlWritter_printAttributes(os, entry.attributes, entry.attributeCount);  
                 os << "?>";  
                 break;  
             }  
   
             case XmlEntry::START_TAG:  
             {  
                 _xmlWritter_indent(os, stack.size(), indentChars);  
   
                 os << "<" << entry.text;  
   
                 if (entry.attributeCount)  
                     os << ' ';  
   
                 _xmlWritter_printAttributes(os, entry.attributes, entry.attributeCount);  
                 os << ">";  
                 stack.push(entry.text);  
                 break;  
             }  
   
             case XmlEntry::EMPTY_TAG:  
             {  
                 _xmlWritter_indent(os, stack.size(), indentChars);  
   
                 os << "<" << entry.text << " ";  
                 _xmlWritter_printAttributes(os, entry.attributes, entry.attributeCount);  
                 os << "/>";  
                 break;  
             }  
   
             case XmlEntry::END_TAG:  
             {  
                 if (!stack.isEmpty() && strcmp(stack.top(), entry.text) == 0)  
                     stack.pop();  
   
                 _xmlWritter_indent(os, stack.size(), indentChars);  
   
                 os << "</" << entry.text << ">";  
                 break;  
             }  
   
             case XmlEntry::COMMENT:  
             {  
   
                 _xmlWritter_indent(os, stack.size(), indentChars);  
                 os << "<!--";  
                 _xmlWritter_appendSpecial(os, entry.text);  
                 os << "-->";  
                 break;  
             }  
   
             case XmlEntry::CONTENT:  
             {  
                 _xmlWritter_indent(os, stack.size(), indentChars);  
                 _xmlWritter_appendSpecial(os, entry.text);  
                 break;  
             }  
   
             case XmlEntry::CDATA:  
             {  
                 _xmlWritter_indent(os, stack.size(), indentChars);  
                 os << "<![CDATA[...]]>";  
                 break;  
             }  
   
             case XmlEntry::DOCTYPE:  
             {  
                 _xmlWritter_indent(os, stack.size(), indentChars);  
                 os << "<!DOCTYPE...>";  
                 break;  
             }  
         }  
   
         os << PEGASUS_STD(endl);  
     }  
   
 }  
   
 //------------------------------------------------------------------------------  
 //  
 // XmlWriter::getNextMessageId() // XmlWriter::getNextMessageId()
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
   static IDFactory _messageIDFactory(1000);
   
 String XmlWriter::getNextMessageId() String XmlWriter::getNextMessageId()
 { {
     // ATTN: make thread-safe:      char scratchBuffer[22];
     static Uint32 messageId = 1000;      Uint32 n;
       const char * startP = Uint32ToString(scratchBuffer,
     messageId++;                                           _messageIDFactory.getID(),
                                            n);
     if (messageId < 1000)      return String(startP, n);
         messageId = 1001;  
   
     char buffer[16];  
     sprintf(buffer, "%d", messageId);  
     return buffer;  
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 3499 
Line 3388 
 // XmlWriter::keyBindingTypeToString // XmlWriter::keyBindingTypeToString
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 const char* XmlWriter::keyBindingTypeToString (CIMKeyBinding::Type type)  const StrLit XmlWriter::keyBindingTypeToString (CIMKeyBinding::Type type)
 { {
     switch (type)     switch (type)
     {     {
         case CIMKeyBinding::BOOLEAN:         case CIMKeyBinding::BOOLEAN:
             return "boolean";              return STRLIT("boolean");
  
         case CIMKeyBinding::STRING:         case CIMKeyBinding::STRING:
             return "string";              return STRLIT("string");
  
         case CIMKeyBinding::NUMERIC:         case CIMKeyBinding::NUMERIC:
             return "numeric";              return STRLIT("numeric");
  
         case CIMKeyBinding::REFERENCE:         case CIMKeyBinding::REFERENCE:
         default:         default:
             PEGASUS_ASSERT(false);             PEGASUS_ASSERT(false);
     }     }
  
     return "unknown";      return STRLIT("unknown");
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END
   
   


Legend:
Removed from v.1.124.2.4  
changed lines
  Added in v.1.169.4.1

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2