(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.126 and 1.143

version 1.126, 2005/10/31 18:21:55 version 1.143, 2006/10/31 18:38:30
Line 1 
Line 1 
 //%2005////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
Line 8 
Line 8 
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 // EMC Corporation; VERITAS Software Corporation; The Open Group. // EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; Symantec Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 39 
Line 41 
 //                               Willis White (whiwill@us.ibm.com) PEP 127 and 128 //                               Willis White (whiwill@us.ibm.com) PEP 127 and 128
 //         Brian G. Campbell, EMC (campbell_brian@emc.com) - PEP140/phase2 //         Brian G. Campbell, EMC (campbell_brian@emc.com) - PEP140/phase2
 //              Dave Sudlik, IBM (dsudlik@us.ibm.com) //              Dave Sudlik, IBM (dsudlik@us.ibm.com)
 //              David Dillard, VERITAS Software Corp.  //              David Dillard, Symantec Corp. (david_dillard@symantec.com)
 //                  (david.dillard@veritas.com)  
 //              Vijay Eli, vijayeli@in.ibm.com, fix for #2571 //              Vijay Eli, vijayeli@in.ibm.com, fix for #2571
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
Line 50 
Line 51 
 #include <cstdio> #include <cstdio>
 #include "Constants.h" #include "Constants.h"
 #include "CIMClass.h" #include "CIMClass.h"
   #include "CIMError.h"
 #include "CIMClassRep.h" #include "CIMClassRep.h"
 #include "CIMInstance.h" #include "CIMInstance.h"
 #include "CIMInstanceRep.h" #include "CIMInstanceRep.h"
Line 72 
Line 74 
 #include <Pegasus/Common/StatisticalData.h> #include <Pegasus/Common/StatisticalData.h>
 #include "CommonUTF.h" #include "CommonUTF.h"
 #include "Buffer.h" #include "Buffer.h"
 // For a future optimization:  #include "StrLit.h"
 #define STRLIT(X) X  #include "LanguageParser.h"
   #include "IDFactory.h"
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
Line 88 
Line 90 
 #define OUTPUT_CONTENTLENGTH                                               \ #define OUTPUT_CONTENTLENGTH                                               \
 {                                                                          \ {                                                                          \
     char contentLengthP[11];                                               \     char contentLengthP[11];                                               \
     sprintf(contentLengthP,"%.10u", contentLength);                        \      int n = sprintf(contentLengthP,"%.10u", contentLength);                \
     out << STRLIT("content-length: ") << contentLengthP << STRLIT("\r\n"); \      out << STRLIT("content-length: ");                                     \
       out.append(contentLengthP, n);                                         \
       out << STRLIT("\r\n");                                                 \
 } }
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Line 98 
Line 102 
 // //
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
  
   // Note: we cannot use StrLit here since it has a constructur (forbits
   // structure initialization).
   
 struct SpecialChar struct SpecialChar
 { {
     const char* str;     const char* str;
Line 109 
Line 116 
 // length in bytes. // length in bytes.
 static const SpecialChar _specialChars[] = static const SpecialChar _specialChars[] =
 { {
     { "&#0;", 4 },      {STRLIT_ARGS("&#0;")},
     { "&#1;", 4 },      {STRLIT_ARGS("&#1;")},
     { "&#2;", 4 },      {STRLIT_ARGS("&#2;")},
     { "&#3;", 4 },      {STRLIT_ARGS("&#3;")},
     { "&#4;", 4 },      {STRLIT_ARGS("&#4;")},
     { "&#5;", 4 },      {STRLIT_ARGS("&#5;")},
     { "&#6;", 4 },      {STRLIT_ARGS("&#6;")},
     { "&#7;", 4 },      {STRLIT_ARGS("&#7;")},
     { "&#8;", 4 },      {STRLIT_ARGS("&#8;")},
     { "&#9;", 4 },      {STRLIT_ARGS("&#9;")},
     { "&#10;", 5 },      {STRLIT_ARGS("&#10;")},
     { "&#11;", 5 },      {STRLIT_ARGS("&#11;")},
     { "&#12;", 5 },      {STRLIT_ARGS("&#12;")},
     { "&#13;", 5 },      {STRLIT_ARGS("&#13;")},
     { "&#14;", 5 },      {STRLIT_ARGS("&#14;")},
     { "&#15;", 5 },      {STRLIT_ARGS("&#15;")},
     { "&#16;", 5 },      {STRLIT_ARGS("&#16;")},
     { "&#17;", 5 },      {STRLIT_ARGS("&#17;")},
     { "&#18;", 5 },      {STRLIT_ARGS("&#18;")},
     { "&#19;", 5 },      {STRLIT_ARGS("&#19;")},
     { "&#20;", 5 },      {STRLIT_ARGS("&#20;")},
     { "&#21;", 5 },      {STRLIT_ARGS("&#21;")},
     { "&#22;", 5 },      {STRLIT_ARGS("&#22;")},
     { "&#23;", 5 },      {STRLIT_ARGS("&#23;")},
     { "&#24;", 5 },      {STRLIT_ARGS("&#24;")},
     { "&#25;", 5 },      {STRLIT_ARGS("&#25;")},
     { "&#26;", 5 },      {STRLIT_ARGS("&#26;")},
     { "&#27;", 5 },      {STRLIT_ARGS("&#27;")},
     { "&#28;", 5 },      {STRLIT_ARGS("&#28;")},
     { "&#29;", 5 },      {STRLIT_ARGS("&#29;")},
     { "&#30;", 5 },      {STRLIT_ARGS("&#30;")},
     { "&#31;", 5 },      {STRLIT_ARGS("&#31;")},
     { " ", 1 },      {STRLIT_ARGS(" ")},
     { "!", 1 },      {STRLIT_ARGS("!")},
     { "&quot;", 6 },      {STRLIT_ARGS("&quot;")},
     { "#", 1 },      {STRLIT_ARGS("#")},
     { "$", 1 },      {STRLIT_ARGS("$")},
     { "%", 1 },      {STRLIT_ARGS("%")},
     { "&amp;", 5 },      {STRLIT_ARGS("&amp;")},
     { "&apos;", 6 },      {STRLIT_ARGS("&apos;")},
     { "(", 1 },      {STRLIT_ARGS("(")},
     { ")", 1 },      {STRLIT_ARGS(")")},
     { "*", 1 },      {STRLIT_ARGS("*")},
     { "+", 1 },      {STRLIT_ARGS("+")},
     { ",", 1 },      {STRLIT_ARGS(",")},
     { "-", 1 },      {STRLIT_ARGS("-")},
     { ".", 1 },      {STRLIT_ARGS(".")},
     { "/", 1 },      {STRLIT_ARGS("/")},
     { "0", 1 },      {STRLIT_ARGS("0")},
     { "1", 1 },      {STRLIT_ARGS("1")},
     { "2", 1 },      {STRLIT_ARGS("2")},
     { "3", 1 },      {STRLIT_ARGS("3")},
     { "4", 1 },      {STRLIT_ARGS("4")},
     { "5", 1 },      {STRLIT_ARGS("5")},
     { "6", 1 },      {STRLIT_ARGS("6")},
     { "7", 1 },      {STRLIT_ARGS("7")},
     { "8", 1 },      {STRLIT_ARGS("8")},
     { "9", 1 },      {STRLIT_ARGS("9")},
     { ":", 1 },      {STRLIT_ARGS(":")},
     { ";", 1 },      {STRLIT_ARGS(";")},
     { "&lt;", 4 },      {STRLIT_ARGS("&lt;")},
     { "=", 1 },      {STRLIT_ARGS("=")},
     { "&gt;", 4 },      {STRLIT_ARGS("&gt;")},
     { "?", 1 },      {STRLIT_ARGS("?")},
     { "@", 1 },      {STRLIT_ARGS("@")},
     { "A", 1 },      {STRLIT_ARGS("A")},
     { "B", 1 },      {STRLIT_ARGS("B")},
     { "C", 1 },      {STRLIT_ARGS("C")},
     { "D", 1 },      {STRLIT_ARGS("D")},
     { "E", 1 },      {STRLIT_ARGS("E")},
     { "F", 1 },      {STRLIT_ARGS("F")},
     { "G", 1 },      {STRLIT_ARGS("G")},
     { "H", 1 },      {STRLIT_ARGS("H")},
     { "I", 1 },      {STRLIT_ARGS("I")},
     { "J", 1 },      {STRLIT_ARGS("J")},
     { "K", 1 },      {STRLIT_ARGS("K")},
     { "L", 1 },      {STRLIT_ARGS("L")},
     { "M", 1 },      {STRLIT_ARGS("M")},
     { "N", 1 },      {STRLIT_ARGS("N")},
     { "O", 1 },      {STRLIT_ARGS("O")},
     { "P", 1 },      {STRLIT_ARGS("P")},
     { "Q", 1 },      {STRLIT_ARGS("Q")},
     { "R", 1 },      {STRLIT_ARGS("R")},
     { "S", 1 },      {STRLIT_ARGS("S")},
     { "T", 1 },      {STRLIT_ARGS("T")},
     { "U", 1 },      {STRLIT_ARGS("U")},
     { "V", 1 },      {STRLIT_ARGS("V")},
     { "W", 1 },      {STRLIT_ARGS("W")},
     { "X", 1 },      {STRLIT_ARGS("X")},
     { "Y", 1 },      {STRLIT_ARGS("Y")},
     { "Z", 1 },      {STRLIT_ARGS("Z")},
     { "[", 1 },      {STRLIT_ARGS("[")},
     { "\\", 1 },      {STRLIT_ARGS("\\")},
     { "]", 1 },      {STRLIT_ARGS("]")},
     { "^", 1 },      {STRLIT_ARGS("^")},
     { "_", 1 },      {STRLIT_ARGS("_")},
     { "`", 1 },      {STRLIT_ARGS("`")},
     { "a", 1 },      {STRLIT_ARGS("a")},
     { "b", 1 },      {STRLIT_ARGS("b")},
     { "c", 1 },      {STRLIT_ARGS("c")},
     { "d", 1 },      {STRLIT_ARGS("d")},
     { "e", 1 },      {STRLIT_ARGS("e")},
     { "f", 1 },      {STRLIT_ARGS("f")},
     { "g", 1 },      {STRLIT_ARGS("g")},
     { "h", 1 },      {STRLIT_ARGS("h")},
     { "i", 1 },      {STRLIT_ARGS("i")},
     { "j", 1 },      {STRLIT_ARGS("j")},
     { "k", 1 },      {STRLIT_ARGS("k")},
     { "l", 1 },      {STRLIT_ARGS("l")},
     { "m", 1 },      {STRLIT_ARGS("m")},
     { "n", 1 },      {STRLIT_ARGS("n")},
     { "o", 1 },      {STRLIT_ARGS("o")},
     { "p", 1 },      {STRLIT_ARGS("p")},
     { "q", 1 },      {STRLIT_ARGS("q")},
     { "r", 1 },      {STRLIT_ARGS("r")},
     { "s", 1 },      {STRLIT_ARGS("s")},
     { "t", 1 },      {STRLIT_ARGS("t")},
     { "u", 1 },      {STRLIT_ARGS("u")},
     { "v", 1 },      {STRLIT_ARGS("v")},
     { "w", 1 },      {STRLIT_ARGS("w")},
     { "x", 1 },      {STRLIT_ARGS("x")},
     { "y", 1 },      {STRLIT_ARGS("y")},
     { "z", 1 },      {STRLIT_ARGS("z")},
     { "{", 1 },      {STRLIT_ARGS("{")},
     { "|", 1 },      {STRLIT_ARGS("|")},
     { "}", 1 },      {STRLIT_ARGS("}")},
     { "~", 1 },      {STRLIT_ARGS("~")},
     { "&#127;", 6 },      {STRLIT_ARGS("&#127;")},
 }; };
  
 // If _isSpecialChar7[ch] is true, then ch is a special character, which must // If _isSpecialChar7[ch] is true, then ch is a special character, which must
Line 245 
Line 252 
 static const int _isSpecialChar7[] = 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,     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,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,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,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,     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) Buffer& operator<<(Buffer& out, const Char16& x)
 { {
     XmlWriter::append(out, x);     XmlWriter::append(out, x);
Line 302 
Line 297 
  
  
 // l10n // l10n
 Buffer& operator<<(Buffer& out, const AcceptLanguages& al)  Buffer& operator<<(Buffer& out, const AcceptLanguageList& al)
 { {
     XmlWriter::append(out, al.toString ());      XmlWriter::append(out, LanguageParser::buildAcceptLanguageHeader(al));
     return out;     return out;
 } }
  
 // l10n // l10n
 Buffer& operator<<(Buffer& out, const ContentLanguages& cl)  Buffer& operator<<(Buffer& out, const ContentLanguageList& cl)
 { {
     XmlWriter::append(out, cl.toString ());      XmlWriter::append(out, LanguageParser::buildContentLanguageHeader(cl));
     return out;     return out;
 } }
  
Line 583 
Line 578 
 void XmlWriter::appendSpecial(Buffer& out, const String& str) void XmlWriter::appendSpecial(Buffer& out, const String& str)
 { {
     const Uint16* p = (const Uint16*)str.getChar16Data();     const Uint16* p = (const Uint16*)str.getChar16Data();
     size_t n = str.size();      // prevCharIsSpace is true when the last character written to the Buffer
       // is a space character (not a character reference).
     // Handle leading ASCII 7 characers in these next two loops (use unrolling).      Boolean prevCharIsSpace = false;
   
     while (n >= 8)      // If the first character is a space, use a character reference to avoid
       // space compression.
       if (*p == ' ')
     {     {
         // The following condition is equivalent to this:          out.append(STRLIT_ARGS("&#32;"));
         //     (p[0] < 128 && p[1] < 128 && p[2] < 128 && p[3] < 128 &&          p++;
         //      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)      Uint16 c;
       while ((c = *p++) != 0)
         {         {
             // Note: "|" is faster than "||" and achieves the same effect          if (c < 128)
             // since p[i] is either 0 or 1.          {
               if (_isSpecialChar7[c])
             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.                  // Write the character reference for the special character
                 _appendSpecialChar7(out, p[0]);                  out.append(
                 _appendSpecialChar7(out, p[1]);                      _specialChars[int(c)].str, _specialChars[int(c)].size);
                 _appendSpecialChar7(out, p[2]);                  prevCharIsSpace = false;
                 _appendSpecialChar7(out, p[3]);              }
                 _appendSpecialChar7(out, p[4]);              else if (prevCharIsSpace && (c == ' '))
                 _appendSpecialChar7(out, p[5]);              {
                 _appendSpecialChar7(out, p[6]);                  // Write the character reference for the space character, to
                 _appendSpecialChar7(out, p[7]);                  // avoid compression
                   out.append(STRLIT_ARGS("&#32;"));
                   prevCharIsSpace = false;
             }             }
             else             else
             {             {
                 // Common case.                  out.append(c);
                 out.append(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);                  prevCharIsSpace = (c == ' ');
             }             }
             p += 8;  
             n -= 8;  
         }         }
         else         else
             break;  
     }  
   
     while (n >= 4)  
     {     {
         // The following condition is equivalent to this:              // Handle UTF8 case
         //     (p[0] < 128 && p[1] < 128 && p[2] < 128 && p[3] < 128)  
  
         if (((p[0]|p[1]|p[2]|p[3]) & 0xFF80) == 0)              if ((((c >= FIRST_HIGH_SURROGATE) && (c <= LAST_HIGH_SURROGATE)) ||
                    ((c >= FIRST_LOW_SURROGATE) && (c <= LAST_LOW_SURROGATE))) &&
                   *p)
         {         {
             if (_isSpecialChar7[p[0]] | _isSpecialChar7[p[1]] |                  _xmlWritter_appendSurrogatePair(out, c, *p++);
                 _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             else
             {             {
                 // Common case:                  _xmlWritter_appendChar(out, c);
                 out.append(p[0], p[1], p[2], p[3]);  
             }             }
  
             p += 4;              prevCharIsSpace = false;
             n -= 4;  
         }         }
         else  
             break;  
     }     }
  
     // Process remaining characters. A UTF8 character must have been      // If the last character is a space, use a character reference to avoid
     // encountered or this would have never been reached.      // space compression.
       if (prevCharIsSpace)
     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);          out.remove(out.size() - 1);
         }          out.append(STRLIT_ARGS("&#32;"));
     }     }
 } }
  
Line 706 
Line 660 
     0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,     0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,
 }; };
  
   // Perform the necessary URI encoding of characters in HTTP header values.
   // This is required by the HTTP/1.1 specification and the CIM/HTTP
   // Specification (section 3.3.2).
 static void _xmlWritter_encodeURIChar(String& outString, Sint8 char8) static void _xmlWritter_encodeURIChar(String& outString, Sint8 char8)
 { {
     Uint8 c = (Uint8)char8;     Uint8 c = (Uint8)char8;
Line 799 
Line 756 
  
     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 1073 
Line 1028 
  
 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 1266 
Line 1223 
                 _xmlWritter_appendValueArray(out, a.getData(), a.size());                 _xmlWritter_appendValueArray(out, a.getData(), a.size());
                 break;                 break;
             }             }
   #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
               case CIMTYPE_INSTANCE:
               {
                   Array<CIMInstance> a;
                   value.get(a);
                   _xmlWritter_appendValueArray(out, a.getData(), a.size());
                   break;
               }
   #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT
             default:             default:
                 PEGASUS_ASSERT(false);                 PEGASUS_ASSERT(false);
         }         }
Line 1403 
Line 1368 
                 _xmlWritter_appendValue(out, v);                 _xmlWritter_appendValue(out, v);
                 break;                 break;
             }             }
   #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
               case CIMTYPE_INSTANCE:
               {
                   CIMInstance v;
                   value.get(v);
                   _xmlWritter_appendValue(out, v);
                   break;
               }
   #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT
             default:             default:
                 PEGASUS_ASSERT(false);                 PEGASUS_ASSERT(false);
         }         }
Line 1931 
Line 1904 
     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)
 { {
     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };
Line 1971 
Line 1944 
  
                 static const char *clientTransferEncodingOff =                 static const char *clientTransferEncodingOff =
                         getenv("PEGASUS_HTTP_TRANSFER_ENCODING_REQUEST");                         getenv("PEGASUS_HTTP_TRANSFER_ENCODING_REQUEST");
   
                 if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0')                 if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0')
 #endif #endif
  
Line 2007 
Line 1981 
 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)
 { {
      char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };      char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };
      out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n");      out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n");
      STAT_SERVERTIME  
   #ifndef PEGASUS_DISABLE_PERFINST
        if (StatisticalData::current()->copyGSD)
        {
            out << STRLIT("WBEMServerResponseTime: ") <<
                CIMValue(serverResponseTime).toString() << STRLIT("\r\n");
        }
   #endif
   
      out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n");      out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n");
      OUTPUT_CONTENTLENGTH;      OUTPUT_CONTENTLENGTH;
  
Line 2063 
Line 2045 
     }     }
     if (errorDetail != String::EMPTY)     if (errorDetail != String::EMPTY)
     {     {
         // ATTN-RK-P3-20020404: It is critical that this text not contain '\n'  
         // ATTN-RK-P3-20020404: Need to encode this value properly.  (See  
         // CIM/HTTP Specification section 3.3.2  
         out << STRLIT(PEGASUS_HTTPHEADERTAG_ERRORDETAIL ": ")         out << STRLIT(PEGASUS_HTTPHEADERTAG_ERRORDETAIL ": ")
             << encodeURICharacters(errorDetail) << STRLIT("\r\n");             << encodeURICharacters(errorDetail) << STRLIT("\r\n");
     }     }
Line 2357 
Line 2336 
  
     out << STRLIT("<ERROR");     out << STRLIT("<ERROR");
     out << STRLIT(" CODE=\"") << Uint32(cimException.getCode());     out << STRLIT(" 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)
Line 2365 
Line 2345 
         appendSpecial(out, description);         appendSpecial(out, description);
         out.append('"');         out.append('"');
     }     }
     out << STRLIT("/>");      out << STRLIT(">");
   
       for (Uint32 i = 0, n = cimException.getErrorCount(); i < n; i++)
       {
           appendInstanceElement(out, cimException.getError(i));
       }
   
       out << STRLIT("</ERROR>");
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 2396 
Line 2383 
         out << STRLIT(" PARAMTYPE=\"string\"");         out << STRLIT(" PARAMTYPE=\"string\"");
         out << STRLIT(" EMBEDDEDOBJECT=\"object\"");         out << STRLIT(" EMBEDDEDOBJECT=\"object\"");
     }     }
   #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
       else if (type == CIMTYPE_INSTANCE)
       {
           out << STRLIT(" PARAMTYPE=\"string\"");
           out << STRLIT(" EMBEDDEDOBJECT=\"instance\"");
       }
   #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT
     else     else
     {     {
         out << STRLIT(" PARAMTYPE=\"") << cimTypeToString (type);         out << STRLIT(" PARAMTYPE=\"") << cimTypeToString (type);
Line 2471 
Line 2465 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // appendQualifierNameIParameter()  
 //  
 //------------------------------------------------------------------------------  
   
 void XmlWriter::appendQualifierNameIParameter(  
     Buffer& out,  
     const char* name,  
     const String& qualifierName)  
 {  
     // <!ELEMENT IPARAMVALUE (VALUE|VALUE.ARRAY|VALUE.REFERENCE  
     //     |INSTANCENAME|CLASSNAME|QUALIFIER.DECLARATION  
     //     |CLASS|INSTANCE|VALUE.NAMEDINSTANCE)?>  
     //  
     // 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);  
     appendClassNameElement(out, qualifierName);  
     _appendIParamValueElementEnd(out);  
 }  
   
 //------------------------------------------------------------------------------  
 //  
 // appendClassNameIParameter() // appendClassNameIParameter()
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 2720 
Line 2690 
     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)
 { {
     Buffer out;     Buffer out;
     Buffer tmp;     Buffer tmp;
Line 2761 
Line 2731 
     const CIMName& methodName,     const CIMName& methodName,
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const ContentLanguages & httpContentLanguages,      const ContentLanguageList& httpContentLanguages,
     const Buffer& body,     const Buffer& body,
                 Uint32 serverResponseTime,                  Uint64 serverResponseTime,
                 Boolean isFirst,                 Boolean isFirst,
                 Boolean isLast)                 Boolean isLast)
 { {
Line 2843 
Line 2813 
     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 2884 
Line 2854 
     const CIMName& iMethodName,     const CIMName& iMethodName,
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const ContentLanguages & httpContentLanguages,      const ContentLanguageList& httpContentLanguages,
     const Buffer& body,     const Buffer& body,
     Uint32 serverResponseTime,      Uint64 serverResponseTime,
     Boolean isFirst,     Boolean isFirst,
     Boolean isLast)     Boolean isLast)
 { {
Line 2983 
Line 2953 
     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' };
Line 3054 
Line 3024 
 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' };
Line 3222 
Line 3192 
     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 3262 
Line 3232 
     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 3443 
Line 3413 
             case XmlEntry::CDATA:             case XmlEntry::CDATA:
             {             {
                 _xmlWritter_indent(os, stack.size(), indentChars);                 _xmlWritter_indent(os, stack.size(), indentChars);
                 os << "<![CDATA[...]]>";                  os << "<![CDATA[" << entry.text << "]]>";
                 break;                 break;
             }             }
  
Line 3466 
Line 3436 
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
   static IDFactory _messageIDFactory(1000);
   
 String XmlWriter::getNextMessageId() String XmlWriter::getNextMessageId()
 { {
     // ATTN: make thread-safe:  
     static Uint32 messageId = 1000;  
   
     messageId++;  
   
     if (messageId < 1000)  
         messageId = 1001;  
   
     char buffer[16];     char buffer[16];
     sprintf(buffer, "%d", messageId);      sprintf(buffer, "%u", _messageIDFactory.getID());
     return buffer;     return buffer;
 } }
  


Legend:
Removed from v.1.126  
changed lines
  Added in v.1.143

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2