version 1.135.2.1, 2006/05/24 07:03:20
|
version 1.141, 2006/08/22 18:30:48
|
|
|
#include "Buffer.h" | #include "Buffer.h" |
#include "StrLit.h" | #include "StrLit.h" |
#include "LanguageParser.h" | #include "LanguageParser.h" |
|
#include "IDFactory.h" |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
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; |
|
|
| |
char* nameSpaceCopy = strdup(nameSpace.getString().getCString()); | char* nameSpaceCopy = strdup(nameSpace.getString().getCString()); |
| |
#if !defined(PEGASUS_COMPILER_MSVC) |
#if !defined(PEGASUS_COMPILER_MSVC) && !defined(PEGASUS_OS_ZOS) |
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)) |
|
|
| |
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) |
|
|
_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); |
} | } |
|
|
_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); |
} | } |
|
|
{ | { |
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; |
| |
|
|
} | } |
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"); |
} | } |
|
|
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); |
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
// 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() |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
|
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; |
} | } |
| |