version 1.2.2.38, 2009/10/13 09:36:35
|
version 1.2.2.75, 2009/11/19 16:25:45
|
|
|
#include <Pegasus/Common/StringConversion.h> | #include <Pegasus/Common/StringConversion.h> |
#include <Pegasus/Common/ArrayIterator.h> | #include <Pegasus/Common/ArrayIterator.h> |
#include <Pegasus/Common/PegasusAssert.h> | #include <Pegasus/Common/PegasusAssert.h> |
|
#include <Pegasus/Common/CIMValueRep.h> |
|
|
|
# if defined PEGASUS_OS_ZOS |
#include <strings.h> | #include <strings.h> |
|
# else |
|
# include <string.h> |
|
# endif |
| |
#ifdef PEGASUS_OS_ZOS | #ifdef PEGASUS_OS_ZOS |
#include <Pegasus/General/SetFileDescriptorToEBCDICEncoding.h> | #include <Pegasus/General/SetFileDescriptorToEBCDICEncoding.h> |
|
|
#define NULLSTR(x) ((x) == 0 ? "" : (x)) | #define NULLSTR(x) ((x) == 0 ? "" : (x)) |
| |
#define NEWCIMSTR(ptr,base) \ | #define NEWCIMSTR(ptr,base) \ |
((ptr).length == 0 ? \ |
((ptr).size == 0 ? \ |
(String()) : \ | (String()) : \ |
(String(&(base)[(ptr).start],((ptr).length)-1))) |
(String(&(base)[(ptr).start],((ptr).size)-1))) |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
* Internal inline functions. | * Internal inline functions. |
*****************************************************************************/ | *****************************************************************************/ |
| |
inline SCMOClass* _getSCMOClass( |
|
const CIMObjectPath& theCIMObj, |
|
const char* altNS, |
|
Uint64 altNSlength) |
|
{ |
|
SCMOClass* theClass=0; |
|
|
|
if (theCIMObj.getClassName().isNull()) |
|
{ |
|
return 0; |
|
} |
|
|
|
if (theCIMObj.getNameSpace().isNull()) |
|
{ |
|
// the name space of the object path is empty, |
|
// use alternative name space. |
|
CString clsName = theCIMObj.getClassName().getString().getCString(); |
|
|
|
SCMOClassCache* theCache = SCMOClassCache::getInstance(); |
|
theClass = theCache->getSCMOClass( |
|
altNS, |
|
altNSlength, |
|
(const char*)clsName, |
|
strlen(clsName)); |
|
|
|
} |
|
else |
|
{ |
|
CString nameSpace = theCIMObj.getNameSpace().getString().getCString(); |
|
CString clsName = theCIMObj.getClassName().getString().getCString(); |
|
|
|
SCMOClassCache* theCache = SCMOClassCache::getInstance(); |
|
theClass = theCache->getSCMOClass( |
|
(const char*)nameSpace, |
|
strlen(nameSpace), |
|
(const char*)clsName, |
|
strlen(clsName)); |
|
} |
|
|
|
return theClass; |
|
} |
|
|
|
inline void _deleteArrayExtReference( | inline void _deleteArrayExtReference( |
SCMBDataPtr& theArray, | SCMBDataPtr& theArray, |
SCMBMgmt_Header** pmem ) | SCMBMgmt_Header** pmem ) |
|
|
SCMBUnion* ptr; | SCMBUnion* ptr; |
// if the array was already set, | // if the array was already set, |
// the previous references has to be deleted | // the previous references has to be deleted |
if(theArray.length != 0) |
if(theArray.size != 0) |
{ | { |
Uint32 oldArraySize=(theArray.length/sizeof(SCMBUnion)); |
Uint32 oldArraySize=(theArray.size/sizeof(SCMBUnion)); |
| |
ptr = (SCMBUnion*)&(((char*)*pmem)[theArray.start]); | ptr = (SCMBUnion*)&(((char*)*pmem)[theArray.start]); |
for (Uint32 i = 0 ; i < oldArraySize ; i++) | for (Uint32 i = 0 ; i < oldArraySize ; i++) |
{ | { |
delete ptr[i].extRefPtr; | delete ptr[i].extRefPtr; |
} |
ptr[i].extRefPtr = 0; |
} |
|
} |
|
|
|
inline void _copyArrayExtReference( |
|
SCMBDataPtr& theArray, |
|
SCMBMgmt_Header** pmem ) |
|
{ |
|
SCMBUnion* ptr; |
|
// if the array was already set, |
|
// the previous references has to be deleted |
|
if(theArray.length != 0) |
|
{ |
|
Uint32 oldArraySize=(theArray.length/sizeof(SCMBUnion)); |
|
|
|
ptr = (SCMBUnion*)&(((char*)*pmem)[theArray.start]); |
|
for (Uint32 i = 0 ; i < oldArraySize ; i++) |
|
{ |
|
if (ptr[i].extRefPtr != 0) |
|
{ |
|
ptr[i].extRefPtr = new SCMOInstance(*ptr[i].extRefPtr); |
|
} |
|
} | } |
} | } |
} | } |
|
|
*****************************************************************************/ | *****************************************************************************/ |
SCMOClass::SCMOClass() | SCMOClass::SCMOClass() |
{ | { |
cls.mem = 0; |
_initSCMOClass(); |
} |
|
|
|
void SCMOClass::_destroyExternalReferences() |
|
{ |
|
// TODO: Has to be optimized not to loop through all props. |
|
// Address the property array |
|
SCMBClassPropertyNode* nodeArray = |
|
(SCMBClassPropertyNode*) |
|
&(cls.base[cls.hdr->propertySet.nodeArray.start]); |
|
|
|
SCMBValue* theValue; |
|
|
|
for (Uint32 i = 0; i < cls.hdr->propertySet.number; i++) |
|
{ |
|
theValue = &(nodeArray[i].theProperty.defaultValue); |
|
| |
// if not an NULL value ! |
_setBinary("",1,cls.hdr->className,&cls.mem ); |
if(!theValue->flags.isNull) |
_setBinary("",1,cls.hdr->nameSpace,&cls.mem ); |
{ |
cls.hdr->flags.isEmpty=true; |
if (theValue->valueType == CIMTYPE_REFERENCE || |
|
theValue->valueType == CIMTYPE_OBJECT || |
|
theValue->valueType == CIMTYPE_INSTANCE ) |
|
{ |
|
if (theValue->flags.isArray) |
|
{ |
|
_deleteArrayExtReference( |
|
theValue->value.arrayValue, |
|
&cls.mem); |
|
} |
|
else |
|
{ |
|
delete theValue->value.extRefPtr; |
|
} // end is Array |
|
} // end is ext. reference. |
|
}// end is not null |
|
}// loop throug all properties |
|
} | } |
| |
inline void SCMOClass::_initSCMOClass() | inline void SCMOClass::_initSCMOClass() |
|
|
| |
SCMOClass::SCMOClass(const char* className, const char* nameSpaceName ) | SCMOClass::SCMOClass(const char* className, const char* nameSpaceName ) |
{ | { |
|
Uint32 clsNameLen = strlen(className); |
|
Uint32 nsNameLen = strlen(nameSpaceName); |
|
|
if (0 == className) | if (0 == className) |
{ | { |
String message("SCMOClass: Class name not set (null pointer)!"); | String message("SCMOClass: Class name not set (null pointer)!"); |
|
|
| |
_initSCMOClass(); | _initSCMOClass(); |
| |
_setBinary(className, |
_setBinary(className,clsNameLen+1,cls.hdr->className,&cls.mem ); |
strlen(className)+1, |
|
cls.hdr->className, |
|
&cls.mem ); |
|
| |
_setBinary(nameSpaceName, |
_setBinary(nameSpaceName,nsNameLen+1,cls.hdr->nameSpace,&cls.mem ); |
strlen(nameSpaceName)+1, |
|
cls.hdr->nameSpace, |
cls.hdr->flags.isEmpty=true; |
&cls.mem ); |
|
| |
} | } |
| |
|
|
{ | { |
// there is no Super ClassName | // there is no Super ClassName |
cls.hdr->superClassName.start=0; | cls.hdr->superClassName.start=0; |
cls.hdr->superClassName.length=0; |
cls.hdr->superClassName.size=0; |
} | } |
| |
CIMObjectPath theObjectPath=theCIMClass.getPath(); | CIMObjectPath theObjectPath=theCIMClass.getPath(); |
|
|
| |
} | } |
| |
|
void SCMOClass::_destroyExternalReferences() |
|
{ |
|
_destroyExternalReferencesInternal(cls.mem); |
|
} |
|
|
|
const char* SCMOClass::getSuperClassName() const |
|
{ |
|
return _getCharString(cls.hdr->superClassName,cls.base); |
|
} |
|
|
|
const char* SCMOClass::getSuperClassName_l(Uint64 & length) const |
|
{ |
|
length = cls.hdr->superClassName.size; |
|
if (0 == length) |
|
{ |
|
return 0; |
|
} |
|
else |
|
{ |
|
length--; |
|
} |
|
return _getCharString(cls.hdr->superClassName,cls.base); |
|
} |
|
|
void SCMOClass::getCIMClass(CIMClass& cimClass) const | void SCMOClass::getCIMClass(CIMClass& cimClass) const |
{ | { |
CIMClass newCimClass( | CIMClass newCimClass( |
|
|
| |
keyNames.clear(); | keyNames.clear(); |
| |
for (Uint32 i = 0, k = cls.hdr->propertySet.number; i < k; i++) |
for (Uint32 i = 0, k = cls.hdr->keyBindingSet.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' |
keyNames.append(NEWCIMSTR(nodeArray[i].name,cls.base)); |
keyNames.append( |
|
String((const char*)_getCharString(nodeArray[i].name,cls.base), |
|
nodeArray[i].name.length-1)); |
|
|
|
} | } |
} | } |
| |
|
|
if (nodeArray[node].nameHashTag == tag) | if (nodeArray[node].nameHashTag == tag) |
{ | { |
// Now it is worth to compare the two names | // Now it is worth to compare the two names |
if (_equalUTF8Strings( |
if (_equalNoCaseUTF8Strings(nodeArray[node].name,cls.base,name,len)) |
nodeArray[node].name,cls.base,name,len)) |
|
{ | { |
// we found the property ! | // we found the property ! |
return SCMO_OK; | return SCMO_OK; |
|
|
if (nodeArray[node].theProperty.nameHashTag == tag) | if (nodeArray[node].theProperty.nameHashTag == tag) |
{ | { |
// Now it is worth to compare the two names | // Now it is worth to compare the two names |
if (_equalUTF8Strings( |
if (_equalNoCaseUTF8Strings( |
nodeArray[node].theProperty.name,cls.base,name,len)) | nodeArray[node].theProperty.name,cls.base,name,len)) |
{ | { |
// we found the property ! | // we found the property ! |
|
|
Uint32 noKeys = 0; | Uint32 noKeys = 0; |
Boolean isKey = false; | Boolean isKey = false; |
| |
Uint32 keyIndex[noProps]; |
Array<Uint32> keyIndex(noProps); |
| |
cls.hdr->propertySet.number=noProps; | cls.hdr->propertySet.number=noProps; |
| |
|
|
startKeyIndexList = _getFreeSpace( | startKeyIndexList = _getFreeSpace( |
cls.hdr->keyIndexList, | cls.hdr->keyIndexList, |
noProps*sizeof(Uint32), | noProps*sizeof(Uint32), |
&cls.mem, |
&cls.mem); |
true); |
|
| |
if(noProps != 0) | if(noProps != 0) |
{ | { |
|
|
// (68 - 1) / 64 = 1 --> The mask consists of two Uint64 values. | // (68 - 1) / 64 = 1 --> The mask consists of two Uint64 values. |
_getFreeSpace(cls.hdr->keyPropertyMask, | _getFreeSpace(cls.hdr->keyPropertyMask, |
sizeof(Uint64)*(((noProps-1)/64)+1), | sizeof(Uint64)*(((noProps-1)/64)+1), |
&cls.mem,true); |
&cls.mem); |
| |
// allocate property array and save the start index of the array. | // allocate property array and save the start index of the array. |
start = _getFreeSpace(cls.hdr->propertySet.nodeArray, | start = _getFreeSpace(cls.hdr->propertySet.nodeArray, |
sizeof(SCMBClassPropertyNode)*noProps, | sizeof(SCMBClassPropertyNode)*noProps, |
&cls.mem,true); |
&cls.mem); |
| |
// clear the hash table | // clear the hash table |
memset(cls.hdr->propertySet.hashTable, | memset(cls.hdr->propertySet.hashTable, |
|
|
// fill the key index list | // fill the key index list |
memcpy( | memcpy( |
&(cls.base[startKeyIndexList]), | &(cls.base[startKeyIndexList]), |
keyIndex, |
keyIndex.getData(), |
noKeys*sizeof(Uint32)); | noKeys*sizeof(Uint32)); |
| |
for (Uint32 i = 0 ; i < noKeys; i++) | for (Uint32 i = 0 ; i < noKeys; i++) |
|
|
else | else |
{ | { |
cls.hdr->keyBindingSet.nodeArray.start=0; | cls.hdr->keyBindingSet.nodeArray.start=0; |
cls.hdr->keyBindingSet.nodeArray.length=0; |
cls.hdr->keyBindingSet.nodeArray.size=0; |
} | } |
} | } |
else | else |
{ | { |
cls.hdr->propertySet.nodeArray.start=0; | cls.hdr->propertySet.nodeArray.start=0; |
cls.hdr->propertySet.nodeArray.length=0; |
cls.hdr->propertySet.nodeArray.size=0; |
cls.hdr->keyPropertyMask.start=0; | cls.hdr->keyPropertyMask.start=0; |
cls.hdr->keyPropertyMask.length=0; |
cls.hdr->keyPropertyMask.size=0; |
cls.hdr->keyBindingSet.nodeArray.start=0; | cls.hdr->keyBindingSet.nodeArray.start=0; |
cls.hdr->keyBindingSet.nodeArray.length=0; |
cls.hdr->keyBindingSet.nodeArray.size=0; |
} | } |
} | } |
| |
|
|
| |
Uint32 *hashTable = cls.hdr->keyBindingSet.hashTable; | Uint32 *hashTable = cls.hdr->keyBindingSet.hashTable; |
| |
if ( newIndex >= cls.hdr->keyBindingSet.number) |
|
{ |
|
throw IndexOutOfBoundsException(); |
|
} |
|
|
|
// calculate the new hash index of the new property. | // calculate the new hash index of the new property. |
Uint32 hash = newKeyNode->nameHashTag % PEGASUS_KEYBINDIG_SCMB_HASHSIZE; | Uint32 hash = newKeyNode->nameHashTag % PEGASUS_KEYBINDIG_SCMB_HASHSIZE; |
| |
|
|
| |
Uint32 *hashTable = cls.hdr->propertySet.hashTable; | Uint32 *hashTable = cls.hdr->propertySet.hashTable; |
| |
if ( newIndex >= cls.hdr->propertySet.number) |
|
{ |
|
throw IndexOutOfBoundsException(); |
|
} |
|
|
|
// calcuate the new hash index of the new property. | // calcuate the new hash index of the new property. |
Uint32 hash = newPropNode->theProperty.nameHashTag % | Uint32 hash = newPropNode->theProperty.nameHashTag % |
PEGASUS_PROPERTY_SCMB_HASHSIZE; | PEGASUS_PROPERTY_SCMB_HASHSIZE; |
|
|
const CIMProperty& theCIMProperty) | const CIMProperty& theCIMProperty) |
{ | { |
CIMPropertyRep* propRep = theCIMProperty._rep; | CIMPropertyRep* propRep = theCIMProperty._rep; |
Uint64 valueStart; |
|
| |
// First do all _setString(). Can cause reallocation. | // First do all _setString(). Can cause reallocation. |
_setString(propRep->_name.getString(), | _setString(propRep->_name.getString(), |
|
|
else | else |
{ | { |
scmoPropNode->theProperty.qualifierArray.start=0; | scmoPropNode->theProperty.qualifierArray.start=0; |
scmoPropNode->theProperty.qualifierArray.length=0; |
scmoPropNode->theProperty.qualifierArray.size=0; |
} | } |
| |
return isKey; | return isKey; |
|
|
else | else |
{ | { |
cls.hdr->qualifierArray.start=0; | cls.hdr->qualifierArray.start=0; |
cls.hdr->qualifierArray.length=0; |
cls.hdr->qualifierArray.size=0; |
} | } |
} | } |
| |
|
|
// Is set to the number of array members by the function. | // Is set to the number of array members by the function. |
scmoValue->valueArraySize, | scmoValue->valueArraySize, |
cls.hdr->nameSpace.start, | cls.hdr->nameSpace.start, |
cls.hdr->nameSpace.length, |
cls.hdr->nameSpace.size, |
rep->u); | rep->u); |
} | } |
else | else |
|
|
&cls.mem, | &cls.mem, |
rep->type, | rep->type, |
cls.hdr->nameSpace.start, | cls.hdr->nameSpace.start, |
cls.hdr->nameSpace.length, |
cls.hdr->nameSpace.size, |
rep->u); | rep->u); |
} | } |
} | } |
|
|
(SCMBClassPropertyNode*) | (SCMBClassPropertyNode*) |
&(cls.base[cls.hdr->propertySet.nodeArray.start]); | &(cls.base[cls.hdr->propertySet.nodeArray.start]); |
| |
return(_equalUTF8Strings( |
return(_equalNoCaseUTF8Strings( |
nodeArray[node].theProperty.originClassName, | nodeArray[node].theProperty.originClassName, |
cls.base, | cls.base, |
origin, | origin, |
|
|
inst.base = 0; | inst.base = 0; |
} | } |
| |
SCMOInstance::SCMOInstance(SCMOClass baseClass) |
SCMOInstance::SCMOInstance(SCMOClass& baseClass) |
{ | { |
_initSCMOInstance(new SCMOClass(baseClass)); | _initSCMOInstance(new SCMOClass(baseClass)); |
} | } |
| |
SCMOInstance::SCMOInstance( | SCMOInstance::SCMOInstance( |
SCMOClass baseClass, |
SCMOClass& baseClass, |
Boolean includeQualifiers, | Boolean includeQualifiers, |
Boolean includeClassOrigin, | Boolean includeClassOrigin, |
const char** propertyList) | const char** propertyList) |
|
|
| |
} | } |
| |
SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMObjectPath& cimObj) |
SCMOInstance::SCMOInstance(SCMOClass& baseClass, const CIMObjectPath& cimObj) |
{ | { |
_initSCMOInstance(new SCMOClass(baseClass)); | _initSCMOInstance(new SCMOClass(baseClass)); |
| |
_setCIMObjectPath(cimObj); | _setCIMObjectPath(cimObj); |
} | } |
| |
SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMInstance& cimInstance) |
SCMOInstance::SCMOInstance(SCMOClass& baseClass, const CIMInstance& cimInstance) |
{ | { |
| |
_initSCMOInstance(new SCMOClass(baseClass)); | _initSCMOInstance(new SCMOClass(baseClass)); |
|
|
| |
} | } |
| |
|
SCMOInstance::SCMOInstance(CIMClass& theCIMClass, const char* altNameSpace) |
|
{ |
|
_initSCMOInstance(new SCMOClass(theCIMClass,altNameSpace)); |
| |
void SCMOInstance::_copyExternalReferences() |
} |
|
|
|
SCMOInstance::SCMOInstance( |
|
const CIMInstance& cimInstance, |
|
const char* altNameSpace, |
|
Uint64 altNSLen) |
|
{ |
|
SCMOClass theSCMOClass = _getSCMOClass( |
|
cimInstance._rep->_reference, |
|
altNameSpace, |
|
altNSLen); |
|
|
|
_initSCMOInstance( new SCMOClass(theSCMOClass)); |
|
|
|
if(theSCMOClass.isEmpty()) |
{ | { |
// TODO: Has to be optimized not to loop through all props. |
// flag the instance as compromized |
// create a pointer to keybinding node array of the class. |
inst.hdr->flags.isCompromised=true; |
Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; |
} |
SCMBKeyBindingNode* theClassKeyBindNodeArray = |
else |
(SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]); |
{ |
|
_setCIMInstance(cimInstance); |
|
} |
|
} |
| |
// create a pointer to instanc key binding array. |
SCMOInstance::SCMOInstance( |
SCMBKeyBindingValue* theInstanceKeyBindingNodeArray = |
const CIMObject& cimObject, |
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
const char* altNameSpace, |
|
Uint64 altNSLen) |
|
{ |
|
if (cimObject.isClass()) |
|
{ |
|
CIMClass cimClass(cimObject); |
| |
for (Uint32 i = 0; i < inst.hdr->numberKeyBindings; i++) |
_initSCMOInstance(new SCMOClass(cimClass,altNameSpace)); |
|
|
|
inst.hdr->flags.isClassOnly=true; |
|
} |
|
else |
{ | { |
if (theInstanceKeyBindingNodeArray[i].isSet) |
CIMInstance cimInstance(cimObject); |
|
|
|
SCMOClass theSCMOClass = _getSCMOClass( |
|
cimInstance._rep->_reference, |
|
altNameSpace, |
|
altNSLen); |
|
|
|
_initSCMOInstance( new SCMOClass(theSCMOClass)); |
|
|
|
if(theSCMOClass.isEmpty()) |
{ | { |
// only references can be a key binding. |
// flag the instance as compromized |
if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE) |
inst.hdr->flags.isCompromised=true; |
|
} |
|
else |
{ | { |
// Use the copy constructro to ref. count the reference. |
_setCIMInstance(cimInstance); |
// These objects are handeld by the SCMOInstance it sef. |
} |
// No one can modify these instances. |
|
theInstanceKeyBindingNodeArray[i].data.extRefPtr = |
|
new SCMOInstance( |
|
*theInstanceKeyBindingNodeArray[i].data.extRefPtr); |
|
} | } |
} | } |
}// for all key bindings defined in the class |
|
| |
// Are there user defined key bindings ? |
SCMOInstance::SCMOInstance( |
if (0 != inst.hdr->numberUserKeyBindindigs) |
const CIMObjectPath& cimObj, |
|
const char* altNameSpace, |
|
Uint64 altNSLen) |
|
{ |
|
SCMOClass theSCMOClass = _getSCMOClass( |
|
cimObj, |
|
altNameSpace, |
|
altNSLen); |
|
|
|
_initSCMOInstance( new SCMOClass(theSCMOClass)); |
|
|
|
if(theSCMOClass.isEmpty()) |
{ | { |
SCMBUserKeyBindingElement* theUserDefKBElement = |
// flag the instance as compromized |
(SCMBUserKeyBindingElement*) |
inst.hdr->flags.isCompromised=true; |
&(inst.base[inst.hdr->userKeyBindingElement.start]); |
} |
|
else |
|
{ |
|
_setCIMObjectPath(cimObj); |
|
} |
|
} |
| |
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; i++) |
void SCMOInstance::_destroyExternalReferences() |
{ | { |
if (theUserDefKBElement->value.isSet) |
_destroyExternalReferencesInternal(inst.mem); |
|
} |
|
|
|
SCMOClass SCMOInstance::_getSCMOClass( |
|
const CIMObjectPath& theCIMObj, |
|
const char* altNS, |
|
Uint64 altNSlength) |
{ | { |
// only references can be a key binding. |
SCMOClass theClass; |
if (theUserDefKBElement->type == CIMTYPE_REFERENCE) |
|
|
if (theCIMObj.getClassName().isNull()) |
{ | { |
// Use the copy constructro to ref. count the reference. |
return SCMOClass(); |
// These objects are handeld by the SCMOInstance it sef. |
} |
// No one can modify these instances. |
|
theUserDefKBElement->value.data.extRefPtr = |
if (theCIMObj.getNameSpace().isNull()) |
new SCMOInstance( |
{ |
*theUserDefKBElement->value.data.extRefPtr); |
// the name space of the object path is empty, |
|
// use alternative name space. |
|
CString clsName = theCIMObj.getClassName().getString().getCString(); |
|
|
|
SCMOClassCache* theCache = SCMOClassCache::getInstance(); |
|
theClass = theCache->getSCMOClass( |
|
altNS, |
|
altNSlength, |
|
(const char*)clsName, |
|
strlen(clsName)); |
} | } |
|
else |
|
{ |
|
CString nameSpace = theCIMObj.getNameSpace().getString().getCString(); |
|
CString clsName = theCIMObj.getClassName().getString().getCString(); |
|
|
|
SCMOClassCache* theCache = SCMOClassCache::getInstance(); |
|
theClass = theCache->getSCMOClass( |
|
(const char*)nameSpace, |
|
strlen(nameSpace), |
|
(const char*)clsName, |
|
strlen(clsName)); |
} | } |
| |
theUserDefKBElement = |
return theClass; |
(SCMBUserKeyBindingElement*) |
|
&(inst.base[theUserDefKBElement->nextElement.start]); |
|
} // for all user def. key bindings. |
|
} | } |
| |
SCMBValue* theInstPropArray = |
#define PEGASUS_SIZE_REFERENCE_INDEX_ARRAY 8 |
(SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]); |
|
| |
for (Uint32 i = 0; i < inst.hdr->numberProperties; i++) |
void SCMOInstance::_setExtRefIndex(SCMBUnion* pInst, SCMBMgmt_Header** pmem) |
{ | { |
// was the property set by the provider ? |
|
if(theInstPropArray[i].flags.isSet) |
Uint64 refPtr =(((char *)pInst) - (char *)(*pmem)); |
|
SCMBMgmt_Header* memHdr = (*pmem); |
|
// Save the number of external references in the array |
|
Uint32 noExtRef = memHdr->numberExtRef; |
|
|
|
// Allocate the external reflerence array |
|
// if it is full or empty ( 0 == 0 ). |
|
if (noExtRef == memHdr->sizeExtRefIndexArray) |
|
{ |
|
Uint64 oldArrayStart = memHdr->extRefIndexArray.start; |
|
Uint32 newSize = |
|
memHdr->sizeExtRefIndexArray + PEGASUS_SIZE_REFERENCE_INDEX_ARRAY; |
|
|
|
// Allocate the external reference index array |
|
_getFreeSpace( |
|
memHdr->extRefIndexArray, |
|
sizeof(Uint64)*newSize, |
|
pmem); |
|
|
|
// reset the pointer. It could be changed due to reallocation ! |
|
memHdr = (*pmem); |
|
|
|
// Assign new size. |
|
memHdr->sizeExtRefIndexArray=newSize; |
|
|
|
// Get absolute pointer to old index array. |
|
Uint64* oldArray = (Uint64*)&(((char*)(*pmem))[oldArrayStart]); |
|
// Get absolute pointer to new index array |
|
Uint64* newArray = |
|
(Uint64*)&(((char*)(*pmem))[memHdr->extRefIndexArray.start]); |
|
|
|
// Copy all elements of the old array to the new. |
|
// If noExtRef = 0, no elements are copied. |
|
for (Uint32 i = 0 ; i < noExtRef ; i++) |
{ | { |
// is the property type reference,instance or object? |
newArray[i] = oldArray[i]; |
if (theInstPropArray[i].valueType == CIMTYPE_REFERENCE || |
} |
theInstPropArray[i].valueType == CIMTYPE_OBJECT || |
} |
theInstPropArray[i].valueType == CIMTYPE_INSTANCE ) |
|
|
// Get absolute pointer to the array |
|
Uint64* array = |
|
(Uint64*)&(((char*)(*pmem))[memHdr->extRefIndexArray.start]); |
|
// look in the table if the index is already in the array |
|
for (Uint32 i = 0 ; i < noExtRef ; i++) |
{ | { |
if (theInstPropArray[i].flags.isArray) |
// is the index already part of the array |
|
if (array[i] == refPtr) |
{ | { |
_copyArrayExtReference( |
// leave. |
theInstPropArray[i].value.arrayValue, |
return; |
&inst.mem); |
|
} | } |
else |
} |
|
// It is not part of the array -> set the new index. |
|
array[noExtRef] = refPtr; |
|
// increment the nuber of external references of this instance. |
|
memHdr->numberExtRef++; |
|
|
|
} |
|
|
|
SCMOInstance* SCMOInstance::getExtRef(Uint32 idx) const |
{ | { |
theInstPropArray[i].value.extRefPtr = |
Uint64* array = |
new SCMOInstance(*theInstPropArray[i].value.extRefPtr); |
(Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]); |
} // end is arry |
SCMBUnion* pUnion; |
} // end is reference |
pUnion = (SCMBUnion*)(&(inst.base[array[idx]])); |
}// end is set |
return pUnion->extRefPtr; |
} // for all properties. |
|
} | } |
| |
void SCMOInstance::_destroyExternalReferences() |
void SCMOInstance::putExtRef(Uint32 idx,SCMOInstance* ptr) |
{ | { |
// TODO: Has to be optimized not to loop through all props. |
Uint64* array = |
// create a pointer to keybinding node array of the class. |
(Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]); |
|
SCMBUnion* pUnion; |
|
pUnion = (SCMBUnion*)(&(inst.base[array[idx]])); |
|
pUnion->extRefPtr = ptr; |
|
} |
|
|
|
void SCMOInstance::_copyExternalReferences() |
|
{ |
|
Uint32 number = inst.mem->numberExtRef; |
|
|
|
if (0 != number) |
|
{ |
|
SCMBUnion* pUnion; |
|
Uint64* array = |
|
(Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]); |
|
for (Uint32 i = 0; i < number; i++) |
|
{ |
|
pUnion = (SCMBUnion*)(&(inst.base[array[i]])); |
|
if (0 != pUnion) |
|
{ |
|
pUnion->extRefPtr = new SCMOInstance(*(pUnion->extRefPtr)); |
|
} |
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
void SCMOInstance::_destroyExternalKeyBindings() |
|
{ |
|
// 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]); |
|
|
}// for all key bindings | }// for all key bindings |
| |
// Are there user defined key bindings ? | // Are there user defined key bindings ? |
if (0 != inst.hdr->numberUserKeyBindindigs) |
if (0 != inst.hdr->numberUserKeyBindings) |
{ | { |
SCMBUserKeyBindingElement* theUserDefKBElement = | SCMBUserKeyBindingElement* theUserDefKBElement = |
(SCMBUserKeyBindingElement*) | (SCMBUserKeyBindingElement*) |
&(inst.base[inst.hdr->userKeyBindingElement.start]); | &(inst.base[inst.hdr->userKeyBindingElement.start]); |
| |
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; i++) |
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindings; i++) |
{ | { |
if (theUserDefKBElement->value.isSet) | if (theUserDefKBElement->value.isSet) |
{ | { |
|
|
&(inst.base[theUserDefKBElement->nextElement.start]); | &(inst.base[theUserDefKBElement->nextElement.start]); |
} // for all user def. key bindings. | } // for all user def. key bindings. |
} | } |
|
|
SCMBValue* theInstPropArray = |
|
(SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]); |
|
|
|
for (Uint32 i = 0; i < inst.hdr->numberProperties; i++) |
|
{ |
|
// was the property set by the provider ? |
|
if(theInstPropArray[i].flags.isSet) |
|
{ |
|
// is the property type reference,instance or object? |
|
if (theInstPropArray[i].valueType == CIMTYPE_REFERENCE || |
|
theInstPropArray[i].valueType == CIMTYPE_OBJECT || |
|
theInstPropArray[i].valueType == CIMTYPE_INSTANCE ) |
|
{ |
|
if (theInstPropArray[i].flags.isArray) |
|
{ |
|
_deleteArrayExtReference( |
|
theInstPropArray[i].value.arrayValue, |
|
&inst.mem); |
|
} |
|
else |
|
{ |
|
delete theInstPropArray[i].value.extRefPtr; |
|
} // end is arry |
|
} // end is reference |
|
}// end is set |
|
} // for all properties. |
|
} | } |
| |
SCMO_RC SCMOInstance::getCIMInstance(CIMInstance& cimInstance) const | SCMO_RC SCMOInstance::getCIMInstance(CIMInstance& cimInstance) const |
{ | { |
| |
SCMO_RC rc = SCMO_OK; | SCMO_RC rc = SCMO_OK; |
Uint32 noProps; |
|
CIMObjectPath objPath; | CIMObjectPath objPath; |
| |
// For better usability define pointers to SCMO Class data structures. | // For better usability define pointers to SCMO Class data structures. |
|
|
} | } |
| |
// Are there user defined key bindings ? | // Are there user defined key bindings ? |
if (0 != inst.hdr->numberUserKeyBindindigs) |
if (0 != inst.hdr->numberUserKeyBindings) |
{ | { |
SCMBUserKeyBindingElement* theUserDefKBElement = | SCMBUserKeyBindingElement* theUserDefKBElement = |
(SCMBUserKeyBindingElement*) | (SCMBUserKeyBindingElement*) |
&(inst.base[inst.hdr->userKeyBindingElement.start]); | &(inst.base[inst.hdr->userKeyBindingElement.start]); |
| |
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; i++) |
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindings; i++) |
{ | { |
if (theUserDefKBElement->value.isSet) | if (theUserDefKBElement->value.isSet) |
{ | { |
|
|
SCMBValue& instValue = | SCMBValue& instValue = |
((SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]))[nodeIdx]; | ((SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]))[nodeIdx]; |
| |
|
if (instValue.flags.isSet) |
|
{ |
_getCIMValueFromSCMBValue(theValue,instValue,inst.base); | _getCIMValueFromSCMBValue(theValue,instValue,inst.base); |
|
} |
|
else |
|
{ |
|
_getCIMValueFromSCMBValue( |
|
theValue, |
|
clsProp.theProperty.defaultValue, |
|
clsbase); |
|
} |
|
|
| |
| |
if (inst.hdr->flags.includeClassOrigin) | if (inst.hdr->flags.includeClassOrigin) |
|
|
Array<Char16> x; | Array<Char16> x; |
for (Uint32 i = 0, k = arraySize; i < k ; i++) | for (Uint32 i = 0, k = arraySize; i < k ; i++) |
{ | { |
x.append(pscmbArrayUn[i].simple.val.c16); |
x.append(Char16(pscmbArrayUn[i].simple.val.c16)); |
} | } |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(scmbUn.simple.val.c16); |
cimV.set(Char16(scmbUn.simple.val.c16)); |
} | } |
break; | break; |
} | } |
|
|
void SCMOInstance::_setCIMObjectPath(const CIMObjectPath& cimObj) | void SCMOInstance::_setCIMObjectPath(const CIMObjectPath& cimObj) |
{ | { |
CIMObjectPathRep* objRep = cimObj._rep; | CIMObjectPathRep* objRep = cimObj._rep; |
SCMO_RC rc; |
|
| |
CString className = objRep->_className.getString().getCString(); | CString className = objRep->_className.getString().getCString(); |
| |
|
|
for (Uint32 i = 0, k = objRep->_keyBindings.size(); i < k; i++) | for (Uint32 i = 0, k = objRep->_keyBindings.size(); i < k; i++) |
{ | { |
String key = objRep->_keyBindings[i].getValue(); | String key = objRep->_keyBindings[i].getValue(); |
rc = _setKeyBindingFromString( |
_setKeyBindingFromString( |
(const char*) | (const char*) |
objRep->_keyBindings[i].getName().getString().getCString(), | objRep->_keyBindings[i].getName().getString().getCString(), |
_CIMTypeFromKeyBindingType( | _CIMTypeFromKeyBindingType( |
(const char*)key.getCString(), | (const char*)key.getCString(), |
objRep->_keyBindings[i].getType()), | objRep->_keyBindings[i].getType()), |
key); | key); |
|
|
if (rc != SCMO_OK) |
|
{ |
|
String message("Can not set CIMObjectPath key binding:'"); |
|
message.append( |
|
objRep->_keyBindings[i].getName().getString()); |
|
message.append("'"); |
|
throw CIMException(CIM_ERR_FAILED, message); |
|
} |
|
} | } |
| |
} | } |
|
|
// Is set to the number of array members by the function. | // Is set to the number of array members by the function. |
theInstProp.valueArraySize, | theInstProp.valueArraySize, |
inst.hdr->instNameSpace.start, | inst.hdr->instNameSpace.start, |
inst.hdr->instNameSpace.length, |
inst.hdr->instNameSpace.size, |
valRep->u); | valRep->u); |
} | } |
else | else |
|
|
&inst.mem, | &inst.mem, |
realType, | realType, |
inst.hdr->instNameSpace.start, | inst.hdr->instNameSpace.start, |
inst.hdr->instNameSpace.length, |
inst.hdr->instNameSpace.size, |
valRep->u); | valRep->u); |
} | } |
} | } |
|
|
| |
void SCMOInstance::setHostName(const char* hostName) | void SCMOInstance::setHostName(const char* hostName) |
{ | { |
Uint32 len; |
Uint32 len = 0; |
|
|
|
_copyOnWrite(); |
| |
if (hostName!=0) | if (hostName!=0) |
{ | { |
| |
len = strlen((const char*)hostName); | len = strlen((const char*)hostName); |
if(len != 0) |
} |
{ |
|
|
|
// copy including trailing '\0' | // copy including trailing '\0' |
_setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem); | _setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem); |
return; |
|
} | } |
| |
|
void SCMOInstance::setHostName_l(const char* hostName, Uint64 len) |
|
{ |
|
// Copy on Write is only necessary if a realloc() becomes necessary |
|
if (inst.mem->freeBytes < len) |
|
{ |
|
_copyOnWrite(); |
} | } |
inst.hdr->hostName.start=0; |
// copy including trailing '\0' |
inst.hdr->hostName.length=0; |
_setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem); |
} | } |
| |
const char* SCMOInstance::getHostName() const | const char* SCMOInstance::getHostName() const |
|
|
| |
const char* SCMOInstance::getHostName_l(Uint64& length) const | const char* SCMOInstance::getHostName_l(Uint64& length) const |
{ | { |
length = inst.hdr->hostName.length; |
length = inst.hdr->hostName.size; |
|
if (0 == length) |
|
{ |
|
return 0; |
|
} |
|
else |
|
{ |
|
length--; |
|
} |
return _getCharString(inst.hdr->hostName,inst.base); | return _getCharString(inst.hdr->hostName,inst.base); |
} | } |
| |
void SCMOInstance::setClassName(const char* className) | void SCMOInstance::setClassName(const char* className) |
{ | { |
Uint32 len; |
Uint32 len=0; |
|
|
|
_copyOnWrite(); |
| |
|
// flag the instance as compromized |
|
inst.hdr->flags.isCompromised=true; |
if (className!=0) | if (className!=0) |
{ | { |
|
|
len = strlen((const char*)className); | len = strlen((const char*)className); |
if(len != 0) |
} |
{ |
|
|
|
// copy including trailing '\0' | // copy including trailing '\0' |
|
// _setBinary also sets the name to 0 if either className==0 or len+1==1 |
_setBinary(className,len+1,inst.hdr->instClassName,&inst.mem); | _setBinary(className,len+1,inst.hdr->instClassName,&inst.mem); |
return; |
|
} |
|
|
|
} | } |
| |
inst.hdr->instClassName.start=0; |
void SCMOInstance::setClassName_l(const char* className, Uint64 len) |
inst.hdr->instClassName.length=0; |
{ |
|
_copyOnWrite(); |
| |
// flag the instance as compromized |
// flag the instance as compromised |
inst.hdr->flags.isCompromised=true; | inst.hdr->flags.isCompromised=true; |
|
// copy including trailing '\0' |
|
// _setBinary also sets the name to 0 if either className==0 or len+1==1 |
|
_setBinary(className,len+1,inst.hdr->instClassName,&inst.mem); |
} | } |
| |
const char* SCMOInstance::getClassName() const | const char* SCMOInstance::getClassName() const |
|
|
| |
const char* SCMOInstance::getClassName_l(Uint64 & length) const | const char* SCMOInstance::getClassName_l(Uint64 & length) const |
{ | { |
length = inst.hdr->instClassName.length; |
length = inst.hdr->instClassName.size; |
|
if (0 == length) |
|
{ |
|
return 0; |
|
} |
|
else |
|
{ |
|
length--; |
|
} |
return _getCharString(inst.hdr->instClassName,inst.base); | return _getCharString(inst.hdr->instClassName,inst.base); |
} | } |
| |
void SCMOInstance::setNameSpace(const char* nameSpace) | void SCMOInstance::setNameSpace(const char* nameSpace) |
{ | { |
Uint32 len; |
Uint32 len = 0; |
|
|
|
_copyOnWrite(); |
|
|
|
// flag the instance as compromized |
|
inst.hdr->flags.isCompromised=true; |
| |
if (nameSpace!=0) | if (nameSpace!=0) |
{ | { |
| |
len = strlen((const char*)nameSpace); | len = strlen((const char*)nameSpace); |
if(len != 0) |
} |
{ |
|
|
|
// copy including trailing '\0' | // copy including trailing '\0' |
_setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem); | _setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem); |
return; |
|
} | } |
| |
|
void SCMOInstance::setNameSpace_l(const char* nameSpace, Uint64 len) |
|
{ |
|
// Copy on Write is only necessary if a realloc() becomes necessary |
|
if (inst.mem->freeBytes < len) |
|
{ |
|
_copyOnWrite(); |
} | } |
|
|
inst.hdr->instNameSpace.start=0; |
|
inst.hdr->instNameSpace.length=0; |
|
|
|
// flag the instance as compromized | // flag the instance as compromized |
inst.hdr->flags.isCompromised=true; | inst.hdr->flags.isCompromised=true; |
|
// copy including trailing '\0' |
|
_setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem); |
} | } |
| |
const char* SCMOInstance::getNameSpace() const | const char* SCMOInstance::getNameSpace() const |
|
|
| |
const char* SCMOInstance::getNameSpace_l(Uint64 & length) const | const char* SCMOInstance::getNameSpace_l(Uint64 & length) const |
{ | { |
length = inst.hdr->instNameSpace.length; |
length = inst.hdr->instNameSpace.size; |
|
if (0 == length) |
|
{ |
|
return 0; |
|
} |
|
else |
|
{ |
|
length--; |
|
} |
return _getCharString(inst.hdr->instNameSpace,inst.base); | return _getCharString(inst.hdr->instNameSpace,inst.base); |
} | } |
| |
void SCMOInstance::buildKeyBindingsFromProperties() | void SCMOInstance::buildKeyBindingsFromProperties() |
{ | { |
|
|
Uint32* theClassKeyPropList = | Uint32* theClassKeyPropList = |
(Uint32*) &((inst.hdr->theClass->cls.base) | (Uint32*) &((inst.hdr->theClass->cls.base) |
[(inst.hdr->theClass->cls.hdr->keyIndexList.start)]); | [(inst.hdr->theClass->cls.hdr->keyIndexList.start)]); |
|
|
// because in _setKeyBindingFromSCMBUnion() | // because in _setKeyBindingFromSCMBUnion() |
// a reallocation can take place. | // a reallocation can take place. |
theKeyBindValueArray = | theKeyBindValueArray = |
(SCMBKeyBindingValue*)&inst.base[inst.hdr->keyBindingArray.start]; |
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
| |
theInstPropNodeArray = | theInstPropNodeArray = |
(SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; | (SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; |
|
|
// get the node index for this key binding form class | // get the node index for this key binding form class |
propNode = theClassKeyPropList[i]; | propNode = theClassKeyPropList[i]; |
| |
// if property was not set by the provider or it is null. |
// if property was set by the provider and it is not null. |
if (!theInstPropNodeArray[propNode].flags.isSet || |
if ( theInstPropNodeArray[propNode].flags.isSet && |
theInstPropNodeArray[propNode].flags.isNull) |
!theInstPropNodeArray[propNode].flags.isNull) |
{ |
{ |
const char * propName = |
_copyOnWrite(); |
inst.hdr->theClass->_getPropertyNameAtNode(propNode); |
|
throw NoSuchProperty(String(propName)); |
|
} |
|
| |
_setKeyBindingFromSCMBUnion( | _setKeyBindingFromSCMBUnion( |
theInstPropNodeArray[propNode].valueType, | theInstPropNodeArray[propNode].valueType, |
|
|
} | } |
} | } |
} | } |
|
} |
| |
void SCMOInstance::_setKeyBindingFromSCMBUnion( | void SCMOInstance::_setKeyBindingFromSCMBUnion( |
CIMType type, | CIMType type, |
|
|
case CIMTYPE_REAL64: | case CIMTYPE_REAL64: |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
|
{ |
|
memcpy(&keyData.data,&u,sizeof(SCMBUnion)); |
|
keyData.data.simple.hasValue=true; |
|
keyData.isSet=true; |
|
break; |
|
} |
case CIMTYPE_DATETIME: | case CIMTYPE_DATETIME: |
{ | { |
memcpy(&keyData.data,&u,sizeof(SCMBUnion)); | memcpy(&keyData.data,&u,sizeof(SCMBUnion)); |
|
|
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
keyData.isSet=true; | keyData.isSet=true; |
|
// Check if a key binding is set with in the same instance. |
|
// If this is the case, a reallocation can take place and the |
|
// uBase pointer can be invalid and cause a read in freed memory! |
|
if (uBase == inst.base) |
|
{ |
|
if (0 != u.stringValue.size ) |
|
{ |
|
// We are doing a in instance copy of data. |
|
// We can not use the _setBinary() function because |
|
// all real pointer can be in valid after |
|
// the _getFreeSprace() function! |
|
// We have to save all relative pointer on the stack. |
|
Uint64 start; |
|
SCMBDataPtr tmp; |
|
tmp.size = u.stringValue.size; |
|
tmp.start = u.stringValue.start; |
|
|
|
// In this function a reallocation may take place! |
|
// The keyData.data.stringValue is set |
|
// before the rallocation. |
|
start = _getFreeSpace( |
|
keyData.data.stringValue, |
|
u.stringValue.size, |
|
&inst.mem); |
|
// Copy the string, |
|
// but using the own base pointer and the saved relative |
|
// string pointer. |
|
memcpy( |
|
&(inst.base[start]), |
|
_getCharString(tmp,inst.base), |
|
tmp.size); |
|
} |
|
else |
|
{ |
|
keyData.data.stringValue.size=0; |
|
keyData.data.stringValue.start=0; |
|
} |
|
|
|
} |
|
else |
|
{ |
_setBinary( | _setBinary( |
&uBase[u.stringValue.start], | &uBase[u.stringValue.start], |
u.stringValue.length, |
u.stringValue.size, |
keyData.data.stringValue, | keyData.data.stringValue, |
&inst.mem); | &inst.mem); |
|
} |
|
|
break; | break; |
} | } |
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
|
|
if(u.extRefPtr) | if(u.extRefPtr) |
{ | { |
keyData.data.extRefPtr = new SCMOInstance(*u.extRefPtr); | keyData.data.extRefPtr = new SCMOInstance(*u.extRefPtr); |
|
keyData.isSet=true; |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(&(keyData.data),&inst.mem); |
} | } |
else | else |
{ | { |
|
keyData.isSet=true; |
keyData.data.extRefPtr=0; | keyData.data.extRefPtr=0; |
} | } |
keyData.isSet=true; |
|
break; | break; |
} | } |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
|
|
_setBinary( | _setBinary( |
_getCharString(inst.hdr->theClass->cls.hdr->className, | _getCharString(inst.hdr->theClass->cls.hdr->className, |
inst.hdr->theClass->cls.base), | inst.hdr->theClass->cls.base), |
inst.hdr->theClass->cls.hdr->className.length, |
inst.hdr->theClass->cls.hdr->className.size, |
inst.hdr->instClassName, | inst.hdr->instClassName, |
&inst.mem); | &inst.mem); |
| |
_setBinary( | _setBinary( |
_getCharString(inst.hdr->theClass->cls.hdr->nameSpace, | _getCharString(inst.hdr->theClass->cls.hdr->nameSpace, |
inst.hdr->theClass->cls.base), | inst.hdr->theClass->cls.base), |
inst.hdr->theClass->cls.hdr->nameSpace.length, |
inst.hdr->theClass->cls.hdr->nameSpace.size, |
inst.hdr->instNameSpace, | inst.hdr->instNameSpace, |
&inst.mem); | &inst.mem); |
| |
|
|
_getFreeSpace( | _getFreeSpace( |
inst.hdr->keyBindingArray, | inst.hdr->keyBindingArray, |
sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings, | sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings, |
&inst.mem, |
&inst.mem); |
true); |
|
| |
// Allocate the SCMBInstancePropertyArray | // Allocate the SCMBInstancePropertyArray |
_getFreeSpace( | _getFreeSpace( |
inst.hdr->propertyArray, | inst.hdr->propertyArray, |
sizeof(SCMBValue)*inst.hdr->numberProperties, | sizeof(SCMBValue)*inst.hdr->numberProperties, |
&inst.mem, |
&inst.mem); |
true); |
|
| |
} | } |
| |
|
|
{ | { |
CIMPropertyRep* propRep; | CIMPropertyRep* propRep; |
Uint32 propNode; | Uint32 propNode; |
Uint64 valueStart; |
|
SCMO_RC rc; | SCMO_RC rc; |
CIMType realType; | CIMType realType; |
| |
|
|
return _getPropertyAtNodeIndex(node,pname,type,pOutVal,isArray,size); | return _getPropertyAtNodeIndex(node,pname,type,pOutVal,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 SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const |
{ | { |
SCMO_RC rc; | SCMO_RC rc; |
|
|
Uint32 size, | Uint32 size, |
const char* origin) | const char* origin) |
{ | { |
|
// In this function no _copyOnWrite(), it does not change the instance. |
|
|
Uint32 node; | Uint32 node; |
SCMO_RC rc; | SCMO_RC rc; |
CIMType realType; | CIMType realType; |
|
|
Boolean isArray, | Boolean isArray, |
Uint32 size) | Uint32 size) |
{ | { |
|
// In this function no _copyOnWrite(), it does not change the instance. |
|
|
SCMO_RC rc; | SCMO_RC rc; |
CIMType realType; | CIMType realType; |
| |
|
|
Boolean isArray, | Boolean isArray, |
Uint32 size) | Uint32 size) |
{ | { |
|
|
|
_copyOnWrite(); |
|
|
SCMBValue* theInstPropNodeArray = | SCMBValue* theInstPropNodeArray = |
(SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]); | (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]); |
| |
|
|
case CIMTYPE_REAL32: | case CIMTYPE_REAL32: |
case CIMTYPE_REAL64: | case CIMTYPE_REAL64: |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(pInVal,size*sizeof(SCMBUnion), |
|
u.arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
memcpy(&u,pInVal,sizeof(SCMBUnion)); |
|
u.simple.hasValue=true; |
|
} |
|
break; |
|
} |
case CIMTYPE_DATETIME: | case CIMTYPE_DATETIME: |
{ | { |
if (isArray) | if (isArray) |
|
|
else | else |
{ | { |
memcpy(&u,pInVal,sizeof(SCMBUnion)); | memcpy(&u,pInVal,sizeof(SCMBUnion)); |
|
|
} | } |
break; | break; |
} | } |
|
|
startPtr = _getFreeSpace( | startPtr = _getFreeSpace( |
u.arrayValue, | u.arrayValue, |
size*sizeof(SCMBUnion), | size*sizeof(SCMBUnion), |
&inst.mem,true); |
&inst.mem); |
| |
for (Uint32 i = 0; i < size; i++) | for (Uint32 i = 0; i < size; i++) |
{ | { |
|
|
startPtr = _getFreeSpace( | startPtr = _getFreeSpace( |
u.arrayValue, | u.arrayValue, |
size*sizeof(SCMBUnion), | size*sizeof(SCMBUnion), |
&inst.mem,false); |
&inst.mem); |
| |
ptr = (SCMBUnion*)&(inst.base[startPtr]); | ptr = (SCMBUnion*)&(inst.base[startPtr]); |
| |
|
|
{ | { |
ptr[i].extRefPtr= | ptr[i].extRefPtr= |
new SCMOInstance(*(pInVal[i].extRefPtr)); | new SCMOInstance(*(pInVal[i].extRefPtr)); |
|
|
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(&(ptr[i]),&inst.mem); |
} | } |
else | else |
{ | { |
|
|
if(pInVal->extRefPtr) | if(pInVal->extRefPtr) |
{ | { |
u.extRefPtr = new SCMOInstance(*(pInVal->extRefPtr)); | u.extRefPtr = new SCMOInstance(*(pInVal->extRefPtr)); |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(&u,&inst.mem); |
|
|
} | } |
else | else |
{ | { |
|
|
CIMType type, | CIMType type, |
Uint32& n, | Uint32& n, |
Uint64 startNS, | Uint64 startNS, |
Uint64 lenNS, |
Uint64 sizeNS, |
Union& u) | Union& u) |
{ | { |
SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); | SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Boolean> iterator(*x); | ConstArrayIterator<Boolean> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Uint8> iterator(*x); | ConstArrayIterator<Uint8> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Sint8> iterator(*x); | ConstArrayIterator<Sint8> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Uint16> iterator(*x); | ConstArrayIterator<Uint16> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Sint16> iterator(*x); | ConstArrayIterator<Sint16> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Uint32> iterator(*x); | ConstArrayIterator<Uint32> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Sint32> iterator(*x); | ConstArrayIterator<Sint32> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Uint64> iterator(*x); | ConstArrayIterator<Uint64> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Sint64> iterator(*x); | ConstArrayIterator<Sint64> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Real32> iterator(*x); | ConstArrayIterator<Real32> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Real64> iterator(*x); | ConstArrayIterator<Real64> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Char16> iterator(*x); | ConstArrayIterator<Char16> iterator(*x); |
| |
|
|
| |
ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); | ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); |
| |
SCMOClass* theRefClass; |
|
|
|
for (Uint32 i = 0; i < loop ; i++) | for (Uint32 i = 0; i < loop ; i++) |
{ | { |
| |
theRefClass = _getSCMOClass( |
ptargetUnion[i].extRefPtr = |
|
new SCMOInstance( |
iterator[i], | iterator[i], |
&(((const char*)*pmem)[startNS]), | &(((const char*)*pmem)[startNS]), |
lenNS); |
sizeNS-1); |
|
// Was the conversion successful? |
if (theRefClass != 0) |
if (ptargetUnion[i].extRefPtr->isEmpty()) |
{ |
|
ptargetUnion[i].extRefPtr = |
|
new SCMOInstance(*theRefClass,iterator[i]); |
|
} else |
|
{ | { |
//There is no reference class for the object path |
// N0, delete the SCMOInstance. |
|
delete ptargetUnion[i].extRefPtr; |
ptargetUnion[i].extRefPtr = 0; | ptargetUnion[i].extRefPtr = 0; |
} | } |
|
else |
|
{ |
|
_setExtRefIndex(&(ptargetUnion[i]),pmem); |
|
} |
} | } |
| |
break; | break; |
|
|
| |
ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); | ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); |
| |
SCMOClass* theRefClass; |
|
|
|
for (Uint32 i = 0; i < loop ; i++) | for (Uint32 i = 0; i < loop ; i++) |
{ | { |
if (iterator[i].isUninitialized()) | if (iterator[i].isUninitialized()) |
|
|
if (iterator[i].isClass()) | if (iterator[i].isClass()) |
{ | { |
CIMClass theClass(iterator[i]); | CIMClass theClass(iterator[i]); |
ptargetUnion[i].extRefPtr = new SCMOInstance(theClass); |
|
|
ptargetUnion[i].extRefPtr = |
|
new SCMOInstance( |
|
theClass, |
|
(&((const char*)*pmem)[startNS])); |
// marke as class only ! | // marke as class only ! |
ptargetUnion[i].extRefPtr-> | ptargetUnion[i].extRefPtr-> |
inst.hdr->flags.isClassOnly=true; | inst.hdr->flags.isClassOnly=true; |
|
|
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(&(ptargetUnion[i]),pmem); |
} | } |
else | else |
{ | { |
CIMInstance theInst(iterator[i]); | CIMInstance theInst(iterator[i]); |
theRefClass = _getSCMOClass( |
|
theInst.getPath(), |
|
&(((const char*)*pmem)[startNS]), |
|
lenNS); |
|
| |
if (theRefClass != 0) |
|
{ |
|
ptargetUnion[i].extRefPtr = | ptargetUnion[i].extRefPtr = |
new SCMOInstance(*theRefClass,theInst); |
new SCMOInstance( |
} else |
theInst, |
|
&(((const char*)*pmem)[startNS]), |
|
sizeNS-1); |
|
// Was the conversion successful? |
|
if (ptargetUnion[i].extRefPtr->isEmpty()) |
{ | { |
//There is no reference class for the object path |
// N0, delete the SCMOInstance. |
|
delete ptargetUnion[i].extRefPtr; |
ptargetUnion[i].extRefPtr = 0; | ptargetUnion[i].extRefPtr = 0; |
} | } |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(&(ptargetUnion[i]),pmem); |
|
} |
} | } |
} | } |
} | } |
|
|
| |
ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); | ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); |
| |
SCMOClass* theRefClass; |
|
|
|
for (Uint32 i = 0; i < loop ; i++) | for (Uint32 i = 0; i < loop ; i++) |
{ | { |
if (iterator[i].isUninitialized()) | if (iterator[i].isUninitialized()) |
|
|
} | } |
else | else |
{ | { |
theRefClass = _getSCMOClass( |
|
iterator[i].getPath(), |
|
&(((const char*)*pmem)[startNS]), |
|
lenNS); |
|
|
|
|
|
if (theRefClass != 0) |
|
{ |
|
ptargetUnion[i].extRefPtr = | ptargetUnion[i].extRefPtr = |
new SCMOInstance(*theRefClass,iterator[i]); |
new SCMOInstance( |
} else |
iterator[i], |
|
&(((const char*)*pmem)[startNS]), |
|
sizeNS-1); |
|
// Was the conversion successful? |
|
if (ptargetUnion[i].extRefPtr->isEmpty()) |
{ | { |
//There is no reference class for the object path |
// N0, delete the SCMOInstance. |
|
delete ptargetUnion[i].extRefPtr; |
ptargetUnion[i].extRefPtr = 0; | ptargetUnion[i].extRefPtr = 0; |
} | } |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(&(ptargetUnion[i]),pmem); |
|
} |
|
|
} | } |
} | } |
| |
|
|
SCMBMgmt_Header** pmem, | SCMBMgmt_Header** pmem, |
CIMType type, | CIMType type, |
Uint64 startNS, | Uint64 startNS, |
Uint64 lenNS, |
Uint64 sizeNS, |
Union& u) | Union& u) |
{ | { |
SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); | SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); |
|
|
CIMObjectPath* theCIMObj = | CIMObjectPath* theCIMObj = |
(CIMObjectPath*)((void*)&u._referenceValue); | (CIMObjectPath*)((void*)&u._referenceValue); |
| |
SCMOClass* theRefClass = _getSCMOClass( |
scmoUnion->extRefPtr = |
|
new SCMOInstance( |
*theCIMObj, | *theCIMObj, |
&(((const char*)*pmem)[startNS]), | &(((const char*)*pmem)[startNS]), |
lenNS); |
sizeNS-1); |
| |
if (theRefClass != 0) |
// Was the conversion successful? |
|
if (scmoUnion->extRefPtr->isEmpty()) |
{ | { |
scmoUnion->extRefPtr = |
// N0, delete the SCMOInstance. |
new SCMOInstance(*theRefClass,*theCIMObj); |
delete scmoUnion->extRefPtr; |
} else |
|
{ |
|
//There is no reference class for the object path |
|
scmoUnion->extRefPtr = 0; | scmoUnion->extRefPtr = 0; |
} | } |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(scmoUnion,pmem); |
|
} |
|
|
break; | break; |
} | } |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
|
|
} | } |
| |
CIMObject* theCIMObject =(CIMObject*)((void*)&u._objectValue); | CIMObject* theCIMObject =(CIMObject*)((void*)&u._objectValue); |
SCMOClass* theRefClass; |
|
| |
if (theCIMObject->isUninitialized()) | if (theCIMObject->isUninitialized()) |
{ | { |
|
|
if (theCIMObject->isClass()) | if (theCIMObject->isClass()) |
{ | { |
CIMClass theClass(*theCIMObject); | CIMClass theClass(*theCIMObject); |
scmoUnion->extRefPtr = new SCMOInstance(theClass); |
|
|
scmoUnion->extRefPtr = |
|
new SCMOInstance( |
|
theClass, |
|
(&((const char*)*pmem)[startNS])); |
// marke as class only ! | // marke as class only ! |
scmoUnion->extRefPtr->inst.hdr->flags.isClassOnly=true; | scmoUnion->extRefPtr->inst.hdr->flags.isClassOnly=true; |
|
|
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(scmoUnion,pmem); |
} | } |
else | else |
{ | { |
CIMInstance theInst(*theCIMObject); |
CIMInstance theCIMInst(*theCIMObject); |
theRefClass = _getSCMOClass( |
|
theInst.getPath(), |
|
&(((const char*)*pmem)[startNS]), |
|
lenNS); |
|
| |
if (theRefClass != 0) |
|
{ |
|
scmoUnion->extRefPtr = | scmoUnion->extRefPtr = |
new SCMOInstance(*theRefClass,theInst); |
new SCMOInstance( |
} else |
theCIMInst, |
|
&(((const char*)*pmem)[startNS]), |
|
sizeNS-1); |
|
|
|
// Was the conversion successful? |
|
if (scmoUnion->extRefPtr->isEmpty()) |
{ | { |
//There is no reference class for the object path |
// N0, delete the SCMOInstance. |
|
delete scmoUnion->extRefPtr; |
scmoUnion->extRefPtr = 0; | scmoUnion->extRefPtr = 0; |
} | } |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(scmoUnion,pmem); |
|
} |
} | } |
} | } |
break; | break; |
|
|
} | } |
else | else |
{ | { |
SCMOClass* theRefClass = _getSCMOClass( |
|
theCIMInst->getPath(), |
|
&(((const char*)*pmem)[startNS]), |
|
lenNS); |
|
if (theRefClass != 0) |
|
{ |
|
scmoUnion->extRefPtr = | scmoUnion->extRefPtr = |
new SCMOInstance(*theRefClass,*theCIMInst); |
new SCMOInstance( |
} else |
*theCIMInst, |
|
&(((const char*)*pmem)[startNS]), |
|
sizeNS-1); |
|
|
|
// Was the conversion successful? |
|
if (scmoUnion->extRefPtr->isEmpty()) |
{ | { |
//There is no reference class for the object path |
// N0, delete the SCMOInstance. |
|
delete scmoUnion->extRefPtr; |
scmoUnion->extRefPtr = 0; | scmoUnion->extRefPtr = 0; |
} | } |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(scmoUnion,pmem); |
|
} |
} | } |
break; | break; |
} | } |
|
|
// Copy the host name to tha new instance- | // Copy the host name to tha new instance- |
_setBinary( | _setBinary( |
_resolveDataPtr(this->inst.hdr->hostName,this->inst.base), | _resolveDataPtr(this->inst.hdr->hostName,this->inst.base), |
this->inst.hdr->hostName.length, |
this->inst.hdr->hostName.size, |
newInst.inst.hdr->hostName, | newInst.inst.hdr->hostName, |
&newInst.inst.mem); | &newInst.inst.mem); |
| |
|
newInst.inst.hdr->flags.isCompromised = |
|
this->inst.hdr->flags.isCompromised; |
|
|
|
// If the instance contains a user set class and/or name space name |
|
if (this->inst.hdr->flags.isCompromised) |
|
{ |
|
// Copy the class name to tha new instance- |
|
_setBinary( |
|
_resolveDataPtr(this->inst.hdr->instClassName,this->inst.base), |
|
this->inst.hdr->instClassName.size, |
|
newInst.inst.hdr->instClassName, |
|
&newInst.inst.mem); |
|
|
|
// Copy the name space name to tha new instance- |
|
_setBinary( |
|
_resolveDataPtr(this->inst.hdr->instNameSpace,this->inst.base), |
|
this->inst.hdr->instNameSpace.size, |
|
newInst.inst.hdr->instNameSpace, |
|
&newInst.inst.mem); |
|
} |
|
|
// Copy the key bindings to that new instance. | // Copy the key bindings to that new instance. |
this->_copyKeyBindings(newInst); | this->_copyKeyBindings(newInst); |
| |
|
|
} | } |
| |
SCMOInstance newInst; | SCMOInstance newInst; |
newInst.inst.base = (char*)malloc(this->inst.mem->totalSize); |
newInst.inst.base = inst.base; |
if (newInst.inst.base == 0 ) |
newInst._clone(); |
|
|
|
return newInst; |
|
} |
|
|
|
void SCMOInstance::_clone() |
|
{ |
|
char* newBase; |
|
newBase = (char*)malloc(inst.mem->totalSize); |
|
if (0 == newBase ) |
{ | { |
throw PEGASUS_STD(bad_alloc)(); | throw PEGASUS_STD(bad_alloc)(); |
} | } |
| |
memcpy( newInst.inst.base,this->inst.base,this->inst.mem->totalSize); |
memcpy( newBase,inst.base,inst.mem->totalSize); |
// reset the refcounter of this new instance |
|
newInst.inst.hdr->refCount = 1; |
// make new new memory block to mine. |
|
inst.base = newBase; |
|
// reset the refcounter of this instance |
|
inst.hdr->refCount = 1; |
// keep the ref counter of the class correct ! | // keep the ref counter of the class correct ! |
newInst.inst.hdr->theClass = new SCMOClass(*(this->inst.hdr->theClass)); |
inst.hdr->theClass = new SCMOClass(*(inst.hdr->theClass)); |
// keep the ref count for external references | // keep the ref count for external references |
newInst._copyExternalReferences(); |
_copyExternalReferences(); |
| |
return newInst; |
|
} | } |
| |
void SCMOInstance::_copyKeyBindings(SCMOInstance& targetInst) const | void SCMOInstance::_copyKeyBindings(SCMOInstance& targetInst) const |
|
|
} | } |
| |
// Are there user defined key bindings ? | // Are there user defined key bindings ? |
if (0 != inst.hdr->numberUserKeyBindindigs) |
if (0 != inst.hdr->numberUserKeyBindings) |
{ | { |
SCMBUserKeyBindingElement* theUserDefKBElement = | SCMBUserKeyBindingElement* theUserDefKBElement = |
(SCMBUserKeyBindingElement*) | (SCMBUserKeyBindingElement*) |
&(inst.base[inst.hdr->userKeyBindingElement.start]); | &(inst.base[inst.hdr->userKeyBindingElement.start]); |
| |
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; i++) |
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindings; i++) |
{ | { |
if (theUserDefKBElement->value.isSet) | if (theUserDefKBElement->value.isSet) |
{ | { |
|
|
ptrNewElement = _getUserDefinedKeyBinding( | ptrNewElement = _getUserDefinedKeyBinding( |
_getCharString(theInsertElement.name,elementBase), | _getCharString(theInsertElement.name,elementBase), |
// lenght is without the trailing '\0' | // lenght is without the trailing '\0' |
theInsertElement.name.length-1, |
theInsertElement.name.size-1, |
theInsertElement.type); | theInsertElement.type); |
| |
// Copy the data | // Copy the data |
|
|
// to the next element of the new element. | // to the next element of the new element. |
ptrNewElement->nextElement.start = | ptrNewElement->nextElement.start = |
inst.hdr->userKeyBindingElement.start; | inst.hdr->userKeyBindingElement.start; |
ptrNewElement->nextElement.length = |
ptrNewElement->nextElement.size = |
inst.hdr->userKeyBindingElement.length; |
inst.hdr->userKeyBindingElement.size; |
// - Assing the the new element | // - Assing the the new element |
// to the start point of user key binding element chain | // to the start point of user key binding element chain |
inst.hdr->userKeyBindingElement.start = newElement.start; | inst.hdr->userKeyBindingElement.start = newElement.start; |
inst.hdr->userKeyBindingElement.length = newElement.length; |
inst.hdr->userKeyBindingElement.size = newElement.size; |
// Adjust the couter of user defined key bindings. | // Adjust the couter of user defined key bindings. |
inst.hdr->numberUserKeyBindindigs++; |
inst.hdr->numberUserKeyBindings++; |
| |
| |
// Copy the type | // Copy the type |
|
|
ptr[i].extString.pchar = | ptr[i].extString.pchar = |
(char*)_getCharString(av[i].stringValue,base); | (char*)_getCharString(av[i].stringValue,base); |
// lenght with out the trailing /0 ! | // lenght with out the trailing /0 ! |
ptr[i].extString.length = av[i].stringValue.length-1; |
ptr[i].extString.length = av[i].stringValue.size-1; |
} | } |
} | } |
else | else |
|
|
ptr->extString.pchar = | ptr->extString.pchar = |
(char*)_getCharString(u->stringValue,base); | (char*)_getCharString(u->stringValue,base); |
// lenght with out the trailing /0 ! | // lenght with out the trailing /0 ! |
ptr->extString.length = u->stringValue.length-1; |
ptr->extString.length = u->stringValue.size-1; |
} | } |
| |
return(ptr); | return(ptr); |
|
|
return 0; | return 0; |
} | } |
| |
|
void SCMOInstance::clearKeyBindings() |
|
{ |
|
_copyOnWrite(); |
|
|
|
// First destroy all external references in the key bindings |
|
_destroyExternalKeyBindings(); |
|
|
|
// reset user keybindings |
|
inst.hdr->numberUserKeyBindings = 0; |
|
inst.hdr->userKeyBindingElement.start = 0; |
|
inst.hdr->userKeyBindingElement.size = 0; |
|
|
|
// Allocate a clean the SCMOInstanceKeyBindingArray |
|
_getFreeSpace( |
|
inst.hdr->keyBindingArray, |
|
sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings, |
|
&inst.mem); |
|
} |
|
|
Uint32 SCMOInstance::getKeyBindingCount() const | Uint32 SCMOInstance::getKeyBindingCount() const |
{ | { |
// count of class keys + user definded keys | // count of class keys + user definded keys |
return(inst.hdr->numberKeyBindings+ | return(inst.hdr->numberKeyBindings+ |
inst.hdr->numberUserKeyBindindigs); |
inst.hdr->numberUserKeyBindings); |
} | } |
| |
| |
|
|
| |
// count of class keys + user definded keys | // count of class keys + user definded keys |
if (node >= (inst.hdr->numberKeyBindings+ | if (node >= (inst.hdr->numberKeyBindings+ |
inst.hdr->numberUserKeyBindindigs)) |
inst.hdr->numberUserKeyBindings)) |
{ | { |
return SCMO_INDEX_OUT_OF_BOUND; | return SCMO_INDEX_OUT_OF_BOUND; |
} | } |
|
|
type = theClassKeyBindNodeArray[node].type; | type = theClassKeyBindNodeArray[node].type; |
| |
// First resolve pointer to the key binding name | // First resolve pointer to the key binding name |
pnameLen = theClassKeyBindNodeArray[node].name.length; |
pnameLen = theClassKeyBindNodeArray[node].name.size; |
*pname = _getCharString( | *pname = _getCharString( |
theClassKeyBindNodeArray[node].name, | theClassKeyBindNodeArray[node].name, |
inst.hdr->theClass->cls.base); | inst.hdr->theClass->cls.base); |
|
|
| |
type = theElem->type; | type = theElem->type; |
| |
pnameLen = theElem->name.length; |
pnameLen = theElem->name.size; |
*pname = _getCharString(theElem->name,inst.base); | *pname = _getCharString(theElem->name,inst.base); |
| |
// There is no value set in the instance | // There is no value set in the instance |
|
|
| |
Uint32 len = strlen(name); | Uint32 len = strlen(name); |
node = 0; | node = 0; |
SCMBUserKeyBindingElement* theUserDefKBElement; |
|
| |
Uint64 elementStart = inst.hdr->userKeyBindingElement.start; | Uint64 elementStart = inst.hdr->userKeyBindingElement.start; |
| |
|
|
SCMBUserKeyBindingElement* theUserDefKBElement = | SCMBUserKeyBindingElement* theUserDefKBElement = |
(SCMBUserKeyBindingElement*)&(inst.base[elementStart]); | (SCMBUserKeyBindingElement*)&(inst.base[elementStart]); |
| |
if (_equalUTF8Strings(theUserDefKBElement->name,inst.base,name,len)) |
if (_equalNoCaseUTF8Strings( |
|
theUserDefKBElement->name,inst.base,name,len)) |
{ | { |
// the node index of a user defined key binding has an offset | // the node index of a user defined key binding has an offset |
// by the number of key bindings defined in the class | // by the number of key bindings defined in the class |
|
|
) | ) |
{ | { |
scmoKBV.isSet=false; | scmoKBV.isSet=false; |
|
// If it not a simple value, it will be over written. |
|
scmoKBV.data.simple.hasValue=false; |
| |
if ( kbs.size() == 0 && type != CIMTYPE_STRING) | if ( kbs.size() == 0 && type != CIMTYPE_STRING) |
{ | { |
|
|
StringConversion::checkUintBounds(x, type)) | StringConversion::checkUintBounds(x, type)) |
{ | { |
scmoKBV.data.simple.val.u8 = Uint8(x); | scmoKBV.data.simple.val.u8 = Uint8(x); |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
StringConversion::checkUintBounds(x, type)) | StringConversion::checkUintBounds(x, type)) |
{ | { |
scmoKBV.data.simple.val.u16 = Uint16(x); | scmoKBV.data.simple.val.u16 = Uint16(x); |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
StringConversion::checkUintBounds(x, type)) | StringConversion::checkUintBounds(x, type)) |
{ | { |
scmoKBV.data.simple.val.u32 = Uint32(x); | scmoKBV.data.simple.val.u32 = Uint32(x); |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (StringConversion::stringToUnsignedInteger(v, x)) | if (StringConversion::stringToUnsignedInteger(v, x)) |
{ | { |
scmoKBV.data.simple.val.u64 = x; | scmoKBV.data.simple.val.u64 = x; |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
StringConversion::checkSintBounds(x, type)) | StringConversion::checkSintBounds(x, type)) |
{ | { |
scmoKBV.data.simple.val.s8 = Sint8(x); | scmoKBV.data.simple.val.s8 = Sint8(x); |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
StringConversion::checkSintBounds(x, type)) | StringConversion::checkSintBounds(x, type)) |
{ | { |
scmoKBV.data.simple.val.s16 = Sint16(x); | scmoKBV.data.simple.val.s16 = Sint16(x); |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
StringConversion::checkSintBounds(x, type)) | StringConversion::checkSintBounds(x, type)) |
{ | { |
scmoKBV.data.simple.val.s32 = Sint32(x); | scmoKBV.data.simple.val.s32 = Sint32(x); |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (StringConversion::stringToSignedInteger(v, x)) | if (StringConversion::stringToSignedInteger(v, x)) |
{ | { |
scmoKBV.data.simple.val.s64 = x; | scmoKBV.data.simple.val.s64 = x; |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (StringConversion::stringToReal64(v, x)) | if (StringConversion::stringToReal64(v, x)) |
{ | { |
scmoKBV.data.simple.val.r32 = Real32(x); | scmoKBV.data.simple.val.r32 = Real32(x); |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (StringConversion::stringToReal64(v, x)) | if (StringConversion::stringToReal64(v, x)) |
{ | { |
scmoKBV.data.simple.val.r64 = x; | scmoKBV.data.simple.val.r64 = x; |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (kbs.size() == 1) | if (kbs.size() == 1) |
{ | { |
scmoKBV.data.simple.val.c16 = kbs[0]; | scmoKBV.data.simple.val.c16 = kbs[0]; |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (String::equalNoCase(kbs,"TRUE")) | if (String::equalNoCase(kbs,"TRUE")) |
{ | { |
scmoKBV.data.simple.val.bin = true; | scmoKBV.data.simple.val.bin = true; |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
else if (String::equalNoCase(kbs,"FALSE")) | else if (String::equalNoCase(kbs,"FALSE")) |
{ | { |
scmoKBV.data.simple.val.bin = false; | scmoKBV.data.simple.val.bin = false; |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
} | } |
// TBD: Optimize parsing and SCMOInstance creation. | // TBD: Optimize parsing and SCMOInstance creation. |
CIMObjectPath theCIMObj(kbs); | CIMObjectPath theCIMObj(kbs); |
SCMOClass* theRefClass = _getSCMOClass( |
|
theCIMObj, |
|
_getCharString(inst.hdr->instNameSpace,inst.base), |
|
inst.hdr->instNameSpace.length); |
|
| |
if (theRefClass != 0) |
scmoKBV.data.extRefPtr = new SCMOInstance(theCIMObj); |
{ |
scmoKBV.isSet=true; |
scmoKBV.data.extRefPtr = |
|
new SCMOInstance(*theRefClass,theCIMObj); |
// Was the conversion successful? |
} else |
if (scmoKBV.data.extRefPtr->isEmpty()) |
{ | { |
|
// N0, delete the SCMOInstance. |
|
delete scmoKBV.data.extRefPtr; |
scmoKBV.data.extRefPtr = 0; | scmoKBV.data.extRefPtr = 0; |
|
scmoKBV.isSet=false; |
|
} |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(&(scmoKBV.data),&inst.mem); |
} | } |
scmoKBV.isSet=true; |
|
break; | break; |
} | } |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
|
|
CIMType type, | CIMType type, |
String cimKeyBinding) | String cimKeyBinding) |
{ | { |
SCMO_RC rc; |
|
Uint32 node; | Uint32 node; |
| |
if (0 == name) | if (0 == name) |
|
|
return SCMO_INVALID_PARAMETER; | return SCMO_INVALID_PARAMETER; |
} | } |
| |
|
_copyOnWrite(); |
|
|
rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); | rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); |
if (rc != SCMO_OK) | if (rc != SCMO_OK) |
{ | { |
|
|
CIMType type, | CIMType type, |
const SCMBUnion* keyvalue) | const SCMBUnion* keyvalue) |
{ | { |
SCMO_RC rc; |
|
|
|
// 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]); |
|
|
|
if (0 == keyvalue) | if (0 == keyvalue) |
{ | { |
return SCMO_INVALID_PARAMETER; | return SCMO_INVALID_PARAMETER; |
|
|
| |
// count of class keys + user definded keys | // count of class keys + user definded keys |
if (node >= (inst.hdr->numberKeyBindings+ | if (node >= (inst.hdr->numberKeyBindings+ |
inst.hdr->numberUserKeyBindindigs)) |
inst.hdr->numberUserKeyBindings)) |
{ | { |
return SCMO_INDEX_OUT_OF_BOUND; | return SCMO_INDEX_OUT_OF_BOUND; |
} | } |
| |
|
_copyOnWrite(); |
|
|
|
// 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]); |
|
|
// is the node a user defined key binding ? | // is the node a user defined key binding ? |
if (node >= inst.hdr->numberKeyBindings) | if (node >= inst.hdr->numberKeyBindings) |
{ | { |
|
|
} | } |
else | else |
{ | { |
|
// If type defined in the class and the provided type does not match |
|
// at this point, no convertaion can be done and the provided type |
|
// is handlend as type missmatch. |
|
if (classType != setType) |
|
{ |
|
return SCMO_TYPE_MISSMATCH; |
|
} |
|
|
switch (classType) | switch (classType) |
{ | { |
|
case CIMTYPE_DATETIME: |
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
case CIMTYPE_UINT64: | case CIMTYPE_UINT64: |
case CIMTYPE_SINT64: | case CIMTYPE_SINT64: |
|
|
| |
} | } |
| |
|
static int _indexComp(const void* left, const void* right) |
|
{ |
|
return((*(Uint32 *)left)-(*(Uint32 *)right)); |
|
} |
| |
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; |
| |
|
_copyOnWrite(); |
|
|
if (inst.hdr->propertyFilter.start == 0) | if (inst.hdr->propertyFilter.start == 0) |
{ | { |
// Allocate the SCMBPropertyFilter | // Allocate the SCMBPropertyFilter |
_getFreeSpace( | _getFreeSpace( |
inst.hdr->propertyFilter, | inst.hdr->propertyFilter, |
sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1), | sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1), |
&inst.mem, |
&inst.mem); |
true); |
|
| |
// Allocate the SCMBPropertyFilterIndexMap | // Allocate the SCMBPropertyFilterIndexMap |
_getFreeSpace( | _getFreeSpace( |
inst.hdr->propertyFilterIndexMap, | inst.hdr->propertyFilterIndexMap, |
sizeof(Uint32)*inst.hdr->numberProperties, | sizeof(Uint32)*inst.hdr->numberProperties, |
&inst.mem, |
&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 = |
|
|
i++; | i++; |
} | } |
| |
|
// sort the filter index to be in order as properties stored in the class. |
|
qsort( |
|
propertyFilterIndexMap, |
|
inst.hdr->filterProperties, |
|
sizeof(Uint32), |
|
_indexComp); |
} | } |
| |
|
|
Uint32 SCMOInstance::_initPropFilterWithKeys() | Uint32 SCMOInstance::_initPropFilterWithKeys() |
{ | { |
| |
|
|
| |
} | } |
| |
void SCMODump::dumpInstanceProperties(SCMOInstance& testInst) const |
void SCMODump::dumpInstanceProperties( |
|
SCMOInstance& testInst, |
|
Boolean verbose) const |
{ | { |
SCMBInstance_Main* insthdr = testInst.inst.hdr; | SCMBInstance_Main* insthdr = testInst.inst.hdr; |
char* instbase = testInst.inst.base; | char* instbase = testInst.inst.base; |
|
|
} | } |
else | else |
{ | { |
printSCMOValue(val[i],instbase); |
printSCMOValue(val[i],instbase,verbose); |
} | } |
} | } |
| |
|
|
} | } |
} | } |
| |
void SCMODump::dumpSCMOInstanceKeyBindings(SCMOInstance& testInst) const |
void SCMODump::dumpSCMOInstanceKeyBindings( |
|
SCMOInstance& testInst, |
|
Boolean verbose) const |
{ | { |
SCMBInstance_Main* insthdr = testInst.inst.hdr; | SCMBInstance_Main* insthdr = testInst.inst.hdr; |
char* instbase = testInst.inst.base; | char* instbase = testInst.inst.base; |
|
|
| |
fprintf(_out,"\n\nInstance Key Bindings :"); | fprintf(_out,"\n\nInstance Key Bindings :"); |
fprintf(_out,"\n======================="); | fprintf(_out,"\n======================="); |
fprintf(_out,"\n\nNumber of Key Bindings : %u",insthdr->numberKeyBindings); |
fprintf(_out,"\n\nNumber of Key Bindings defined in the Class: %u", |
|
insthdr->numberKeyBindings); |
| |
for (Uint32 i = 0, k = insthdr->numberKeyBindings; i < k; i++) | for (Uint32 i = 0, k = insthdr->numberKeyBindings; i < k; i++) |
{ | { |
if (ptr[i].isSet) | if (ptr[i].isSet) |
{ | { |
fprintf(_out,"\n\nNo %u : '%s'",i, |
fprintf(_out,"\n\nName: '%s'\nType: '%s'", |
(const char*)printUnionValue( |
NULLSTR(_getCharString( |
|
theClassKeyBindNodeArray[i].name, |
|
insthdr->theClass->cls.base)), |
|
cimTypeToString(theClassKeyBindNodeArray[i].type)); |
|
printUnionValue( |
theClassKeyBindNodeArray[i].type, | theClassKeyBindNodeArray[i].type, |
ptr[i].data, | ptr[i].data, |
instbase).getCString()); |
instbase, |
|
verbose); |
} | } |
else | else |
{ | { |
fprintf(_out,"\n\nNo %u : Not Set",i); |
fprintf(_out,"\n\nName: '%s': Not Set", |
|
NULLSTR(_getCharString( |
|
theClassKeyBindNodeArray[i].name, |
|
insthdr->theClass->cls.base))); |
|
} |
|
} |
|
|
|
fprintf(_out,"\n\nNumber of User Defined Key Bindings: %u", |
|
insthdr->numberUserKeyBindings); |
|
|
|
|
|
SCMBUserKeyBindingElement* theUserDefKBElement; |
|
|
|
Uint64 start = insthdr->userKeyBindingElement.start; |
|
while (start != 0) |
|
{ |
|
theUserDefKBElement = (SCMBUserKeyBindingElement*)&(instbase[start]); |
| |
|
if (theUserDefKBElement->value.isSet) |
|
{ |
|
fprintf(_out,"\n\nName: '%s'\nType: '%s'", |
|
NULLSTR(_getCharString(theUserDefKBElement->name,instbase)), |
|
cimTypeToString(theUserDefKBElement->type)); |
|
printUnionValue( |
|
theUserDefKBElement->type, |
|
theUserDefKBElement->value.data, |
|
instbase, |
|
verbose); |
} | } |
|
else |
|
{ |
|
fprintf(_out,"\n\n %s : Not Set", |
|
NULLSTR(_getCharString(theUserDefKBElement->name,instbase))); |
|
|
} | } |
fprintf(_out,"\n"); |
start = theUserDefKBElement->nextElement.start; |
|
} // for all user def. key bindings. |
|
|
|
fprintf(_out,"\n\n"); |
|
|
} | } |
| |
void SCMODump::dumpSCMOClass(SCMOClass& testCls) const | void SCMODump::dumpSCMOClass(SCMOClass& testCls) const |
|
|
| |
void SCMODump::hexDumpSCMOClass(SCMOClass& testCls) const | void SCMODump::hexDumpSCMOClass(SCMOClass& testCls) const |
{ | { |
char* tmp; |
|
|
|
SCMBClass_Main* clshdr = testCls.cls.hdr; | SCMBClass_Main* clshdr = testCls.cls.hdr; |
char* clsbase = testCls.cls.base; | char* clsbase = testCls.cls.base; |
| |
|
|
| |
void SCMODump::printSCMOValue( | void SCMODump::printSCMOValue( |
const SCMBValue& theValue, | const SCMBValue& theValue, |
char* base) const |
char* base, |
|
Boolean verbose) const |
{ | { |
fprintf(_out,"\nValueType : %s",cimTypeToString(theValue.valueType)); | fprintf(_out,"\nValueType : %s",cimTypeToString(theValue.valueType)); |
fprintf(_out,"\nValue was set: %s", | fprintf(_out,"\nValue was set: %s", |
|
|
} | } |
if (theValue.flags.isArray) | if (theValue.flags.isArray) |
{ | { |
fprintf(_out, |
fprintf( |
|
_out, |
"\nThe value is an Array of size: %u", | "\nThe value is an Array of size: %u", |
theValue.valueArraySize); | theValue.valueArraySize); |
fprintf(_out,"\nThe values are: %s", |
printArrayValue( |
(const char*)printArrayValue( |
|
theValue.valueType, | theValue.valueType, |
theValue.valueArraySize, | theValue.valueArraySize, |
theValue.value, | theValue.value, |
base).getCString()); |
base, |
|
verbose); |
} | } |
else | else |
{ | { |
fprintf(_out,"\nThe Value is: '%s'", |
printUnionValue(theValue.valueType,theValue.value,base,verbose); |
(const char*) |
|
printUnionValue(theValue.valueType,theValue.value,base) |
|
.getCString()); |
|
} | } |
| |
return; | return; |
|
|
} | } |
} | } |
| |
String SCMODump::printArrayValue( |
void SCMODump::printArrayValue( |
CIMType type, | CIMType type, |
Uint32 size, | Uint32 size, |
SCMBUnion u, | SCMBUnion u, |
char* base) const |
char* base, |
|
Boolean verbose) const |
{ | { |
Buffer out; | Buffer out; |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
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) |
if ( 0 != p[i].size) |
{ | { |
out.append('\''); | out.append('\''); |
out.append((const char*)_getCharString(p[i],base), | out.append((const char*)_getCharString(p[i],base), |
p[i].length-1); |
p[i].size-1); |
out.append('\''); | out.append('\''); |
} | } |
else | else |
|
|
} | } |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
_toString(out,x); | _toString(out,x); |
out.append(' '); | out.append(' '); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
{ | { |
// TODO: has to dump SCMOInstance ... |
if (verbose) |
|
{ |
|
for (Uint32 i = 0; i < size; i++) |
|
{ |
|
fprintf(_out,"\n-----------> " |
|
"Start of embedded external reference [%d]" |
|
" <-----------\n\n",i); |
|
dumpSCMOInstance(*u.extRefPtr); |
|
fprintf(_out,"\n-----------> " |
|
"End of embedded external reference [%d]" |
|
" <-----------\n\n",i); |
|
} |
|
|
|
} else |
|
{ |
|
fprintf(_out,"\nThe values are: "); |
|
|
|
for (Uint32 i = 0; i < size; i++) |
|
{ |
|
fprintf( |
|
_out, |
|
"Pointer to external Reference[%d] : \'%p\';", |
|
i,p[i].extRefPtr); |
|
} |
|
} |
|
|
break; | break; |
|
|
} | } |
default: | default: |
{ | { |
|
|
} | } |
} | } |
| |
return out.getData(); |
return; |
} | } |
| |
String SCMODump::printUnionValue( |
void SCMODump::printUnionValue( |
CIMType type, | CIMType type, |
SCMBUnion u, | SCMBUnion u, |
char* base) const |
char* base, |
|
Boolean verbose) const |
{ | { |
| |
Buffer out; | Buffer out; |
|
|
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
{ | { |
_toString(out,u.simple.val.bin); | _toString(out,u.simple.val.bin); |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_UINT8: | case CIMTYPE_UINT8: |
{ | { |
_toString(out,u.simple.val.u8); | _toString(out,u.simple.val.u8); |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_SINT8: | case CIMTYPE_SINT8: |
{ | { |
_toString(out,u.simple.val.s8); | _toString(out,u.simple.val.s8); |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_UINT16: | case CIMTYPE_UINT16: |
{ | { |
_toString(out,(Uint32)u.simple.val.u16); | _toString(out,(Uint32)u.simple.val.u16); |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_SINT16: | case CIMTYPE_SINT16: |
{ | { |
_toString(out,u.simple.val.s16); | _toString(out,u.simple.val.s16); |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_UINT32: | case CIMTYPE_UINT32: |
{ | { |
_toString(out,u.simple.val.u32); | _toString(out,u.simple.val.u32); |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_SINT32: | case CIMTYPE_SINT32: |
{ | { |
_toString(out,u.simple.val.s32); | _toString(out,u.simple.val.s32); |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_UINT64: | case CIMTYPE_UINT64: |
{ | { |
_toString(out,u.simple.val.u64); | _toString(out,u.simple.val.u64); |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_SINT64: | case CIMTYPE_SINT64: |
{ | { |
_toString(out,u.simple.val.s64); | _toString(out,u.simple.val.s64); |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_REAL32: | case CIMTYPE_REAL32: |
{ | { |
_toString(out,u.simple.val.r32); | _toString(out,u.simple.val.r32); |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_REAL64: | case CIMTYPE_REAL64: |
{ | { |
_toString(out,u.simple.val.r32); | _toString(out,u.simple.val.r32); |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
{ | { |
_toString(out,u.simple.val.c16); | _toString(out,u.simple.val.c16); |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
if ( 0 != u.stringValue.length) |
if ( 0 != u.stringValue.size) |
{ | { |
out.append((const char*)_getCharString(u.stringValue,base), | out.append((const char*)_getCharString(u.stringValue,base), |
u.stringValue.length-1); |
u.stringValue.size-1); |
} | } |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
|
|
CIMDateTime x; | CIMDateTime x; |
memcpy(x._rep,&(u.dateTimeValue),sizeof(SCMBDateTime)); | memcpy(x._rep,&(u.dateTimeValue),sizeof(SCMBDateTime)); |
_toString(out,x); | _toString(out,x); |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
|
|
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
{ | { |
// TODO: Has to dump SCMOInstance. |
if (verbose) |
|
{ |
|
fprintf(_out,"\n-----------> " |
|
"Start of embedded external reference" |
|
" <-----------\n\n"); |
|
dumpSCMOInstance(*u.extRefPtr); |
|
fprintf(_out,"\n-----------> " |
|
"End of embedded external reference" |
|
" <-----------\n\n"); |
|
} else |
|
{ |
|
fprintf( |
|
_out, |
|
"Pointer to external Reference : \'%p\'", |
|
u.extRefPtr); |
|
} |
|
|
break; | break; |
} | } |
default: | default: |
|
|
} | } |
} | } |
| |
return out.getData(); |
return; |
} | } |
| |
| |
|
|
* The constant functions | * The constant functions |
*****************************************************************************/ | *****************************************************************************/ |
| |
static Boolean _equalUTF8Strings( |
|
const SCMBDataPtr& ptr_a, |
|
char* base, |
|
const char* name, |
|
Uint32 len) |
|
|
|
{ |
|
// size without trailing '\0' !! |
|
if (ptr_a.length-1 != len) |
|
{ |
|
return false; |
|
} |
|
const char* a = (const char*)_getCharString(ptr_a,base); |
|
|
|
// lets do a loop-unrolling optimized compare here |
|
while (len >= 8) |
|
{ |
|
if ((a[0] - name[0]) || (a[1] - name[1]) || |
|
(a[2] - name[2]) || (a[3] - name[3]) || |
|
(a[4] - name[4]) || (a[5] - name[5]) || |
|
(a[6] - name[6]) || (a[7] - name[7])) |
|
{ |
|
return false; |
|
} |
|
len -= 8; |
|
a += 8; |
|
name += 8; |
|
} |
|
while (len >= 4) |
|
{ |
|
if ((a[0] - name[0]) || (a[1] - name[1]) || |
|
(a[2] - name[2]) || (a[3] - name[3])) |
|
{ |
|
return false; |
|
} |
|
len -= 4; |
|
a += 4; |
|
name += 4; |
|
} |
|
while (len--) |
|
{ |
|
if (a[0] - name[0]) |
|
{ |
|
return false; |
|
} |
|
a++; |
|
name++; |
|
} |
|
return true; |
|
} |
|
|
|
|
|
static Boolean _equalNoCaseUTF8Strings( |
|
const SCMBDataPtr& ptr_a, |
|
char* base, |
|
const char* name, |
|
Uint32 len) |
|
|
|
{ |
|
|
|
//both are empty strings, so they are equal. |
|
if (ptr_a.length == 0 && len == 0) |
|
{ |
|
return true; |
|
} |
|
|
|
// size without trailing '\0' !! |
|
if (ptr_a.length-1 != len) |
|
{ |
|
return false; |
|
} |
|
|
|
const char* a = (const char*)_getCharString(ptr_a,base); |
|
|
|
#ifdef PEGASUS_HAS_ICU |
|
return ( _utf8ICUncasecmp(a,name,len)== 0); |
|
#else |
|
return ( strncasecmp(a,name,len )== 0 ); |
|
#endif |
|
} |
|
|
|
#ifdef PEGASUS_HAS_ICU | #ifdef PEGASUS_HAS_ICU |
static Uint32 _utf8ICUncasecmp( |
Uint32 _utf8ICUncasecmp( |
const char* a, | const char* a, |
const char* b, | const char* b, |
Uint32 len) | Uint32 len) |
|
|
static Uint64 _getFreeSpace( | static Uint64 _getFreeSpace( |
SCMBDataPtr& ptr, | SCMBDataPtr& ptr, |
Uint64 size, | Uint64 size, |
SCMBMgmt_Header** pmem, |
SCMBMgmt_Header** pmem) |
Boolean clear) |
|
{ | { |
Uint64 oldSize, start; | Uint64 oldSize, start; |
| |
if (size == 0) | if (size == 0) |
{ | { |
ptr.start = 0; | ptr.start = 0; |
ptr.length = 0; |
ptr.size = 0; |
return 0; | return 0; |
} | } |
| |
// The SCMBDataPtr has to be set before any reallocation. | // The SCMBDataPtr has to be set before any reallocation. |
start = (*pmem)->startOfFreeSpace; | start = (*pmem)->startOfFreeSpace; |
ptr.start = start; | ptr.start = start; |
ptr.length = size; |
ptr.size = size; |
| |
while ((*pmem)->freeBytes < size) | while ((*pmem)->freeBytes < size) |
{ | { |
|
|
oldSize = (*pmem)->totalSize; | oldSize = (*pmem)->totalSize; |
// reallocate the buffer, double the space ! | // reallocate the buffer, double the space ! |
// This is a working approach until a better algorithm is found. | // This is a working approach until a better algorithm is found. |
(*pmem) = (SCMBMgmt_Header*)realloc((*pmem),oldSize*2); |
void* newBlockPtr = realloc((*pmem),oldSize*2); |
if ((*pmem) == 0) |
if ((newBlockPtr) == 0) |
{ | { |
// Not enough memory! | // Not enough memory! |
throw PEGASUS_STD(bad_alloc)(); | throw PEGASUS_STD(bad_alloc)(); |
} | } |
|
(*pmem) = (SCMBMgmt_Header*)newBlockPtr; |
// increase the total size and free space | // increase the total size and free space |
(*pmem)->freeBytes+=oldSize; | (*pmem)->freeBytes+=oldSize; |
(*pmem)->totalSize+=oldSize; | (*pmem)->totalSize+=oldSize; |
|
|
(*pmem)->freeBytes -= size; | (*pmem)->freeBytes -= size; |
(*pmem)->startOfFreeSpace += size; | (*pmem)->startOfFreeSpace += size; |
| |
if (clear) |
// Init memory to 0. |
{ |
|
// If requested, set memory to 0. |
|
memset(&((char*)(*pmem))[start],0,size); | memset(&((char*)(*pmem))[start],0,size); |
} |
|
return start; | return start; |
} | } |
| |
|
|
else | else |
{ | { |
ptr.start = 0; | ptr.start = 0; |
ptr.length = 0; |
ptr.size = 0; |
} | } |
} | } |
| |
|
|
{ | { |
| |
// If buffer is not empty. | // If buffer is not empty. |
if (bufferSize != 1 && theBuffer != 0) |
if (bufferSize != 0 && theBuffer != 0) |
{ | { |
| |
Uint64 start; | Uint64 start; |
|
|
else | else |
{ | { |
ptr.start = 0; | ptr.start = 0; |
ptr.length = 0; |
ptr.size = 0; |
|
} |
|
} |
|
|
|
static void _destroyExternalReferencesInternal(SCMBMgmt_Header* memHdr) |
|
{ |
|
|
|
Uint32 number = memHdr->numberExtRef; |
|
|
|
if (0 != number) |
|
{ |
|
char * base = ((char*)memHdr); |
|
Uint64* array = |
|
(Uint64*)&(base[memHdr->extRefIndexArray.start]); |
|
for (Uint32 i = 0; i < number; i++) |
|
{ |
|
delete ((SCMBUnion*)(&(base[array[i]])))->extRefPtr; |
|
} |
|
|
} | } |
} | } |
| |