CMPIStatus indProvMustPoll (CMPIIndicationMI * cThis, const CMPIContext *ctx, const CMPISelectExp *filter, const char *clsName, const CMPIObjectPath * classPath) { char* op = CMGetCharPtr(CMObjectPathToString(classPath, NULL)); fprintf (stderr, "+++ indProvMustPoll for %s %s\n", op, clsName); CMReturn(CMPI_RC_OK); }
CMPIStatus indProvActivateFilter (CMPIIndicationMI * cThis, const CMPIContext *ctx, const CMPISelectExp *exp, const char *clsName, const CMPIObjectPath * classPath, CMPIBoolean firstActivation) { char* op = CMGetCharPtr(CMObjectPathToString(classPath, NULL)); fprintf (stderr, "+++ indProvActivateFilter() for %s %s\n", op, clsName); if (strcmp(op, "root/interop:Test_Indication") == 0) activated = 1; else if (strcmp(op, "root/interop2:Test_Indication") == 0) activated2 = 1; CMReturn(CMPI_RC_OK); }
static int _testCMPIObjectPath() { CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIObjectPath *objPath = NULL; CMPIObjectPath *clonedObjPath = NULL; CMPIObjectPath *otherObjPath = NULL; CMPIObjectPath *fakeObjPath = NULL; const char *hostName = "HOSTNAME"; const char *nameSpace = "root/dummy"; const char *className = "classname"; CMPIString *returnedHostname = NULL; CMPIBoolean equalHostname = 0; CMPIString *returnedNamespace = NULL; CMPIBoolean equalNamespace = 0; CMPIString *returnedClassName; CMPIBoolean equalClassName = 0; CMPIString *returnedObjectPath; CMPIBoolean cloneSuccessful = 0; CMPIBoolean getKeySuccessful = 0; CMPIBoolean getKeyCountSuccessful = 0; CMPIBoolean getKeyAtSuccessful = 0; const char *objectPath1 = NULL; const char *objectPath2 = NULL; CMPIData data; CMPIValue value; unsigned int keyCount = 0; objPath = make_ObjectPath(_broker, _Namespace, _ClassName); rc = CMSetHostname(objPath, hostName); returnedHostname = CMGetHostname(objPath, &rc); if (strcmp(hostName, CMGetCharsPtr(returnedHostname, &rc)) == 0) { equalHostname = 1; } rc = CMSetNameSpace(objPath, nameSpace); returnedNamespace = CMGetNameSpace(objPath, &rc); if (strcmp(nameSpace, CMGetCharsPtr(returnedNamespace, &rc)) == 0) { equalNamespace = 1; } rc = CMSetClassName(objPath, className); returnedClassName = CMGetClassName(objPath, &rc); if (strcmp(className, CMGetCharsPtr(returnedClassName, &rc)) == 0) { equalClassName = 1; } otherObjPath = make_ObjectPath(_broker, _Namespace, _ClassName); returnedNamespace = CMGetNameSpace(otherObjPath, &rc); rc = CMSetNameSpaceFromObjectPath(otherObjPath, objPath); returnedNamespace = CMGetNameSpace(otherObjPath, &rc); if (strcmp(nameSpace, CMGetCharsPtr(returnedNamespace, &rc)) == 0) { equalNamespace = 1; } returnedHostname = CMGetHostname(otherObjPath, &rc); rc = CMSetHostAndNameSpaceFromObjectPath(otherObjPath, objPath); returnedHostname = CMGetHostname(otherObjPath, &rc); if (strcmp(hostName, CMGetCharsPtr(returnedHostname, &rc)) == 0) { equalHostname = 1; } returnedObjectPath = CMObjectPathToString(objPath, &rc); objectPath1 = CMGetCharsPtr(returnedObjectPath, &rc); clonedObjPath = objPath->ft->clone(objPath, &rc); returnedObjectPath = CMObjectPathToString(clonedObjPath, &rc); rc = clonedObjPath->ft->release(clonedObjPath); objectPath2 = CMGetCharsPtr(returnedObjectPath, &rc); if (strcmp(objectPath1, objectPath2) == 0) { cloneSuccessful = 1; } else { cloneSuccessful = 0; } fakeObjPath = CMNewObjectPath(_broker, "root#cimv2", "Sample_Instance", &rc); rc = CMAddKey(fakeObjPath, "ElementName", (CMPIValue *) "Fake", CMPI_chars); rc = CMAddKey(otherObjPath, "ElementName1", (CMPIValue *) "otherObjPath", CMPI_chars); data = CMGetKey(fakeObjPath, "ElementName", &rc); if (strcmp(CMGetCharsPtr(data.value.string, &rc), "Fake") == 0) { getKeySuccessful = 1; } keyCount = CMGetKeyCount(fakeObjPath, &rc); if (keyCount == 1) { getKeyCountSuccessful = 1; } data = CMGetKeyAt(fakeObjPath, 0, NULL, &rc); if (rc.rc == 0) { getKeyAtSuccessful = 1; } value.uint16 = 67; rc = CMAddKey(fakeObjPath, "Numeric_key_unsigned", (CMPIValue *) & value, CMPI_uint16); data = CMGetKey(fakeObjPath, "Numeric_key_unsigned", &rc); value.sint16 = -67; rc = CMAddKey(fakeObjPath, "Numeric_key_signed", (CMPIValue *) & value, CMPI_sint16); data = CMGetKey(fakeObjPath, "Numeric_key_signed", &rc); value.boolean = 1; rc = CMAddKey(fakeObjPath, "Boolean_key", (CMPIValue *) & value, CMPI_boolean); data = CMGetKey(fakeObjPath, "Boolean_key", &rc); CMGetKeyAt(objPath, 500, NULL, &rc); if (rc.rc != CMPI_RC_ERR_NO_SUCH_PROPERTY) { return 1; } rc = objPath->ft->release(objPath); rc = fakeObjPath->ft->release(fakeObjPath); return 0; }
static int _testCMPIInstance() { CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIInstance *instance = NULL; CMPIInstance *clonedInstance = NULL; CMPIObjectPath *objPath = NULL; CMPIObjectPath *newObjPath = NULL; CMPIObjectPath *returnedObjPath = NULL; CMPIData returnedData1; CMPIData returnedData2; CMPIData clonedData1; CMPIString *returnedName = NULL; unsigned int count = 0; const char *name1 = "firstPropertyName"; CMPIValue value1; const char *name2 = "secondPropertyName"; CMPIValue value2; CMPIType type = CMPI_uint64; CMPIBoolean dataEqual = 0; CMPIBoolean objectPathEqual = 0; CMPIBoolean cloneSuccessful = 0; CMPIString *beforeObjPath = NULL; CMPIString *afterObjPath = NULL; const char *beforeString = NULL; const char *afterString = NULL; objPath = make_ObjectPath(_broker, _Namespace, _ClassName); instance = make_Instance(objPath); value1.uint32 = 10; rc = CMSetProperty(instance, name1, &value1, type); value2.uint32 = 20; rc = CMSetProperty(instance, name2, &value2, type); count = CMGetPropertyCount(instance, &rc); returnedData1 = CMGetProperty(instance, name1, &rc); if (returnedData1.value.uint32 == 10) { dataEqual = 1; } returnedData2 = CMGetPropertyAt(instance, 2, &returnedName, &rc); if (returnedData2.value.uint32 == 20) { dataEqual = 1; } newObjPath = make_ObjectPath(_broker, _Namespace, _ClassName); returnedObjPath = CMGetObjectPath(instance, &rc); beforeObjPath = CMObjectPathToString(returnedObjPath, &rc); beforeString = CMGetCharsPtr(beforeObjPath, &rc); rc = CMSetNameSpace(newObjPath, "newNamespace"); rc = CMSetObjectPath(instance, newObjPath); returnedObjPath = CMGetObjectPath(instance, &rc); afterObjPath = CMObjectPathToString(returnedObjPath, &rc); afterString = CMGetCharsPtr(afterObjPath, &rc); afterString = CMGetCharsPtr(CMGetNameSpace(returnedObjPath, &rc), &rc); if (strcmp("newNamespace", afterString) == 0) { objectPathEqual = 1; } clonedInstance = instance->ft->clone(instance, &rc); clonedData1 = CMGetProperty(clonedInstance, name1, &rc); rc = clonedInstance->ft->release(clonedInstance); if (returnedData1.value.uint32 == clonedData1.value.uint32) { cloneSuccessful = 1; } else { cloneSuccessful = 0; } CMGetProperty(instance, "noProperty", &rc); if (rc.rc != CMPI_RC_ERR_NO_SUCH_PROPERTY) { return 1; } CMGetPropertyAt(instance, 100, &returnedName, &rc); if (rc.rc != CMPI_RC_ERR_NO_SUCH_PROPERTY) { return 1; } rc = instance->ft->release(instance); return 0; }