version 1.2, 2009/07/20 10:41:43
|
version 1.2.2.23, 2009/09/03 13:54:05
|
|
|
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include "SCMO.h" |
#include <Pegasus/Common/SCMO.h> |
|
#include <Pegasus/Common/SCMOClass.h> |
|
#include <Pegasus/Common/SCMOInstance.h> |
|
#include <Pegasus/Common/SCMODump.h> |
#include <Pegasus/Common/CharSet.h> | #include <Pegasus/Common/CharSet.h> |
#include <Pegasus/Common/CIMDateTimeRep.h> | #include <Pegasus/Common/CIMDateTimeRep.h> |
#include <Pegasus/Common/CIMPropertyRep.h> | #include <Pegasus/Common/CIMPropertyRep.h> |
|
#include <Pegasus/Common/CIMInstanceRep.h> |
|
#include <Pegasus/Common/CIMObjectPathRep.h> |
|
#include <Pegasus/Common/CIMNameCast.h> |
#include <Pegasus/Common/CommonUTF.h> | #include <Pegasus/Common/CommonUTF.h> |
#include <Pegasus/Common/StrLit.h> | #include <Pegasus/Common/StrLit.h> |
#include <Pegasus/Common/XmlWriter.h> | #include <Pegasus/Common/XmlWriter.h> |
|
#include <Pegasus/Common/System.h> |
|
#include <Pegasus/Common/FileSystem.h> |
|
#include <Pegasus/Common/StringConversion.h> |
|
#include <strings.h> |
|
|
|
#ifdef PEGASUS_OS_ZOS |
|
#include <Pegasus/General/SetFileDescriptorToEBCDICEncoding.h> |
|
#endif |
| |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
#define SCMB_INITIAL_MEMORY_CHUNK_SIZE 4096 | #define SCMB_INITIAL_MEMORY_CHUNK_SIZE 4096 |
| |
|
/** |
|
* This macro is used at the SCMODump class |
|
* for generating C/C++ runtime independend output. |
|
* For example on Linux if fprintf got a NULL pointer |
|
* for a string format specification, the string "(null)" is |
|
* substituted. On other platforms no string "" is substituded. |
|
*/ |
|
#define NULLSTR(x) ((x) == NULL ? "" : (x)) |
|
|
|
#define NEWCIMSTR(ptr,base) \ |
|
((ptr).length == 0 ? \ |
|
(String()) : \ |
|
(String(&(base)[(ptr).start],((ptr).length)-1))) |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
static StrLit _qualifierNameStrLit[] = |
const StrLit SCMOClass::_qualifierNameStrLit[72] = |
{ | { |
STRLIT(""), | STRLIT(""), |
STRLIT("ABSTRACT"), | STRLIT("ABSTRACT"), |
STRLIT("AGGREGATE"), | STRLIT("AGGREGATE"), |
STRLIT("AGGREGATION"), | STRLIT("AGGREGATION"), |
STRLIT("ALIAS"), | STRLIT("ALIAS"), |
STRLIT("ARRATYPE"), |
STRLIT("ARRAYTYPE"), |
|
STRLIT("ASSOCIATION"), |
STRLIT("BITMAP"), | STRLIT("BITMAP"), |
STRLIT("BITVALUES"), | STRLIT("BITVALUES"), |
STRLIT("CLASSCONSTRAINT"), | STRLIT("CLASSCONSTRAINT"), |
|
|
STRLIT("EXPENSIVE"), | STRLIT("EXPENSIVE"), |
STRLIT("EXPERIMENTAL"), | STRLIT("EXPERIMENTAL"), |
STRLIT("GAUGE"), | STRLIT("GAUGE"), |
STRLIT("IFDELETE"), |
STRLIT("IFDELETED"), |
STRLIT("IN"), | STRLIT("IN"), |
|
STRLIT("INDICATION"), |
STRLIT("INVISIBLE"), | STRLIT("INVISIBLE"), |
STRLIT("ISPUNIT"), | STRLIT("ISPUNIT"), |
STRLIT("KEY"), | STRLIT("KEY"), |
|
|
STRLIT("VALUEMAP"), | STRLIT("VALUEMAP"), |
STRLIT("VALUES"), | STRLIT("VALUES"), |
STRLIT("VERSION"), | STRLIT("VERSION"), |
STRLIT("WEEK"), |
STRLIT("WEAK"), |
STRLIT("WRITE") | STRLIT("WRITE") |
}; | }; |
| |
|
|
cls.mem = NULL; | cls.mem = NULL; |
} | } |
| |
SCMOClass::SCMOClass(CIMClass& theCIMClass) |
SCMOClass::SCMOClass(CIMClass& theCIMClass, const char* nameSpaceName) |
{ | { |
PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE | PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE |
- sizeof(SCMBClass_Main)>0); | - sizeof(SCMBClass_Main)>0); |
| |
cls.base = (unsigned char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE); |
cls.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE); |
if (cls.base == NULL) | if (cls.base == NULL) |
{ | { |
// Not enough memory! | // Not enough memory! |
|
|
CIMObjectPath theObjectPath=theCIMClass.getPath(); | CIMObjectPath theObjectPath=theCIMClass.getPath(); |
| |
//set name space | //set name space |
|
if (nameSpaceName) |
|
{ |
|
_setBinary(nameSpaceName, |
|
strlen(nameSpaceName)+1, |
|
cls.hdr->nameSpace, |
|
&cls.mem ); |
|
} |
|
else |
|
{ |
_setString(theObjectPath.getNameSpace().getString(), | _setString(theObjectPath.getNameSpace().getString(), |
cls.hdr->nameSpace, | cls.hdr->nameSpace, |
&cls.mem ); | &cls.mem ); |
|
} |
| |
| |
| |
|
|
| |
keyNames.clear(); | keyNames.clear(); |
| |
for (Uint32 i = 0 ; i < cls.hdr->propertySet.number; i++) |
for (Uint32 i = 0, k = cls.hdr->propertySet.number; i < k; i++) |
{ | { |
// Append the key property name. | // Append the key property name. |
// The length has to be reduces by 1 not to copy the trailing '\0' | // The length has to be reduces by 1 not to copy the trailing '\0' |
|
|
} | } |
} | } |
| |
|
const char* SCMOClass::_getPropertyNameAtNode(Uint32 propNode) const |
|
{ |
|
SCMBClassPropertyNode* nodeArray = |
|
(SCMBClassPropertyNode*) |
|
&(cls.base[cls.hdr->propertySet.nodeArray.start]); |
|
|
|
return(_getCharString(nodeArray[propNode].theProperty.name,cls.base)); |
|
} |
|
|
SCMO_RC SCMOClass::_getKeyBindingNodeIndex(Uint32& node, const char* name) const | SCMO_RC SCMOClass::_getKeyBindingNodeIndex(Uint32& node, const char* name) const |
{ | { |
| |
Uint32 tag,len,hashIdx; | Uint32 tag,len,hashIdx; |
| |
len = strlen(name); | len = strlen(name); |
tag = _generateStringTag((const unsigned char*)name, len); |
tag = _generateStringTag((const char*)name, len); |
// get the node index of the hash table | // get the node index of the hash table |
hashIdx = | hashIdx = |
cls.hdr->keyBindingSet.hashTable[tag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE]; | cls.hdr->keyBindingSet.hashTable[tag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE]; |
|
|
Uint32 tag,len,hashIdx; | Uint32 tag,len,hashIdx; |
| |
len = strlen(name); | len = strlen(name); |
tag = _generateStringTag((const unsigned char*)name, len); |
tag = _generateStringTag((const char*)name, len); |
// get the node index of the hash table | // get the node index of the hash table |
hashIdx = | hashIdx = |
cls.hdr->propertySet.hashTable[tag%PEGASUS_PROPERTY_SCMB_HASHSIZE]; | cls.hdr->propertySet.hashTable[tag%PEGASUS_PROPERTY_SCMB_HASHSIZE]; |
|
|
| |
// calculate the relative pointer for the default value | // calculate the relative pointer for the default value |
Uint64 valueStart = | Uint64 valueStart = |
(unsigned char*)&scmoPropNode->theProperty.defaultValue - cls.base; |
(char*)&scmoPropNode->theProperty.defaultValue - cls.base; |
| |
_setValue(valueStart,propRep->_value); | _setValue(valueStart,propRep->_value); |
| |
|
|
scmoQual->name = name; | scmoQual->name = name; |
scmoQual->flavor = theCIMQualifier.getFlavor().cimFlavor; | scmoQual->flavor = theCIMQualifier.getFlavor().cimFlavor; |
| |
valueStart = (unsigned char*)&scmoQual->value - cls.base; |
valueStart = (char*)&scmoQual->value - cls.base; |
| |
_setValue(valueStart,theCIMQualifier.getValue()); | _setValue(valueStart,theCIMQualifier.getValue()); |
| |
|
|
// Only initalized by for completeness. | // Only initalized by for completeness. |
scmoValue->flags.isSet = false; | scmoValue->flags.isSet = false; |
| |
valueStart = (unsigned char*)&scmoValue->value - cls.base; |
|
|
|
if (rep->isNull) | if (rep->isNull) |
{ | { |
return; | return; |
} | } |
| |
|
valueStart = (char*)&scmoValue->value - cls.base; |
|
|
if (scmoValue->flags.isArray) | if (scmoValue->flags.isArray) |
{ | { |
scmoValue->valueArraySize = theCIMValue.getArraySize(); |
SCMOInstance::_setArrayValue( |
_setArrayValue(valueStart,rep->type, rep->u); |
valueStart, |
|
&cls.mem, |
|
rep->type, |
|
// Is set to the number of array members by the function. |
|
scmoValue->valueArraySize, |
|
rep->u); |
} | } |
else | else |
{ | { |
_setUnionValue(valueStart, rep->type, rep->u); |
SCMOInstance::_setUnionValue( |
|
valueStart, |
|
&cls.mem, |
|
rep->type, |
|
rep->u); |
} | } |
} | } |
| |
void SCMOClass::_setArrayValue(Uint64 start, CIMType type, Union& u) |
QualifierNameEnum SCMOClass::_getSCMOQualifierNameEnum( |
|
const CIMName& theCIMName) |
{ | { |
SCMBUnion* scmoUnion = (SCMBUnion*)&(cls.base[start]); |
// Get the UTF8 CString |
Uint64 arrayStart; |
CString theCString=theCIMName.getString().getCString(); |
Uint32 n; |
// Get the real size of the UTF8 sting. |
|
Uint32 length = strlen((const char*)theCString); |
| |
switch (type) |
|
|
// The start index is 1, because the at index 0 is a place holder for |
|
// the user defined qualifier name which is not part of the qualifier name |
|
// list. |
|
for (Uint32 i = 1; i < _NUM_QUALIFIER_NAMES; i++) |
{ | { |
case CIMTYPE_BOOLEAN: |
if (qualifierNameStrLit(i).size == length) |
{ | { |
Array<Boolean> *x = reinterpret_cast<Array<Boolean>*>(&u); |
// TBD: Make it more efficent... |
n = x->size(); |
if(String::equalNoCase( |
arrayStart = _getFreeSpace( |
theCIMName.getString(), |
scmoUnion->_arrayValue, |
qualifierNameStrLit(i).str)) |
n*sizeof(Boolean), |
{ |
&cls.mem); |
return (QualifierNameEnum)i; |
memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Boolean)); |
} |
break; |
} |
} | } |
| |
case CIMTYPE_UINT8: |
return QUALNAME_USERDEFINED; |
{ |
|
Array<Uint8> *x = reinterpret_cast<Array<Uint8>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Uint8), |
|
&cls.mem); |
|
memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Uint8)); |
|
break; |
|
} | } |
| |
case CIMTYPE_SINT8: |
Boolean SCMOClass::_isSamePropOrigin(Uint32 node, const char* origin) const |
{ | { |
Array<Sint8> *x = reinterpret_cast<Array<Sint8>*>(&u); |
Uint32 len = strlen(origin); |
n = x->size(); |
|
arrayStart = _getFreeSpace( |
SCMBClassPropertyNode* nodeArray = |
scmoUnion->_arrayValue, |
(SCMBClassPropertyNode*) |
n*sizeof(Sint8), |
&(cls.base[cls.hdr->propertySet.nodeArray.start]); |
&cls.mem); |
|
memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Sint8)); |
return(_equalUTF8Strings( |
break; |
nodeArray[node].theProperty.originClassName, |
|
cls.base, |
|
origin, |
|
len)); |
} | } |
| |
case CIMTYPE_UINT16: |
inline SCMO_RC SCMOClass::_isNodeSameType( |
|
Uint32 node, |
|
CIMType type, |
|
Boolean isArray) const |
{ | { |
Array<Uint16> *x = reinterpret_cast<Array<Uint16>*>(&u); |
SCMBClassPropertyNode* nodeArray = |
n = x->size(); |
(SCMBClassPropertyNode*) |
arrayStart = _getFreeSpace( |
&(cls.base[cls.hdr->propertySet.nodeArray.start]); |
scmoUnion->_arrayValue, |
|
n*sizeof(Uint16), |
|
&cls.mem); |
|
memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Uint16)); |
|
| |
break; |
|
} |
|
| |
case CIMTYPE_SINT16: |
if(nodeArray[node].theProperty.defaultValue.valueType != type) |
{ | { |
Array<Sint16> *x = reinterpret_cast<Array<Sint16>*>(&u); |
return SCMO_WRONG_TYPE; |
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Sint16), |
|
&cls.mem); |
|
memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Sint16)); |
|
break; |
|
} | } |
| |
case CIMTYPE_UINT32: |
if (isArray) |
{ | { |
Array<Uint32> *x = reinterpret_cast<Array<Uint32>*>(&u); |
if (nodeArray[node].theProperty.defaultValue.flags.isArray) |
n = x->size(); |
{ |
arrayStart = _getFreeSpace( |
return SCMO_OK; |
scmoUnion->_arrayValue, |
|
n*sizeof(Uint32), |
|
&cls.mem); |
|
memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Uint32)); |
|
break; |
|
} | } |
|
else |
case CIMTYPE_SINT32: |
|
{ | { |
Array<Sint32> *x = reinterpret_cast<Array<Sint32>*>(&u); |
return SCMO_NOT_AN_ARRAY; |
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Sint32), |
|
&cls.mem); |
|
memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Sint32)); |
|
break; |
|
} | } |
| |
case CIMTYPE_UINT64: |
|
{ |
|
Array<Uint64> *x = reinterpret_cast<Array<Uint64>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Uint64), |
|
&cls.mem); |
|
memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Uint64)); |
|
break; |
|
} | } |
| |
case CIMTYPE_SINT64: |
if (nodeArray[node].theProperty.defaultValue.flags.isArray) |
{ | { |
Array<Sint64> *x = reinterpret_cast<Array<Sint64>*>(&u); |
return SCMO_IS_AN_ARRAY; |
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Sint64), |
|
&cls.mem); |
|
memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Sint64)); |
|
break; |
|
} | } |
| |
case CIMTYPE_REAL32: |
return SCMO_OK; |
{ |
|
Array<Real32> *x = reinterpret_cast<Array<Real32>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Real32), |
|
&cls.mem); |
|
memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Real32)); |
|
break; |
|
} | } |
|
/***************************************************************************** |
|
* The SCMOInstance methods |
|
*****************************************************************************/ |
| |
case CIMTYPE_REAL64: |
SCMOInstance::SCMOInstance() |
{ | { |
Array<Real64> *x = reinterpret_cast<Array<Real64>*>(&u); |
inst.base = NULL; |
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Real64), |
|
&cls.mem); |
|
memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Real64)); |
|
break; |
|
} | } |
| |
case CIMTYPE_CHAR16: |
SCMOInstance::SCMOInstance(SCMOClass baseClass) |
{ | { |
Array<Char16> *x = reinterpret_cast<Array<Char16>*>(&u); |
_initSCMOInstance(new SCMOClass(baseClass),false,false); |
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Char16), |
|
&cls.mem); |
|
memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Char16)); |
|
break; |
|
} | } |
| |
case CIMTYPE_STRING: |
SCMOInstance::SCMOInstance( |
|
SCMOClass baseClass, |
|
Boolean includeQualifiers, |
|
Boolean includeClassOrigin, |
|
const char** propertyList) |
{ | { |
SCMBDataPtr *ptr; |
|
|
|
Array<String> *x = reinterpret_cast<Array<String>*>(&u); |
|
| |
n = x->size(); |
_initSCMOInstance( |
arrayStart = _getFreeSpace( |
new SCMOClass(baseClass), |
scmoUnion->_arrayValue, |
includeQualifiers, |
n*sizeof(SCMBDataPtr), |
includeClassOrigin); |
&cls.mem); |
|
| |
for (Uint32 i = 0; i < n ; i++) |
setPropertyFilter(propertyList); |
{ |
|
// the pointer has to be set eache loop, |
|
// because a reallocation may take place. |
|
ptr = (SCMBDataPtr*)(&cls.base[arrayStart]); |
|
_setString( (*x)[i],ptr[i], &cls.mem ); |
|
} |
|
| |
break; |
|
} | } |
| |
case CIMTYPE_DATETIME: |
SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMObjectPath& cimObj) |
{ | { |
SCMBDateTime *ptr; |
_initSCMOInstance(new SCMOClass(baseClass),false,false); |
Array<CIMDateTime> *x = reinterpret_cast<Array<CIMDateTime>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(SCMBDateTime), |
|
&cls.mem); |
|
| |
ptr=(SCMBDateTime*)(&cls.base[arrayStart]); |
_setCIMObjectPath(cimObj); |
| |
for (Uint32 i = 0; i < n ; i++) |
|
{ |
|
memcpy(&(ptr[i]),(*x)[i]._rep,sizeof(SCMBDateTime)); |
|
} | } |
break; |
|
} |
|
|
|
case CIMTYPE_REFERENCE: |
|
| |
break; |
SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMInstance& cimInstance) |
|
{ |
case CIMTYPE_OBJECT: |
|
| |
break; |
CIMPropertyRep* propRep; |
|
Uint32 propNode; |
|
Uint64 valueStart; |
|
SCMO_RC rc; |
| |
case CIMTYPE_INSTANCE: |
CIMInstanceRep* instRep = cimInstance._rep; |
|
Boolean hasQualifiers = (instRep->_qualifiers.getCount()>0); |
|
Boolean hasClassOrigin = false; |
| |
break; |
_initSCMOInstance(new SCMOClass(baseClass),hasQualifiers,hasClassOrigin); |
} |
|
} |
|
| |
|
_setCIMObjectPath(instRep->_reference); |
| |
void SCMOClass::_setUnionValue(Uint64 start, CIMType type, Union& u) |
// Copy all properties |
|
for (Uint32 i = 0, k = instRep->_properties.size(); i < k; i++) |
{ | { |
SCMBUnion* scmoUnion = (SCMBUnion*)&(cls.base[start]); |
propRep = instRep->_properties[i]._rep; |
|
// if not already detected that qualifiers are specified and |
switch (type) |
// there are qualifers at that property. |
|
if (!hasQualifiers && propRep->getQualifierCount() > 0) |
{ | { |
case CIMTYPE_BOOLEAN: |
includeQualifiers(); |
|
} |
|
// if not already detected that class origins are specified and |
|
// there is a class origin specified at that property. |
|
if (!hasClassOrigin && !propRep->_classOrigin.isNull()) |
{ | { |
scmoUnion->_booleanValue = u._booleanValue; |
includeClassOrigins(); |
break; |
|
} | } |
| |
case CIMTYPE_UINT8: |
// get the property node index for the property |
|
rc = inst.hdr->theClass->_getProperyNodeIndex( |
|
propNode, |
|
(const char*)propRep->_name.getString().getCString()); |
|
|
|
if (rc != SCMO_OK) |
{ | { |
scmoUnion->_uint8Value = u._uint8Value; |
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NO_SUCH_PROPERTY, |
break; |
propRep->_name.getString()); |
} | } |
|
rc = inst.hdr->theClass->_isNodeSameType( |
case CIMTYPE_SINT8: |
propNode, |
|
propRep->_value._rep->type, |
|
propRep->_value._rep->isArray); |
|
if (rc == SCMO_OK) |
{ | { |
scmoUnion->_sint8Value = u._sint8Value; |
_setCIMValueAtNodeIndex(propNode, propRep->_value._rep); |
break; |
|
} | } |
|
else |
case CIMTYPE_UINT16: |
|
{ | { |
scmoUnion->_uint16Value = u._uint16Value; |
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_TYPE_MISMATCH, |
break; |
propRep->_name.getString()); |
|
} |
} | } |
| |
case CIMTYPE_SINT16: |
|
{ |
|
scmoUnion->_sint16Value = u._sint16Value; |
|
break; |
|
} | } |
| |
case CIMTYPE_UINT32: |
SCMO_RC SCMOInstance::getCIMInstance(CIMInstance& cimInstance) const |
{ | { |
scmoUnion->_uint32Value = u._uint32Value; |
|
break; |
|
} |
|
| |
case CIMTYPE_SINT32: |
SCMO_RC rc = SCMO_OK; |
{ |
Uint32 noProps; |
scmoUnion->_sint32Value = u._sint32Value; |
CIMObjectPath objPath; |
break; |
|
} |
|
| |
case CIMTYPE_UINT64: |
// For better usability define pointers to SCMO Class data structures. |
{ |
SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr; |
scmoUnion->_uint64Value = u._uint64Value; |
char* clsbase = inst.hdr->theClass->cls.base; |
break; |
|
} |
|
| |
case CIMTYPE_SINT64: |
getCIMObjectPath(objPath); |
{ |
|
scmoUnion->_sint64Value = u._sint64Value; |
|
break; |
|
} |
|
| |
case CIMTYPE_REAL32: |
cimInstance._rep = new CIMInstanceRep(objPath); |
{ |
|
scmoUnion->_real32Value = u._real32Value; |
|
break; |
|
} |
|
| |
case CIMTYPE_REAL64: |
if (inst.hdr->flags.includeQualifiers) |
{ | { |
scmoUnion->_real64Value = u._real64Value; |
SCMBQualifier* qualiArray = |
break; |
(SCMBQualifier*)&(clsbase[clshdr->qualifierArray.start]); |
} |
|
| |
case CIMTYPE_CHAR16: |
CIMName qualiName; |
|
CIMValue theValue; |
|
|
|
Uint32 i, k = clshdr->numberOfQualifiers; |
|
|
|
for ( i = 0 ; i < k ; i++) |
{ | { |
scmoUnion->_char16Value = u._char16Value; |
_getCIMValueFromSCMBValue(theValue,qualiArray[i].value,clsbase); |
break; |
|
} |
|
| |
case CIMTYPE_STRING: |
if (qualiArray[i].name == QUALNAME_USERDEFINED) |
{ | { |
_setString(*((String*)((void*)&u)), |
qualiName = NEWCIMSTR(qualiArray[i].userDefName,clsbase); |
scmoUnion->_stringValue, |
|
&cls.mem ); |
|
break; |
|
} | } |
|
else |
case CIMTYPE_DATETIME: |
|
{ | { |
memcpy( |
qualiName = String( |
&scmoUnion->_dateTimeValue, |
SCMOClass::qualifierNameStrLit(qualiArray[i].name).str, |
(*((CIMDateTime*)((void*)&u)))._rep, |
SCMOClass::qualifierNameStrLit(qualiArray[i].name).size); |
sizeof(SCMBDateTime)); |
|
break; |
|
} | } |
| |
case CIMTYPE_REFERENCE: |
cimInstance._rep->_qualifiers.addUnchecked( |
|
CIMQualifier( |
break; |
qualiName, |
|
theValue, |
case CIMTYPE_OBJECT: |
qualiArray[i].flavor, |
|
qualiArray[i].propagated)); |
break; |
|
case CIMTYPE_INSTANCE: |
|
|
|
break; |
|
} | } |
|
|
} | } |
| |
QualifierNameEnum SCMOClass::_getSCMOQualifierNameEnum( |
if (inst.hdr->flags.isFiltered) |
const CIMName& theCIMName) |
|
{ | { |
// Get the UTF8 CString |
// Get absolut pointer to property filter index map of the instance |
CString theCString=theCIMName.getString().getCString(); |
Uint32* propertyFilterIndexMap = |
// Get the real size of the UTF8 sting. |
(Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]); |
Uint32 length = strlen((const char*)theCString); |
|
|
|
| |
// The start index is 1, because the at index 0 is a place holder for |
for(Uint32 i = 0, k = inst.hdr->filterProperties; i<k; i++) |
// the user defined qualifier name which is not part of the qualifier name |
|
// list. |
|
for (Uint32 i = 1; i < _NUM_QUALIFIER_NAMES; i++) |
|
{ |
|
if (_qualifierNameStrLit[i].size == length) |
|
{ | { |
// TBD: Make it more efficent... |
// Get absolut pointer to property filter index map |
if(String::equalNoCase( |
// of the instance get the real node index of the property. |
theCIMName.getString(), |
CIMProperty theProperty=_getCIMPropertyAtNodeIndex( |
_qualifierNameStrLit[i].str)) |
propertyFilterIndexMap[i]); |
{ |
|
return (QualifierNameEnum)i; |
|
} |
|
} |
|
} |
|
| |
return QUALNAME_USERDEFINED; |
cimInstance._rep->_properties.append(theProperty); |
} | } |
| |
Boolean SCMOClass::_isSamePropOrigin(Uint32 node, const char* origin) const |
} |
|
else |
{ | { |
Uint32 len = strlen(origin); |
for(Uint32 i = 0, k = inst.hdr->numberProperties; i<k; i++) |
|
{ |
SCMBClassPropertyNode* nodeArray = |
// no filtering. Counter is node index |
(SCMBClassPropertyNode*) |
CIMProperty theProperty=_getCIMPropertyAtNodeIndex(i); |
&(cls.base[cls.hdr->propertySet.nodeArray.start]); |
|
| |
return(_equalUTF8Strings( |
cimInstance._rep->_properties.append(theProperty); |
nodeArray[node].theProperty.originClassName, |
|
cls.base, |
|
origin, |
|
len)); |
|
} | } |
| |
/***************************************************************************** |
|
* The SCMOInstance methods |
|
*****************************************************************************/ |
|
|
|
SCMOInstance::SCMOInstance() |
|
{ |
|
inst.base = NULL; |
|
} | } |
| |
SCMOInstance::SCMOInstance(SCMOClass baseClass) |
return rc; |
{ |
|
_initSCMOInstance(new SCMOClass(baseClass),false,false); |
|
} | } |
| |
SCMOInstance::SCMOInstance( |
void SCMOInstance::getCIMObjectPath(CIMObjectPath& cimObj) const |
SCMOClass baseClass, |
|
Boolean includeQualifiers, |
|
Boolean includeClassOrigin, |
|
const char** propertyList) |
|
{ | { |
|
// For better usability define pointers to SCMO Class data structures. |
|
SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr; |
|
char* clsbase = inst.hdr->theClass->cls.base; |
| |
_initSCMOInstance( |
// Address the class keybinding information |
new SCMOClass(baseClass), |
SCMBKeyBindingNode* scmoClassArray = |
includeQualifiers, |
(SCMBKeyBindingNode*)&clsbase[clshdr->keyBindingSet.nodeArray.start]; |
includeClassOrigin); |
|
| |
setPropertyFilter(propertyList); |
// Address the instance keybinding information |
|
SCMBInstanceKeyBinding* scmoInstArray = |
|
(SCMBInstanceKeyBinding*)&inst.base[inst.hdr->keyBindingArray.start]; |
| |
} |
Uint32 numberKeyBindings = inst.hdr->numberKeyBindings; |
| |
void SCMOInstance::_initSCMOInstance( |
for (Uint32 i = 0; i < numberKeyBindings; i ++) |
SCMOClass* pClass, |
|
Boolean inclQual, |
|
Boolean inclOrigin) |
|
{ | { |
PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE |
if (scmoInstArray[i].isSet) |
- sizeof(SCMBInstance_Main)>0); |
|
|
|
|
|
inst.base = (unsigned char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE); |
|
if (inst.base == NULL) |
|
{ | { |
// Not enough memory! |
cimObj._rep->_keyBindings.append( |
throw PEGASUS_STD(bad_alloc)(); |
CIMKeyBinding( |
|
CIMNameCast(NEWCIMSTR(scmoClassArray[i].name,clsbase)), |
|
NEWCIMSTR(scmoInstArray[i].value,inst.base), |
|
scmoClassArray[i].type)); |
|
} |
} | } |
| |
// initalize eye catcher |
cimObj._rep->_host = NEWCIMSTR(inst.hdr->hostName,inst.base); |
inst.hdr->header.magic=PEGASUS_SCMB_INSTANCE_MAGIC; |
cimObj._rep->_nameSpace = |
inst.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE; |
CIMNamespaceNameCast(NEWCIMSTR(clshdr->nameSpace,clsbase)); |
// The # of bytes free |
cimObj._rep->_className=CIMNameCast(NEWCIMSTR(clshdr->className,clsbase)); |
inst.hdr->header.freeBytes= |
} |
SCMB_INITIAL_MEMORY_CHUNK_SIZE-sizeof(SCMBInstance_Main); |
|
// Index to the start of the free space in this instance |
|
inst.hdr->header.startOfFreeSpace=sizeof(SCMBInstance_Main); |
|
|
|
inst.hdr->refCount=1; |
|
|
|
//Assign the SCMBClass structure this instance based on. |
|
inst.hdr->theClass = pClass; |
|
|
|
// Init flags |
|
inst.hdr->flags.includeQualifiers=inclQual; |
|
inst.hdr->flags.includeClassOrigin=inclOrigin; |
|
inst.hdr->flags.isFiltered=false; |
|
| |
inst.hdr->hostName.start=0; |
CIMProperty SCMOInstance::_getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const |
inst.hdr->hostName.length=0; |
{ |
|
CIMValue theValue; |
|
CIMProperty retProperty; |
| |
// Number of key bindings |
// For better usability define pointers to SCMO Class data structures. |
inst.hdr->numberKeyBindings = |
SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr; |
inst.hdr->theClass->cls.hdr->keyBindingSet.number; |
char* clsbase = inst.hdr->theClass->cls.base; |
| |
// Number of properties |
|
inst.hdr->numberProperties = |
|
inst.hdr->theClass->cls.hdr->propertySet.number; |
|
| |
// Allocate the SCMOInstanceKeyBindingArray |
SCMBClassPropertyNode& clsProp = |
_getFreeSpace( |
((SCMBClassPropertyNode*) |
inst.hdr->keyBindingArray, |
&(clsbase[clshdr->propertySet.nodeArray.start]))[nodeIdx]; |
sizeof(SCMBDataPtr)*inst.hdr->numberKeyBindings, |
|
&inst.mem, |
|
true); |
|
| |
// Allocate the SCMBPropertyFilter |
SCMBValue& instValue = |
_getFreeSpace( |
((SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]))[nodeIdx]; |
inst.hdr->propertyFilter, |
|
sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1), |
|
&inst.mem, |
|
true); |
|
| |
// Allocate the SCMBPropertyFilterIndexMap |
_getCIMValueFromSCMBValue(theValue,instValue,inst.base); |
_getFreeSpace( |
|
inst.hdr->propertyFilterIndexMap, |
|
sizeof(Uint32)*inst.hdr->numberProperties, |
|
&inst.mem, |
|
true); |
|
| |
// Allocate the SCMBInstancePropertyArray |
|
_getFreeSpace( |
|
inst.hdr->propertyArray, |
|
sizeof(SCMBValue)*inst.hdr->numberProperties, |
|
&inst.mem, |
|
true); |
|
| |
|
if (inst.hdr->flags.includeClassOrigin) |
|
{ |
|
retProperty = CIMProperty( |
|
CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,clsbase)), |
|
theValue, |
|
theValue.getArraySize(), |
|
CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,clsbase)), |
|
CIMNameCast(NEWCIMSTR(clsProp.theProperty.originClassName,clsbase)), |
|
clsProp.theProperty.flags.propagated); |
|
} |
|
else |
|
{ |
|
retProperty = CIMProperty( |
|
CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,clsbase)), |
|
theValue, |
|
theValue.getArraySize(), |
|
CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,clsbase)), |
|
CIMName(), |
|
clsProp.theProperty.flags.propagated); |
} | } |
| |
SCMO_RC SCMOInstance::getProperty( |
if (inst.hdr->flags.includeQualifiers) |
const char* name, |
|
CIMType& type, |
|
const void** pvalue, |
|
Boolean& isArray, |
|
Uint32& size ) const |
|
{ | { |
Uint32 node; |
SCMBQualifier* qualiArray = |
const unsigned char** pname; |
(SCMBQualifier*) |
SCMO_RC rc = SCMO_OK; |
&(clsbase[clsProp.theProperty.qualifierArray.start]); |
| |
*pvalue = NULL; |
CIMName qualiName; |
isArray = false; |
|
size = 0; |
|
| |
rc = inst.hdr->theClass->_getProperyNodeIndex(node,name); |
Uint32 i, k = clsProp.theProperty.numberOfQualifiers; |
if (rc != SCMO_OK) |
for ( i = 0 ; i < k ; i++) |
{ | { |
return rc; |
_getCIMValueFromSCMBValue(theValue,qualiArray[i].value,clsbase); |
} |
|
| |
// is filtering on ? |
if (qualiArray[i].name == QUALNAME_USERDEFINED) |
if (inst.hdr->flags.isFiltered) |
|
{ |
|
// Is the property NOT in the property filter ? |
|
if(!_isPropertyInFilter(node)) |
|
{ | { |
// The named propery is not part of this instance |
qualiName = NEWCIMSTR(qualiArray[i].userDefName,clsbase); |
// due to filtering. |
|
return SCMO_NOT_FOUND; |
|
} | } |
|
else |
|
{ |
|
qualiName = String( |
|
SCMOClass::qualifierNameStrLit(qualiArray[i].name).str, |
|
SCMOClass::qualifierNameStrLit(qualiArray[i].name).size); |
} | } |
| |
return _getPropertyAtNodeIndex(node,pname,type,pvalue,isArray,size); |
retProperty._rep->_qualifiers.addUnchecked( |
|
CIMQualifier( |
|
qualiName, |
|
theValue, |
|
qualiArray[i].flavor, |
|
qualiArray[i].propagated)); |
|
} |
} | } |
| |
SCMO_RC SCMOInstance::getPropertyAt( |
return retProperty; |
Uint32 idx, |
|
const unsigned char** pname, |
|
CIMType& type, |
|
const void** pvalue, |
|
Boolean& isArray, |
|
Uint32& size ) const |
|
{ |
|
*pname = NULL; |
|
*pvalue = NULL; |
|
isArray = false; |
|
size = 0; |
|
Uint32 node; |
|
| |
// is filtering on ? |
} |
if (inst.hdr->flags.isFiltered) |
|
|
void SCMOInstance::_getCIMValueFromSCMBValue( |
|
CIMValue& cimV, |
|
const SCMBValue& scmbV, |
|
const char * base) const |
{ | { |
// check the number of properties part of the filter |
if (scmbV.flags.isNull) |
if (idx >= inst.hdr->filterProperties) |
|
{ | { |
return SCMO_INDEX_OUT_OF_BOUND; |
cimV.setNullValue( |
|
scmbV.valueType, |
|
scmbV.flags.isArray, |
|
scmbV.valueArraySize); |
|
return; |
} | } |
| |
// Get absolut pointer to property filter index map of the instance |
switch (scmbV.valueType) |
Uint32* propertyFilterIndexMap = |
{ |
(Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]); |
|
| |
// get the real node index of the property. |
case CIMTYPE_UINT8: |
node = propertyFilterIndexMap[idx]; |
|
} |
|
else |
|
{ | { |
// the index is used as node index. |
if (scmbV.flags.isArray) |
node = idx; |
|
if (node >= inst.hdr->numberProperties) |
|
{ | { |
return SCMO_INDEX_OUT_OF_BOUND; |
const Uint8* u=(Uint8*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Uint8> x; |
|
x.append(u,scmbV.valueArraySize); |
|
cimV.set(x); |
} | } |
|
else |
|
{ |
|
cimV.set(scmbV.value._uint8Value); |
} | } |
|
break; |
return _getPropertyAtNodeIndex(node,pname,type,pvalue,isArray,size); |
|
} | } |
| |
SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const |
case CIMTYPE_UINT16: |
{ | { |
if(name==NULL) |
if (scmbV.flags.isArray) |
{ | { |
return SCMO_INVALID_PARAMETER; |
const Uint16* u=(Uint16*)&(base[scmbV.value._arrayValue.start]); |
} |
Array<Uint16> x; |
|
x.append(u,scmbV.valueArraySize); |
return (inst.hdr->theClass->_getProperyNodeIndex(node,name)); |
cimV.set(x); |
} | } |
SCMO_RC SCMOInstance::setPropertyWithOrigin( |
else |
const char* name, |
|
CIMType type, |
|
void* value, |
|
Boolean isArray, |
|
Uint32 size, |
|
const char* origin) |
|
{ | { |
Uint32 node; |
cimV.set(scmbV.value._uint16Value); |
SCMO_RC rc; |
} |
|
break; |
|
} |
| |
rc = inst.hdr->theClass->_getProperyNodeIndex(node,name); |
case CIMTYPE_UINT32: |
if (rc != SCMO_OK) |
|
{ | { |
return rc; |
if (scmbV.flags.isArray) |
|
{ |
|
const Uint32* u=(Uint32*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Uint32> x; |
|
x.append(u,scmbV.valueArraySize); |
|
cimV.set(x); |
|
} |
|
else |
|
{ |
|
cimV.set(scmbV.value._uint32Value); |
|
} |
|
break; |
} | } |
| |
// is filtering on ? |
case CIMTYPE_UINT64: |
if (inst.hdr->flags.isFiltered) |
|
{ | { |
// Is the property NOT in the property filter ? |
if (scmbV.flags.isArray) |
if(!_isPropertyInFilter(node)) |
|
{ | { |
// The named propery is not part of this instance |
const Uint64* u=(Uint64*)&(base[scmbV.value._arrayValue.start]); |
// due to filtering. |
Array<Uint64> x; |
return SCMO_NOT_FOUND; |
x.append(u,scmbV.valueArraySize); |
|
cimV.set(x); |
|
} |
|
else |
|
{ |
|
cimV.set(scmbV.value._uint64Value); |
} | } |
|
break; |
} | } |
| |
// check class origin if set. |
case CIMTYPE_SINT8: |
if (origin!= NULL) |
|
{ | { |
if(!inst.hdr->theClass->_isSamePropOrigin(node,origin)) |
if (scmbV.flags.isArray) |
{ | { |
return SCMO_NOT_SAME_ORIGIN; |
const Sint8* u=(Sint8*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Sint8> x; |
|
x.append(u,scmbV.valueArraySize); |
|
cimV.set(x); |
} | } |
|
else |
|
{ |
|
cimV.set(scmbV.value._sint8Value); |
|
} |
|
break; |
} | } |
| |
_setPropertyAtNodeIndex(node,type,value,isArray,size); |
case CIMTYPE_SINT16: |
|
{ |
|
if (scmbV.flags.isArray) |
|
{ |
|
const Sint16* u=(Sint16*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Sint16> x; |
|
x.append(u,scmbV.valueArraySize); |
|
cimV.set(x); |
|
} |
|
else |
|
{ |
|
cimV.set(scmbV.value._sint16Value); |
|
} |
|
break; |
|
} |
| |
return SCMO_OK; |
case CIMTYPE_SINT32: |
|
{ |
|
if (scmbV.flags.isArray) |
|
{ |
|
const Sint32* u=(Sint32*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Sint32> x; |
|
x.append(u,scmbV.valueArraySize); |
|
cimV.set(x); |
|
} |
|
else |
|
{ |
|
cimV.set(scmbV.value._sint32Value); |
|
} |
|
break; |
} | } |
| |
SCMO_RC SCMOInstance::setPropertyWithNodeIndex( |
case CIMTYPE_SINT64: |
Uint32 node, |
|
CIMType type, |
|
void* value, |
|
Boolean isArray, |
|
Uint32 size) |
|
{ | { |
if (node >= inst.hdr->numberProperties) |
if (scmbV.flags.isArray) |
{ | { |
return SCMO_INDEX_OUT_OF_BOUND; |
const Sint64* u=(Sint64*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Sint64> x; |
|
x.append(u,scmbV.valueArraySize); |
|
cimV.set(x); |
|
} |
|
else |
|
{ |
|
cimV.set(scmbV.value._sint64Value); |
|
} |
|
break; |
} | } |
| |
// is filtering on ? |
case CIMTYPE_REAL32: |
if (inst.hdr->flags.isFiltered) |
|
{ | { |
// Is the property NOT in the property filter ? |
if (scmbV.flags.isArray) |
if(!_isPropertyInFilter(node)) |
|
{ | { |
// The named propery is not part of this instance |
const Real32* u=(Real32*)&(base[scmbV.value._arrayValue.start]); |
// due to filtering. |
Array<Real32> x; |
return SCMO_NOT_FOUND; |
x.append(u,scmbV.valueArraySize); |
|
cimV.set(x); |
|
} |
|
else |
|
{ |
|
cimV.set(scmbV.value._real32Value); |
} | } |
|
break; |
} | } |
| |
_setPropertyAtNodeIndex(node,type,value,isArray,size); |
case CIMTYPE_REAL64: |
|
{ |
|
if (scmbV.flags.isArray) |
|
{ |
|
const Real64* u=(Real64*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Real64> x; |
|
x.append(u,scmbV.valueArraySize); |
|
cimV.set(x); |
|
} |
|
else |
|
{ |
|
cimV.set(scmbV.value._real64Value); |
|
} |
|
break; |
|
} |
| |
return SCMO_OK; |
case CIMTYPE_CHAR16: |
|
{ |
|
if (scmbV.flags.isArray) |
|
{ |
|
const Char16* u=(Char16*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Char16> x; |
|
x.append(u,scmbV.valueArraySize); |
|
cimV.set(x); |
|
} |
|
else |
|
{ |
|
cimV.set(scmbV.value._char16Value); |
|
} |
|
break; |
} | } |
| |
void SCMOInstance::_setPropertyAtNodeIndex( |
case CIMTYPE_BOOLEAN: |
Uint32 node, |
{ |
CIMType type, |
if (scmbV.flags.isArray) |
void* value, |
{ |
Boolean isArray, |
const Boolean* u= |
Uint32 size) |
(Boolean*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Boolean> x; |
|
x.append(u,scmbV.valueArraySize); |
|
cimV.set(x); |
|
} |
|
else |
|
{ |
|
cimV.set(scmbV.value._booleanValue); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_STRING: |
|
{ |
|
if (scmbV.flags.isArray) |
|
{ |
|
// get the pointer to the array of relative SCMB pointers |
|
const SCMBDataPtr *ptr = |
|
(SCMBDataPtr*)&(base[scmbV.value._arrayValue.start]); |
|
|
|
Array<String> x; |
|
|
|
for (Uint32 i = 0, k = scmbV.valueArraySize; i < k ; i++) |
|
{ |
|
x.append(NEWCIMSTR(ptr[i],base)); |
|
} |
|
cimV.set(x); |
|
} |
|
else |
|
{ |
|
cimV.set(NEWCIMSTR(scmbV.value._stringValue,base)); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_DATETIME: |
|
{ |
|
if (scmbV.flags.isArray) |
|
{ |
|
// get the pointer to the array of SCMBDateTime |
|
const SCMBDateTime *ptr = |
|
(SCMBDateTime*)&(base[scmbV.value._arrayValue.start]); |
|
|
|
Array<CIMDateTime> x; |
|
|
|
for (Uint32 i = 0, k = scmbV.valueArraySize; i < k ; i++) |
|
{ |
|
x.append(CIMDateTime(&(ptr[i]))); |
|
} |
|
cimV.set(x); |
|
} |
|
else |
|
{ |
|
cimV.set(CIMDateTime(&scmbV.value._dateTimeValue)); |
|
} |
|
break; |
|
|
|
} |
|
|
|
case CIMTYPE_REFERENCE: |
|
|
|
break; |
|
|
|
case CIMTYPE_OBJECT: |
|
|
|
break; |
|
|
|
case CIMTYPE_INSTANCE: |
|
|
|
break; |
|
} |
|
|
|
} |
|
|
|
void SCMOInstance::_setCIMObjectPath(const CIMObjectPath& cimObj) |
|
{ |
|
CIMObjectPathRep* objRep = cimObj._rep; |
|
SCMO_RC rc; |
|
|
|
// For better usability define pointers to SCMO Class data structures. |
|
SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr; |
|
char* clsbase = inst.hdr->theClass->cls.base; |
|
|
|
CString className = objRep->_className.getString().getCString(); |
|
CString nameSpace = objRep->_nameSpace.getString().getCString(); |
|
|
|
// Is the instance from the same class and name space ? |
|
if (!(_equalNoCaseUTF8Strings( |
|
clshdr->className, |
|
clsbase, |
|
(const char*)className, |
|
strlen(className)) && |
|
_equalNoCaseUTF8Strings( |
|
clshdr->nameSpace, |
|
clsbase, |
|
(const char*)nameSpace, |
|
strlen(nameSpace))) |
|
) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS, |
|
objRep->_className.getString()); |
|
} |
|
|
|
//set host name |
|
_setString(objRep->_host,inst.hdr->hostName,&inst.mem ); |
|
|
|
if (inst.hdr->numberKeyBindings < objRep->_keyBindings.size()) |
|
{ |
|
String message("CIMObjectPath has more keybindings " |
|
"than the associated class key properties."); |
|
throw CIMException(CIM_ERR_FAILED, message); |
|
} |
|
|
|
for (Uint32 i = 0, k = objRep->_keyBindings.size(); i < k; i++) |
|
{ |
|
|
|
rc = setKeyBinding( |
|
(const char*) |
|
objRep->_keyBindings[i].getName().getString().getCString(), |
|
objRep->_keyBindings[i].getType(), |
|
(const char*) objRep->_keyBindings[i].getValue().getCString()); |
|
|
|
if (rc != SCMO_OK) |
|
{ |
|
switch (rc) |
|
{ |
|
case SCMO_NOT_FOUND: |
|
{ |
|
String message("CIMObjectPath key binding "); |
|
message.append( |
|
objRep->_keyBindings[i].getName().getString()); |
|
message.append(" not found."); |
|
throw CIMException(CIM_ERR_FAILED, message); |
|
} |
|
default: |
|
{ |
|
String message("CIMObjectPath key binding "); |
|
message.append( |
|
objRep->_keyBindings[i].getName().getString()); |
|
message.append(" does not match class definition!"); |
|
throw CIMException(CIM_ERR_FAILED, message); |
|
} |
|
} |
|
} |
|
} |
|
|
|
} |
|
void SCMOInstance::_setCIMValueAtNodeIndex(Uint32 node, CIMValueRep* valRep) |
{ | { |
SCMBValue* theInstPropNodeArray = | SCMBValue* theInstPropNodeArray = |
(SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; | (SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; |
| |
| |
theInstPropNodeArray[node].flags.isSet=true; |
SCMBValue& theInstProp = theInstPropNodeArray[node]; |
theInstPropNodeArray[node].valueType=type; |
|
theInstPropNodeArray[node].flags.isArray=isArray; |
theInstProp.valueType=valRep->type; |
if (isArray) |
theInstProp.flags.isNull=valRep->isNull; |
|
theInstProp.flags.isArray=valRep->isArray; |
|
theInstProp.flags.isSet=true; |
|
theInstProp.valueArraySize=0; |
|
|
|
if (valRep->isNull) |
{ | { |
theInstPropNodeArray[node].valueArraySize=size; |
return; |
} | } |
| |
if (value==NULL) |
Uint64 start = ((const char*)&(theInstProp.value))-inst.base; |
|
|
|
if (valRep->isArray) |
{ | { |
theInstPropNodeArray[node].flags.isNull=true; |
_setArrayValue( |
|
start, |
|
&inst.mem, |
|
valRep->type, |
|
// Is set to the number of array members by the function. |
|
theInstProp.valueArraySize, |
|
valRep->u); |
} | } |
else | else |
{ | { |
Uint64 start = |
_setUnionValue(start,&inst.mem,valRep->type,valRep->u); |
(unsigned const char*)&(theInstPropNodeArray[node].value)-inst.base; |
} |
|
} |
| |
_setSCMBUnion(value,type,isArray,size,start); |
|
|
Boolean SCMOInstance::isSame(SCMOInstance& theInstance) const |
|
{ |
|
return inst.base == theInstance.inst.base; |
} | } |
|
|
|
const char* SCMOInstance::getHostName() const |
|
{ |
|
return _getCharString(inst.hdr->hostName,inst.base); |
} | } |
| |
void SCMOInstance::_setSCMBUnion( |
void SCMOInstance::buildKeyBindingsFromProperties() |
void* value, |
{ |
|
|
|
Uint32* theClassKeyPropList = |
|
(Uint32*) &((inst.hdr->theClass->cls.base) |
|
[(inst.hdr->theClass->cls.hdr->keyIndexList.start)]); |
|
|
|
SCMBInstanceKeyBinding* theInstKeyBindNodeArray; |
|
SCMBValue* theInstPropNodeArray; |
|
|
|
Uint32 propNode; |
|
|
|
for (Uint32 i = 0, k = inst.hdr->numberKeyBindings; i < k; i++) |
|
{ |
|
// the instance pointers has to be reinitialized each time, |
|
// because in _setKeyBindingFromSCMBUnion() |
|
// a reallocation can take place. |
|
theInstKeyBindNodeArray = |
|
(SCMBInstanceKeyBinding*)&inst.base[inst.hdr->keyBindingArray.start]; |
|
|
|
theInstPropNodeArray = |
|
(SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; |
|
|
|
// If the keybinding is not set. |
|
if (!theInstKeyBindNodeArray[i].isSet) |
|
{ |
|
// get the node index for this key binding form class |
|
propNode = theClassKeyPropList[i]; |
|
|
|
// if property was not set by the provider or it is null. |
|
if (!theInstPropNodeArray[propNode].flags.isSet || |
|
theInstPropNodeArray[propNode].flags.isNull) |
|
{ |
|
const char * propName = |
|
inst.hdr->theClass->_getPropertyNameAtNode(propNode); |
|
throw NoSuchProperty(String(propName)); |
|
} |
|
|
|
_setKeyBindingFromSCMBUnion( |
|
theInstPropNodeArray[propNode].valueType, |
|
theInstPropNodeArray[propNode].value, |
|
theInstKeyBindNodeArray[i].value); |
|
|
|
theInstKeyBindNodeArray[i].isSet=true; |
|
} |
|
} |
|
} |
|
|
|
void SCMOInstance::_setKeyBindingFromSCMBUnion( |
|
CIMType type, |
|
SCMBUnion& u, |
|
SCMBDataPtr& keyNode) |
|
{ |
|
Uint32 outputLength=0; |
|
const char * output; |
|
|
|
switch (type) |
|
{ |
|
case CIMTYPE_UINT8: |
|
{ |
|
char buffer[22]; |
|
output = Uint8ToString(buffer, u._uint8Value, outputLength); |
|
// including trailing '\0' ! |
|
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
|
break; |
|
} |
|
|
|
case CIMTYPE_UINT16: |
|
{ |
|
char buffer[22]; |
|
output = Uint16ToString(buffer, u._uint16Value, outputLength); |
|
// including trailing '\0' ! |
|
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
|
break; |
|
} |
|
|
|
case CIMTYPE_UINT32: |
|
{ |
|
char buffer[22]; |
|
output = Uint32ToString(buffer, u._uint32Value, outputLength); |
|
// including trailing '\0' ! |
|
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
|
break; |
|
} |
|
|
|
case CIMTYPE_UINT64: |
|
{ |
|
char buffer[22]; |
|
output = Uint64ToString(buffer, u._uint64Value, outputLength); |
|
// including trailing '\0' ! |
|
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT8: |
|
{ |
|
char buffer[22]; |
|
output = Sint8ToString(buffer, u._sint8Value, outputLength); |
|
// including trailing '\0' ! |
|
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT16: |
|
{ |
|
char buffer[22]; |
|
output = Sint16ToString(buffer, u._sint16Value, outputLength); |
|
// including trailing '\0' ! |
|
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT32: |
|
{ |
|
char buffer[22]; |
|
output = Sint32ToString(buffer, u._sint32Value, outputLength); |
|
// including trailing '\0' ! |
|
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT64: |
|
{ |
|
char buffer[22]; |
|
output = Sint64ToString(buffer, u._sint64Value, outputLength); |
|
// including trailing '\0' ! |
|
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
|
break; |
|
} |
|
|
|
case CIMTYPE_REAL32: |
|
{ |
|
char buffer[128]; |
|
output = Real32ToString(buffer, u._real32Value, outputLength); |
|
// including trailing '\0' ! |
|
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
|
break; |
|
} |
|
|
|
case CIMTYPE_REAL64: |
|
{ |
|
char buffer[128]; |
|
output = Real64ToString(buffer, u._real64Value, outputLength); |
|
// including trailing '\0' ! |
|
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
|
break; |
|
break; |
|
} |
|
|
|
case CIMTYPE_CHAR16: |
|
{ |
|
Buffer out; |
|
_toString(out,u._char16Value); |
|
// including trailing '\0' ! |
|
_setBinary(out.getData(),out.size()+1,keyNode,&inst.mem); |
|
break; |
|
} |
|
|
|
case CIMTYPE_BOOLEAN: |
|
{ |
|
if (u._booleanValue) |
|
{ |
|
_setBinary("TRUE",strlen("TRUE")+1,keyNode,&inst.mem); |
|
} |
|
else |
|
{ |
|
_setBinary("FALSE",strlen("FALSE")+1,keyNode,&inst.mem); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_STRING: |
|
{ |
|
_setBinary( |
|
&inst.base[u._stringValue.start], |
|
u._stringValue.length, |
|
keyNode, |
|
&inst.mem); |
|
break; |
|
} |
|
|
|
case CIMTYPE_DATETIME: |
|
{ |
|
_setString( |
|
CIMDateTime(&u._dateTimeValue).toString(), |
|
keyNode, |
|
&inst.mem); |
|
break; |
|
} |
|
|
|
case CIMTYPE_REFERENCE: |
|
{ |
|
_setBinary( |
|
(const void*)u._voidPtr, |
|
sizeof(u._voidPtr), |
|
keyNode, |
|
&inst.mem); |
|
break; |
|
} |
|
|
|
case CIMTYPE_OBJECT: |
|
case CIMTYPE_INSTANCE: |
|
// From PEP 194: EmbeddedObjects cannot be keys. |
|
throw TypeMismatchException(); |
|
break; |
|
} |
|
} |
|
|
|
void SCMOInstance::setHostName(const char* hostName) |
|
{ |
|
Uint32 len; |
|
|
|
if (hostName!=NULL) |
|
{ |
|
|
|
len = strlen((const char*)hostName); |
|
if(len != 0) |
|
{ |
|
|
|
// copy including trailing '\0' |
|
_setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem); |
|
return; |
|
} |
|
|
|
} |
|
inst.hdr->hostName.start=0; |
|
inst.hdr->hostName.length=0; |
|
} |
|
|
|
const char* SCMOInstance::getClassName() const |
|
{ |
|
return _getCharString( |
|
inst.hdr->theClass->cls.hdr->className, |
|
inst.hdr->theClass->cls.base); |
|
} |
|
|
|
const char* SCMOInstance::getClassName_l(Uint64 & length) const |
|
{ |
|
SCMOClass * scmoCls = inst.hdr->theClass; |
|
length = scmoCls->cls.hdr->className.length; |
|
return _getCharString( |
|
scmoCls->cls.hdr->className, |
|
scmoCls->cls.base); |
|
|
|
} |
|
|
|
|
|
const char* SCMOInstance::getNameSpace() const |
|
{ |
|
return _getCharString( |
|
inst.hdr->theClass->cls.hdr->nameSpace, |
|
inst.hdr->theClass->cls.base); |
|
} |
|
|
|
void SCMOInstance::_initSCMOInstance( |
|
SCMOClass* pClass, |
|
Boolean inclQual, |
|
Boolean inclOrigin) |
|
{ |
|
PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE |
|
- sizeof(SCMBInstance_Main)>0); |
|
|
|
|
|
inst.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE); |
|
if (inst.base == NULL) |
|
{ |
|
// Not enough memory! |
|
throw PEGASUS_STD(bad_alloc)(); |
|
} |
|
|
|
// initalize eye catcher |
|
inst.hdr->header.magic=PEGASUS_SCMB_INSTANCE_MAGIC; |
|
inst.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE; |
|
// The # of bytes free |
|
inst.hdr->header.freeBytes= |
|
SCMB_INITIAL_MEMORY_CHUNK_SIZE-sizeof(SCMBInstance_Main); |
|
// Index to the start of the free space in this instance |
|
inst.hdr->header.startOfFreeSpace=sizeof(SCMBInstance_Main); |
|
|
|
inst.hdr->refCount=1; |
|
|
|
//Assign the SCMBClass structure this instance based on. |
|
inst.hdr->theClass = pClass; |
|
|
|
// Init flags |
|
inst.hdr->flags.includeQualifiers=inclQual; |
|
inst.hdr->flags.includeClassOrigin=inclOrigin; |
|
inst.hdr->flags.isFiltered=false; |
|
|
|
inst.hdr->hostName.start=0; |
|
inst.hdr->hostName.length=0; |
|
|
|
// Number of key bindings |
|
inst.hdr->numberKeyBindings = |
|
inst.hdr->theClass->cls.hdr->keyBindingSet.number; |
|
|
|
// Number of properties |
|
inst.hdr->numberProperties = |
|
inst.hdr->theClass->cls.hdr->propertySet.number; |
|
|
|
// Allocate the SCMOInstanceKeyBindingArray |
|
_getFreeSpace( |
|
inst.hdr->keyBindingArray, |
|
sizeof(SCMBInstanceKeyBinding)*inst.hdr->numberKeyBindings, |
|
&inst.mem, |
|
true); |
|
|
|
// Allocate the SCMBInstancePropertyArray |
|
_getFreeSpace( |
|
inst.hdr->propertyArray, |
|
sizeof(SCMBValue)*inst.hdr->numberProperties, |
|
&inst.mem, |
|
true); |
|
|
|
inst.hdr->propertyFilter.start=0; |
|
inst.hdr->propertyFilter.length=0; |
|
inst.hdr->propertyFilterIndexMap.start=0; |
|
inst.hdr->propertyFilterIndexMap.length=0; |
|
|
|
|
|
} |
|
|
|
SCMO_RC SCMOInstance::getProperty( |
|
const char* name, |
|
CIMType& type, |
|
const void** pvalue, |
|
Boolean& isArray, |
|
Uint32& size ) const |
|
{ |
|
Uint32 node; |
|
const char* pname; |
|
SCMO_RC rc = SCMO_OK; |
|
|
|
*pvalue = NULL; |
|
isArray = false; |
|
size = 0; |
|
|
|
rc = inst.hdr->theClass->_getProperyNodeIndex(node,name); |
|
if (rc != SCMO_OK) |
|
{ |
|
return rc; |
|
} |
|
|
|
// is filtering on ? |
|
if (inst.hdr->flags.isFiltered) |
|
{ |
|
// Is the property NOT in the property filter ? |
|
if(!_isPropertyInFilter(node)) |
|
{ |
|
// The named propery is not part of this instance |
|
// due to filtering. |
|
return SCMO_NOT_FOUND; |
|
} |
|
} |
|
|
|
return _getPropertyAtNodeIndex(node,&pname,type,pvalue,isArray,size); |
|
} |
|
|
|
SCMO_RC SCMOInstance::getPropertyAt( |
|
Uint32 idx, |
|
const char** pname, |
|
CIMType& type, |
|
const void** pvalue, |
|
Boolean& isArray, |
|
Uint32& size ) const |
|
{ |
|
*pname = NULL; |
|
*pvalue = NULL; |
|
isArray = false; |
|
size = 0; |
|
Uint32 node; |
|
|
|
// is filtering on ? |
|
if (inst.hdr->flags.isFiltered) |
|
{ |
|
// check the number of properties part of the filter |
|
if (idx >= inst.hdr->filterProperties) |
|
{ |
|
return SCMO_INDEX_OUT_OF_BOUND; |
|
} |
|
|
|
// Get absolut pointer to property filter index map of the instance |
|
Uint32* propertyFilterIndexMap = |
|
(Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]); |
|
|
|
// get the real node index of the property. |
|
node = propertyFilterIndexMap[idx]; |
|
} |
|
else |
|
{ |
|
// the index is used as node index. |
|
node = idx; |
|
if (node >= inst.hdr->numberProperties) |
|
{ |
|
return SCMO_INDEX_OUT_OF_BOUND; |
|
} |
|
} |
|
|
|
return _getPropertyAtNodeIndex(node,pname,type,pvalue,isArray,size); |
|
} |
|
|
|
SCMO_RC SCMOInstance::getPropertyAt( |
|
Uint32 pos, |
|
SCMBValue** value, |
|
const char ** valueBase, |
|
SCMBClassProperty ** propDef) const |
|
{ |
|
Uint32 node; |
|
// is filtering on ? |
|
if (inst.hdr->flags.isFiltered) |
|
{ |
|
// check the number of properties part of the filter |
|
if (pos >= inst.hdr->filterProperties) |
|
{ |
|
return SCMO_INDEX_OUT_OF_BOUND; |
|
} |
|
|
|
// Get absolut pointer to property filter index map of the instance |
|
Uint32* propertyFilterIndexMap = |
|
(Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]); |
|
|
|
// get the real node index of the property. |
|
node = propertyFilterIndexMap[pos]; |
|
} |
|
else |
|
{ |
|
// the index is used as node index. |
|
node = pos; |
|
if (node >= inst.hdr->numberProperties) |
|
{ |
|
return SCMO_INDEX_OUT_OF_BOUND; |
|
} |
|
} |
|
|
|
SCMBValue* theInstPropNodeArray = |
|
(SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; |
|
|
|
// create a pointer to property node array of the class. |
|
Uint64 idx = inst.hdr->theClass->cls.hdr->propertySet.nodeArray.start; |
|
SCMBClassPropertyNode* theClassPropNodeArray = |
|
(SCMBClassPropertyNode*)&(inst.hdr->theClass->cls.base)[idx]; |
|
|
|
// return the absolute pointer to the property definition |
|
*propDef= &(theClassPropNodeArray[node].theProperty); |
|
|
|
// need check if property set or not, if not set use the default value |
|
if (theInstPropNodeArray[node].flags.isSet) |
|
{ |
|
// return the absolute pointer to the property value in the instance |
|
*value = &(theInstPropNodeArray[node]); |
|
*valueBase = inst.base; |
|
} |
|
else |
|
{ |
|
// return the absolute pointer to |
|
*value = &(theClassPropNodeArray[node].theProperty.defaultValue); |
|
*valueBase = inst.hdr->theClass->cls.base; |
|
} |
|
|
|
return SCMO_OK; |
|
} |
|
|
|
|
|
SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const |
|
{ |
|
SCMO_RC rc; |
|
if(name==NULL) |
|
{ |
|
return SCMO_INVALID_PARAMETER; |
|
} |
|
|
|
rc = inst.hdr->theClass->_getProperyNodeIndex(node,name); |
|
|
|
return rc; |
|
|
|
} |
|
SCMO_RC SCMOInstance::setPropertyWithOrigin( |
|
const char* name, |
|
CIMType type, |
|
void* value, |
|
Boolean isArray, |
|
Uint32 size, |
|
const char* origin) |
|
{ |
|
Uint32 node; |
|
SCMO_RC rc; |
|
|
|
rc = inst.hdr->theClass->_getProperyNodeIndex(node,name); |
|
if (rc != SCMO_OK) |
|
{ |
|
return rc; |
|
} |
|
|
|
// Is the traget type OK ? |
|
rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray); |
|
if (rc != SCMO_OK) |
|
{ |
|
return rc; |
|
} |
|
|
|
// is filtering on ? |
|
if (inst.hdr->flags.isFiltered) |
|
{ |
|
// Is the property NOT in the property filter ? |
|
if(!_isPropertyInFilter(node)) |
|
{ |
|
// The named propery is not part of this instance |
|
// due to filtering. |
|
return SCMO_NOT_FOUND; |
|
} |
|
} |
|
|
|
// check class origin if set. |
|
if (origin!= NULL) |
|
{ |
|
if(!inst.hdr->theClass->_isSamePropOrigin(node,origin)) |
|
{ |
|
return SCMO_NOT_SAME_ORIGIN; |
|
} |
|
} |
|
|
|
|
|
_setPropertyAtNodeIndex(node,type,value,isArray,size); |
|
|
|
return SCMO_OK; |
|
} |
|
|
|
SCMO_RC SCMOInstance::setPropertyWithNodeIndex( |
|
Uint32 node, |
|
CIMType type, |
|
void* value, |
|
Boolean isArray, |
|
Uint32 size) |
|
{ |
|
SCMO_RC rc; |
|
|
|
if (node >= inst.hdr->numberProperties) |
|
{ |
|
return SCMO_INDEX_OUT_OF_BOUND; |
|
} |
|
|
|
// is filtering on ? |
|
if (inst.hdr->flags.isFiltered) |
|
{ |
|
// Is the property NOT in the property filter ? |
|
if(!_isPropertyInFilter(node)) |
|
{ |
|
// The proptery of the is not set due to filtering. |
|
return SCMO_OK; |
|
} |
|
} |
|
|
|
// Is the traget type OK ? |
|
rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray); |
|
if (rc != SCMO_OK) |
|
{ |
|
return rc; |
|
} |
|
|
|
_setPropertyAtNodeIndex(node,type,value,isArray,size); |
|
|
|
return SCMO_OK; |
|
} |
|
|
|
void SCMOInstance::_setPropertyAtNodeIndex( |
|
Uint32 node, |
|
CIMType type, |
|
void* value, |
|
Boolean isArray, |
|
Uint32 size) |
|
{ |
|
SCMBValue* theInstPropNodeArray = |
|
(SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; |
|
|
|
|
|
theInstPropNodeArray[node].flags.isSet=true; |
|
theInstPropNodeArray[node].valueType=type; |
|
theInstPropNodeArray[node].flags.isArray=isArray; |
|
if (isArray) |
|
{ |
|
theInstPropNodeArray[node].valueArraySize=size; |
|
} |
|
|
|
if (value==NULL) |
|
{ |
|
theInstPropNodeArray[node].flags.isNull=true; |
|
} |
|
else |
|
{ |
|
Uint64 start = |
|
(const char*)&(theInstPropNodeArray[node].value)-inst.base; |
|
|
|
_setSCMBUnion(value,type,isArray,size,start); |
|
} |
|
} |
|
|
|
void SCMOInstance::_setSCMBUnion( |
|
void* value, |
|
CIMType type, |
|
Boolean isArray, |
|
Uint32 size, |
|
Uint64 start) |
|
{ |
|
SCMBUnion* u = (SCMBUnion*)&(inst.base[start]); |
|
|
|
switch (type) |
|
{ |
|
case CIMTYPE_BOOLEAN: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Boolean), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_booleanValue = *((Boolean*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_UINT8: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Uint8), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_uint8Value = *((Uint8*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT8: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Sint8), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_sint8Value = *((Sint8*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_UINT16: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Uint16), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_uint16Value = *((Uint16*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT16: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Sint16), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_sint16Value = *((Sint16*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_UINT32: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Uint32), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_uint32Value = *((Uint32*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT32: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Sint32), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_sint32Value = *((Sint32*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_UINT64: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Uint64), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_uint64Value = *((Uint64*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT64: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Sint64), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_sint64Value = *((Sint64*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_REAL32: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Real32), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_real32Value = *((Real32*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_REAL64: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Real64), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_real64Value = *((Real64*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_CHAR16: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Char16), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_char16Value = *((Char16*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_DATETIME: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(SCMBDateTime), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_dateTimeValue = *((SCMBDateTime*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_STRING: |
|
{ |
|
if (isArray) |
|
{ |
|
SCMBDataPtr* ptr; |
|
char** tmp; |
|
Uint64 startPtr; |
|
|
|
startPtr = _getFreeSpace( |
|
u->_arrayValue, |
|
size*sizeof(SCMBDataPtr), |
|
&inst.mem,false); |
|
// the value is pointer to an array of char* |
|
tmp = (char**)value; |
|
|
|
for (Uint32 i = 0; i < size; i++) |
|
{ |
|
ptr = (SCMBDataPtr*)&(inst.base[startPtr]); |
|
// Copy the sting including the trailing '\0' |
|
_setBinary(tmp[i],strlen(tmp[i])+1,ptr[i],&inst.mem ); |
|
} |
|
} |
|
else |
|
{ |
|
// Copy the sting including the trailing '\0' |
|
_setBinary( |
|
value, |
|
strlen((char*)value)+1, |
|
u->_stringValue, |
|
&inst.mem ); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_REFERENCE: |
|
|
|
break; |
|
|
|
case CIMTYPE_OBJECT: |
|
|
|
break; |
|
case CIMTYPE_INSTANCE: |
|
|
|
break; |
|
} |
|
} |
|
|
|
void SCMOInstance::_setArrayValue( |
|
Uint64 start, |
|
SCMBMgmt_Header** pmem, |
|
CIMType type, |
|
Uint32& n, |
|
Union& u) |
|
{ |
|
SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); |
|
Uint64 arrayStart; |
|
|
|
switch (type) |
|
{ |
|
case CIMTYPE_BOOLEAN: |
|
{ |
|
Array<Boolean> *x = reinterpret_cast<Array<Boolean>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Boolean), |
|
pmem); |
|
memcpy( |
|
&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Boolean)); |
|
break; |
|
} |
|
|
|
case CIMTYPE_UINT8: |
|
{ |
|
Array<Uint8> *x = reinterpret_cast<Array<Uint8>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Uint8), |
|
pmem); |
|
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint8)); |
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT8: |
|
{ |
|
Array<Sint8> *x = reinterpret_cast<Array<Sint8>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Sint8), |
|
pmem); |
|
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint8)); |
|
break; |
|
} |
|
|
|
case CIMTYPE_UINT16: |
|
{ |
|
Array<Uint16> *x = reinterpret_cast<Array<Uint16>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Uint16), |
|
pmem); |
|
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint16)); |
|
|
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT16: |
|
{ |
|
Array<Sint16> *x = reinterpret_cast<Array<Sint16>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Sint16), |
|
pmem); |
|
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint16)); |
|
break; |
|
} |
|
|
|
case CIMTYPE_UINT32: |
|
{ |
|
Array<Uint32> *x = reinterpret_cast<Array<Uint32>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Uint32), |
|
pmem); |
|
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint32)); |
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT32: |
|
{ |
|
Array<Sint32> *x = reinterpret_cast<Array<Sint32>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Sint32), |
|
pmem); |
|
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint32)); |
|
break; |
|
} |
|
|
|
case CIMTYPE_UINT64: |
|
{ |
|
Array<Uint64> *x = reinterpret_cast<Array<Uint64>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Uint64), |
|
pmem); |
|
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint64)); |
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT64: |
|
{ |
|
Array<Sint64> *x = reinterpret_cast<Array<Sint64>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Sint64), |
|
pmem); |
|
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint64)); |
|
break; |
|
} |
|
|
|
case CIMTYPE_REAL32: |
|
{ |
|
Array<Real32> *x = reinterpret_cast<Array<Real32>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Real32), |
|
pmem); |
|
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Real32)); |
|
break; |
|
} |
|
|
|
case CIMTYPE_REAL64: |
|
{ |
|
Array<Real64> *x = reinterpret_cast<Array<Real64>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Real64), |
|
pmem); |
|
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Real64)); |
|
break; |
|
} |
|
|
|
case CIMTYPE_CHAR16: |
|
{ |
|
Array<Char16> *x = reinterpret_cast<Array<Char16>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Char16), |
|
pmem); |
|
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Char16)); |
|
break; |
|
} |
|
|
|
case CIMTYPE_STRING: |
|
{ |
|
SCMBDataPtr *ptr; |
|
|
|
Array<String> *x = reinterpret_cast<Array<String>*>(&u); |
|
|
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(SCMBDataPtr), |
|
pmem); |
|
|
|
for (Uint32 i = 0; i < n ; i++) |
|
{ |
|
// the pointer has to be set eache loop, |
|
// because a reallocation may take place. |
|
ptr = (SCMBDataPtr*)(&((char*)*pmem)[arrayStart]); |
|
_setString( (*x)[i],ptr[i], pmem ); |
|
} |
|
|
|
break; |
|
} |
|
|
|
case CIMTYPE_DATETIME: |
|
{ |
|
SCMBDateTime *ptr; |
|
Array<CIMDateTime> *x = reinterpret_cast<Array<CIMDateTime>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(SCMBDateTime), |
|
pmem); |
|
|
|
ptr=(SCMBDateTime*)(&((char*)*pmem)[arrayStart]); |
|
|
|
for (Uint32 i = 0; i < n ; i++) |
|
{ |
|
memcpy(&(ptr[i]),(*x)[i]._rep,sizeof(SCMBDateTime)); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_REFERENCE: |
|
|
|
break; |
|
|
|
case CIMTYPE_OBJECT: |
|
|
|
break; |
|
|
|
case CIMTYPE_INSTANCE: |
|
|
|
break; |
|
} |
|
} |
|
|
|
|
|
void SCMOInstance::_setUnionValue( |
|
Uint64 start, |
|
SCMBMgmt_Header** pmem, |
CIMType type, | CIMType type, |
Boolean isArray, |
Union& u) |
Uint32 size, |
|
Uint64 start) |
|
{ | { |
SCMBUnion* u = (SCMBUnion*)&(inst.base[start]); |
SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); |
| |
switch (type) | switch (type) |
{ | { |
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
{ | { |
if (isArray) |
scmoUnion->_booleanValue = u._booleanValue; |
{ |
|
_setBinary(value,size*sizeof(Boolean), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_booleanValue = *((Boolean*)value); |
|
} |
|
break; | break; |
} | } |
| |
case CIMTYPE_UINT8: | case CIMTYPE_UINT8: |
{ | { |
if (isArray) |
scmoUnion->_uint8Value = u._uint8Value; |
{ |
|
_setBinary(value,size*sizeof(Uint8), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_uint8Value = *((Uint8*)value); |
|
} |
|
break; | break; |
} | } |
| |
case CIMTYPE_SINT8: | case CIMTYPE_SINT8: |
{ | { |
if (isArray) |
scmoUnion->_sint8Value = u._sint8Value; |
{ |
|
_setBinary(value,size*sizeof(Sint8), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_sint8Value = *((Sint8*)value); |
|
} |
|
break; | break; |
} | } |
| |
case CIMTYPE_UINT16: | case CIMTYPE_UINT16: |
{ | { |
if (isArray) |
scmoUnion->_uint16Value = u._uint16Value; |
{ |
|
_setBinary(value,size*sizeof(Uint16), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_uint16Value = *((Uint16*)value); |
|
} |
|
break; | break; |
} | } |
| |
case CIMTYPE_SINT16: | case CIMTYPE_SINT16: |
{ | { |
if (isArray) |
scmoUnion->_sint16Value = u._sint16Value; |
{ |
|
_setBinary(value,size*sizeof(Sint16), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_sint16Value = *((Sint16*)value); |
|
} |
|
break; | break; |
} | } |
| |
case CIMTYPE_UINT32: | case CIMTYPE_UINT32: |
{ | { |
if (isArray) |
scmoUnion->_uint32Value = u._uint32Value; |
{ |
|
_setBinary(value,size*sizeof(Uint32), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_uint32Value = *((Uint32*)value); |
|
} |
|
break; | break; |
} | } |
| |
case CIMTYPE_SINT32: | case CIMTYPE_SINT32: |
{ | { |
if (isArray) |
scmoUnion->_sint32Value = u._sint32Value; |
{ |
|
_setBinary(value,size*sizeof(Sint32), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_sint32Value = *((Sint32*)value); |
|
} |
|
break; | break; |
} | } |
| |
case CIMTYPE_UINT64: | case CIMTYPE_UINT64: |
{ | { |
if (isArray) |
scmoUnion->_uint64Value = u._uint64Value; |
{ |
|
_setBinary(value,size*sizeof(Uint64), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_uint64Value = *((Uint64*)value); |
|
} |
|
break; | break; |
} | } |
| |
case CIMTYPE_SINT64: | case CIMTYPE_SINT64: |
{ | { |
if (isArray) |
scmoUnion->_sint64Value = u._sint64Value; |
{ |
|
_setBinary(value,size*sizeof(Sint64), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_sint64Value = *((Sint64*)value); |
|
} |
|
break; | break; |
} | } |
| |
case CIMTYPE_REAL32: | case CIMTYPE_REAL32: |
{ | { |
if (isArray) |
scmoUnion->_real32Value = u._real32Value; |
{ |
|
_setBinary(value,size*sizeof(Real32), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_real32Value = *((Real32*)value); |
|
} |
|
break; | break; |
} | } |
| |
case CIMTYPE_REAL64: | case CIMTYPE_REAL64: |
{ | { |
if (isArray) |
scmoUnion->_real64Value = u._real64Value; |
{ |
|
_setBinary(value,size*sizeof(Real64), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_real64Value = *((Real64*)value); |
|
} |
|
break; | break; |
} | } |
| |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
{ | { |
if (isArray) |
scmoUnion->_char16Value = u._char16Value; |
{ |
|
_setBinary(value,size*sizeof(Char16), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_char16Value = *((Char16*)value); |
|
} |
|
break; | break; |
} | } |
| |
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
if (isArray) |
_setString(*((String*)((void*)&u)), |
{ |
scmoUnion->_stringValue, |
SCMBDataPtr* ptr; |
pmem ); |
char** tmp; |
|
Uint64 startPtr; |
|
|
|
startPtr = _getFreeSpace( |
|
u->_arrayValue, |
|
size*sizeof(SCMBDataPtr), |
|
&inst.mem,false); |
|
// the value is pointer to an array of char* |
|
tmp = (char**)value; |
|
|
|
for (Uint32 i = 0; i < size; i++) |
|
{ |
|
ptr = (SCMBDataPtr*)&(inst.base[startPtr]); |
|
// Copy the sting including the trailing '\0' |
|
_setBinary(tmp[i],strlen(tmp[i])+1,ptr[i],&inst.mem ); |
|
} |
|
} |
|
else |
|
{ |
|
// Copy the sting including the trailing '\0' |
|
_setBinary( |
|
value, |
|
strlen((char*)value)+1, |
|
u->_stringValue, |
|
&inst.mem ); |
|
} |
|
break; | break; |
} | } |
| |
case CIMTYPE_DATETIME: | case CIMTYPE_DATETIME: |
{ | { |
if (isArray) |
|
{ |
memcpy( |
_setBinary(value,size*sizeof(SCMBDateTime), |
&scmoUnion->_dateTimeValue, |
u->_arrayValue, |
(*((CIMDateTime*)((void*)&u)))._rep, |
&inst.mem ); |
sizeof(SCMBDateTime)); |
} |
|
else |
|
{ |
|
memcpy(&u->_dateTimeValue,value,sizeof(SCMBDateTime)); |
|
} |
|
break; | break; |
} | } |
| |
|
|
| |
break; | break; |
} | } |
|
|
} | } |
| |
SCMO_RC SCMOInstance::_getPropertyAtNodeIndex( | SCMO_RC SCMOInstance::_getPropertyAtNodeIndex( |
Uint32 node, | Uint32 node, |
const unsigned char** pname, |
const char** pname, |
CIMType& type, | CIMType& type, |
const void** pvalue, | const void** pvalue, |
Boolean& isArray, | Boolean& isArray, |
|
|
| |
// calculate the relative index for the value. | // calculate the relative index for the value. |
Uint64 start = | Uint64 start = |
(unsigned const char*)&(theInstPropNodeArray[node].value) - |
(const char*)&(theInstPropNodeArray[node].value) - |
inst.base; | inst.base; |
| |
// the caller has to copy the value ! | // the caller has to copy the value ! |
|
|
| |
// calcutate the relativ start address of the value | // calcutate the relativ start address of the value |
Uint64 start = | Uint64 start = |
(unsigned const char*) |
(const char*) |
&(theClassPropNodeArray[node].theProperty.defaultValue.value) - | &(theClassPropNodeArray[node].theProperty.defaultValue.value) - |
(inst.hdr->theClass->cls.base); | (inst.hdr->theClass->cls.base); |
| |
|
|
| |
} | } |
| |
SCMOInstance SCMOInstance::clone() const |
SCMOInstance SCMOInstance::clone(Boolean objectPathOnly) const |
{ | { |
|
if (objectPathOnly) |
|
{ |
|
// Create a new, empty SCMOInstance |
|
SCMOInstance newInst(*(this->inst.hdr->theClass)); |
|
|
|
// Copy the host name to tha new instance- |
|
_setBinary( |
|
_resolveDataPtr(this->inst.hdr->hostName,this->inst.base), |
|
this->inst.hdr->hostName.length, |
|
newInst.inst.hdr->hostName, |
|
&newInst.inst.mem); |
|
|
|
// Copy the key bindings to that new instance. |
|
this->_copyKeyBindings(newInst); |
|
|
|
return newInst; |
|
} |
|
|
SCMOInstance newInst; | SCMOInstance newInst; |
newInst.inst.base = (unsigned char*)malloc(this->inst.mem->totalSize); |
newInst.inst.base = (char*)malloc(this->inst.mem->totalSize); |
if (newInst.inst.base == NULL ) | if (newInst.inst.base == NULL ) |
{ | { |
throw PEGASUS_STD(bad_alloc)(); | throw PEGASUS_STD(bad_alloc)(); |
|
|
return newInst; | return newInst; |
} | } |
| |
|
void SCMOInstance::_copyKeyBindings(SCMOInstance& targetInst) const |
|
{ |
|
Uint32 noBindings = inst.hdr->numberKeyBindings; |
|
SCMBInstanceKeyBinding* sourceArray = |
|
(SCMBInstanceKeyBinding*)&inst.base[inst.hdr->keyBindingArray.start]; |
|
|
|
SCMBInstanceKeyBinding* targetArray; |
|
|
|
for (Uint32 i = 0; i < noBindings; i++) |
|
{ |
|
// hast to be set every time, because of reallocation. |
|
targetArray=(SCMBInstanceKeyBinding*)&targetInst.inst.base |
|
[targetInst.inst.hdr->keyBindingArray.start]; |
|
if(sourceArray[i].isSet) |
|
{ |
|
_setBinary( |
|
_resolveDataPtr(sourceArray[i].value,inst.base), |
|
sourceArray[i].value.length, |
|
targetArray[i].value, |
|
&targetInst.inst.mem); |
|
|
|
targetArray[i].isSet=true; |
|
} |
|
} |
|
|
|
} |
Uint32 SCMOInstance::getPropertyCount() const | Uint32 SCMOInstance::getPropertyCount() const |
{ | { |
|
if (inst.hdr->flags.isFiltered) |
|
{ |
|
return(inst.hdr->filterProperties); |
|
} |
|
|
return(inst.hdr->numberProperties); | return(inst.hdr->numberProperties); |
} | } |
| |
const void* SCMOInstance::_getSCMBUnion( |
void* SCMOInstance::_getSCMBUnion( |
CIMType type, | CIMType type, |
Boolean isArray, | Boolean isArray, |
Uint32 size, | Uint32 size, |
Uint64 start, | Uint64 start, |
unsigned char* base) const |
char* base) const |
{ | { |
| |
SCMBUnion* u = (SCMBUnion*)&(base[start]); | SCMBUnion* u = (SCMBUnion*)&(base[start]); |
| |
void* av = NULL; | void* av = NULL; |
|
|
if (isArray) | if (isArray) |
{ | { |
|
if (size == 0) |
|
{ |
|
return NULL; |
|
} |
av = (void*)&base[u->_arrayValue.start]; | av = (void*)&base[u->_arrayValue.start]; |
} | } |
| |
|
|
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
SCMBDataPtr *ptr; | SCMBDataPtr *ptr; |
unsigned char** tmp; |
char** tmp=NULL; |
| |
if (isArray) | if (isArray) |
{ | { |
// allocate an array of char* pointers. | // allocate an array of char* pointers. |
*tmp = (unsigned char*)malloc(size*sizeof(unsigned char*)); |
tmp = (char**)malloc(size*sizeof(char*)); |
if (*tmp == NULL ) |
if (tmp == NULL ) |
{ | { |
throw PEGASUS_STD(bad_alloc)(); | throw PEGASUS_STD(bad_alloc)(); |
} | } |
|
|
for(Uint32 i = 0; i < size; i++) | for(Uint32 i = 0; i < size; i++) |
{ | { |
// resolv relative pointer to absolute pointer | // resolv relative pointer to absolute pointer |
tmp[i] = (unsigned char*)_getCharString(ptr[i],base); |
tmp[i] = (char*)_getCharString(ptr[i],base); |
} | } |
| |
return((void*)*tmp); |
return((void*)tmp); |
} | } |
else | else |
{ | { |
return(_getCharString(u->_stringValue,base)); |
return((void*)_getCharString(u->_stringValue,base)); |
} | } |
| |
| |
|
|
return NULL; | return NULL; |
} | } |
| |
Uint32 SCMOInstance::getKeyBindingCount() |
Uint32 SCMOInstance::getKeyBindingCount() const |
{ | { |
return(inst.hdr->numberKeyBindings); | return(inst.hdr->numberKeyBindings); |
} | } |
|
|
| |
SCMO_RC SCMOInstance::getKeyBindingAt( | SCMO_RC SCMOInstance::getKeyBindingAt( |
Uint32 node, | Uint32 node, |
const unsigned char** pname, |
const char** pname, |
CIMKeyBinding::Type& type, | CIMKeyBinding::Type& type, |
const unsigned char** pvalue) const |
const char** pvalue) const |
{ | { |
*pname = NULL; | *pname = NULL; |
*pvalue = NULL; | *pvalue = NULL; |
|
|
return SCMO_INDEX_OUT_OF_BOUND; | return SCMO_INDEX_OUT_OF_BOUND; |
} | } |
| |
return _getKeyBindingAtNodeIndex(node,pname,type,pvalue); |
return _getKeyBindingAtNodeIndex(node,pname,type,pvalue); |
|
} |
|
|
|
SCMO_RC SCMOInstance::getKeyBinding( |
|
const char* name, |
|
CIMKeyBinding::Type& type, |
|
const char** pvalue) const |
|
{ |
|
SCMO_RC rc; |
|
Uint32 node; |
|
const char* pname=NULL; |
|
|
|
rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); |
|
if (rc != SCMO_OK) |
|
{ |
|
return rc; |
|
} |
|
|
|
return _getKeyBindingAtNodeIndex(node,&pname,type,pvalue); |
|
|
|
} |
|
|
|
SCMO_RC SCMOInstance::_getKeyBindingAtNodeIndex( |
|
Uint32 node, |
|
const char** pname, |
|
CIMKeyBinding::Type& type, |
|
const char** pvalue) const |
|
{ |
|
Uint32 pnameLen=0; |
|
Uint32 pvalueLen=0; |
|
return |
|
_getKeyBindingAtNodeIndex_l(node,pname,pnameLen,type,pvalue,pvalueLen); |
|
} |
|
|
|
SCMO_RC SCMOInstance::_getKeyBindingAtNodeIndex_l( |
|
Uint32 node, |
|
const char** pname, |
|
Uint32 & pnameLen, |
|
CIMKeyBinding::Type& type, |
|
const char** pvalue, |
|
Uint32 & pvalueLen) const |
|
{ |
|
SCMBInstanceKeyBinding* theInstKeyBindNodeArray = |
|
(SCMBInstanceKeyBinding*)&inst.base[inst.hdr->keyBindingArray.start]; |
|
|
|
// create a pointer to keybinding node array of the class. |
|
Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; |
|
SCMBKeyBindingNode* theClassKeyBindNodeArray = |
|
(SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx]; |
|
|
|
type = theClassKeyBindNodeArray[node].type; |
|
|
|
/* First resolve pointer to the property name */ |
|
|
|
pnameLen = theClassKeyBindNodeArray[node].name.length; |
|
*pname = _getCharString( |
|
theClassKeyBindNodeArray[node].name, |
|
inst.hdr->theClass->cls.base); |
|
|
|
// There is no value set in the instance |
|
if (!theInstKeyBindNodeArray[node].isSet) |
|
{ |
|
*pvalue = NULL; |
|
return SCMO_NULL_VALUE; |
|
} |
|
|
|
pvalueLen = theInstKeyBindNodeArray[node].value.length; |
|
// Set the absolut pointer to the key binding value |
|
*pvalue = _getCharString(theInstKeyBindNodeArray[node].value,inst.base); |
|
|
|
return SCMO_OK; |
} | } |
| |
SCMO_RC SCMOInstance::getKeyBinding( |
SCMO_RC SCMOInstance::setKeyBinding( |
const char* name, | const char* name, |
CIMKeyBinding::Type& type, |
CIMKeyBinding::Type type, |
const unsigned char** pvalue) const |
const char* pvalue) |
{ | { |
pvalue = NULL; |
|
SCMO_RC rc; | SCMO_RC rc; |
Uint32 node; | Uint32 node; |
const unsigned char** pname; |
|
|
if (NULL == name) |
|
{ |
|
return SCMO_INVALID_PARAMETER; |
|
} |
| |
rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); | rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); |
if (rc != SCMO_OK) | if (rc != SCMO_OK) |
|
|
return rc; | return rc; |
} | } |
| |
return _getKeyBindingAtNodeIndex(node,pname,type,pvalue); |
return setKeyBindingAt(node, type, pvalue); |
|
|
} | } |
| |
SCMO_RC SCMOInstance::_getKeyBindingAtNodeIndex( |
SCMO_RC SCMOInstance::setKeyBindingAt( |
Uint32 node, | Uint32 node, |
const unsigned char** pname, |
CIMKeyBinding::Type type, |
CIMKeyBinding::Type& type, |
const char* pvalue) |
const unsigned char** pvalue) const |
|
{ | { |
|
SCMO_RC rc; |
SCMBDataPtr* theInstKeyBindNodeArray = |
|
(SCMBDataPtr*)&inst.base[inst.hdr->keyBindingArray.start]; |
|
| |
// create a pointer to keybinding node array of the class. | // create a pointer to keybinding node array of the class. |
Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; | Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; |
SCMBKeyBindingNode* theClassKeyBindNodeArray = | SCMBKeyBindingNode* theClassKeyBindNodeArray = |
(SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx]; | (SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx]; |
| |
type = theClassKeyBindNodeArray->type; |
if (NULL == pvalue) |
*pname = _getCharString( |
{ |
theClassKeyBindNodeArray->name, |
return SCMO_INVALID_PARAMETER; |
inst.hdr->theClass->cls.base); |
} |
| |
// There is no value set in the instance |
if (theClassKeyBindNodeArray[node].type != type) |
// if the relative pointer has no start value. |
|
if (theInstKeyBindNodeArray[node].start==0) |
|
{ | { |
return SCMO_NULL_VALUE; |
return SCMO_TYPE_MISSMATCH; |
} | } |
| |
// Set the absolut pointer to the key binding value |
SCMBInstanceKeyBinding* theInstKeyBindNodeArray = |
*pvalue = _getCharString(theInstKeyBindNodeArray[node],inst.base); |
(SCMBInstanceKeyBinding*)&inst.base[inst.hdr->keyBindingArray.start]; |
|
|
|
// copy the value including trailing '\0' |
|
_setBinary( |
|
pvalue, |
|
strlen(pvalue)+1, |
|
theInstKeyBindNodeArray[node].value, |
|
&inst.mem); |
| |
return SCMO_OK; |
|
| |
|
theInstKeyBindNodeArray[node].isSet=true; |
|
|
|
return SCMO_OK; |
} | } |
| |
SCMO_RC SCMOInstance::setKeyBinding( | SCMO_RC SCMOInstance::setKeyBinding( |
const char* name, | const char* name, |
CIMKeyBinding::Type type, |
CIMType type, |
const char* pvalue) |
void* keyvalue) |
{ | { |
SCMO_RC rc; | SCMO_RC rc; |
Uint32 node; | Uint32 node; |
| |
|
if (NULL == name) |
|
{ |
|
return SCMO_INVALID_PARAMETER; |
|
} |
|
|
rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); | rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); |
if (rc != SCMO_OK) | if (rc != SCMO_OK) |
{ | { |
return rc; | return rc; |
} | } |
| |
|
return setKeyBindingAt(node, type, keyvalue); |
|
} |
|
|
|
SCMO_RC SCMOInstance::setKeyBindingAt( |
|
Uint32 node, |
|
CIMType type, |
|
void* keyvalue) |
|
{ |
|
SCMO_RC rc; |
|
|
// create a pointer to keybinding node array of the class. | // create a pointer to keybinding node array of the class. |
Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; | Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; |
SCMBKeyBindingNode* theClassKeyBindNodeArray = | SCMBKeyBindingNode* theClassKeyBindNodeArray = |
(SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx]; | (SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx]; |
| |
if (theClassKeyBindNodeArray[node].type != type) |
if (NULL == keyvalue) |
{ | { |
return SCMO_TYPE_MISSMATCH; |
return SCMO_INVALID_PARAMETER; |
} | } |
| |
SCMBDataPtr* theInstKeyBindNodeArray = |
/*if (theClassKeyBindNodeArray[node].type != type) |
(SCMBDataPtr*)&inst.base[inst.hdr->keyBindingArray.start]; |
{ |
|
return SCMO_TYPE_MISSMATCH; |
|
}*/ |
| |
// copy the value including trailing '\0' |
SCMBInstanceKeyBinding* theInstKeyBindNodeArray = |
_setBinary(pvalue,strlen(pvalue)+1,theInstKeyBindNodeArray[node],&inst.mem); |
(SCMBInstanceKeyBinding*)&inst.base[inst.hdr->keyBindingArray.start]; |
| |
return SCMO_OK; |
// TBD: |
|
// For the time being set the keyvalue as string. But there is a strong |
|
// need to store it binary instead |
|
// --> awaiting performance measurment results |
|
_setKeyBindingFromSCMBUnion( |
|
type, |
|
*((SCMBUnion*)keyvalue), |
|
theInstKeyBindNodeArray[node].value); |
| |
|
theInstKeyBindNodeArray[node].isSet=true; |
|
|
|
return SCMO_OK; |
} | } |
| |
|
|
void SCMOInstance::setPropertyFilter(const char **propertyList) | void SCMOInstance::setPropertyFilter(const char **propertyList) |
{ | { |
SCMO_RC rc; | SCMO_RC rc; |
Uint32 node,i = 0; | Uint32 node,i = 0; |
| |
|
if (inst.hdr->propertyFilter.start == 0) |
|
{ |
|
// Allocate the SCMBPropertyFilter |
|
_getFreeSpace( |
|
inst.hdr->propertyFilter, |
|
sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1), |
|
&inst.mem, |
|
true); |
|
|
|
// Allocate the SCMBPropertyFilterIndexMap |
|
_getFreeSpace( |
|
inst.hdr->propertyFilterIndexMap, |
|
sizeof(Uint32)*inst.hdr->numberProperties, |
|
&inst.mem, |
|
true); |
|
} |
// Get absolut pointer to property filter index map of the instance | // Get absolut pointer to property filter index map of the instance |
Uint32* propertyFilterIndexMap = | Uint32* propertyFilterIndexMap = |
(Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]); | (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]); |
|
|
memset( | memset( |
propertyFilterIndexMap, | propertyFilterIndexMap, |
0, | 0, |
sizeof(Uint32)*inst.hdr->filterProperties); |
sizeof(Uint32)*inst.hdr->numberProperties); |
| |
//reset number filter properties to all | //reset number filter properties to all |
inst.hdr->filterProperties = inst.hdr->numberProperties; | inst.hdr->filterProperties = inst.hdr->numberProperties; |
|
|
// the hash index of the property if the property name is found | // the hash index of the property if the property name is found |
rc = inst.hdr->theClass->_getProperyNodeIndex(node,propertyList[i]); | rc = inst.hdr->theClass->_getProperyNodeIndex(node,propertyList[i]); |
| |
if (rc == SCMO_OK) |
// if property is already in the filter |
|
// ( eg. key properties ) do not add them ! |
|
if (rc == SCMO_OK && !_isPropertyInFilter(node)) |
{ | { |
// The property name was found. Otherwise ignore this property name. | // The property name was found. Otherwise ignore this property name. |
// insert the hash index into the filter index map | // insert the hash index into the filter index map |
|
|
/****************************************************************************** | /****************************************************************************** |
* SCMODump Print and Dump functions | * SCMODump Print and Dump functions |
*****************************************************************************/ | *****************************************************************************/ |
|
SCMODump::SCMODump() |
|
{ |
|
_out = stdout; |
|
_fileOpen = false; |
|
|
|
#ifdef PEGASUS_OS_ZOS |
|
setEBCDICEncoding(fileno(_out)); |
|
#endif |
|
|
|
} |
|
|
|
SCMODump::SCMODump(char* filename) |
|
{ |
|
openFile(filename); |
|
} |
|
|
|
void SCMODump::openFile(char* filename) |
|
{ |
|
const char* pegasusHomeDir = getenv("PEGASUS_HOME"); |
|
|
|
if (pegasusHomeDir == NULL) |
|
{ |
|
pegasusHomeDir = "."; |
|
} |
|
|
|
_filename = pegasusHomeDir; |
|
_filename.append("/"); |
|
_filename.append(filename); |
|
|
|
_out = fopen((const char*)_filename.getCString(),"w+"); |
|
|
|
_fileOpen = true; |
|
|
|
#ifdef PEGASUS_OS_ZOS |
|
setEBCDICEncoding(fileno(_out)); |
|
#endif |
|
|
|
} |
|
|
|
void SCMODump::deleteFile() |
|
{ |
|
if(_fileOpen) |
|
{ |
|
closeFile(); |
|
} |
|
|
|
System::removeFile((const char*)_filename.getCString()); |
|
|
|
} |
|
void SCMODump::closeFile() |
|
{ |
|
if (_fileOpen) |
|
{ |
|
fclose(_out); |
|
_fileOpen=false; |
|
_out = stdout; |
|
} |
|
} |
|
|
|
SCMODump::~SCMODump() |
|
{ |
|
if (_fileOpen) |
|
{ |
|
fclose(_out); |
|
_fileOpen=false; |
|
} |
|
} |
|
|
|
Boolean SCMODump::compareFile(String master) |
|
{ |
|
|
|
if (!_fileOpen) |
|
{ |
|
return false; |
|
} |
|
|
|
closeFile(); |
|
|
|
return (FileSystem::compareFiles(_filename, master)); |
|
} |
|
|
|
void SCMODump::dumpSCMOInstance(SCMOInstance& testInst) const |
|
{ |
|
SCMBInstance_Main* insthdr = testInst.inst.hdr; |
|
char* instbase = testInst.inst.base; |
|
|
|
fprintf(_out,"\n\nDump of SCMOInstance\n"); |
|
// The magic number for SCMO class |
|
fprintf(_out,"\nheader.magic=%08X",insthdr->header.magic); |
|
// Total size of the instance memory block( # bytes ) |
|
fprintf(_out,"\nheader.totalSize=%llu",insthdr->header.totalSize); |
|
// The reference counter for this c++ class |
|
fprintf(_out,"\nrefCount=%i",insthdr->refCount.get()); |
|
fprintf(_out,"\ntheClass: %p",insthdr->theClass); |
|
fprintf(_out,"\n\nThe Flags:"); |
|
fprintf(_out,"\n includeQualifiers: %s", |
|
(insthdr->flags.includeQualifiers ? "True" : "False")); |
|
fprintf(_out,"\n includeClassOrigin: %s", |
|
(insthdr->flags.includeClassOrigin ? "True" : "False")); |
|
fprintf(_out,"\n isFiltered: %s", |
|
(insthdr->flags.isFiltered ? "True" : "False")); |
|
fprintf(_out,"\n\nhostName: \'%s\'", |
|
NULLSTR(_getCharString(insthdr->hostName,instbase))); |
|
|
|
dumpSCMOInstanceKeyBindings(testInst); |
|
|
|
dumpSCMOInstancePropertyFilter(testInst); |
|
|
|
dumpInstanceProperties(testInst); |
|
fprintf(_out,"\n\n"); |
|
|
|
} |
|
|
|
void SCMODump::dumpSCMOInstancePropertyFilter(SCMOInstance& testInst) const |
|
{ |
|
SCMBInstance_Main* insthdr = testInst.inst.hdr; |
|
char* instbase = testInst.inst.base; |
|
|
|
if (!insthdr->flags.isFiltered) |
|
{ |
|
fprintf(_out,"\n\nNo propterty filter!\n\n"); |
|
return; |
|
} |
|
|
|
fprintf(_out,"\n\nInstance Property Filter :"); |
|
fprintf(_out,"\n=========================="); |
|
fprintf(_out,"\n\nNumber of properties in the filter : %u\n" |
|
,insthdr->filterProperties); |
|
|
|
dumpPropertyFilter(testInst); |
|
|
|
dumpPropertyFilterIndexMap(testInst); |
|
|
|
} |
|
|
|
void SCMODump::dumpInstanceProperties(SCMOInstance& testInst) const |
|
{ |
|
SCMBInstance_Main* insthdr = testInst.inst.hdr; |
|
char* instbase = testInst.inst.base; |
|
|
|
SCMBValue* val = |
|
(SCMBValue*)_resolveDataPtr(insthdr->propertyArray,instbase); |
|
|
|
fprintf(_out,"\n\nInstance Properties :"); |
|
fprintf(_out,"\n====================="); |
|
fprintf(_out,"\n\nNumber of properties in instance : %u", |
|
insthdr->numberProperties); |
|
|
|
for (Uint32 i = 0, k = insthdr->numberProperties; i < k; i++) |
|
{ |
|
fprintf(_out,"\n\nInstance property (#%3u) %s\n",i, |
|
NULLSTR(insthdr->theClass->_getPropertyNameAtNode(i))); |
|
if(insthdr->flags.isFiltered && !testInst._isPropertyInFilter(i)) |
|
{ |
|
fprintf(_out,"\nProperty is filtered out!"); |
|
} |
|
else |
|
{ |
|
printSCMOValue(val[i],instbase); |
|
} |
|
} |
|
|
|
} |
|
|
|
void SCMODump::dumpPropertyFilterIndexMap(SCMOInstance& testInst) const |
|
{ |
|
|
|
SCMBInstance_Main* insthdr = testInst.inst.hdr; |
|
char* instbase = testInst.inst.base; |
|
|
|
if (!insthdr->flags.isFiltered) |
|
{ |
|
fprintf(_out,"\n\nNo propterty filter!\n\n"); |
|
return; |
|
} |
|
|
|
fprintf(_out,"\n\nProperty Filter Index Max:"); |
|
fprintf(_out,"\n==========================\n"); |
|
|
|
// Get absolut pointer to key index list of the class |
|
Uint32* keyIndex = |
|
(Uint32*)&(instbase)[insthdr->propertyFilterIndexMap.start]; |
|
|
|
Uint32 line,j,i,k = insthdr->filterProperties; |
|
|
|
for (j = 0; j < k; j = j + line) |
|
{ |
|
if ((insthdr->filterProperties-j)/16) |
|
{ |
|
line = 16 ; |
|
} |
|
else |
|
{ |
|
line = insthdr->filterProperties%16; |
|
} |
|
|
|
|
|
fprintf(_out,"Index :"); |
|
for (i = 0; i < line; i++) |
|
{ |
|
fprintf(_out," %3u",j+i); |
|
} |
|
|
|
fprintf(_out,"\nNode :"); |
|
for (i = 0; i < line; i++) |
|
{ |
|
fprintf(_out," %3u",keyIndex[j+i]); |
|
} |
|
|
|
fprintf(_out,"\n\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
void SCMODump::dumpPropertyFilter(SCMOInstance& testInst) const |
|
{ |
|
|
|
SCMBInstance_Main* insthdr = testInst.inst.hdr; |
|
char* instbase = testInst.inst.base; |
|
|
|
if (!insthdr->flags.isFiltered) |
|
{ |
|
fprintf(_out,"\n\nNo propterty filter!"); |
|
return; |
|
} |
|
|
|
Uint64 *thePropertyFilter = |
|
(Uint64*)&(instbase[insthdr->propertyFilter.start]); |
|
Uint32 end, noProperties = insthdr->numberProperties; |
|
Uint32 noMasks = (noProperties-1)/64; |
|
Uint64 printMask = 1; |
|
|
|
for (Uint32 i = 0; i <= noMasks; i++ ) |
|
{ |
|
printMask = 1; |
|
if (i < noMasks) |
|
{ |
|
end = 64; |
|
} |
|
else |
|
{ |
|
end = noProperties%64; |
|
} |
|
|
|
fprintf(_out,"\npropertyFilter[%02u]= ",i); |
|
|
|
for (Uint32 j = 0; j < end; j++) |
|
{ |
|
if (j > 0 && !(j%8)) |
|
{ |
|
fprintf(_out," "); |
|
} |
|
|
|
if (thePropertyFilter[i] & printMask) |
|
{ |
|
fprintf(_out,"1"); |
|
} |
|
else |
|
{ |
|
fprintf(_out,"0"); |
|
} |
|
|
|
printMask = printMask << 1; |
|
} |
|
fprintf(_out,"\n"); |
|
} |
|
} |
|
|
|
void SCMODump::dumpSCMOInstanceKeyBindings(SCMOInstance& testInst) const |
|
{ |
|
SCMBInstance_Main* insthdr = testInst.inst.hdr; |
|
char* instbase = testInst.inst.base; |
|
|
|
SCMBInstanceKeyBinding* ptr = |
|
(SCMBInstanceKeyBinding*) |
|
_resolveDataPtr(insthdr->keyBindingArray,instbase); |
|
|
|
fprintf(_out,"\n\nInstance Key Bindings :"); |
|
fprintf(_out,"\n======================="); |
|
fprintf(_out,"\n\nNumber of Key Bindings : %u",insthdr->numberKeyBindings); |
|
|
|
for (Uint32 i = 0, k = insthdr->numberKeyBindings; i < k; i++) |
|
{ |
|
if (ptr[i].isSet) |
|
{ |
|
fprintf(_out,"\n\nNo %u : '%s'",i, |
|
NULLSTR(_getCharString(ptr[i].value,instbase))); |
|
} |
|
else |
|
{ |
|
fprintf(_out,"\n\nNo %u : Not Set",i); |
|
|
|
} |
|
} |
|
fprintf(_out,"\n"); |
|
} |
| |
void SCMODump::dumpSCMOClass(SCMOClass& testCls) const | void SCMODump::dumpSCMOClass(SCMOClass& testCls) const |
{ | { |
SCMBClass_Main* clshdr = testCls.cls.hdr; | SCMBClass_Main* clshdr = testCls.cls.hdr; |
unsigned char* clsbase = testCls.cls.base; |
char* clsbase = testCls.cls.base; |
| |
printf("\n\nDump of SCMOClass\n"); |
fprintf(_out,"\n\nDump of SCMOClass\n"); |
// The magic number for SCMO class | // The magic number for SCMO class |
printf("\nheader.magic=%08X",clshdr->header.magic); |
fprintf(_out,"\nheader.magic=%08X",clshdr->header.magic); |
// Total size of the instance memory block( # bytes ) | // Total size of the instance memory block( # bytes ) |
printf("\nheader.totalSize=%llu",clshdr->header.totalSize); |
fprintf(_out,"\nheader.totalSize=%llu",clshdr->header.totalSize); |
// The # of bytes free |
// The reference counter for this c++ class |
printf("\nheader.freeBytes=%llu",clshdr->header.freeBytes); |
fprintf(_out,"\nrefCount=%i",clshdr->refCount.get()); |
// Index to the start of the free space in this insance |
|
printf("\nheader.StartOfFreeSpace=%llu",clshdr->header.startOfFreeSpace); |
fprintf(_out,"\n\nsuperClassName: \'%s\'", |
// The reference counter for this class |
NULLSTR(_getCharString(clshdr->superClassName,clsbase))); |
printf("\nrefCount=%i",clshdr->refCount.get()); |
fprintf(_out,"\nnameSpace: \'%s\'", |
|
NULLSTR(_getCharString(clshdr->nameSpace,clsbase))); |
printf("\n\nsuperClassName: \'%s\'", |
fprintf(_out,"\nclassName: \'%s\'", |
_getCharString(clshdr->superClassName,clsbase)); |
NULLSTR(_getCharString(clshdr->className,clsbase))); |
printf("\nnameSpace: \'%s\'",_getCharString(clshdr->nameSpace,clsbase)); |
fprintf(_out,"\n\nTheClass qualfiers:"); |
printf("\nclassName: \'%s\'",_getCharString(clshdr->className,clsbase)); |
|
printf("\n\nTheClass qualfiers:"); |
|
_dumpQualifierArray( | _dumpQualifierArray( |
clshdr->qualifierArray.start, | clshdr->qualifierArray.start, |
clshdr->numberOfQualifiers, | clshdr->numberOfQualifiers, |
clsbase); | clsbase); |
printf("\n"); |
fprintf(_out,"\n"); |
dumpKeyPropertyMask(testCls); | dumpKeyPropertyMask(testCls); |
printf("\n"); |
fprintf(_out,"\n"); |
dumpKeyIndexList(testCls); | dumpKeyIndexList(testCls); |
printf("\n"); |
fprintf(_out,"\n"); |
dumpClassProperties(testCls); | dumpClassProperties(testCls); |
printf("\n"); |
fprintf(_out,"\n"); |
dumpKeyBindingSet(testCls); | dumpKeyBindingSet(testCls); |
printf("\n"); |
fprintf(_out,"\n"); |
/* | /* |
*/ | */ |
printf("\n"); |
fprintf(_out,"\n"); |
|
|
|
} |
|
|
|
void SCMODump::dumpSCMOClassQualifiers(SCMOClass& testCls) const |
|
{ |
|
SCMBClass_Main* clshdr = testCls.cls.hdr; |
|
char* clsbase = testCls.cls.base; |
|
|
|
fprintf(_out,"\n\nTheClass qualfiers:"); |
|
_dumpQualifierArray( |
|
clshdr->qualifierArray.start, |
|
clshdr->numberOfQualifiers, |
|
clsbase); |
|
fprintf(_out,"\n\n\n"); |
| |
} | } |
| |
void SCMODump::hexDumpSCMOClass(SCMOClass& testCls) const | void SCMODump::hexDumpSCMOClass(SCMOClass& testCls) const |
{ | { |
unsigned char* tmp; |
char* tmp; |
| |
SCMBClass_Main* clshdr = testCls.cls.hdr; | SCMBClass_Main* clshdr = testCls.cls.hdr; |
unsigned char* clsbase = testCls.cls.base; |
char* clsbase = testCls.cls.base; |
| |
printf("\n\nHex dump of a SCMBClass:"); |
fprintf(_out,"\n\nHex dump of a SCMBClass:"); |
printf("\n========================"); |
fprintf(_out,"\n========================"); |
printf("\n\n Size of SCMBClass: %llu",clshdr->header.totalSize); |
fprintf(_out,"\n\n Size of SCMBClass: %llu\n\n",clshdr->header.totalSize); |
printf("\n cls.base = %p\n\n",clsbase); |
|
| |
_hexDump(clsbase,clshdr->header.totalSize); | _hexDump(clsbase,clshdr->header.totalSize); |
| |
|
|
void SCMODump::dumpKeyIndexList(SCMOClass& testCls) const | void SCMODump::dumpKeyIndexList(SCMOClass& testCls) const |
{ | { |
SCMBClass_Main* clshdr = testCls.cls.hdr; | SCMBClass_Main* clshdr = testCls.cls.hdr; |
unsigned char* clsbase = testCls.cls.base; |
char* clsbase = testCls.cls.base; |
| |
printf("\n\nKey Index List:"); |
fprintf(_out,"\n\nKey Index List:"); |
printf("\n===============\n"); |
fprintf(_out,"\n===============\n"); |
| |
// Get absolut pointer to key index list of the class | // Get absolut pointer to key index list of the class |
Uint32* keyIndex = (Uint32*)&(clsbase)[clshdr->keyIndexList.start]; | Uint32* keyIndex = (Uint32*)&(clsbase)[clshdr->keyIndexList.start]; |
Uint32 line,j,i; |
Uint32 line,j,i,k = clshdr->propertySet.number; |
for (j = 0; j < clshdr->propertySet.number; j = j + line) |
for (j = 0; j < k; j = j + line) |
{ | { |
if ((clshdr->propertySet.number-j)/16) | if ((clshdr->propertySet.number-j)/16) |
{ | { |
|
|
} | } |
| |
| |
printf("Index :"); |
fprintf(_out,"Index :"); |
for (i = 0; i < line; i++) | for (i = 0; i < line; i++) |
{ | { |
printf(" %3u",j+i); |
fprintf(_out," %3u",j+i); |
} | } |
| |
printf("\nNode :"); |
fprintf(_out,"\nNode :"); |
for (i = 0; i < line; i++) | for (i = 0; i < line; i++) |
{ | { |
printf(" %3u",keyIndex[j+i]); |
fprintf(_out," %3u",keyIndex[j+i]); |
} | } |
| |
printf("\n\n"); |
fprintf(_out,"\n\n"); |
| |
} | } |
| |
|
|
void SCMODump::dumpKeyBindingSet(SCMOClass& testCls) const | void SCMODump::dumpKeyBindingSet(SCMOClass& testCls) const |
{ | { |
SCMBClass_Main* clshdr = testCls.cls.hdr; | SCMBClass_Main* clshdr = testCls.cls.hdr; |
unsigned char* clsbase = testCls.cls.base; |
char* clsbase = testCls.cls.base; |
| |
printf("\n\nKey Binding Set:"); |
fprintf(_out,"\n\nKey Binding Set:"); |
printf("\n=================\n"); |
fprintf(_out,"\n=================\n"); |
printf("\nNumber of key bindings: %3u",clshdr->keyBindingSet.number); |
fprintf(_out,"\nNumber of key bindings: %3u",clshdr->keyBindingSet.number); |
dumpHashTable( | dumpHashTable( |
clshdr->keyBindingSet.hashTable, | clshdr->keyBindingSet.hashTable, |
PEGASUS_KEYBINDIG_SCMB_HASHSIZE); | PEGASUS_KEYBINDIG_SCMB_HASHSIZE); |
|
|
void SCMODump::dumpClassKeyBindingNodeArray(SCMOClass& testCls) const | void SCMODump::dumpClassKeyBindingNodeArray(SCMOClass& testCls) const |
{ | { |
SCMBClass_Main* clshdr = testCls.cls.hdr; | SCMBClass_Main* clshdr = testCls.cls.hdr; |
unsigned char* clsbase = testCls.cls.base; |
char* clsbase = testCls.cls.base; |
| |
SCMBKeyBindingNode* nodeArray = | SCMBKeyBindingNode* nodeArray = |
(SCMBKeyBindingNode*) | (SCMBKeyBindingNode*) |
&(clsbase[clshdr->keyBindingSet.nodeArray.start]); | &(clsbase[clshdr->keyBindingSet.nodeArray.start]); |
| |
for (Uint32 i = 0; i < clshdr->keyBindingSet.number; i++) |
for (Uint32 i = 0, k = clshdr->keyBindingSet.number; i < k; i++) |
{ | { |
printf("\n\n==================="); |
fprintf(_out,"\n\n==================="); |
printf("\nKey Binding #%3u",i); |
fprintf(_out,"\nKey Binding #%3u",i); |
printf("\n==================="); |
fprintf(_out,"\n==================="); |
| |
printf("\nHas next: %s",(nodeArray[i].hasNext?"TRUE":"FALSE")); |
fprintf(_out,"\nHas next: %s",(nodeArray[i].hasNext?"TRUE":"FALSE")); |
if (nodeArray[i].hasNext) | if (nodeArray[i].hasNext) |
{ | { |
printf("\nNext Node: %3u",nodeArray[i].nextNode); |
fprintf(_out,"\nNext Node: %3u",nodeArray[i].nextNode); |
} | } |
else | else |
{ | { |
printf("\nNext Node: N/A"); |
fprintf(_out,"\nNext Node: N/A"); |
} | } |
| |
printf("\nKey Property name: %s", |
fprintf(_out,"\nKey Property name: %s", |
_getCharString(nodeArray[i].name,clsbase)); |
NULLSTR(_getCharString(nodeArray[i].name,clsbase))); |
| |
printf("\nHash Tag %3u Hash Index %3u", |
fprintf(_out,"\nHash Tag %3u Hash Index %3u", |
nodeArray[i].nameHashTag, | nodeArray[i].nameHashTag, |
nodeArray[i].nameHashTag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE); | nodeArray[i].nameHashTag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE); |
| |
printf("\nKey binding type: %s", |
fprintf(_out,"\nKey binding type: %s", |
XmlWriter::keyBindingTypeToString(nodeArray[i].type).str); | XmlWriter::keyBindingTypeToString(nodeArray[i].type).str); |
| |
} | } |
|
|
void SCMODump::dumpClassProperties(SCMOClass& testCls) const | void SCMODump::dumpClassProperties(SCMOClass& testCls) const |
{ | { |
SCMBClass_Main* clshdr = testCls.cls.hdr; | SCMBClass_Main* clshdr = testCls.cls.hdr; |
unsigned char* clsbase = testCls.cls.base; |
char* clsbase = testCls.cls.base; |
| |
printf("\n\nClass Properties:"); |
fprintf(_out,"\n\nClass Properties:"); |
printf("\n=================\n"); |
fprintf(_out,"\n=================\n"); |
printf("\nNumber of properties: %3u",clshdr->propertySet.number); |
fprintf(_out,"\nNumber of properties: %3u",clshdr->propertySet.number); |
dumpHashTable( | dumpHashTable( |
clshdr->propertySet.hashTable, | clshdr->propertySet.hashTable, |
PEGASUS_PROPERTY_SCMB_HASHSIZE); | PEGASUS_PROPERTY_SCMB_HASHSIZE); |
|
|
void SCMODump::dumpClassPropertyNodeArray(SCMOClass& testCls) const | void SCMODump::dumpClassPropertyNodeArray(SCMOClass& testCls) const |
{ | { |
SCMBClass_Main* clshdr = testCls.cls.hdr; | SCMBClass_Main* clshdr = testCls.cls.hdr; |
unsigned char* clsbase = testCls.cls.base; |
char* clsbase = testCls.cls.base; |
| |
SCMBClassPropertyNode* nodeArray = | SCMBClassPropertyNode* nodeArray = |
(SCMBClassPropertyNode*) | (SCMBClassPropertyNode*) |
&(clsbase[clshdr->propertySet.nodeArray.start]); | &(clsbase[clshdr->propertySet.nodeArray.start]); |
| |
for (Uint32 i = 0; i < clshdr->propertySet.number; i++) |
for (Uint32 i = 0, k = clshdr->propertySet.number; i < k; i++) |
{ | { |
| |
printf("\n\n==================="); |
fprintf(_out,"\nClass property #%3u",i); |
printf("\nClass property #%3u",i); |
fprintf(_out,"\n==================="); |
printf("\n==================="); |
|
| |
printf("\nHas next: %s",(nodeArray[i].hasNext?"TRUE":"FALSE")); |
fprintf(_out,"\nHas next: %s",(nodeArray[i].hasNext?"TRUE":"FALSE")); |
if (nodeArray[i].hasNext) | if (nodeArray[i].hasNext) |
{ | { |
printf("\nNext Node: %3u",nodeArray[i].nextNode); |
fprintf(_out,"\nNext Node: %3u",nodeArray[i].nextNode); |
} | } |
else | else |
{ | { |
printf("\nNext Node: N/A"); |
fprintf(_out,"\nNext Node: N/A"); |
} | } |
| |
_dumpClassProperty(nodeArray[i].theProperty,clsbase); | _dumpClassProperty(nodeArray[i].theProperty,clsbase); |
|
|
| |
void SCMODump::_dumpClassProperty( | void SCMODump::_dumpClassProperty( |
const SCMBClassProperty& prop, | const SCMBClassProperty& prop, |
unsigned char* clsbase) const |
char* clsbase) const |
{ | { |
printf("\nProperty name: %s",_getCharString(prop.name,clsbase)); |
fprintf(_out,"\nProperty name: %s", |
|
NULLSTR(_getCharString(prop.name,clsbase))); |
| |
printf("\nHash Tag %3u Hash Index %3u", |
fprintf(_out,"\nHash Tag %3u Hash Index %3u", |
prop.nameHashTag, | prop.nameHashTag, |
prop.nameHashTag%PEGASUS_PROPERTY_SCMB_HASHSIZE); | prop.nameHashTag%PEGASUS_PROPERTY_SCMB_HASHSIZE); |
printf("\nPropagated: %s isKey: %s", |
fprintf(_out,"\nPropagated: %s isKey: %s", |
(prop.flags.propagated?"TRUE":"FALSE"), | (prop.flags.propagated?"TRUE":"FALSE"), |
(prop.flags.isKey?"TRUE":"FALSE") | (prop.flags.isKey?"TRUE":"FALSE") |
); | ); |
| |
printf("\nOrigin class name: %s", |
fprintf(_out,"\nOrigin class name: %s", |
_getCharString(prop.originClassName,clsbase)); |
NULLSTR(_getCharString(prop.originClassName,clsbase))); |
printf("\nReference class name: %s", |
fprintf(_out,"\nReference class name: %s", |
_getCharString(prop.refClassName,clsbase)); |
NULLSTR(_getCharString(prop.refClassName,clsbase))); |
| |
printSCMOValue(prop.defaultValue,clsbase); | printSCMOValue(prop.defaultValue,clsbase); |
| |
|
|
void SCMODump::dumpHashTable(Uint32* hashTable,Uint32 size) const | void SCMODump::dumpHashTable(Uint32* hashTable,Uint32 size) const |
{ | { |
Uint32 i,j,line; | Uint32 i,j,line; |
printf("\n\nHash table:\n"); |
fprintf(_out,"\n\nHash table:\n"); |
| |
| |
for (j = 0; j < size; j = j + line) | for (j = 0; j < size; j = j + line) |
|
|
} | } |
| |
| |
printf("Index :"); |
fprintf(_out,"Index :"); |
for (i = 0; i < line; i++) | for (i = 0; i < line; i++) |
{ | { |
printf(" %3u",j+i); |
fprintf(_out," %3u",j+i); |
} | } |
| |
printf("\nHashTable:"); |
fprintf(_out,"\nHashTable:"); |
for (i = 0; i < line; i++) | for (i = 0; i < line; i++) |
{ | { |
printf(" %3u",hashTable[j+i]); |
fprintf(_out," %3u",hashTable[j+i]); |
} | } |
| |
printf("\n\n"); |
fprintf(_out,"\n\n"); |
| |
} | } |
| |
|
|
void SCMODump::_dumpQualifierArray( | void SCMODump::_dumpQualifierArray( |
Uint64 start, | Uint64 start, |
Uint32 size, | Uint32 size, |
unsigned char* clsbase |
char* clsbase |
) const | ) const |
{ | { |
| |
|
|
| |
void SCMODump::_dumpQualifier( | void SCMODump::_dumpQualifier( |
const SCMBQualifier& theQualifier, | const SCMBQualifier& theQualifier, |
unsigned char* clsbase |
char* clsbase |
) const | ) const |
{ | { |
if(theQualifier.name == QUALNAME_USERDEFINED) | if(theQualifier.name == QUALNAME_USERDEFINED) |
{ | { |
printf("\n\nQualifier user defined name: \'%s\'", |
fprintf(_out,"\n\nQualifier user defined name: \'%s\'", |
_getCharString(theQualifier.userDefName,clsbase)); |
NULLSTR(_getCharString(theQualifier.userDefName,clsbase))); |
} | } |
else | else |
{ | { |
printf("\n\nQualifier DMTF defined name: \'%s\'", |
fprintf(_out,"\n\nQualifier DMTF defined name: \'%s\'", |
_qualifierNameStrLit[theQualifier.name].str); |
SCMOClass::qualifierNameStrLit(theQualifier.name).str); |
} | } |
| |
printf("\nPropagated : %s", |
fprintf(_out,"\nPropagated : %s", |
(theQualifier.propagated ? "True" : "False")); | (theQualifier.propagated ? "True" : "False")); |
printf("\nFlavor : %s", |
fprintf(_out,"\nFlavor : %s", |
(const char*)(CIMFlavor(theQualifier.flavor).toString().getCString())); | (const char*)(CIMFlavor(theQualifier.flavor).toString().getCString())); |
| |
printSCMOValue(theQualifier.value,clsbase); | printSCMOValue(theQualifier.value,clsbase); |
|
|
| |
void SCMODump::printSCMOValue( | void SCMODump::printSCMOValue( |
const SCMBValue& theValue, | const SCMBValue& theValue, |
unsigned char* base) const |
char* base) const |
{ | { |
printf("\nValueType : %s",cimTypeToString(theValue.valueType)); |
fprintf(_out,"\nValueType : %s",cimTypeToString(theValue.valueType)); |
printf("\nValue was set by the provider: %s", |
fprintf(_out,"\nValue was set by the provider: %s", |
(theValue.flags.isSet ? "True" : "False")); | (theValue.flags.isSet ? "True" : "False")); |
if (theValue.flags.isNull) | if (theValue.flags.isNull) |
{ | { |
printf("\nIt's a NULL value."); |
fprintf(_out,"\nIt's a NULL value."); |
return; | return; |
} | } |
if (theValue.flags.isArray) | if (theValue.flags.isArray) |
{ | { |
printf("\nThe value is an Array of size: %u",theValue.valueArraySize); |
fprintf(_out, |
printf("\nThe values are: '%s'", |
"\nThe value is an Array of size: %u", |
|
theValue.valueArraySize); |
|
fprintf(_out,"\nThe values are: '%s'", |
(const char*)printArrayValue( | (const char*)printArrayValue( |
theValue.valueType, | theValue.valueType, |
theValue.valueArraySize, | theValue.valueArraySize, |
|
|
} | } |
else | else |
{ | { |
printf("\nThe Value is: '%s'", |
fprintf(_out,"\nThe Value is: '%s'", |
(const char*) | (const char*) |
printUnionValue(theValue.valueType,theValue.value,base) | printUnionValue(theValue.valueType,theValue.value,base) |
.getCString()); | .getCString()); |
|
|
| |
} | } |
| |
|
void SCMODump::dumpKeyPropertyMask(SCMOClass& testCls ) const |
|
{ |
|
|
|
SCMBClass_Main* clshdr = testCls.cls.hdr; |
|
char* clsbase = testCls.cls.base; |
|
|
|
Uint64 *theKeyMask = (Uint64*)&(clsbase[clshdr->keyPropertyMask.start]); |
|
Uint32 end, noProperties = clshdr->propertySet.number; |
|
Uint32 noMasks = (noProperties-1)/64; |
|
Uint64 printMask = 1; |
|
|
|
for (Uint32 i = 0; i <= noMasks; i++ ) |
|
{ |
|
printMask = 1; |
|
if (i < noMasks) |
|
{ |
|
end = 64; |
|
} |
|
else |
|
{ |
|
end = noProperties%64; |
|
} |
|
|
|
fprintf(_out,"\nkeyPropertyMask[%02u]= ",i); |
|
|
|
for (Uint32 j = 0; j < end; j++) |
|
{ |
|
if (j > 0 && !(j%8)) |
|
{ |
|
fprintf(_out," "); |
|
} |
|
|
|
if (theKeyMask[i] & printMask) |
|
{ |
|
fprintf(_out,"1"); |
|
} |
|
else |
|
{ |
|
fprintf(_out,"0"); |
|
} |
|
|
|
printMask = printMask << 1; |
|
} |
|
fprintf(_out,"\n"); |
|
} |
|
} |
|
|
|
void SCMODump::_hexDump(char* buffer,int length) const |
|
{ |
|
|
|
unsigned char printLine[3][80]; |
|
int p; |
|
int len; |
|
unsigned char item; |
|
|
|
for (int i = 0; i < length;i=i+1) |
|
{ |
|
p = i%80; |
|
|
|
if ((p == 0 && i > 0) || i == length-1 ) |
|
{ |
|
for (int y = 0; y < 3; y=y+1) |
|
{ |
|
if (p == 0) |
|
{ |
|
len = 80; |
|
} else |
|
{ |
|
len = p; |
|
} |
|
|
|
for (int x = 0; x < len; x=x+1) |
|
{ |
|
if (y == 0) |
|
{ |
|
fprintf(_out,"%c",printLine[y][x]); |
|
} |
|
else |
|
{ |
|
fprintf(_out,"%1X",printLine[y][x]); |
|
} |
|
} |
|
fprintf(_out,"\n"); |
|
} |
|
fprintf(_out,"\n"); |
|
} |
|
|
|
item = (unsigned char)buffer[i]; |
|
|
|
if (item < 32 || item > 125 ) |
|
{ |
|
printLine[0][p] = '.'; |
|
} else |
|
{ |
|
printLine[0][p] = item; |
|
} |
|
|
|
printLine[1][p] = item/16; |
|
printLine[2][p] = item%16; |
|
|
|
} |
|
} |
|
|
String SCMODump::printArrayValue( | String SCMODump::printArrayValue( |
CIMType type, | CIMType type, |
Uint32 size, | Uint32 size, |
SCMBUnion u, | SCMBUnion u, |
unsigned char* base) const |
char* base) const |
{ | { |
Buffer out; | Buffer out; |
| |
|
|
SCMBDataPtr* p = (SCMBDataPtr*)&(base[u._arrayValue.start]); | SCMBDataPtr* p = (SCMBDataPtr*)&(base[u._arrayValue.start]); |
for (Uint32 i = 0; i < size; i++) | for (Uint32 i = 0; i < size; i++) |
{ | { |
|
if ( 0 != p[i].length) |
|
{ |
out.append((const char*)_getCharString(p[i],base), | out.append((const char*)_getCharString(p[i],base), |
p[i].length-1); | p[i].length-1); |
|
} |
|
else |
|
{ |
|
out.append(' '); |
|
} |
out.append(' '); | out.append(' '); |
} | } |
break; | break; |
|
|
{ | { |
memcpy(x._rep,&(p[i]),sizeof(SCMBDateTime)); | memcpy(x._rep,&(p[i]),sizeof(SCMBDateTime)); |
_toString(out,x); | _toString(out,x); |
|
out.append(' '); |
} | } |
break; | break; |
} | } |
|
|
String SCMODump::printUnionValue( | String SCMODump::printUnionValue( |
CIMType type, | CIMType type, |
SCMBUnion u, | SCMBUnion u, |
unsigned char* base) const |
char* base) const |
{ | { |
|
|
Buffer out; | Buffer out; |
| |
switch (type) | switch (type) |
|
|
| |
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
|
if ( 0 != u._stringValue.length) |
|
{ |
out.append((const char*)_getCharString(u._stringValue,base), | out.append((const char*)_getCharString(u._stringValue,base), |
u._stringValue.length-1); | u._stringValue.length-1); |
|
} |
break; | break; |
} | } |
| |
|
|
return out.getData(); | return out.getData(); |
} | } |
| |
void SCMODump::dumpKeyPropertyMask(SCMOClass& testCls ) const |
|
{ |
|
|
|
SCMBClass_Main* clshdr = testCls.cls.hdr; |
|
unsigned char* clsbase = testCls.cls.base; |
|
| |
Uint64 *theKeyMask = (Uint64*)&(clsbase[clshdr->keyPropertyMask.start]); |
/***************************************************************************** |
Uint32 end, noProperties = clshdr->propertySet.number; |
* The constant functions |
Uint32 noMasks = (noProperties-1)/64; |
*****************************************************************************/ |
Uint64 printMask = 1; |
|
| |
for (Uint32 i = 0; i <= noMasks; i++ ) |
static CIMKeyBinding::Type _cimTypeToKeyBindType(CIMType cimType) |
{ | { |
printMask = 1; |
switch (cimType) |
if (i < noMasks) |
|
{ | { |
end = 64; |
case CIMTYPE_BOOLEAN: |
|
return(CIMKeyBinding::BOOLEAN); |
|
break; |
|
case CIMTYPE_CHAR16: |
|
case CIMTYPE_STRING: |
|
case CIMTYPE_DATETIME: |
|
return(CIMKeyBinding::STRING); |
|
break; |
|
case CIMTYPE_REFERENCE: |
|
return(CIMKeyBinding::REFERENCE); |
|
break; |
|
case CIMTYPE_OBJECT: |
|
case CIMTYPE_INSTANCE: |
|
// From PEP 194: EmbeddedObjects cannot be keys. |
|
throw TypeMismatchException(); |
|
break; |
|
default: |
|
return(CIMKeyBinding::NUMERIC); |
|
break; |
} | } |
else |
|
{ |
|
end = noProperties%64; |
|
} | } |
| |
printf("\nkeyPropertyMask[%02u]= ",i); |
/* OLD THILO VERSION |
|
static Boolean _equalUTF8Strings( |
|
const SCMBDataPtr& ptr_a, |
|
char* base, |
|
const char* name, |
|
Uint32 len) |
| |
for (Uint32 j = 0; j < end; j++) |
|
{ | { |
if (j > 0 && !(j%8)) |
//both are empty strings, so they are equal. |
|
if (ptr_a.length == 0 && len == 0) |
{ | { |
printf(" "); |
return true; |
} | } |
| |
if (theKeyMask[i] & printMask) |
// size without trailing '\0' !! |
{ |
if (ptr_a.length-1 != len) |
printf("1"); |
|
} |
|
else |
|
{ | { |
printf("0"); |
return false; |
} | } |
| |
printMask = printMask << 1; |
const char* a = (const char*)_getCharString(ptr_a,base); |
} |
|
printf("\n"); |
|
} |
|
} |
|
| |
void SCMODump::_hexDump(unsigned char* buffer,int length) const |
// ToDo: Here an UTF8 complinet comparison should take place |
{ |
return ( strncmp(a,name,len )== 0 ); |
| |
unsigned char printLine[3][80]; |
} |
int p; |
*/ |
int len; |
|
unsigned char item; |
|
| |
for (int i = 0; i < length;i=i+1) |
static Boolean _equalUTF8Strings( |
{ |
const SCMBDataPtr& ptr_a, |
p = i%80; |
char* base, |
|
const char* name, |
|
Uint32 len) |
| |
if ((p == 0 && i > 0) || i == length-1 ) |
|
{ | { |
for (int y = 0; y < 3; y=y+1) |
// size without trailing '\0' !! |
{ |
if (ptr_a.length-1 != len) |
if (p == 0) |
|
{ |
|
len = 80; |
|
} else |
|
{ | { |
len = p; |
return false; |
} | } |
|
const char* a = (const char*)_getCharString(ptr_a,base); |
| |
for (int x = 0; x < len; x=x+1) |
// lets do a loop-unrolling optimized compare here |
|
while (len >= 8) |
{ | { |
if (y == 0) |
if ((a[0] - name[0]) || (a[1] - name[1]) || |
{ |
(a[2] - name[2]) || (a[3] - name[3]) || |
printf("%c",printLine[y][x]); |
(a[4] - name[4]) || (a[5] - name[5]) || |
} |
(a[6] - name[6]) || (a[7] - name[7])) |
else |
|
{ | { |
printf("%1X",printLine[y][x]); |
return false; |
} |
|
} |
|
printf("\n"); |
|
} | } |
printf("\n"); |
len -= 8; |
|
a += 8; |
|
name += 8; |
} | } |
|
while (len >= 4) |
item = buffer[i]; |
|
|
|
if (item < 32 || item > 125 ) |
|
{ | { |
printLine[0][p] = '.'; |
if ((a[0] - name[0]) || (a[1] - name[1]) || |
} else |
(a[2] - name[2]) || (a[3] - name[3])) |
{ | { |
printLine[0][p] = item; |
return false; |
} |
|
|
|
printLine[1][p] = item/16; |
|
printLine[2][p] = item%16; |
|
|
|
} |
|
} | } |
|
len -= 4; |
/***************************************************************************** |
a += 4; |
* The constant functions |
name += 4; |
*****************************************************************************/ |
|
|
|
static const void* _resolveDataPtr( |
|
const SCMBDataPtr& ptr, |
|
unsigned char* base) |
|
{ |
|
return ((ptr.start==(Uint64)0 ? NULL : (void*)&(base[ptr.start]))); |
|
} | } |
|
while (len--) |
PEGASUS_COMMON_LINKAGE const unsigned char* _getCharString( |
|
const SCMBDataPtr& ptr, |
|
unsigned char* base) |
|
{ | { |
return ((ptr.start==(Uint64)0 ? NULL : &(base[ptr.start]))); |
if (a[0] - name[0]) |
} |
|
|
|
|
|
static Uint32 _generateSCMOStringTag( |
|
const SCMBDataPtr& ptr, |
|
unsigned char* base) |
|
{ | { |
// The lenght of a SCMBDataPtr to a UTF8 string includs the trailing '\0'. |
return false; |
return _generateStringTag(_getCharString(ptr,base),ptr.length-1); |
|
} | } |
|
a++; |
static Uint32 _generateStringTag(const unsigned char* str, Uint32 len) |
name++; |
{ |
|
if (len == 0) |
|
{ |
|
return 0; |
|
} | } |
return |
return true; |
(Uint32(CharSet::toUpperHash(str[0]) << 1) | |
|
Uint32(CharSet::toUpperHash(str[len-1]))); |
|
} | } |
| |
static CIMKeyBinding::Type _cimTypeToKeyBindType(CIMType cimType) |
|
{ |
|
switch (cimType) |
|
{ |
|
case CIMTYPE_BOOLEAN: |
|
return(CIMKeyBinding::BOOLEAN); |
|
break; |
|
case CIMTYPE_CHAR16: |
|
case CIMTYPE_STRING: |
|
case CIMTYPE_DATETIME: |
|
return(CIMKeyBinding::STRING); |
|
break; |
|
case CIMTYPE_REFERENCE: |
|
return(CIMKeyBinding::REFERENCE); |
|
break; |
|
case CIMTYPE_OBJECT: |
|
case CIMTYPE_INSTANCE: |
|
// From PEP 194: EmbeddedObjects cannot be keys. |
|
throw TypeMismatchException(); |
|
break; |
|
default: |
|
return(CIMKeyBinding::NUMERIC); |
|
break; |
|
} |
|
} |
|
| |
static Boolean _equalUTF8Strings( |
static Boolean _equalNoCaseUTF8Strings( |
const SCMBDataPtr& ptr_a, | const SCMBDataPtr& ptr_a, |
unsigned char* base, |
char* base, |
const char* name, | const char* name, |
Uint32 len) | Uint32 len) |
| |
{ | { |
|
|
|
//both are empty strings, so they are equal. |
|
if (ptr_a.length == 0 && len == 0) |
|
{ |
|
return true; |
|
} |
|
|
// size without trailing '\0' !! | // size without trailing '\0' !! |
if (ptr_a.length-1 != len) | if (ptr_a.length-1 != len) |
{ | { |
|
|
const char* a = (const char*)_getCharString(ptr_a,base); | const char* a = (const char*)_getCharString(ptr_a,base); |
| |
// ToDo: Here an UTF8 complinet comparison should take place | // ToDo: Here an UTF8 complinet comparison should take place |
return ( strncmp(a,name,len )== 0 ); |
return ( strncasecmp(a,name,len )== 0 ); |
| |
} | } |
| |
|
|
/** | /** |
* This function calcutates a free memory slot in the single chunk memory block. | * This function calcutates a free memory slot in the single chunk memory block. |
* Warning: In this routine a reallocation may take place. | * Warning: In this routine a reallocation may take place. |
|
|
throw PEGASUS_STD(bad_alloc)(); | throw PEGASUS_STD(bad_alloc)(); |
} | } |
// increase the total size and free space | // increase the total size and free space |
(*pmem)->freeBytes= (*pmem)->freeBytes + oldSize; |
(*pmem)->freeBytes+=oldSize; |
(*pmem)->totalSize= (*pmem)->totalSize + oldSize; |
(*pmem)->totalSize+=oldSize; |
} | } |
| |
(*pmem)->freeBytes = (*pmem)->freeBytes - size; |
(*pmem)->freeBytes -= size; |
(*pmem)->startOfFreeSpace = (*pmem)->startOfFreeSpace + size; |
(*pmem)->startOfFreeSpace += size; |
| |
if (clear) | if (clear) |
{ | { |
// If requested, set memory to 0. | // If requested, set memory to 0. |
memset(&((unsigned char*)(*pmem))[start],0,size); |
memset(&((char*)(*pmem))[start],0,size); |
} | } |
return start; | return start; |
} | } |
|
|
// --> use the returned start index. | // --> use the returned start index. |
start = _getFreeSpace(ptr , length, pmem); | start = _getFreeSpace(ptr , length, pmem); |
// Copy string including trailing \0 | // Copy string including trailing \0 |
memcpy(&((unsigned char*)(*pmem))[start],(const char*)theCString,length); |
memcpy(&((char*)(*pmem))[start],(const char*)theCString,length); |
} | } |
else | else |
{ | { |
|
|
start = _getFreeSpace(ptr , bufferSize, pmem); | start = _getFreeSpace(ptr , bufferSize, pmem); |
// Copy buffer into SCMB | // Copy buffer into SCMB |
memcpy( | memcpy( |
&((unsigned char*)(*pmem))[start], |
&((char*)(*pmem))[start], |
(const char*)theBuffer, | (const char*)theBuffer, |
bufferSize); | bufferSize); |
} | } |