(file) Return to SCMO.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/SCMO.cpp between version 1.2 and 1.2.2.11

version 1.2, 2009/07/20 10:41:43 version 1.2.2.11, 2009/08/04 13:28:47
Line 29 
Line 29 
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include "SCMO.h"  #include <Pegasus/Common/SCMO.h>
   #include <Pegasus/Common/SCMOClass.h>
   #include <Pegasus/Common/SCMOInstance.h>
   #include <Pegasus/Common/SCMODump.h>
 #include <Pegasus/Common/CharSet.h> #include <Pegasus/Common/CharSet.h>
 #include <Pegasus/Common/CIMDateTimeRep.h> #include <Pegasus/Common/CIMDateTimeRep.h>
 #include <Pegasus/Common/CIMPropertyRep.h> #include <Pegasus/Common/CIMPropertyRep.h>
 #include <Pegasus/Common/CommonUTF.h> #include <Pegasus/Common/CommonUTF.h>
 #include <Pegasus/Common/StrLit.h> #include <Pegasus/Common/StrLit.h>
 #include <Pegasus/Common/XmlWriter.h> #include <Pegasus/Common/XmlWriter.h>
   #include <Pegasus/Common/System.h>
   #include <Pegasus/Common/FileSystem.h>
   #include <Pegasus/Common/StringConversion.h>
   
   #ifdef PEGASUS_OS_ZOS
     #include <Pegasus/General/SetFileDescriptorToEBCDICEncoding.h>
   #endif
  
 PEGASUS_USING_STD; PEGASUS_USING_STD;
  
 #define SCMB_INITIAL_MEMORY_CHUNK_SIZE 4096 #define SCMB_INITIAL_MEMORY_CHUNK_SIZE 4096
  
   /**
    * This macro is used at the SCMODump class
    * for generating C/C++ runtime independend output.
    * For example on Linux if fprintf got a NULL pointer
    * for a string format specification, the string "(null)" is
    * substituted. On other platforms no string "" is substituded.
    */
   #define NULLSTR(x) ((x) == NULL ? "" : (x))
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
Line 53 
Line 69 
     STRLIT("AGGREGATE"),     STRLIT("AGGREGATE"),
     STRLIT("AGGREGATION"),     STRLIT("AGGREGATION"),
     STRLIT("ALIAS"),     STRLIT("ALIAS"),
     STRLIT("ARRATYPE"),      STRLIT("ARRAYTYPE"),
       STRLIT("ASSOCIATION"),
     STRLIT("BITMAP"),     STRLIT("BITMAP"),
     STRLIT("BITVALUES"),     STRLIT("BITVALUES"),
     STRLIT("CLASSCONSTRAINT"),     STRLIT("CLASSCONSTRAINT"),
Line 72 
Line 89 
     STRLIT("EXPENSIVE"),     STRLIT("EXPENSIVE"),
     STRLIT("EXPERIMENTAL"),     STRLIT("EXPERIMENTAL"),
     STRLIT("GAUGE"),     STRLIT("GAUGE"),
     STRLIT("IFDELETE"),      STRLIT("IFDELETED"),
     STRLIT("IN"),     STRLIT("IN"),
       STRLIT("INDICATION"),
     STRLIT("INVISIBLE"),     STRLIT("INVISIBLE"),
     STRLIT("ISPUNIT"),     STRLIT("ISPUNIT"),
     STRLIT("KEY"),     STRLIT("KEY"),
Line 116 
Line 134 
     STRLIT("VALUEMAP"),     STRLIT("VALUEMAP"),
     STRLIT("VALUES"),     STRLIT("VALUES"),
     STRLIT("VERSION"),     STRLIT("VERSION"),
     STRLIT("WEEK"),      STRLIT("WEAK"),
     STRLIT("WRITE")     STRLIT("WRITE")
 }; };
  
Line 136 
Line 154 
     PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE     PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE
         - sizeof(SCMBClass_Main)>0);         - sizeof(SCMBClass_Main)>0);
  
     cls.base = (unsigned char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);      cls.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);
     if (cls.base == NULL)     if (cls.base == NULL)
     {     {
         // Not enough memory!         // Not enough memory!
Line 209 
Line 227 
     }     }
 } }
  
   const char* SCMOClass::_getPropertyNameAtNode(Uint32 propNode) const
   {
       SCMBClassPropertyNode* nodeArray =
           (SCMBClassPropertyNode*)
               &(cls.base[cls.hdr->propertySet.nodeArray.start]);
   
       return(_getCharString(nodeArray[propNode].theProperty.name,cls.base));
   }
   
 SCMO_RC SCMOClass::_getKeyBindingNodeIndex(Uint32& node, const char* name) const SCMO_RC SCMOClass::_getKeyBindingNodeIndex(Uint32& node, const char* name) const
 { {
  
     Uint32 tag,len,hashIdx;     Uint32 tag,len,hashIdx;
  
     len = strlen(name);     len = strlen(name);
     tag = _generateStringTag((const unsigned char*)name, len);      tag = _generateStringTag((const char*)name, len);
     // get the node index of the hash table     // get the node index of the hash table
     hashIdx =     hashIdx =
         cls.hdr->keyBindingSet.hashTable[tag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE];         cls.hdr->keyBindingSet.hashTable[tag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE];
Line 272 
Line 299 
     Uint32 tag,len,hashIdx;     Uint32 tag,len,hashIdx;
  
     len = strlen(name);     len = strlen(name);
     tag = _generateStringTag((const unsigned char*)name, len);      tag = _generateStringTag((const char*)name, len);
     // get the node index of the hash table     // get the node index of the hash table
     hashIdx =     hashIdx =
         cls.hdr->propertySet.hashTable[tag%PEGASUS_PROPERTY_SCMB_HASHSIZE];         cls.hdr->propertySet.hashTable[tag%PEGASUS_PROPERTY_SCMB_HASHSIZE];
Line 670 
Line 697 
  
     // calculate the relative pointer for the default value     // calculate the relative pointer for the default value
     Uint64 valueStart =     Uint64 valueStart =
         (unsigned char*)&scmoPropNode->theProperty.defaultValue - cls.base;          (char*)&scmoPropNode->theProperty.defaultValue - cls.base;
  
     _setValue(valueStart,propRep->_value);     _setValue(valueStart,propRep->_value);
  
Line 768 
Line 795 
     scmoQual->name = name;     scmoQual->name = name;
     scmoQual->flavor = theCIMQualifier.getFlavor().cimFlavor;     scmoQual->flavor = theCIMQualifier.getFlavor().cimFlavor;
  
     valueStart = (unsigned char*)&scmoQual->value - cls.base;      valueStart = (char*)&scmoQual->value - cls.base;
  
     _setValue(valueStart,theCIMQualifier.getValue());     _setValue(valueStart,theCIMQualifier.getValue());
  
Line 797 
Line 824 
     // Only initalized by for completeness.     // Only initalized by for completeness.
     scmoValue->flags.isSet = false;     scmoValue->flags.isSet = false;
  
     valueStart = (unsigned char*)&scmoValue->value - cls.base;      valueStart = (char*)&scmoValue->value - cls.base;
  
     if (rep->isNull)     if (rep->isNull)
     {     {
Line 1113 
Line 1140 
  
     case CIMTYPE_DATETIME:     case CIMTYPE_DATETIME:
         {         {
   
             memcpy(             memcpy(
                 &scmoUnion->_dateTimeValue,                 &scmoUnion->_dateTimeValue,
                 (*((CIMDateTime*)((void*)&u)))._rep,                 (*((CIMDateTime*)((void*)&u)))._rep,
Line 1178 
Line 1206 
        len));        len));
 } }
  
   inline SCMO_RC SCMOClass::_isNodeSameType(
       Uint32 node,
       CIMType type,
       Boolean isArray) const
   {
       SCMBClassPropertyNode* nodeArray =
           (SCMBClassPropertyNode*)
               &(cls.base[cls.hdr->propertySet.nodeArray.start]);
   
   
       if(nodeArray[node].theProperty.defaultValue.valueType != type)
       {
           return SCMO_WRONG_TYPE;
       }
   
       if (isArray)
       {
           if (nodeArray[node].theProperty.defaultValue.flags.isArray)
           {
               return SCMO_OK;
           }
           else
           {
               return SCMO_NOT_AN_ARRAY;
           }
   
       }
   
       if (nodeArray[node].theProperty.defaultValue.flags.isArray)
       {
           return SCMO_IS_AN_ARRAY;
       }
   
       return SCMO_OK;
   
   }
 /***************************************************************************** /*****************************************************************************
  * The SCMOInstance methods  * The SCMOInstance methods
  *****************************************************************************/  *****************************************************************************/
Line 1208 
Line 1272 
  
 } }
  
   
   SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMInstance& cimInstance)
   {
   
       _initSCMOInstance(new SCMOClass(baseClass),false,false);
   
   }
   
   Boolean SCMOInstance::isSame(SCMOInstance& theInstance) const
   {
       return inst.base == theInstance.inst.base;
   }
   
   const char* SCMOInstance::getHostName() const
   {
     return _getCharString(inst.hdr->hostName,inst.base);
   }
   
   void SCMOInstance::buildKeyBindingsFromProperties()
   {
   
       SCMBDataPtr* theInstKeyBindNodeArray =
           (SCMBDataPtr*)&inst.base[inst.hdr->keyBindingArray.start];
   
       Uint32* theClassKeyPropList =
           (Uint32*) &(inst.hdr->theClass->cls.base)
                             [(inst.hdr->theClass->cls.hdr->keyIndexList.start)];
   
       SCMBValue* theInstPropNodeArray =
           (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
   
       Uint32 propNode;
   
       for (Uint32 i = 0; i < inst.hdr->numberKeyBindings; i++)
       {
           // If the keybinding is not set.
           if (theInstKeyBindNodeArray[i].start == 0)
           {
               // get the node index for this key binding form class
               propNode = theClassKeyPropList[i];
   
               // if property was not set by the provider or it is null.
               if (!theInstPropNodeArray[propNode].flags.isSet ||
                    theInstPropNodeArray[propNode].flags.isNull)
               {
                   const char * propName =
                       inst.hdr->theClass->_getPropertyNameAtNode(propNode);
                   throw NoSuchProperty(String(propName));
               }
   
               _setKeyBindingFromSCMBUnion(
                   theInstPropNodeArray[propNode].valueType,
                   theInstPropNodeArray[propNode].value,
                   theInstKeyBindNodeArray[i]);
           }
       }
   }
   
   void SCMOInstance::_setKeyBindingFromSCMBUnion(
       CIMType type,
       SCMBUnion& u,
       SCMBDataPtr& keyNode)
   {
       Uint32 outputLength=0;
       const char * output;
   
       switch (type)
       {
       case CIMTYPE_UINT8:
           {
               char buffer[22];
               output = Uint8ToString(buffer, u._uint8Value, outputLength);
               // including trailing '\0' !
               _setBinary(output,outputLength+1,keyNode,&inst.mem);
               break;
           }
   
       case CIMTYPE_UINT16:
           {
               char buffer[22];
               output = Uint16ToString(buffer, u._uint16Value, outputLength);
               // including trailing '\0' !
               _setBinary(output,outputLength+1,keyNode,&inst.mem);
               break;
           }
   
       case CIMTYPE_UINT32:
           {
               char buffer[22];
               output = Uint32ToString(buffer, u._uint32Value, outputLength);
               // including trailing '\0' !
               _setBinary(output,outputLength+1,keyNode,&inst.mem);
               break;
           }
   
       case CIMTYPE_UINT64:
           {
               char buffer[22];
               output = Uint64ToString(buffer, u._uint64Value, outputLength);
               // including trailing '\0' !
               _setBinary(output,outputLength+1,keyNode,&inst.mem);
               break;
           }
   
       case CIMTYPE_SINT8:
           {
               char buffer[22];
               output = Sint8ToString(buffer, u._sint8Value, outputLength);
               // including trailing '\0' !
               _setBinary(output,outputLength+1,keyNode,&inst.mem);
               break;
           }
   
       case CIMTYPE_SINT16:
           {
               char buffer[22];
               output = Sint16ToString(buffer, u._sint16Value, outputLength);
               // including trailing '\0' !
               _setBinary(output,outputLength+1,keyNode,&inst.mem);
               break;
           }
   
       case CIMTYPE_SINT32:
           {
               char buffer[22];
               output = Sint32ToString(buffer, u._sint32Value, outputLength);
               // including trailing '\0' !
               _setBinary(output,outputLength+1,keyNode,&inst.mem);
               break;
           }
   
       case CIMTYPE_SINT64:
           {
               char buffer[22];
               output = Sint64ToString(buffer, u._sint64Value, outputLength);
               // including trailing '\0' !
               _setBinary(output,outputLength+1,keyNode,&inst.mem);
               break;
           }
   
       case CIMTYPE_REAL32:
           {
               char buffer[128];
               output = Real32ToString(buffer, u._real32Value, outputLength);
               // including trailing '\0' !
               _setBinary(output,outputLength+1,keyNode,&inst.mem);
               break;
           }
   
       case CIMTYPE_REAL64:
           {
               char buffer[128];
               output = Real64ToString(buffer, u._real64Value, outputLength);
               // including trailing '\0' !
               _setBinary(output,outputLength+1,keyNode,&inst.mem);
               break;
               break;
           }
   
       case CIMTYPE_CHAR16:
           {
               Buffer out;
               _toString(out,u._char16Value);
               // including trailing '\0' !
               _setBinary(out.getData(),out.size()+1,keyNode,&inst.mem);
               break;
           }
   
       case CIMTYPE_BOOLEAN:
           {
               if (u._booleanValue)
               {
                   _setBinary("TRUE",strlen("TRUE")+1,keyNode,&inst.mem);
               }
               else
               {
                   _setBinary("FALSE",strlen("FLASE")+1,keyNode,&inst.mem);
               }
               break;
           }
   
       case CIMTYPE_STRING:
           {
               _setBinary(
                   &inst.base[u._stringValue.start],
                   u._stringValue.length,
                   keyNode,
                   &inst.mem);
               break;
           }
   
       case CIMTYPE_DATETIME:
           {
               _setString(
                   CIMDateTime(&u._dateTimeValue).toString(),
                   keyNode,
                   &inst.mem);
               break;
           }
   
           case CIMTYPE_REFERENCE:
   
               break;
   
           case CIMTYPE_OBJECT:
   
               break;
           case CIMTYPE_INSTANCE:
   
               break;
       }
   
   
   
   }
   
   void SCMOInstance::setHostName(const char* hostName)
   {
       Uint32 len;
   
       if (hostName!=NULL)
       {
   
           len = strlen((const char*)hostName);
           if(len != 0)
           {
   
               // copy including trailing '\0'
               _setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem);
               return;
           }
   
       }
       inst.hdr->hostName.start=0;
       inst.hdr->hostName.length=0;
   }
   
   const char* SCMOInstance::getClassName() const
   {
       return _getCharString(
           inst.hdr->theClass->cls.hdr->className,
           inst.hdr->theClass->cls.base);
   }
   
   const char* SCMOInstance::getNameSpace() const
   {
       return _getCharString(
           inst.hdr->theClass->cls.hdr->nameSpace,
           inst.hdr->theClass->cls.base);
   }
   
 void SCMOInstance::_initSCMOInstance( void SCMOInstance::_initSCMOInstance(
     SCMOClass* pClass,     SCMOClass* pClass,
     Boolean inclQual,     Boolean inclQual,
Line 1217 
Line 1532 
         - sizeof(SCMBInstance_Main)>0);         - sizeof(SCMBInstance_Main)>0);
  
  
     inst.base = (unsigned char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);      inst.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);
     if (inst.base == NULL)     if (inst.base == NULL)
     {     {
         // Not enough memory!         // Not enough memory!
Line 1261 
Line 1576 
           &inst.mem,           &inst.mem,
           true);           true);
  
     // Allocate the SCMBPropertyFilter  
     _getFreeSpace(  
         inst.hdr->propertyFilter,  
         sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1),  
         &inst.mem,  
         true);  
   
     // Allocate the SCMBPropertyFilterIndexMap  
     _getFreeSpace(  
         inst.hdr->propertyFilterIndexMap,  
         sizeof(Uint32)*inst.hdr->numberProperties,  
         &inst.mem,  
         true);  
   
     // Allocate the SCMBInstancePropertyArray     // Allocate the SCMBInstancePropertyArray
     _getFreeSpace(     _getFreeSpace(
         inst.hdr->propertyArray,         inst.hdr->propertyArray,
Line 1282 
Line 1583 
         &inst.mem,         &inst.mem,
         true);         true);
  
       inst.hdr->propertyFilter.start=0;
       inst.hdr->propertyFilter.length=0;
       inst.hdr->propertyFilterIndexMap.start=0;
       inst.hdr->propertyFilterIndexMap.length=0;
   
   
 } }
  
 SCMO_RC SCMOInstance::getProperty( SCMO_RC SCMOInstance::getProperty(
Line 1292 
Line 1599 
     Uint32& size ) const     Uint32& size ) const
 { {
     Uint32 node;     Uint32 node;
     const unsigned char** pname;      const char* pname;
     SCMO_RC rc = SCMO_OK;     SCMO_RC rc = SCMO_OK;
  
     *pvalue = NULL;     *pvalue = NULL;
Line 1317 
Line 1624 
         }         }
     }     }
  
     return  _getPropertyAtNodeIndex(node,pname,type,pvalue,isArray,size);      return  _getPropertyAtNodeIndex(node,&pname,type,pvalue,isArray,size);
 } }
  
 SCMO_RC SCMOInstance::getPropertyAt( SCMO_RC SCMOInstance::getPropertyAt(
         Uint32 idx,         Uint32 idx,
         const unsigned char** pname,          const char** pname,
         CIMType& type,         CIMType& type,
         const void** pvalue,         const void** pvalue,
         Boolean& isArray,         Boolean& isArray,
Line 1365 
Line 1672 
  
 SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const
 { {
       SCMO_RC rc;
     if(name==NULL)     if(name==NULL)
     {     {
         return SCMO_INVALID_PARAMETER;         return SCMO_INVALID_PARAMETER;
     }     }
  
     return (inst.hdr->theClass->_getProperyNodeIndex(node,name));      rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);
   
       return rc;
   
 } }
 SCMO_RC SCMOInstance::setPropertyWithOrigin( SCMO_RC SCMOInstance::setPropertyWithOrigin(
     const char* name,     const char* name,
Line 1389 
Line 1700 
         return rc;         return rc;
     }     }
  
       // Is the traget type OK ?
       rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray);
       if (rc != SCMO_OK)
       {
           return rc;
       }
   
     // is filtering on ?     // is filtering on ?
     if (inst.hdr->flags.isFiltered)     if (inst.hdr->flags.isFiltered)
     {     {
Line 1410 
Line 1728 
         }         }
     }     }
  
   
     _setPropertyAtNodeIndex(node,type,value,isArray,size);     _setPropertyAtNodeIndex(node,type,value,isArray,size);
  
     return SCMO_OK;     return SCMO_OK;
Line 1422 
Line 1741 
      Boolean isArray,      Boolean isArray,
      Uint32 size)      Uint32 size)
  {  {
        SCMO_RC rc;
   
      if (node >= inst.hdr->numberProperties)      if (node >= inst.hdr->numberProperties)
      {      {
          return SCMO_INDEX_OUT_OF_BOUND;          return SCMO_INDEX_OUT_OF_BOUND;
Line 1433 
Line 1754 
          // Is the property NOT in the property filter ?          // Is the property NOT in the property filter ?
          if(!_isPropertyInFilter(node))          if(!_isPropertyInFilter(node))
          {          {
              // The named propery is not part of this instance               // The proptery of the is not set due to filtering.
              // due to filtering.               return SCMO_OK;
              return SCMO_NOT_FOUND;           }
          }          }
   
        // Is the traget type OK ?
        rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray);
        if (rc != SCMO_OK)
        {
            return rc;
      }      }
  
      _setPropertyAtNodeIndex(node,type,value,isArray,size);      _setPropertyAtNodeIndex(node,type,value,isArray,size);
Line 1470 
Line 1797 
     else     else
     {     {
         Uint64 start =         Uint64 start =
             (unsigned const char*)&(theInstPropNodeArray[node].value)-inst.base;              (const char*)&(theInstPropNodeArray[node].value)-inst.base;
  
         _setSCMBUnion(value,type,isArray,size,start);         _setSCMBUnion(value,type,isArray,size,start);
     }     }
Line 1667 
Line 1994 
             break;             break;
         }         }
  
       case CIMTYPE_DATETIME:
           {
               if (isArray)
               {
                   _setBinary(value,size*sizeof(SCMBDateTime),
                              u->_arrayValue,
                              &inst.mem );
               }
               else
               {
                   u->_dateTimeValue = *((SCMBDateTime*)value);
               }
               break;
           }
   
     case CIMTYPE_STRING:     case CIMTYPE_STRING:
         {         {
             if (isArray)             if (isArray)
Line 1701 
Line 2043 
             break;             break;
         }         }
  
     case CIMTYPE_DATETIME:  
         {  
             if (isArray)  
             {  
                 _setBinary(value,size*sizeof(SCMBDateTime),  
                            u->_arrayValue,  
                            &inst.mem );  
             }  
             else  
             {  
                 memcpy(&u->_dateTimeValue,value,sizeof(SCMBDateTime));  
             }  
             break;  
         }  
   
         case CIMTYPE_REFERENCE:         case CIMTYPE_REFERENCE:
  
             break;             break;
Line 1731 
Line 2058 
  
 SCMO_RC SCMOInstance::_getPropertyAtNodeIndex( SCMO_RC SCMOInstance::_getPropertyAtNodeIndex(
         Uint32 node,         Uint32 node,
         const unsigned char** pname,          const char** pname,
         CIMType& type,         CIMType& type,
         const void** pvalue,         const void** pvalue,
         Boolean& isArray,         Boolean& isArray,
Line 1770 
Line 2097 
  
         // calculate the relative index for the value.         // calculate the relative index for the value.
         Uint64 start =         Uint64 start =
             (unsigned const char*)&(theInstPropNodeArray[node].value) -              (const char*)&(theInstPropNodeArray[node].value) -
             inst.base;             inst.base;
  
         // the caller has to copy the value !         // the caller has to copy the value !
Line 1796 
Line 2123 
  
     // calcutate the relativ start address of the value     // calcutate the relativ start address of the value
     Uint64 start =     Uint64 start =
         (unsigned const char*)          (const char*)
                &(theClassPropNodeArray[node].theProperty.defaultValue.value) -                &(theClassPropNodeArray[node].theProperty.defaultValue.value) -
         (inst.hdr->theClass->cls.base);         (inst.hdr->theClass->cls.base);
  
Line 1815 
Line 2142 
 SCMOInstance SCMOInstance::clone() const SCMOInstance SCMOInstance::clone() const
 { {
     SCMOInstance newInst;     SCMOInstance newInst;
     newInst.inst.base = (unsigned char*)malloc(this->inst.mem->totalSize);      newInst.inst.base = (char*)malloc(this->inst.mem->totalSize);
     if (newInst.inst.base == NULL )     if (newInst.inst.base == NULL )
     {     {
         throw PEGASUS_STD(bad_alloc)();         throw PEGASUS_STD(bad_alloc)();
Line 1832 
Line 2159 
  
 Uint32 SCMOInstance::getPropertyCount() const Uint32 SCMOInstance::getPropertyCount() const
 { {
       if (inst.hdr->flags.isFiltered)
       {
           return(inst.hdr->filterProperties);
       }
   
     return(inst.hdr->numberProperties);     return(inst.hdr->numberProperties);
 } }
  
 const void* SCMOInstance::_getSCMBUnion(  void* SCMOInstance::_getSCMBUnion(
     CIMType type,     CIMType type,
     Boolean isArray,     Boolean isArray,
     Uint32 size,     Uint32 size,
     Uint64 start,     Uint64 start,
     unsigned char* base) const      char* base) const
 { {
  
     SCMBUnion* u = (SCMBUnion*)&(base[start]);     SCMBUnion* u = (SCMBUnion*)&(base[start]);
  
     void* av = NULL;     void* av = NULL;
   
     if (isArray)     if (isArray)
     {     {
           if (size == 0)
           {
               return NULL;
           }
         av = (void*)&base[u->_arrayValue.start];         av = (void*)&base[u->_arrayValue.start];
     }     }
  
Line 1882 
Line 2219 
     case CIMTYPE_STRING:     case CIMTYPE_STRING:
         {         {
             SCMBDataPtr *ptr;             SCMBDataPtr *ptr;
             unsigned char** tmp;              char** tmp=NULL;
  
             if (isArray)             if (isArray)
             {             {
                 // allocate an array of char* pointers.                 // allocate an array of char* pointers.
                 *tmp = (unsigned char*)malloc(size*sizeof(unsigned char*));                  tmp = (char**)malloc(size*sizeof(char*));
                 if (*tmp == NULL )                  if (tmp == NULL )
                 {                 {
                     throw PEGASUS_STD(bad_alloc)();                     throw PEGASUS_STD(bad_alloc)();
                 }                 }
Line 1899 
Line 2236 
                 for(Uint32 i = 0; i < size; i++)                 for(Uint32 i = 0; i < size; i++)
                 {                 {
                     // resolv relative pointer to absolute pointer                     // resolv relative pointer to absolute pointer
                     tmp[i] = (unsigned char*)_getCharString(ptr[i],base);                      tmp[i] = (char*)_getCharString(ptr[i],base);
                 }                 }
  
                 return((void*)*tmp);                  return((void*)tmp);
             }             }
             else             else
             {             {
                 return(_getCharString(u->_stringValue,base));                  return((void*)_getCharString(u->_stringValue,base));
             }             }
  
  
Line 1940 
Line 2277 
  
 SCMO_RC SCMOInstance::getKeyBindingAt( SCMO_RC SCMOInstance::getKeyBindingAt(
         Uint32 node,         Uint32 node,
         const unsigned char** pname,          const char** pname,
         CIMKeyBinding::Type& type,         CIMKeyBinding::Type& type,
         const unsigned char** pvalue) const          const char** pvalue) const
 { {
     *pname = NULL;     *pname = NULL;
     *pvalue = NULL;     *pvalue = NULL;
Line 1958 
Line 2295 
 SCMO_RC SCMOInstance::getKeyBinding( SCMO_RC SCMOInstance::getKeyBinding(
     const char* name,     const char* name,
     CIMKeyBinding::Type& type,     CIMKeyBinding::Type& type,
     const unsigned char** pvalue) const      const char** pvalue) const
 { {
     pvalue = NULL;  
     SCMO_RC rc;     SCMO_RC rc;
     Uint32 node;     Uint32 node;
     const unsigned char** pname;      const char* pname=NULL;
  
     rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name);     rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name);
     if (rc != SCMO_OK)     if (rc != SCMO_OK)
Line 1971 
Line 2307 
         return rc;         return rc;
     }     }
  
     return _getKeyBindingAtNodeIndex(node,pname,type,pvalue);      return _getKeyBindingAtNodeIndex(node,&pname,type,pvalue);
  
 } }
  
 SCMO_RC SCMOInstance::_getKeyBindingAtNodeIndex( SCMO_RC SCMOInstance::_getKeyBindingAtNodeIndex(
     Uint32 node,     Uint32 node,
     const unsigned char** pname,      const char** pname,
     CIMKeyBinding::Type& type,     CIMKeyBinding::Type& type,
     const unsigned char** pvalue) const      const char** pvalue) const
 { {
  
     SCMBDataPtr* theInstKeyBindNodeArray =     SCMBDataPtr* theInstKeyBindNodeArray =
Line 1990 
Line 2326 
     SCMBKeyBindingNode* theClassKeyBindNodeArray =     SCMBKeyBindingNode* theClassKeyBindNodeArray =
         (SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx];         (SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx];
  
     type = theClassKeyBindNodeArray->type;      type = theClassKeyBindNodeArray[node].type;
   
     *pname = _getCharString(     *pname = _getCharString(
         theClassKeyBindNodeArray->name,          theClassKeyBindNodeArray[node].name,
         inst.hdr->theClass->cls.base);         inst.hdr->theClass->cls.base);
  
         // There is no value set in the instance         // There is no value set in the instance
     // if the relative pointer has no start value.     // if the relative pointer has no start value.
     if (theInstKeyBindNodeArray[node].start==0)     if (theInstKeyBindNodeArray[node].start==0)
     {     {
           *pvalue = NULL;
         return SCMO_NULL_VALUE;         return SCMO_NULL_VALUE;
     }     }
  
Line 2048 
Line 2386 
     SCMO_RC rc;     SCMO_RC rc;
     Uint32 node,i = 0;     Uint32 node,i = 0;
  
       if (inst.hdr->propertyFilter.start == 0)
       {
           // Allocate the SCMBPropertyFilter
           _getFreeSpace(
               inst.hdr->propertyFilter,
               sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1),
               &inst.mem,
               true);
   
           // Allocate the SCMBPropertyFilterIndexMap
           _getFreeSpace(
               inst.hdr->propertyFilterIndexMap,
               sizeof(Uint32)*inst.hdr->numberProperties,
               &inst.mem,
               true);
       }
     // Get absolut pointer to property filter index map of the instance     // Get absolut pointer to property filter index map of the instance
     Uint32* propertyFilterIndexMap =     Uint32* propertyFilterIndexMap =
         (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);         (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);
Line 2197 
Line 2551 
 /****************************************************************************** /******************************************************************************
  * SCMODump Print and Dump functions  * SCMODump Print and Dump functions
  *****************************************************************************/  *****************************************************************************/
   SCMODump::SCMODump()
   {
       _out = stdout;
       _fileOpen = false;
   
   #ifdef PEGASUS_OS_ZOS
       setEBCDICEncoding(fileno(_out));
   #endif
   
   }
   
   SCMODump::SCMODump(char* filename)
   {
       openFile(filename);
   }
   
   void SCMODump::openFile(char* filename)
   {
       const char* pegasusHomeDir = getenv("PEGASUS_HOME");
   
       if (pegasusHomeDir == NULL)
       {
           pegasusHomeDir = ".";
       }
   
       _filename = pegasusHomeDir;
       _filename.append("/");
       _filename.append(filename);
   
       _out = fopen((const char*)_filename.getCString(),"w+");
   
       _fileOpen = true;
   
   #ifdef PEGASUS_OS_ZOS
       setEBCDICEncoding(fileno(_out));
   #endif
   
   }
   
   void SCMODump::deleteFile()
   {
       if(_fileOpen)
       {
           closeFile();
       }
   
       System::removeFile((const char*)_filename.getCString());
   
   }
   void SCMODump::closeFile()
   {
       if (_fileOpen)
       {
           fclose(_out);
           _fileOpen=false;
           _out = stdout;
       }
   }
   
   SCMODump::~SCMODump()
   {
       if (_fileOpen)
       {
           fclose(_out);
           _fileOpen=false;
       }
   }
   
   Boolean SCMODump::compareFile(String master)
   {
   
       if (!_fileOpen)
       {
           return false;
       }
   
       closeFile();
   
       return (FileSystem::compareFiles(_filename, master));
   }
   
   void SCMODump::dumpSCMOInstance(SCMOInstance& testInst) const
   {
       SCMBInstance_Main* insthdr = testInst.inst.hdr;
       char* instbase = testInst.inst.base;
   
       fprintf(_out,"\n\nDump of SCMOInstance\n");
       // The magic number for SCMO class
       fprintf(_out,"\nheader.magic=%08X",insthdr->header.magic);
       // Total size of the instance memory block( # bytes )
       fprintf(_out,"\nheader.totalSize=%llu",insthdr->header.totalSize);
       // The reference counter for this c++ class
       fprintf(_out,"\nrefCount=%i",insthdr->refCount.get());
       fprintf(_out,"\ntheClass: %p",insthdr->theClass);
       fprintf(_out,"\n\nThe Flags:");
       fprintf(_out,"\n   includeQualifiers: %s",
              (insthdr->flags.includeQualifiers ? "True" : "False"));
       fprintf(_out,"\n   includeClassOrigin: %s",
              (insthdr->flags.includeClassOrigin ? "True" : "False"));
       fprintf(_out,"\n   isFiltered: %s",
              (insthdr->flags.isFiltered ? "True" : "False"));
       fprintf(_out,"\n\nhostName: \'%s\'",
              NULLSTR(_getCharString(insthdr->hostName,instbase)));
   
       dumpSCMOInstanceKeyBindings(testInst);
   
       dumpSCMOInstancePropertyFilter(testInst);
   
       dumpInstanceProperties(testInst);
       fprintf(_out,"\n\n");
   
   }
   
   void SCMODump::dumpSCMOInstancePropertyFilter(SCMOInstance& testInst) const
   {
       SCMBInstance_Main* insthdr = testInst.inst.hdr;
       char* instbase = testInst.inst.base;
   
       if (!insthdr->flags.isFiltered)
       {
           fprintf(_out,"\n\nNo propterty filter!\n\n");
           return;
       }
   
       fprintf(_out,"\n\nInstance Property Filter :");
       fprintf(_out,"\n==========================");
       fprintf(_out,"\n\nNumber of properties in the filter : %u\n"
           ,insthdr->filterProperties);
   
       dumpPropertyFilter(testInst);
   
       dumpPropertyFilterIndexMap(testInst);
   
   }
   
   void SCMODump::dumpInstanceProperties(SCMOInstance& testInst) const
   {
       SCMBInstance_Main* insthdr = testInst.inst.hdr;
       char* instbase = testInst.inst.base;
   
       SCMBValue* val =
           (SCMBValue*)_resolveDataPtr(insthdr->propertyArray,instbase);
   
       fprintf(_out,"\n\nInstance Properties :");
       fprintf(_out,"\n=====================");
       fprintf(_out,"\n\nNumber of properties in instance : %u",
              insthdr->numberProperties);
   
       for (Uint32 i = 0; i < insthdr->numberProperties; i++)
       {
           fprintf(_out,"\n\nInstance property (#%3u) %s\n",i,
                   NULLSTR(insthdr->theClass->_getPropertyNameAtNode(i)));
           if(insthdr->flags.isFiltered && !testInst._isPropertyInFilter(i))
           {
               fprintf(_out,"\nProperty is filtered out!");
           }
           else
           {
               printSCMOValue(val[i],instbase);
           }
       }
   
   }
   
   void SCMODump::dumpPropertyFilterIndexMap(SCMOInstance& testInst) const
   {
   
       SCMBInstance_Main* insthdr = testInst.inst.hdr;
       char* instbase = testInst.inst.base;
   
       if (!insthdr->flags.isFiltered)
       {
           fprintf(_out,"\n\nNo propterty filter!\n\n");
           return;
       }
   
       fprintf(_out,"\n\nProperty Filter Index Max:");
       fprintf(_out,"\n==========================\n");
   
       // Get absolut pointer to key index list of the class
       Uint32* keyIndex =
           (Uint32*)&(instbase)[insthdr->propertyFilterIndexMap.start];
       Uint32 line,j,i;
       for (j = 0; j < insthdr->filterProperties; j = j + line)
       {
           if ((insthdr->filterProperties-j)/16)
           {
               line = 16 ;
           }
           else
           {
               line = insthdr->filterProperties%16;
           }
   
   
           fprintf(_out,"Index :");
           for (i = 0; i < line; i++)
           {
               fprintf(_out," %3u",j+i);
           }
   
           fprintf(_out,"\nNode  :");
           for (i = 0; i < line; i++)
           {
               fprintf(_out," %3u",keyIndex[j+i]);
           }
   
           fprintf(_out,"\n\n");
   
       }
   
   }
   
   void SCMODump::dumpPropertyFilter(SCMOInstance& testInst) const
   {
   
       SCMBInstance_Main* insthdr = testInst.inst.hdr;
       char* instbase = testInst.inst.base;
   
       if (!insthdr->flags.isFiltered)
       {
           fprintf(_out,"\n\nNo propterty filter!");
           return;
       }
   
       Uint64 *thePropertyFilter =
           (Uint64*)&(instbase[insthdr->propertyFilter.start]);
        Uint32 end, noProperties = insthdr->numberProperties;
        Uint32 noMasks = (noProperties-1)/64;
        Uint64 printMask = 1;
   
        for (Uint32 i = 0; i <= noMasks; i++ )
        {
            printMask = 1;
            if (i < noMasks)
            {
                end = 64;
            }
            else
            {
                end = noProperties%64;
            }
   
            fprintf(_out,"\npropertyFilter[%02u]= ",i);
   
            for (Uint32 j = 0; j < end; j++)
            {
                if (j > 0 && !(j%8))
                {
                    fprintf(_out," ");
                }
   
                if (thePropertyFilter[i] & printMask)
                {
                    fprintf(_out,"1");
                }
                else
                {
                    fprintf(_out,"0");
                }
   
                printMask = printMask << 1;
            }
            fprintf(_out,"\n");
        }
   }
   
   void SCMODump::dumpSCMOInstanceKeyBindings(SCMOInstance& testInst) const
   {
       SCMBInstance_Main* insthdr = testInst.inst.hdr;
       char* instbase = testInst.inst.base;
   
       SCMBDataPtr* ptr =
           (SCMBDataPtr*)_resolveDataPtr(insthdr->keyBindingArray,instbase);
   
       fprintf(_out,"\n\nInstance Key Bindings :");
       fprintf(_out,"\n=======================");
       fprintf(_out,"\n\nNumber of Key Bindings : %u",insthdr->numberKeyBindings);
   
       for (Uint32 i = 0; i < insthdr->numberKeyBindings; i++)
       {
           fprintf(_out,"\n\nNo %u : '%s'",i,
                   NULLSTR(_getCharString(ptr[i],instbase)));
       }
       fprintf(_out,"\n");
   }
  
 void SCMODump::dumpSCMOClass(SCMOClass& testCls) const void SCMODump::dumpSCMOClass(SCMOClass& testCls) const
 { {
     SCMBClass_Main* clshdr = testCls.cls.hdr;     SCMBClass_Main* clshdr = testCls.cls.hdr;
     unsigned char* clsbase = testCls.cls.base;      char* clsbase = testCls.cls.base;
  
     printf("\n\nDump of SCMOClass\n");      fprintf(_out,"\n\nDump of SCMOClass\n");
     // The magic number for SCMO class     // The magic number for SCMO class
     printf("\nheader.magic=%08X",clshdr->header.magic);      fprintf(_out,"\nheader.magic=%08X",clshdr->header.magic);
     // Total size of the instance memory block( # bytes )     // Total size of the instance memory block( # bytes )
     printf("\nheader.totalSize=%llu",clshdr->header.totalSize);      fprintf(_out,"\nheader.totalSize=%llu",clshdr->header.totalSize);
     // The # of bytes free      // The reference counter for this c++ class
     printf("\nheader.freeBytes=%llu",clshdr->header.freeBytes);      fprintf(_out,"\nrefCount=%i",clshdr->refCount.get());
     // Index to the start of the free space in this insance  
     printf("\nheader.StartOfFreeSpace=%llu",clshdr->header.startOfFreeSpace);      fprintf(_out,"\n\nsuperClassName: \'%s\'",
     // The reference counter for this class             NULLSTR(_getCharString(clshdr->superClassName,clsbase)));
     printf("\nrefCount=%i",clshdr->refCount.get());      fprintf(_out,"\nnameSpace: \'%s\'",
               NULLSTR(_getCharString(clshdr->nameSpace,clsbase)));
     printf("\n\nsuperClassName: \'%s\'",      fprintf(_out,"\nclassName: \'%s\'",
            _getCharString(clshdr->superClassName,clsbase));              NULLSTR(_getCharString(clshdr->className,clsbase)));
     printf("\nnameSpace: \'%s\'",_getCharString(clshdr->nameSpace,clsbase));      fprintf(_out,"\n\nTheClass qualfiers:");
     printf("\nclassName: \'%s\'",_getCharString(clshdr->className,clsbase));  
     printf("\n\nTheClass qualfiers:");  
     _dumpQualifierArray(     _dumpQualifierArray(
         clshdr->qualifierArray.start,         clshdr->qualifierArray.start,
         clshdr->numberOfQualifiers,         clshdr->numberOfQualifiers,
         clsbase);         clsbase);
     printf("\n");      fprintf(_out,"\n");
     dumpKeyPropertyMask(testCls);     dumpKeyPropertyMask(testCls);
     printf("\n");      fprintf(_out,"\n");
     dumpKeyIndexList(testCls);     dumpKeyIndexList(testCls);
     printf("\n");      fprintf(_out,"\n");
     dumpClassProperties(testCls);     dumpClassProperties(testCls);
     printf("\n");      fprintf(_out,"\n");
     dumpKeyBindingSet(testCls);     dumpKeyBindingSet(testCls);
     printf("\n");      fprintf(_out,"\n");
     /*     /*
     */     */
     printf("\n");      fprintf(_out,"\n");
   
   }
   
   void SCMODump::dumpSCMOClassQualifiers(SCMOClass& testCls) const
   {
       SCMBClass_Main* clshdr = testCls.cls.hdr;
       char* clsbase = testCls.cls.base;
   
       fprintf(_out,"\n\nTheClass qualfiers:");
       _dumpQualifierArray(
           clshdr->qualifierArray.start,
           clshdr->numberOfQualifiers,
           clsbase);
       fprintf(_out,"\n\n\n");
  
 } }
  
 void SCMODump::hexDumpSCMOClass(SCMOClass& testCls) const void SCMODump::hexDumpSCMOClass(SCMOClass& testCls) const
 { {
     unsigned char* tmp;      char* tmp;
  
     SCMBClass_Main* clshdr = testCls.cls.hdr;     SCMBClass_Main* clshdr = testCls.cls.hdr;
     unsigned char* clsbase = testCls.cls.base;      char* clsbase = testCls.cls.base;
  
     printf("\n\nHex dump of a SCMBClass:");      fprintf(_out,"\n\nHex dump of a SCMBClass:");
     printf("\n========================");      fprintf(_out,"\n========================");
     printf("\n\n Size of SCMBClass: %llu",clshdr->header.totalSize);      fprintf(_out,"\n\n Size of SCMBClass: %llu\n\n",clshdr->header.totalSize);
     printf("\n cls.base = %p\n\n",clsbase);  
  
     _hexDump(clsbase,clshdr->header.totalSize);     _hexDump(clsbase,clshdr->header.totalSize);
  
Line 2257 
Line 2908 
 void SCMODump::dumpKeyIndexList(SCMOClass& testCls) const void SCMODump::dumpKeyIndexList(SCMOClass& testCls) const
 { {
     SCMBClass_Main* clshdr = testCls.cls.hdr;     SCMBClass_Main* clshdr = testCls.cls.hdr;
     unsigned char* clsbase = testCls.cls.base;      char* clsbase = testCls.cls.base;
  
     printf("\n\nKey Index List:");      fprintf(_out,"\n\nKey Index List:");
     printf("\n===============\n");      fprintf(_out,"\n===============\n");
  
     // Get absolut pointer to key index list of the class     // Get absolut pointer to key index list of the class
     Uint32* keyIndex = (Uint32*)&(clsbase)[clshdr->keyIndexList.start];     Uint32* keyIndex = (Uint32*)&(clsbase)[clshdr->keyIndexList.start];
Line 2277 
Line 2928 
         }         }
  
  
         printf("Index :");          fprintf(_out,"Index :");
         for (i = 0; i < line; i++)         for (i = 0; i < line; i++)
         {         {
             printf(" %3u",j+i);              fprintf(_out," %3u",j+i);
         }         }
  
         printf("\nNode  :");          fprintf(_out,"\nNode  :");
         for (i = 0; i < line; i++)         for (i = 0; i < line; i++)
         {         {
             printf(" %3u",keyIndex[j+i]);              fprintf(_out," %3u",keyIndex[j+i]);
         }         }
  
         printf("\n\n");          fprintf(_out,"\n\n");
  
     }     }
  
Line 2298 
Line 2949 
 void SCMODump::dumpKeyBindingSet(SCMOClass& testCls) const void SCMODump::dumpKeyBindingSet(SCMOClass& testCls) const
 { {
     SCMBClass_Main* clshdr = testCls.cls.hdr;     SCMBClass_Main* clshdr = testCls.cls.hdr;
     unsigned char* clsbase = testCls.cls.base;      char* clsbase = testCls.cls.base;
  
     printf("\n\nKey Binding Set:");      fprintf(_out,"\n\nKey Binding Set:");
     printf("\n=================\n");      fprintf(_out,"\n=================\n");
     printf("\nNumber of key bindings: %3u",clshdr->keyBindingSet.number);      fprintf(_out,"\nNumber of key bindings: %3u",clshdr->keyBindingSet.number);
     dumpHashTable(     dumpHashTable(
         clshdr->keyBindingSet.hashTable,         clshdr->keyBindingSet.hashTable,
         PEGASUS_KEYBINDIG_SCMB_HASHSIZE);         PEGASUS_KEYBINDIG_SCMB_HASHSIZE);
Line 2314 
Line 2965 
 void SCMODump::dumpClassKeyBindingNodeArray(SCMOClass& testCls) const void SCMODump::dumpClassKeyBindingNodeArray(SCMOClass& testCls) const
 { {
     SCMBClass_Main* clshdr = testCls.cls.hdr;     SCMBClass_Main* clshdr = testCls.cls.hdr;
     unsigned char* clsbase = testCls.cls.base;      char* clsbase = testCls.cls.base;
  
     SCMBKeyBindingNode* nodeArray =     SCMBKeyBindingNode* nodeArray =
         (SCMBKeyBindingNode*)         (SCMBKeyBindingNode*)
Line 2322 
Line 2973 
  
     for (Uint32 i = 0; i <  clshdr->keyBindingSet.number; i++)     for (Uint32 i = 0; i <  clshdr->keyBindingSet.number; i++)
     {     {
         printf("\n\n===================");          fprintf(_out,"\n\n===================");
         printf("\nKey Binding #%3u",i);          fprintf(_out,"\nKey Binding #%3u",i);
         printf("\n===================");          fprintf(_out,"\n===================");
  
         printf("\nHas next: %s",(nodeArray[i].hasNext?"TRUE":"FALSE"));          fprintf(_out,"\nHas next: %s",(nodeArray[i].hasNext?"TRUE":"FALSE"));
         if (nodeArray[i].hasNext)         if (nodeArray[i].hasNext)
         {         {
             printf("\nNext Node: %3u",nodeArray[i].nextNode);              fprintf(_out,"\nNext Node: %3u",nodeArray[i].nextNode);
         }         }
         else         else
         {         {
             printf("\nNext Node: N/A");              fprintf(_out,"\nNext Node: N/A");
         }         }
  
         printf("\nKey Property name: %s",          fprintf(_out,"\nKey Property name: %s",
                _getCharString(nodeArray[i].name,clsbase));                 NULLSTR(_getCharString(nodeArray[i].name,clsbase)));
  
         printf("\nHash Tag %3u Hash Index %3u",          fprintf(_out,"\nHash Tag %3u Hash Index %3u",
                nodeArray[i].nameHashTag,                nodeArray[i].nameHashTag,
                nodeArray[i].nameHashTag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE);                nodeArray[i].nameHashTag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE);
  
         printf("\nKey binding type: %s",          fprintf(_out,"\nKey binding type: %s",
                XmlWriter::keyBindingTypeToString(nodeArray[i].type).str);                XmlWriter::keyBindingTypeToString(nodeArray[i].type).str);
  
     }     }
Line 2353 
Line 3004 
 void SCMODump::dumpClassProperties(SCMOClass& testCls) const void SCMODump::dumpClassProperties(SCMOClass& testCls) const
 { {
     SCMBClass_Main* clshdr = testCls.cls.hdr;     SCMBClass_Main* clshdr = testCls.cls.hdr;
     unsigned char* clsbase = testCls.cls.base;      char* clsbase = testCls.cls.base;
  
     printf("\n\nClass Properties:");      fprintf(_out,"\n\nClass Properties:");
     printf("\n=================\n");      fprintf(_out,"\n=================\n");
     printf("\nNumber of properties: %3u",clshdr->propertySet.number);      fprintf(_out,"\nNumber of properties: %3u",clshdr->propertySet.number);
     dumpHashTable(     dumpHashTable(
         clshdr->propertySet.hashTable,         clshdr->propertySet.hashTable,
         PEGASUS_PROPERTY_SCMB_HASHSIZE);         PEGASUS_PROPERTY_SCMB_HASHSIZE);
Line 2368 
Line 3019 
 void SCMODump::dumpClassPropertyNodeArray(SCMOClass& testCls) const void SCMODump::dumpClassPropertyNodeArray(SCMOClass& testCls) const
 { {
     SCMBClass_Main* clshdr = testCls.cls.hdr;     SCMBClass_Main* clshdr = testCls.cls.hdr;
     unsigned char* clsbase = testCls.cls.base;      char* clsbase = testCls.cls.base;
  
     SCMBClassPropertyNode* nodeArray =     SCMBClassPropertyNode* nodeArray =
         (SCMBClassPropertyNode*)         (SCMBClassPropertyNode*)
Line 2377 
Line 3028 
     for (Uint32 i = 0; i <  clshdr->propertySet.number; i++)     for (Uint32 i = 0; i <  clshdr->propertySet.number; i++)
     {     {
  
         printf("\n\n===================");          fprintf(_out,"\nClass property #%3u",i);
         printf("\nClass property #%3u",i);          fprintf(_out,"\n===================");
         printf("\n===================");  
  
         printf("\nHas next: %s",(nodeArray[i].hasNext?"TRUE":"FALSE"));          fprintf(_out,"\nHas next: %s",(nodeArray[i].hasNext?"TRUE":"FALSE"));
         if (nodeArray[i].hasNext)         if (nodeArray[i].hasNext)
         {         {
             printf("\nNext Node: %3u",nodeArray[i].nextNode);              fprintf(_out,"\nNext Node: %3u",nodeArray[i].nextNode);
         }         }
         else         else
         {         {
             printf("\nNext Node: N/A");              fprintf(_out,"\nNext Node: N/A");
         }         }
  
         _dumpClassProperty(nodeArray[i].theProperty,clsbase);         _dumpClassProperty(nodeArray[i].theProperty,clsbase);
Line 2397 
Line 3047 
  
 void SCMODump::_dumpClassProperty( void SCMODump::_dumpClassProperty(
     const SCMBClassProperty& prop,     const SCMBClassProperty& prop,
     unsigned char* clsbase) const      char* clsbase) const
 { {
     printf("\nProperty name: %s",_getCharString(prop.name,clsbase));      fprintf(_out,"\nProperty name: %s",
               NULLSTR(_getCharString(prop.name,clsbase)));
  
     printf("\nHash Tag %3u Hash Index %3u",      fprintf(_out,"\nHash Tag %3u Hash Index %3u",
            prop.nameHashTag,            prop.nameHashTag,
            prop.nameHashTag%PEGASUS_PROPERTY_SCMB_HASHSIZE);            prop.nameHashTag%PEGASUS_PROPERTY_SCMB_HASHSIZE);
     printf("\nPropagated: %s isKey: %s",      fprintf(_out,"\nPropagated: %s isKey: %s",
            (prop.flags.propagated?"TRUE":"FALSE"),            (prop.flags.propagated?"TRUE":"FALSE"),
            (prop.flags.isKey?"TRUE":"FALSE")            (prop.flags.isKey?"TRUE":"FALSE")
            );            );
  
     printf("\nOrigin class name: %s",      fprintf(_out,"\nOrigin class name: %s",
            _getCharString(prop.originClassName,clsbase));             NULLSTR(_getCharString(prop.originClassName,clsbase)));
     printf("\nReference class name: %s",      fprintf(_out,"\nReference class name: %s",
            _getCharString(prop.refClassName,clsbase));             NULLSTR(_getCharString(prop.refClassName,clsbase)));
  
     printSCMOValue(prop.defaultValue,clsbase);     printSCMOValue(prop.defaultValue,clsbase);
  
Line 2426 
Line 3077 
 void SCMODump::dumpHashTable(Uint32* hashTable,Uint32 size) const void SCMODump::dumpHashTable(Uint32* hashTable,Uint32 size) const
 { {
     Uint32 i,j,line;     Uint32 i,j,line;
     printf("\n\nHash table:\n");      fprintf(_out,"\n\nHash table:\n");
  
  
     for (j = 0; j < size; j = j + line)     for (j = 0; j < size; j = j + line)
Line 2441 
Line 3092 
         }         }
  
  
         printf("Index    :");          fprintf(_out,"Index    :");
         for (i = 0; i < line; i++)         for (i = 0; i < line; i++)
         {         {
             printf(" %3u",j+i);              fprintf(_out," %3u",j+i);
         }         }
  
         printf("\nHashTable:");          fprintf(_out,"\nHashTable:");
         for (i = 0; i < line; i++)         for (i = 0; i < line; i++)
         {         {
             printf(" %3u",hashTable[j+i]);              fprintf(_out," %3u",hashTable[j+i]);
         }         }
  
         printf("\n\n");          fprintf(_out,"\n\n");
  
     }     }
  
Line 2463 
Line 3114 
 void SCMODump::_dumpQualifierArray( void SCMODump::_dumpQualifierArray(
     Uint64 start,     Uint64 start,
     Uint32 size,     Uint32 size,
     unsigned char* clsbase      char* clsbase
     ) const     ) const
 { {
  
Line 2477 
Line 3128 
  
 void SCMODump::_dumpQualifier( void SCMODump::_dumpQualifier(
     const SCMBQualifier& theQualifier,     const SCMBQualifier& theQualifier,
     unsigned char* clsbase      char* clsbase
     ) const     ) const
 { {
      if(theQualifier.name == QUALNAME_USERDEFINED)      if(theQualifier.name == QUALNAME_USERDEFINED)
      {      {
          printf("\n\nQualifier user defined name: \'%s\'",           fprintf(_out,"\n\nQualifier user defined name: \'%s\'",
                 _getCharString(theQualifier.userDefName,clsbase));                  NULLSTR(_getCharString(theQualifier.userDefName,clsbase)));
      }      }
      else      else
      {      {
          printf("\n\nQualifier DMTF defined name: \'%s\'",           fprintf(_out,"\n\nQualifier DMTF defined name: \'%s\'",
                 _qualifierNameStrLit[theQualifier.name].str);                 _qualifierNameStrLit[theQualifier.name].str);
      }      }
  
      printf("\nPropagated : %s",       fprintf(_out,"\nPropagated : %s",
             (theQualifier.propagated ? "True" : "False"));             (theQualifier.propagated ? "True" : "False"));
      printf("\nFlavor : %s",       fprintf(_out,"\nFlavor : %s",
          (const char*)(CIMFlavor(theQualifier.flavor).toString().getCString()));          (const char*)(CIMFlavor(theQualifier.flavor).toString().getCString()));
  
      printSCMOValue(theQualifier.value,clsbase);      printSCMOValue(theQualifier.value,clsbase);
Line 2502 
Line 3153 
  
 void SCMODump::printSCMOValue( void SCMODump::printSCMOValue(
     const SCMBValue& theValue,     const SCMBValue& theValue,
     unsigned char* base) const      char* base) const
 { {
    printf("\nValueType : %s",cimTypeToString(theValue.valueType));     fprintf(_out,"\nValueType : %s",cimTypeToString(theValue.valueType));
    printf("\nValue was set by the provider: %s",     fprintf(_out,"\nValue was set by the provider: %s",
        (theValue.flags.isSet ? "True" : "False"));        (theValue.flags.isSet ? "True" : "False"));
    if (theValue.flags.isNull)    if (theValue.flags.isNull)
    {    {
        printf("\nIt's a NULL value.");         fprintf(_out,"\nIt's a NULL value.");
        return;        return;
    }    }
    if (theValue.flags.isArray)    if (theValue.flags.isArray)
    {    {
        printf("\nThe value is an Array of size: %u",theValue.valueArraySize);         fprintf(_out,
        printf("\nThe values are: '%s'",                 "\nThe value is an Array of size: %u",
                  theValue.valueArraySize);
          fprintf(_out,"\nThe values are: '%s'",
               (const char*)printArrayValue(               (const char*)printArrayValue(
                   theValue.valueType,                   theValue.valueType,
                   theValue.valueArraySize,                   theValue.valueArraySize,
Line 2524 
Line 3177 
    }    }
    else    else
    {    {
       printf("\nThe Value is: '%s'",        fprintf(_out,"\nThe Value is: '%s'",
           (const char*)           (const char*)
              printUnionValue(theValue.valueType,theValue.value,base)              printUnionValue(theValue.valueType,theValue.value,base)
              .getCString());              .getCString());
Line 2534 
Line 3187 
  
 } }
  
   void SCMODump::dumpKeyPropertyMask(SCMOClass& testCls ) const
   {
   
       SCMBClass_Main* clshdr = testCls.cls.hdr;
       char* clsbase = testCls.cls.base;
   
        Uint64 *theKeyMask = (Uint64*)&(clsbase[clshdr->keyPropertyMask.start]);
        Uint32 end, noProperties = clshdr->propertySet.number;
        Uint32 noMasks = (noProperties-1)/64;
        Uint64 printMask = 1;
   
        for (Uint32 i = 0; i <= noMasks; i++ )
        {
            printMask = 1;
            if (i < noMasks)
            {
                end = 64;
            }
            else
            {
                end = noProperties%64;
            }
   
            fprintf(_out,"\nkeyPropertyMask[%02u]= ",i);
   
            for (Uint32 j = 0; j < end; j++)
            {
                if (j > 0 && !(j%8))
                {
                    fprintf(_out," ");
                }
   
                if (theKeyMask[i] & printMask)
                {
                    fprintf(_out,"1");
                }
                else
                {
                    fprintf(_out,"0");
                }
   
                printMask = printMask << 1;
            }
            fprintf(_out,"\n");
        }
   }
   
   void SCMODump::_hexDump(char* buffer,int length) const
   {
   
       unsigned char printLine[3][80];
       int p;
       int len;
       unsigned char item;
   
       for (int i = 0; i < length;i=i+1)
       {
           p = i%80;
   
           if ((p == 0 && i > 0) || i == length-1 )
           {
               for (int y = 0; y < 3; y=y+1)
               {
                   if (p == 0)
                   {
                       len = 80;
                   } else
                   {
                       len = p;
                   }
   
                   for (int x = 0; x < len; x=x+1)
                   {
                       if (y == 0)
                       {
                           fprintf(_out,"%c",printLine[y][x]);
                       }
                       else
                       {
                           fprintf(_out,"%1X",printLine[y][x]);
                       }
                   }
                   fprintf(_out,"\n");
               }
               fprintf(_out,"\n");
           }
   
           item = (unsigned char)buffer[i];
   
           if (item < 32 || item > 125 )
           {
               printLine[0][p] = '.';
           } else
           {
               printLine[0][p] = item;
           }
   
           printLine[1][p] = item/16;
           printLine[2][p] = item%16;
   
       }
   }
   
 String SCMODump::printArrayValue( String SCMODump::printArrayValue(
     CIMType type,     CIMType type,
     Uint32 size,     Uint32 size,
     SCMBUnion u,     SCMBUnion u,
     unsigned char* base) const      char* base) const
 { {
     Buffer out;     Buffer out;
  
Line 2652 
Line 3408 
             {             {
                 memcpy(x._rep,&(p[i]),sizeof(SCMBDateTime));                 memcpy(x._rep,&(p[i]),sizeof(SCMBDateTime));
                 _toString(out,x);                 _toString(out,x);
                   out.append(' ');
             }             }
             break;             break;
         }         }
Line 2682 
Line 3439 
 String SCMODump::printUnionValue( String SCMODump::printUnionValue(
     CIMType type,     CIMType type,
     SCMBUnion u,     SCMBUnion u,
     unsigned char* base) const      char* base) const
 { {
   
     Buffer out;     Buffer out;
  
     switch (type)     switch (type)
Line 2798 
Line 3556 
   return out.getData();   return out.getData();
 } }
  
 void SCMODump::dumpKeyPropertyMask(SCMOClass& testCls ) const  
 {  
   
     SCMBClass_Main* clshdr = testCls.cls.hdr;  
     unsigned char* clsbase = testCls.cls.base;  
   
      Uint64 *theKeyMask = (Uint64*)&(clsbase[clshdr->keyPropertyMask.start]);  
      Uint32 end, noProperties = clshdr->propertySet.number;  
      Uint32 noMasks = (noProperties-1)/64;  
      Uint64 printMask = 1;  
   
      for (Uint32 i = 0; i <= noMasks; i++ )  
      {  
          printMask = 1;  
          if (i < noMasks)  
          {  
              end = 64;  
          }  
          else  
          {  
              end = noProperties%64;  
          }  
   
          printf("\nkeyPropertyMask[%02u]= ",i);  
   
          for (Uint32 j = 0; j < end; j++)  
          {  
              if (j > 0 && !(j%8))  
              {  
                  printf(" ");  
              }  
   
              if (theKeyMask[i] & printMask)  
              {  
                  printf("1");  
              }  
              else  
              {  
                  printf("0");  
              }  
   
              printMask = printMask << 1;  
          }  
          printf("\n");  
      }  
 }  
   
 void SCMODump::_hexDump(unsigned char* buffer,int length) const  
 {  
   
     unsigned char printLine[3][80];  
     int p;  
     int len;  
     unsigned char item;  
   
     for (int i = 0; i < length;i=i+1)  
     {  
         p = i%80;  
   
         if ((p == 0 && i > 0) || i == length-1 )  
         {  
             for (int y = 0; y < 3; y=y+1)  
             {  
                 if (p == 0)  
                 {  
                     len = 80;  
                 } else  
                 {  
                     len = p;  
                 }  
   
                 for (int x = 0; x < len; x=x+1)  
                 {  
                     if (y == 0)  
                     {  
                         printf("%c",printLine[y][x]);  
                     }  
                     else  
                     {  
                         printf("%1X",printLine[y][x]);  
                     }  
                 }  
                 printf("\n");  
             }  
             printf("\n");  
         }  
   
         item = buffer[i];  
   
         if (item < 32 || item > 125 )  
         {  
             printLine[0][p] = '.';  
         } else  
         {  
             printLine[0][p] = item;  
         }  
   
         printLine[1][p] = item/16;  
         printLine[2][p] = item%16;  
   
     }  
 }  
  
 /***************************************************************************** /*****************************************************************************
  * The constant functions  * The constant functions
Line 2907 
Line 3563 
  
 static const void* _resolveDataPtr( static const void* _resolveDataPtr(
     const SCMBDataPtr& ptr,     const SCMBDataPtr& ptr,
     unsigned char* base)      char* base)
 { {
     return ((ptr.start==(Uint64)0 ? NULL : (void*)&(base[ptr.start])));     return ((ptr.start==(Uint64)0 ? NULL : (void*)&(base[ptr.start])));
 } }
  
 PEGASUS_COMMON_LINKAGE const unsigned char* _getCharString(  PEGASUS_COMMON_LINKAGE const char* _getCharString(
     const SCMBDataPtr& ptr,     const SCMBDataPtr& ptr,
     unsigned char* base)      char* base)
 { {
     return ((ptr.start==(Uint64)0 ? NULL : &(base[ptr.start])));     return ((ptr.start==(Uint64)0 ? NULL : &(base[ptr.start])));
 } }
Line 2922 
Line 3578 
  
 static Uint32 _generateSCMOStringTag( static Uint32 _generateSCMOStringTag(
     const SCMBDataPtr& ptr,     const SCMBDataPtr& ptr,
     unsigned char* base)      char* base)
 { {
     // The lenght of a SCMBDataPtr to a UTF8 string includs the trailing '\0'.     // The lenght of a SCMBDataPtr to a UTF8 string includs the trailing '\0'.
     return _generateStringTag(_getCharString(ptr,base),ptr.length-1);     return _generateStringTag(_getCharString(ptr,base),ptr.length-1);
 } }
  
 static Uint32 _generateStringTag(const unsigned char* str, Uint32 len)  static Uint32 _generateStringTag(const char* str, Uint32 len)
 { {
     if (len == 0)     if (len == 0)
     {     {
Line 2967 
Line 3623 
  
 static Boolean _equalUTF8Strings( static Boolean _equalUTF8Strings(
     const SCMBDataPtr& ptr_a,     const SCMBDataPtr& ptr_a,
     unsigned char* base,      char* base,
     const char* name,     const char* name,
     Uint32 len)     Uint32 len)
  
Line 3042 
Line 3698 
     if (clear)     if (clear)
     {     {
         // If requested, set memory to 0.         // If requested, set memory to 0.
         memset(&((unsigned char*)(*pmem))[start],0,size);          memset(&((char*)(*pmem))[start],0,size);
     }     }
     return start;     return start;
 } }
Line 3069 
Line 3725 
        // --> use the returned start index.        // --> use the returned start index.
        start = _getFreeSpace(ptr , length, pmem);        start = _getFreeSpace(ptr , length, pmem);
        // Copy string including trailing \0        // Copy string including trailing \0
        memcpy(&((unsigned char*)(*pmem))[start],(const char*)theCString,length);         memcpy(&((char*)(*pmem))[start],(const char*)theCString,length);
     }     }
     else     else
     {     {
Line 3096 
Line 3752 
         start = _getFreeSpace(ptr , bufferSize, pmem);         start = _getFreeSpace(ptr , bufferSize, pmem);
         // Copy buffer into SCMB         // Copy buffer into SCMB
         memcpy(         memcpy(
             &((unsigned char*)(*pmem))[start],              &((char*)(*pmem))[start],
             (const char*)theBuffer,             (const char*)theBuffer,
             bufferSize);             bufferSize);
     }     }


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.2.2.11

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2