version 1.135, 2006/01/30 16:17:08
|
version 1.147, 2007/01/11 16:21:54
|
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// 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, Symantec Corp. (david_dillard@symantec.com) |
|
// Vijay Eli, vijayeli@in.ibm.com, fix for #2571 |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
|
|
#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 |
| |
|
|
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, |
}; | }; |
|
|
} | } |
| |
| |
// l10n |
|
Buffer& operator<<(Buffer& out, const AcceptLanguageList& al) | Buffer& operator<<(Buffer& out, const AcceptLanguageList& al) |
{ | { |
XmlWriter::append(out, LanguageParser::buildAcceptLanguageHeader(al)); | XmlWriter::append(out, LanguageParser::buildAcceptLanguageHeader(al)); |
return out; | return out; |
} | } |
| |
// l10n |
|
Buffer& operator<<(Buffer& out, const ContentLanguageList& cl) | Buffer& operator<<(Buffer& out, const ContentLanguageList& cl) |
{ | { |
XmlWriter::append(out, LanguageParser::buildContentLanguageHeader(cl)); | XmlWriter::append(out, LanguageParser::buildContentLanguageHeader(cl)); |
|
|
Uint8 *strtgt = (Uint8 *)str; | Uint8 *strtgt = (Uint8 *)str; |
Uint8 *endtgt = (Uint8 *)&str[5]; | Uint8 *endtgt = (Uint8 *)&str[5]; |
| |
UTF16toUTF8(&strsrc, |
UTF16toUTF8( |
|
&strsrc, |
endsrc, | endsrc, |
&strtgt, | &strtgt, |
endtgt); | endtgt); |
|
|
Uint8 *strtgt = (Uint8 *)str; | Uint8 *strtgt = (Uint8 *)str; |
Uint8 *endtgt = (Uint8 *)&str[5]; | Uint8 *endtgt = (Uint8 *)&str[5]; |
| |
UTF16toUTF8(&strsrc, |
UTF16toUTF8( |
|
&strsrc, |
endsrc, | endsrc, |
&strtgt, | &strtgt, |
endtgt); | endtgt); |
|
|
void XmlWriter::append(Buffer& out, Real64 x) | void XmlWriter::append(Buffer& out, Real64 x) |
{ | { |
char buffer[128]; | char buffer[128]; |
// %.16e gives '[-]m.dddddddddddddddde+/-xx', which seems compatible with the format |
// %.16e gives '[-]m.dddddddddddddddde+/-xx', which seems compatible |
// given in the CIM/XML spec, and the precision required by the CIM 2.2 spec |
// with the format given in the CIM/XML spec, and the precision required |
// (8 byte IEEE floating point) |
// by the CIM 2.2 spec (8 byte IEEE floating point) |
sprintf(buffer, "%.16e", x); | sprintf(buffer, "%.16e", x); |
append(out, buffer); | append(out, buffer); |
} | } |
|
|
continue; | continue; |
} | } |
| |
// Hanlde UTF8 case (if reached). |
// Handle UTF8 case (if reached). |
| |
if(((c >= FIRST_HIGH_SURROGATE) && (c <= LAST_HIGH_SURROGATE)) || | if(((c >= FIRST_HIGH_SURROGATE) && (c <= LAST_HIGH_SURROGATE)) || |
((c >= FIRST_LOW_SURROGATE) && (c <= LAST_LOW_SURROGATE))) | ((c >= FIRST_LOW_SURROGATE) && (c <= LAST_LOW_SURROGATE))) |
|
|
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; |
|
|
Char16 highSurrogate = uriString[i]; | Char16 highSurrogate = uriString[i]; |
Char16 lowSurrogate = uriString[++i]; | Char16 lowSurrogate = uriString[++i]; |
| |
_xmlWritter_appendSurrogatePair(utf8, Uint16(highSurrogate),Uint16(lowSurrogate)); |
_xmlWritter_appendSurrogatePair( |
|
utf8, Uint16(highSurrogate),Uint16(lowSurrogate)); |
} | } |
else | else |
{ | { |
|
|
| |
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)) |
|
|
CIMObjectPath ref = keyBindings[i].getValue(); | CIMObjectPath ref = keyBindings[i].getValue(); |
appendValueReferenceElement(out, ref, true); | appendValueReferenceElement(out, ref, true); |
} | } |
else { |
else |
|
{ |
out << STRLIT("<KEYVALUE VALUETYPE=\""); | out << STRLIT("<KEYVALUE VALUETYPE=\""); |
out << keyBindingTypeToString(keyBindings[i].getType()); | out << keyBindingTypeToString(keyBindings[i].getType()); |
out << STRLIT("\">"); | out << STRLIT("\">"); |
|
|
| |
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); |
} | } |
|
|
} | } |
if (contentLanguages.size() > 0) | if (contentLanguages.size() > 0) |
{ | { |
out << STRLIT("Content-Language: ") << contentLanguages << STRLIT("\r\n"); |
out << STRLIT("Content-Language: ") << contentLanguages << |
|
STRLIT("\r\n"); |
} | } |
| |
#ifdef PEGASUS_DEBUG | #ifdef PEGASUS_DEBUG |
|
|
| |
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 |
| |
|
|
else | else |
{ | { |
out << STRLIT("CIMOperation: MethodCall\r\n"); | out << STRLIT("CIMOperation: MethodCall\r\n"); |
out << STRLIT("CIMMethod: ") << encodeURICharacters(cimMethod.getString()) |
out << STRLIT("CIMMethod: ") |
|
<< encodeURICharacters(cimMethod.getString()) |
<< STRLIT("\r\n"); | << STRLIT("\r\n"); |
out << STRLIT("CIMObject: ") << encodeURICharacters(cimObject) | out << STRLIT("CIMObject: ") << encodeURICharacters(cimObject) |
<< STRLIT("\r\n"); | << STRLIT("\r\n"); |
|
|
{ | { |
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 (contentLanguages.size() > 0) | if (contentLanguages.size() > 0) |
{ | { |
out << STRLIT("Content-Language: ") << contentLanguages << STRLIT("\r\n"); |
out << STRLIT("Content-Language: ") << contentLanguages << |
|
STRLIT("\r\n"); |
} | } |
if (httpMethod == HTTP_METHOD_M_POST) | if (httpMethod == HTTP_METHOD_M_POST) |
{ | { |
|
|
} | } |
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("<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) |
{ | { |
out << STRLIT(" DESCRIPTION=\""); | out << STRLIT(" DESCRIPTION=\""); |
appendSpecial(out, description); | appendSpecial(out, description); |
out.append('"'); | out.append('"'); |
} | } |
|
|
|
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("/>"); | out << STRLIT("/>"); |
} | } |
| |
|
|
| |
CIMType type = value.getType(); | 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) |
// else | // else |
// output the real type | // output the real type |
if (type == CIMTYPE_OBJECT) | if (type == CIMTYPE_OBJECT) |
|
|
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() |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
httpMethod, | httpMethod, |
httpAcceptLanguages, | httpAcceptLanguages, |
httpContentLanguages, | httpContentLanguages, |
out.size()); |
(Uint32)out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
{ | { |
// 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); |
|
|
} | } |
| |
| |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
// XmlWriter::formatSimpleMethodErrorRspMessage() | // XmlWriter::formatSimpleMethodErrorRspMessage() |
|
|
_appendSimpleRspElementEnd(out); | _appendSimpleRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
// l10n |
appendMethodResponseHeader( |
appendMethodResponseHeader(tmp, |
tmp, |
httpMethod, | httpMethod, |
cimException.getContentLanguages(), | cimException.getContentLanguages(), |
out.size()); |
(Uint32)out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
httpMethod, | httpMethod, |
httpAcceptLanguages, | httpAcceptLanguages, |
httpContentLanguages, | httpContentLanguages, |
out.size()); |
(Uint32)out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
{ | { |
// 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 |
|
|
_appendSimpleRspElementEnd(out); | _appendSimpleRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
// l10n |
|
appendMethodResponseHeader(tmp, | appendMethodResponseHeader(tmp, |
httpMethod, | httpMethod, |
cimException.getContentLanguages(), | cimException.getContentLanguages(), |
out.size()); |
(Uint32)out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
} | } |
if (contentLanguages.size() > 0) | if (contentLanguages.size() > 0) |
{ | { |
out << STRLIT("Content-Language: ") << contentLanguages << STRLIT("\r\n"); |
out << STRLIT("Content-Language: ") << contentLanguages << |
|
STRLIT("\r\n"); |
} | } |
| |
#ifdef PEGASUS_DEBUG | #ifdef PEGASUS_DEBUG |
|
|
out << STRLIT("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 << STRLIT("\r\n"); | out << nn << STRLIT("\r\n"); |
out << nn << STRLIT("-CIMExport: MethodRequest\r\n"); | out << nn << STRLIT("-CIMExport: MethodRequest\r\n"); |
out << nn << STRLIT("-CIMExportMethod: ") << cimMethod << STRLIT("\r\n"); |
out << nn << STRLIT("-CIMExportMethod: ") << cimMethod << |
|
STRLIT("\r\n"); |
} | } |
else | else |
{ | { |
|
|
| |
if (contentLanguages.size() > 0) | if (contentLanguages.size() > 0) |
{ | { |
out << STRLIT("Content-Language: ") << contentLanguages << STRLIT("\r\n"); |
out << STRLIT("Content-Language: ") << contentLanguages << |
|
STRLIT("\r\n"); |
} | } |
if (httpMethod == HTTP_METHOD_M_POST) | if (httpMethod == HTTP_METHOD_M_POST) |
{ | { |
|
|
authenticationHeader, | authenticationHeader, |
httpAcceptLanguages, | httpAcceptLanguages, |
httpContentLanguages, | httpContentLanguages, |
out.size()); |
(Uint32)out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
appendEMethodResponseHeader(tmp, | appendEMethodResponseHeader(tmp, |
httpMethod, | httpMethod, |
httpContentLanguages, | httpContentLanguages, |
out.size()); |
(Uint32)out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
_appendSimpleExportRspElementEnd(out); | _appendSimpleExportRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
// l10n |
appendEMethodResponseHeader( |
appendEMethodResponseHeader(tmp, |
tmp, |
httpMethod, | httpMethod, |
cimException.getContentLanguages(), | cimException.getContentLanguages(), |
out.size()); |
(Uint32)out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
void _xmlWritter_indent(PEGASUS_STD(ostream)& os, Uint32 level, Uint32 indentChars) |
void _xmlWritter_indent( |
|
PEGASUS_STD(ostream)& os, |
|
Uint32 level, |
|
Uint32 indentChars) |
{ | { |
Uint32 n = level * indentChars; | Uint32 n = level * indentChars; |
| |
|
|
_xmlWritter_indent(os, stack.size(), indentChars); | _xmlWritter_indent(os, stack.size(), indentChars); |
| |
os << "<?" << entry.text << " "; | os << "<?" << entry.text << " "; |
_xmlWritter_printAttributes(os, entry.attributes, entry.attributeCount); |
_xmlWritter_printAttributes( |
|
os, entry.attributes, entry.attributeCount); |
os << "?>"; | os << "?>"; |
break; | break; |
} | } |
|
|
if (entry.attributeCount) | if (entry.attributeCount) |
os << ' '; | os << ' '; |
| |
_xmlWritter_printAttributes(os, entry.attributes, entry.attributeCount); |
_xmlWritter_printAttributes( |
|
os, entry.attributes, entry.attributeCount); |
os << ">"; | os << ">"; |
stack.push(entry.text); | stack.push(entry.text); |
break; | break; |
|
|
_xmlWritter_indent(os, stack.size(), indentChars); | _xmlWritter_indent(os, stack.size(), indentChars); |
| |
os << "<" << entry.text << " "; | os << "<" << entry.text << " "; |
_xmlWritter_printAttributes(os, entry.attributes, entry.attributeCount); |
_xmlWritter_printAttributes( |
|
os, entry.attributes, entry.attributeCount); |
os << "/>"; | os << "/>"; |
break; | break; |
} | } |
|
|
| |
case XmlEntry::COMMENT: | case XmlEntry::COMMENT: |
{ | { |
|
|
_xmlWritter_indent(os, stack.size(), indentChars); | _xmlWritter_indent(os, stack.size(), indentChars); |
os << "<!--"; | os << "<!--"; |
_xmlWritter_appendSpecial(os, entry.text); | _xmlWritter_appendSpecial(os, entry.text); |
|
|
| |
os << PEGASUS_STD(endl); | os << PEGASUS_STD(endl); |
} | } |
|
|
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
|
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; |
} | } |
| |