From 82f17656c3ef7c7e2647b2d81aedac3757651c7c Mon Sep 17 00:00:00 2001 From: Peter Schiffer Date: Wed, 7 May 2014 19:02:29 +0200 Subject: Software-dbus: embrace the new openlmi common library --- src/libs/libopenlmi/openlmi.h | 14 ++- .../LMI_HostedSoftwareCollectionProvider.c | 6 +- .../LMI_InstalledSoftwareIdentityProvider.c | 68 ++++++------ .../LMI_MemberOfSoftwareCollectionProvider.c | 90 ++++++++------- .../LMI_ResourceForSoftwareIdentityProvider.c | 119 ++++++++++---------- src/software-dbus/LMI_SoftwareIdentityProvider.c | 4 +- .../LMI_SoftwareIdentityResourceProvider.c | 31 +++--- .../LMI_SystemSoftwareCollectionProvider.c | 6 +- src/software-dbus/sw-utils.c | 123 +++++++-------------- src/software-dbus/sw-utils.h | 47 +------- 10 files changed, 217 insertions(+), 291 deletions(-) diff --git a/src/libs/libopenlmi/openlmi.h b/src/libs/libopenlmi/openlmi.h index a35e01e..8999ace 100644 --- a/src/libs/libopenlmi/openlmi.h +++ b/src/libs/libopenlmi/openlmi.h @@ -43,10 +43,16 @@ #define ARRAY_SIZE(name) (sizeof(name) / sizeof(name[0])) /* Association sides. */ -#define LMI_GROUP_COMPONENT "GroupComponent" -#define LMI_PART_COMPONENT "PartComponent" -#define LMI_SAME_ELEMENT "SameElement" -#define LMI_SYSTEM_ELEMENT "SystemElement" +#define LMI_GROUP_COMPONENT "GroupComponent" +#define LMI_PART_COMPONENT "PartComponent" +#define LMI_SAME_ELEMENT "SameElement" +#define LMI_SYSTEM_ELEMENT "SystemElement" +#define LMI_COLLECTION "Collection" +#define LMI_MEMBER "Member" +#define LMI_SYSTEM "System" +#define LMI_INSTALLED_SOFTWARE "InstalledSoftware" +#define LMI_AVAILABLE_SAP "AvailableSAP" +#define LMI_MANAGED_ELEMENT "ManagedElement" /* CMPI_RC_ERR_ values end at 200. 0xFF should be safe. */ #define LMI_RC_ERR_CLASS_CHECK_FAILED 0xFF diff --git a/src/software-dbus/LMI_HostedSoftwareCollectionProvider.c b/src/software-dbus/LMI_HostedSoftwareCollectionProvider.c index 8277baa..7fcd1de 100644 --- a/src/software-dbus/LMI_HostedSoftwareCollectionProvider.c +++ b/src/software-dbus/LMI_HostedSoftwareCollectionProvider.c @@ -54,10 +54,10 @@ static CMPIStatus LMI_HostedSoftwareCollectionEnumInstances( const CMPIObjectPath* cop, const char** properties) { - char instance_id[INSTANCE_ID_LEN] = ""; + char instance_id[BUFLEN] = ""; - create_instance_id(SYSTEM_SW_COLLECTION_CLASS_NAME, NULL, instance_id, - INSTANCE_ID_LEN); + create_instance_id(LMI_SystemSoftwareCollection_ClassName, NULL, instance_id, + BUFLEN); LMI_SystemSoftwareCollectionRef ssc; LMI_SystemSoftwareCollectionRef_Init(&ssc, _cb, KNameSpace(cop)); diff --git a/src/software-dbus/LMI_InstalledSoftwareIdentityProvider.c b/src/software-dbus/LMI_InstalledSoftwareIdentityProvider.c index 144c805..a190327 100644 --- a/src/software-dbus/LMI_InstalledSoftwareIdentityProvider.c +++ b/src/software-dbus/LMI_InstalledSoftwareIdentityProvider.c @@ -43,13 +43,13 @@ static CMPIStatus enum_instances(const CMPIResult *cr, const char *ns, GPtrArray *array = NULL; SwPackage sw_pkg; unsigned i; - char error_msg[ERROR_MSG_LEN] = "", elem_name[ELEM_NAME_LEN] = "", - instance_id[INSTANCE_ID_LEN] = ""; + char error_msg[BUFLEN] = "", elem_name[BUFLEN] = "", + instance_id[BUFLEN] = ""; init_sw_package(&sw_pkg); get_pk_packages(pk_bitfield_value(PK_FILTER_ENUM_INSTALLED), &array, - error_msg, ERROR_MSG_LEN); + error_msg, BUFLEN); if (!array) { goto done; } @@ -60,10 +60,10 @@ static CMPIStatus enum_instances(const CMPIResult *cr, const char *ns, continue; } - sw_pkg_get_element_name(&sw_pkg, elem_name, ELEM_NAME_LEN); + sw_pkg_get_element_name(&sw_pkg, elem_name, BUFLEN); - create_instance_id(SW_IDENTITY_CLASS_NAME, elem_name, instance_id, - INSTANCE_ID_LEN); + create_instance_id(LMI_SoftwareIdentity_ClassName, elem_name, instance_id, + BUFLEN); free_sw_package(&sw_pkg); @@ -207,54 +207,53 @@ static CMPIStatus associators( const short names) { CMPIStatus st; - char error_msg[ERROR_MSG_LEN] = ""; + char error_msg[BUFLEN] = ""; const char *computer_system_name; - computer_system_name = get_str_property_from_op(lmi_get_computer_system(), + computer_system_name = lmi_get_string_property_from_objectpath(lmi_get_computer_system(), "CreationClassName"); - if (!cm_class_is_a(_cb, KNameSpace(cop), assocClass, - ORGID "_" INST_SW_IDENTITY_CLASS_NAME)) { - goto done; - } + st = lmi_class_path_is_a(_cb, KNameSpace(cop), + LMI_InstalledSoftwareIdentity_ClassName, assocClass); + lmi_return_if_class_check_not_ok(st); if (CMClassPathIsA(_cb, cop, computer_system_name, &st)) { /* got PG_ComputerSystem - System */ - if (cm_class_is_a(_cb, KNameSpace(cop), resultClass, - ORGID "_" SW_IDENTITY_CLASS_NAME) != 0) { - goto done; - } - if (role && strcmp(role, SYSTEM_ATTR) != 0) { + st = lmi_class_path_is_a(_cb, KNameSpace(cop), + LMI_SoftwareIdentity_ClassName, resultClass); + lmi_return_if_class_check_not_ok(st); + + if (role && strcmp(role, LMI_SYSTEM) != 0) { goto done; } - if (resultRole && strcmp(resultRole, INST_SW_ATTR) != 0) { + if (resultRole && strcmp(resultRole, LMI_INSTALLED_SOFTWARE) != 0) { goto done; } if (names) { enum_sw_identity_instance_names( pk_bitfield_value(PK_FILTER_ENUM_INSTALLED), _cb, - KNameSpace(cop), cr, error_msg, ERROR_MSG_LEN); + KNameSpace(cop), cr, error_msg, BUFLEN); } else { enum_sw_identity_instances( pk_bitfield_value(PK_FILTER_ENUM_INSTALLED), _cb, - KNameSpace(cop), cr, error_msg, ERROR_MSG_LEN); + KNameSpace(cop), cr, error_msg, BUFLEN); } - } else if (CMClassPathIsA(_cb, cop, ORGID "_" SW_IDENTITY_CLASS_NAME, &st)) { + } else if (CMClassPathIsA(_cb, cop, LMI_SoftwareIdentity_ClassName, &st)) { /* got SoftwareIdentity - InstalledSoftware */ PkPackage *pk_pkg = NULL; SwPackage sw_pkg; init_sw_package(&sw_pkg); - if (cm_class_is_a(_cb, KNameSpace(cop), resultClass, - computer_system_name) != 0) { - goto done; - } - if (role && strcmp(role, INST_SW_ATTR) != 0) { + st = lmi_class_path_is_a(_cb, KNameSpace(cop), computer_system_name, + resultClass); + lmi_return_if_class_check_not_ok(st); + + if (role && strcmp(role, LMI_INSTALLED_SOFTWARE) != 0) { goto done; } - if (resultRole && strcmp(resultRole, SYSTEM_ATTR) != 0) { + if (resultRole && strcmp(resultRole, LMI_SYSTEM) != 0) { goto done; } @@ -326,29 +325,28 @@ static CMPIStatus references( CMPIStatus st; const char *computer_system_name; - computer_system_name = get_str_property_from_op(lmi_get_computer_system(), + computer_system_name = lmi_get_string_property_from_objectpath(lmi_get_computer_system(), "CreationClassName"); - if (!cm_class_is_a(_cb, KNameSpace(cop), assocClass, - ORGID "_" INST_SW_IDENTITY_CLASS_NAME)) { - goto done; - } + st = lmi_class_path_is_a(_cb, KNameSpace(cop), + LMI_InstalledSoftwareIdentity_ClassName, assocClass); + lmi_return_if_class_check_not_ok(st); if (CMClassPathIsA(_cb, cop, computer_system_name, &st)) { /* got PG_ComputerSystem - System */ - if (role && strcmp(role, SYSTEM_ATTR) != 0) { + if (role && strcmp(role, LMI_SYSTEM) != 0) { goto done; } return enum_instances(cr, KNameSpace(cop), names); - } else if (CMClassPathIsA(_cb, cop, ORGID "_" SW_IDENTITY_CLASS_NAME, &st)) { + } else if (CMClassPathIsA(_cb, cop, LMI_SoftwareIdentity_ClassName, &st)) { /* got SoftwareIdentity - InstalledSoftware */ PkPackage *pk_pkg = NULL; SwPackage sw_pkg; init_sw_package(&sw_pkg); - if (role && strcmp(role, INST_SW_ATTR) != 0) { + if (role && strcmp(role, LMI_INSTALLED_SOFTWARE) != 0) { goto done; } diff --git a/src/software-dbus/LMI_MemberOfSoftwareCollectionProvider.c b/src/software-dbus/LMI_MemberOfSoftwareCollectionProvider.c index 1d4bb45..b50f420 100644 --- a/src/software-dbus/LMI_MemberOfSoftwareCollectionProvider.c +++ b/src/software-dbus/LMI_MemberOfSoftwareCollectionProvider.c @@ -43,11 +43,11 @@ static CMPIStatus enum_instances(const CMPIResult *cr, const char *ns, GPtrArray *array = NULL; SwPackage sw_pkg; unsigned i; - char error_msg[ERROR_MSG_LEN] = "", elem_name[ELEM_NAME_LEN] = "", - instance_id[INSTANCE_ID_LEN] = ""; + char error_msg[BUFLEN] = "", elem_name[BUFLEN] = "", + instance_id[BUFLEN] = ""; - create_instance_id(SYSTEM_SW_COLLECTION_CLASS_NAME, NULL, instance_id, - INSTANCE_ID_LEN); + create_instance_id(LMI_SystemSoftwareCollection_ClassName, NULL, instance_id, + BUFLEN); LMI_SystemSoftwareCollectionRef ssc; LMI_SystemSoftwareCollectionRef_Init(&ssc, _cb, ns); @@ -55,7 +55,7 @@ static CMPIStatus enum_instances(const CMPIResult *cr, const char *ns, init_sw_package(&sw_pkg); - get_pk_packages(0, &array, error_msg, ERROR_MSG_LEN); + get_pk_packages(0, &array, error_msg, BUFLEN); if (!array) { goto done; } @@ -66,10 +66,10 @@ static CMPIStatus enum_instances(const CMPIResult *cr, const char *ns, continue; } - sw_pkg_get_element_name(&sw_pkg, elem_name, ELEM_NAME_LEN); + sw_pkg_get_element_name(&sw_pkg, elem_name, BUFLEN); - create_instance_id(SW_IDENTITY_CLASS_NAME, elem_name, instance_id, - INSTANCE_ID_LEN); + create_instance_id(LMI_SoftwareIdentity_ClassName, elem_name, instance_id, + BUFLEN); free_sw_package(&sw_pkg); @@ -129,17 +129,17 @@ static CMPIStatus LMI_MemberOfSoftwareCollectionGetInstance( { PkPackage *pk_pkg = NULL; SwPackage sw_pkg; - char instance_id[INSTANCE_ID_LEN] = ""; + char instance_id[BUFLEN] = ""; init_sw_package(&sw_pkg); - create_instance_id(SYSTEM_SW_COLLECTION_CLASS_NAME, NULL, instance_id, - INSTANCE_ID_LEN); + create_instance_id(LMI_SystemSoftwareCollection_ClassName, NULL, instance_id, + BUFLEN); LMI_MemberOfSoftwareCollection w; LMI_MemberOfSoftwareCollection_InitFromObjectPath(&w, _cb, cop); - if (strcmp(get_str_property_from_op(w.Collection.value, "InstanceID"), + if (strcmp(lmi_get_string_property_from_objectpath(w.Collection.value, "InstanceID"), instance_id) != 0) { CMReturn(CMPI_RC_ERR_NOT_FOUND); } @@ -220,50 +220,49 @@ static CMPIStatus associators( const short names) { CMPIStatus st; - char error_msg[ERROR_MSG_LEN] = ""; + char error_msg[BUFLEN] = ""; - if (!cm_class_is_a(_cb, KNameSpace(cop), assocClass, - ORGID "_" MEM_SW_COLL_CLASS_NAME)) { - goto done; - } + st = lmi_class_path_is_a(_cb, KNameSpace(cop), + LMI_MemberOfSoftwareCollection_ClassName, assocClass); + lmi_return_if_class_check_not_ok(st); - if (CMClassPathIsA(_cb, cop, ORGID "_" SYSTEM_SW_COLLECTION_CLASS_NAME, &st)) { + if (CMClassPathIsA(_cb, cop, LMI_SystemSoftwareCollection_ClassName, &st)) { /* got SystemSoftwareCollection - Collection; * where listing only associators names is supported */ if (!names) { CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); } - if (cm_class_is_a(_cb, KNameSpace(cop), resultClass, - ORGID "_" SW_IDENTITY_CLASS_NAME) != 0) { - goto done; - } - if (role && strcmp(role, COLLECTION_ATTR) != 0) { + st = lmi_class_path_is_a(_cb, KNameSpace(cop), + LMI_SoftwareIdentity_ClassName, resultClass); + lmi_return_if_class_check_not_ok(st); + + if (role && strcmp(role, LMI_COLLECTION) != 0) { goto done; } - if (resultRole && strcmp(resultRole, MEMBER_ATTR) != 0) { + if (resultRole && strcmp(resultRole, LMI_MEMBER) != 0) { goto done; } enum_sw_identity_instance_names(0, _cb, KNameSpace(cop), cr, error_msg, - ERROR_MSG_LEN); - } else if (CMClassPathIsA(_cb, cop, ORGID "_" SW_IDENTITY_CLASS_NAME, &st)) { + BUFLEN); + } else if (CMClassPathIsA(_cb, cop, LMI_SoftwareIdentity_ClassName, &st)) { /* got SoftwareIdentity - Member */ - char instance_id[INSTANCE_ID_LEN] = ""; + char instance_id[BUFLEN] = ""; - if (cm_class_is_a(_cb, KNameSpace(cop), resultClass, - ORGID "_" SYSTEM_SW_COLLECTION_CLASS_NAME) != 0) { - goto done; - } - if (role && strcmp(role, MEMBER_ATTR) != 0) { + st = lmi_class_path_is_a(_cb, KNameSpace(cop), + LMI_SystemSoftwareCollection_ClassName, resultClass); + lmi_return_if_class_check_not_ok(st); + + if (role && strcmp(role, LMI_MEMBER) != 0) { goto done; } - if (resultRole && strcmp(resultRole, COLLECTION_ATTR) != 0) { + if (resultRole && strcmp(resultRole, LMI_COLLECTION) != 0) { goto done; } - create_instance_id(SYSTEM_SW_COLLECTION_CLASS_NAME, NULL, instance_id, - INSTANCE_ID_LEN); + create_instance_id(LMI_SystemSoftwareCollection_ClassName, NULL, instance_id, + BUFLEN); LMI_SystemSoftwareCollectionRef ssc; LMI_SystemSoftwareCollectionRef_Init(&ssc, _cb, KNameSpace(cop)); @@ -324,28 +323,27 @@ static CMPIStatus references( { CMPIStatus st; - if (!cm_class_is_a(_cb, KNameSpace(cop), assocClass, - ORGID "_" MEM_SW_COLL_CLASS_NAME)) { - goto done; - } + st = lmi_class_path_is_a(_cb, KNameSpace(cop), + LMI_MemberOfSoftwareCollection_ClassName, assocClass); + lmi_return_if_class_check_not_ok(st); - if (CMClassPathIsA(_cb, cop, ORGID "_" SYSTEM_SW_COLLECTION_CLASS_NAME, &st)) { + if (CMClassPathIsA(_cb, cop, LMI_SystemSoftwareCollection_ClassName, &st)) { /* got SystemSoftwareCollection - Collection */ - if (role && strcmp(role, COLLECTION_ATTR) != 0) { + if (role && strcmp(role, LMI_COLLECTION) != 0) { goto done; } return enum_instances(cr, KNameSpace(cop), names); - } else if (CMClassPathIsA(_cb, cop, ORGID "_" SW_IDENTITY_CLASS_NAME, &st)) { + } else if (CMClassPathIsA(_cb, cop, LMI_SoftwareIdentity_ClassName, &st)) { /* got SoftwareIdentity - Member */ - char instance_id[INSTANCE_ID_LEN] = ""; + char instance_id[BUFLEN] = ""; - if (role && strcmp(role, MEMBER_ATTR) != 0) { + if (role && strcmp(role, LMI_MEMBER) != 0) { goto done; } - create_instance_id(SYSTEM_SW_COLLECTION_CLASS_NAME, NULL, instance_id, - INSTANCE_ID_LEN); + create_instance_id(LMI_SystemSoftwareCollection_ClassName, NULL, instance_id, + BUFLEN); LMI_SystemSoftwareCollectionRef ssc; LMI_SystemSoftwareCollectionRef_Init(&ssc, _cb, KNameSpace(cop)); diff --git a/src/software-dbus/LMI_ResourceForSoftwareIdentityProvider.c b/src/software-dbus/LMI_ResourceForSoftwareIdentityProvider.c index d1681ff..62864fd 100644 --- a/src/software-dbus/LMI_ResourceForSoftwareIdentityProvider.c +++ b/src/software-dbus/LMI_ResourceForSoftwareIdentityProvider.c @@ -42,7 +42,7 @@ static void k_return_rfsi(const gchar *pkg_id, const char *ns, const short names) { SwPackage sw_pkg; - char elem_name[ELEM_NAME_LEN] = "", instance_id[INSTANCE_ID_LEN] = ""; + char elem_name[BUFLEN] = "", instance_id[BUFLEN] = ""; init_sw_package(&sw_pkg); @@ -50,10 +50,10 @@ static void k_return_rfsi(const gchar *pkg_id, goto done; } - sw_pkg_get_element_name(&sw_pkg, elem_name, ELEM_NAME_LEN); + sw_pkg_get_element_name(&sw_pkg, elem_name, BUFLEN); - create_instance_id(SW_IDENTITY_CLASS_NAME, elem_name, instance_id, - INSTANCE_ID_LEN); + create_instance_id(LMI_SoftwareIdentity_ClassName, elem_name, instance_id, + BUFLEN); LMI_SoftwareIdentityRef si; LMI_SoftwareIdentityRef_Init(&si, _cb, ns); @@ -88,11 +88,11 @@ static CMPIStatus enum_instances(const CMPIResult *cr, const char *ns, **pk_det_id_split = NULL; const gchar *pkg_id_c = NULL; unsigned i, j; - char error_msg[ERROR_MSG_LEN] = ""; + char error_msg[BUFLEN] = ""; /* Get all available repos, create LMI_SoftwareIdentityResourceRef for * all of them and store it in hash table. */ - get_pk_repos(&array, error_msg, ERROR_MSG_LEN); + get_pk_repos(&array, error_msg, BUFLEN); if (!array) { goto done; } @@ -104,11 +104,11 @@ static CMPIStatus enum_instances(const CMPIResult *cr, const char *ns, sir = g_new0(LMI_SoftwareIdentityResourceRef, 1); LMI_SoftwareIdentityResourceRef_Init(sir, _cb, ns); - LMI_SoftwareIdentityResourceRef_Set_SystemName(sir, get_system_name()); + LMI_SoftwareIdentityResourceRef_Set_SystemName(sir, lmi_get_system_name()); LMI_SoftwareIdentityResourceRef_Set_CreationClassName(sir, - ORGID "_" SW_IDENTITY_RESOURCE_CLASS_NAME); + LMI_SoftwareIdentityResource_ClassName); LMI_SoftwareIdentityResourceRef_Set_SystemCreationClassName(sir, - get_system_creation_class_name()); + lmi_get_system_creation_class_name()); LMI_SoftwareIdentityResourceRef_Set_Name(sir, repo_id); g_hash_table_insert(repo_hash, repo_id, sir); @@ -119,7 +119,7 @@ static CMPIStatus enum_instances(const CMPIResult *cr, const char *ns, /* Get all packages and check their repo. If found in hash table, return * the LMI_ResourceForSoftwareIdentity instance. If not, save the package * in array for next processing. */ - get_pk_packages(0, &pkg_array, error_msg, ERROR_MSG_LEN); + get_pk_packages(0, &pkg_array, error_msg, BUFLEN); if (!pkg_array) { goto done; } @@ -244,7 +244,7 @@ static CMPIStatus LMI_ResourceForSoftwareIdentityGetInstance( PkPackage *pk_pkg = NULL; SwPackage sw_pkg; CMPIrc rc_stat = CMPI_RC_ERR_NOT_FOUND; - char error_msg[ERROR_MSG_LEN] = ""; + char error_msg[BUFLEN] = ""; init_sw_package(&sw_pkg); @@ -252,20 +252,20 @@ static CMPIStatus LMI_ResourceForSoftwareIdentityGetInstance( LMI_ResourceForSoftwareIdentity_InitFromObjectPath(&w, _cb, cop); /* Check repo */ - if (strcmp(get_str_property_from_op(w.AvailableSAP.value, "CreationClassName"), - ORGID "_" SW_IDENTITY_RESOURCE_CLASS_NAME) != 0) { + if (strcmp(lmi_get_string_property_from_objectpath(w.AvailableSAP.value, + "CreationClassName"), LMI_SoftwareIdentityResource_ClassName) != 0) { goto done; } - if (strcmp(get_str_property_from_op(w.AvailableSAP.value, "SystemCreationClassName"), - get_system_creation_class_name()) != 0) { + if (strcmp(lmi_get_string_property_from_objectpath(w.AvailableSAP.value, + "SystemCreationClassName"), lmi_get_system_creation_class_name()) != 0) { goto done; } - if (strcmp(get_str_property_from_op(w.AvailableSAP.value, "SystemName"), - get_system_name()) != 0) { + if (strcmp(lmi_get_string_property_from_objectpath(w.AvailableSAP.value, + "SystemName"), lmi_get_system_name()) != 0) { goto done; } - repo_id = get_str_property_from_op(w.AvailableSAP.value, "Name"); - get_pk_repo(repo_id, &pk_repo, error_msg, ERROR_MSG_LEN); + repo_id = lmi_get_string_property_from_objectpath(w.AvailableSAP.value, "Name"); + get_pk_repo(repo_id, &pk_repo, error_msg, BUFLEN); if (!pk_repo) { goto done; } @@ -410,8 +410,12 @@ static void enum_sw_instance_names_for_repo(const char *repo_id_p, k_return_sw_identity_op_from_pkg_id(pk_package_get_id(pkg), _cb, ns, cr); } + g_free(repo_id); + repo_id = NULL; break; } + g_free(repo_id); + repo_id = NULL; } if (!found) { g_ptr_array_add(array, g_object_ref(pkg)); @@ -466,52 +470,52 @@ static CMPIStatus associators( const short names) { CMPIStatus st; - char error_msg[ERROR_MSG_LEN] = ""; + char error_msg[BUFLEN] = ""; - if (!cm_class_is_a(_cb, KNameSpace(cop), assocClass, - ORGID "_" RESOURCE_FOR_SW_IDENTITY_CLASS_NAME)) { - goto done; - } + st = lmi_class_path_is_a(_cb, KNameSpace(cop), + LMI_ResourceForSoftwareIdentity_ClassName, assocClass); + lmi_return_if_class_check_not_ok(st); - if (CMClassPathIsA(_cb, cop, ORGID "_" SW_IDENTITY_RESOURCE_CLASS_NAME, &st)) { + if (CMClassPathIsA(_cb, cop, LMI_SoftwareIdentityResource_ClassName, &st)) { /* got SoftwareIdentityResource - AvailableSAP; * where listing only associators names is supported */ if (!names) { CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); } - if (cm_class_is_a(_cb, KNameSpace(cop), resultClass, - ORGID "_" SW_IDENTITY_CLASS_NAME) != 0) { - goto done; - } - if (role && strcmp(role, AVAIL_SAP_ATTR) != 0) { + st = lmi_class_path_is_a(_cb, KNameSpace(cop), + LMI_SoftwareIdentity_ClassName, resultClass); + lmi_return_if_class_check_not_ok(st); + + if (role && strcmp(role, LMI_AVAILABLE_SAP) != 0) { goto done; } - if (resultRole && strcmp(resultRole, MNGD_ELEM_ATTR) != 0) { + if (resultRole && strcmp(resultRole, LMI_MANAGED_ELEMENT) != 0) { goto done; } - enum_sw_instance_names_for_repo(get_str_property_from_op(cop, "Name"), - cr, KNameSpace(cop), error_msg, ERROR_MSG_LEN); - } else if (CMClassPathIsA(_cb, cop, ORGID "_" SW_IDENTITY_CLASS_NAME, &st)) { + enum_sw_instance_names_for_repo( + lmi_get_string_property_from_objectpath(cop, "Name"), cr, + KNameSpace(cop), error_msg, BUFLEN); + } else if (CMClassPathIsA(_cb, cop, LMI_SoftwareIdentity_ClassName, &st)) { /* got SoftwareIdentity - ManagedElement */ SwPackage sw_pkg; gchar *repo_id = NULL; - if (cm_class_is_a(_cb, KNameSpace(cop), resultClass, - ORGID "_" SW_IDENTITY_RESOURCE_CLASS_NAME) != 0) { - goto done; - } - if (role && strcmp(role, MNGD_ELEM_ATTR) != 0) { + st = lmi_class_path_is_a(_cb, KNameSpace(cop), + LMI_SoftwareIdentityResource_ClassName, resultClass); + lmi_return_if_class_check_not_ok(st); + + if (role && strcmp(role, LMI_MANAGED_ELEMENT) != 0) { goto done; } - if (resultRole && strcmp(resultRole, AVAIL_SAP_ATTR) != 0) { + if (resultRole && strcmp(resultRole, LMI_AVAILABLE_SAP) != 0) { goto done; } init_sw_package(&sw_pkg); get_sw_pkg_from_sw_identity_op(cop, &sw_pkg); - get_repo_id_from_sw_pkg(&sw_pkg, &repo_id, error_msg, ERROR_MSG_LEN); + get_repo_id_from_sw_pkg(&sw_pkg, &repo_id, error_msg, BUFLEN); free_sw_package(&sw_pkg); if (*error_msg) { @@ -525,11 +529,11 @@ static CMPIStatus associators( LMI_SoftwareIdentityResourceRef sir; LMI_SoftwareIdentityResourceRef_Init(&sir, _cb, KNameSpace(cop)); - LMI_SoftwareIdentityResourceRef_Set_SystemName(&sir, get_system_name()); + LMI_SoftwareIdentityResourceRef_Set_SystemName(&sir, lmi_get_system_name()); LMI_SoftwareIdentityResourceRef_Set_CreationClassName(&sir, - ORGID "_" SW_IDENTITY_RESOURCE_CLASS_NAME); + LMI_SoftwareIdentityResource_ClassName); LMI_SoftwareIdentityResourceRef_Set_SystemCreationClassName(&sir, - get_system_creation_class_name()); + lmi_get_system_creation_class_name()); LMI_SoftwareIdentityResourceRef_Set_Name(&sir, repo_id); g_free(repo_id); @@ -589,33 +593,32 @@ static CMPIStatus references( const short names) { CMPIStatus st; - char error_msg[ERROR_MSG_LEN] = ""; + char error_msg[BUFLEN] = ""; - if (!cm_class_is_a(_cb, KNameSpace(cop), assocClass, - ORGID "_" RESOURCE_FOR_SW_IDENTITY_CLASS_NAME)) { - goto done; - } + st = lmi_class_path_is_a(_cb, KNameSpace(cop), + LMI_ResourceForSoftwareIdentity_ClassName, assocClass); + lmi_return_if_class_check_not_ok(st); - if (CMClassPathIsA(_cb, cop, ORGID "_" SW_IDENTITY_RESOURCE_CLASS_NAME, &st)) { + if (CMClassPathIsA(_cb, cop, LMI_SoftwareIdentityResource_ClassName, &st)) { /* got SoftwareIdentityResource - AvailableSAP */ - if (role && strcmp(role, AVAIL_SAP_ATTR) != 0) { + if (role && strcmp(role, LMI_AVAILABLE_SAP) != 0) { goto done; } return enum_instances(cr, KNameSpace(cop), names, - get_str_property_from_op(cop, "Name")); - } else if (CMClassPathIsA(_cb, cop, ORGID "_" SW_IDENTITY_CLASS_NAME, &st)) { + lmi_get_string_property_from_objectpath(cop, "Name")); + } else if (CMClassPathIsA(_cb, cop, LMI_SoftwareIdentity_ClassName, &st)) { /* got SoftwareIdentity - ManagedElement */ SwPackage sw_pkg; gchar *repo_id = NULL; - if (role && strcmp(role, MNGD_ELEM_ATTR) != 0) { + if (role && strcmp(role, LMI_MANAGED_ELEMENT) != 0) { goto done; } init_sw_package(&sw_pkg); get_sw_pkg_from_sw_identity_op(cop, &sw_pkg); - get_repo_id_from_sw_pkg(&sw_pkg, &repo_id, error_msg, ERROR_MSG_LEN); + get_repo_id_from_sw_pkg(&sw_pkg, &repo_id, error_msg, BUFLEN); free_sw_package(&sw_pkg); if (*error_msg) { @@ -629,11 +632,11 @@ static CMPIStatus references( LMI_SoftwareIdentityResourceRef sir; LMI_SoftwareIdentityResourceRef_Init(&sir, _cb, KNameSpace(cop)); - LMI_SoftwareIdentityResourceRef_Set_SystemName(&sir, get_system_name()); + LMI_SoftwareIdentityResourceRef_Set_SystemName(&sir, lmi_get_system_name()); LMI_SoftwareIdentityResourceRef_Set_CreationClassName(&sir, - ORGID "_" SW_IDENTITY_RESOURCE_CLASS_NAME); + LMI_SoftwareIdentityResource_ClassName); LMI_SoftwareIdentityResourceRef_Set_SystemCreationClassName(&sir, - get_system_creation_class_name()); + lmi_get_system_creation_class_name()); LMI_SoftwareIdentityResourceRef_Set_Name(&sir, repo_id); g_free(repo_id); diff --git a/src/software-dbus/LMI_SoftwareIdentityProvider.c b/src/software-dbus/LMI_SoftwareIdentityProvider.c index 2936555..ffe15be 100644 --- a/src/software-dbus/LMI_SoftwareIdentityProvider.c +++ b/src/software-dbus/LMI_SoftwareIdentityProvider.c @@ -43,10 +43,10 @@ static CMPIStatus LMI_SoftwareIdentityEnumInstanceNames( const CMPIResult* cr, const CMPIObjectPath* cop) { - char error_msg[ERROR_MSG_LEN] = ""; + char error_msg[BUFLEN] = ""; enum_sw_identity_instance_names(0, _cb, KNameSpace(cop), cr, error_msg, - ERROR_MSG_LEN); + BUFLEN); if (*error_msg) { KReturn2(_cb, ERR_FAILED, "%s", error_msg); diff --git a/src/software-dbus/LMI_SoftwareIdentityResourceProvider.c b/src/software-dbus/LMI_SoftwareIdentityResourceProvider.c index 4c77bf5..18d3946 100644 --- a/src/software-dbus/LMI_SoftwareIdentityResourceProvider.c +++ b/src/software-dbus/LMI_SoftwareIdentityResourceProvider.c @@ -22,8 +22,6 @@ #include "LMI_SoftwareIdentityResource.h" #include "sw-utils.h" -#define DSC_LEN 256 - static const CMPIBroker* _cb = NULL; static void LMI_SoftwareIdentityResourceInitialize(const CMPIContext *ctx) @@ -60,10 +58,10 @@ static CMPIStatus LMI_SoftwareIdentityResourceEnumInstances( gboolean repo_enabled; gchar *repo_id = NULL, *repo_desc = NULL; unsigned i; - char error_msg[ERROR_MSG_LEN] = "", dsc[DSC_LEN] = "", - instance_id[INSTANCE_ID_LEN] = ""; + char error_msg[BUFLEN] = "", dsc[BUFLEN] = "", + instance_id[BUFLEN] = ""; - get_pk_repos(&array, error_msg, ERROR_MSG_LEN); + get_pk_repos(&array, error_msg, BUFLEN); if (!array) { goto done; } @@ -71,15 +69,15 @@ static CMPIStatus LMI_SoftwareIdentityResourceEnumInstances( for (i = 0; i < array->len; i++) { g_object_get(g_ptr_array_index(array, i), "repo-id", &repo_id, "description", &repo_desc, "enabled", &repo_enabled, NULL); - snprintf(dsc, DSC_LEN, "[%s] - %s", repo_id, repo_desc); - create_instance_id(SW_IDENTITY_RESOURCE_CLASS_NAME, repo_id, - instance_id, INSTANCE_ID_LEN); + snprintf(dsc, BUFLEN, "[%s] - %s", repo_id, repo_desc); + create_instance_id(LMI_SoftwareIdentityResource_ClassName, repo_id, + instance_id, BUFLEN); LMI_SoftwareIdentityResource w; LMI_SoftwareIdentityResource_Init(&w, _cb, KNameSpace(cop)); LMI_SoftwareIdentityResource_Set_SystemName(&w, lmi_get_system_name()); LMI_SoftwareIdentityResource_Set_CreationClassName(&w, - ORGID "_" SW_IDENTITY_RESOURCE_CLASS_NAME); + LMI_SoftwareIdentityResource_ClassName); LMI_SoftwareIdentityResource_Set_SystemCreationClassName(&w, lmi_get_system_creation_class_name()); LMI_SoftwareIdentityResource_Set_Name(&w, repo_id); @@ -124,18 +122,17 @@ static CMPIStatus LMI_SoftwareIdentityResourceEnumInstances( } KReturnInstance(cr, w); + + g_free(repo_id); + repo_id = NULL; + g_free(repo_desc); + repo_desc = NULL; } done: if (array) { g_ptr_array_unref(array); } - if (repo_id) { - g_free(repo_id); - } - if (repo_desc) { - g_free(repo_desc); - } if (*error_msg) { KReturn2(_cb, ERR_FAILED, "%s", error_msg); @@ -244,7 +241,7 @@ KUint32 LMI_SoftwareIdentityResource_RequestStateChange( PkResults *results = NULL; GError *gerror = NULL; gboolean enable; - char error_msg[ERROR_MSG_LEN] = ""; + char error_msg[BUFLEN] = ""; unsigned ret = 1; if (RequestedState->null || !RequestedState->exists) { @@ -276,7 +273,7 @@ KUint32 LMI_SoftwareIdentityResource_RequestStateChange( results = pk_task_repo_enable_sync(task, self->Name.chars, enable, NULL, NULL, NULL, &gerror); if (check_and_create_error_msg(results, gerror, - "Failed to set repository state", error_msg, ERROR_MSG_LEN)) { + "Failed to set repository state", error_msg, BUFLEN)) { goto done; } diff --git a/src/software-dbus/LMI_SystemSoftwareCollectionProvider.c b/src/software-dbus/LMI_SystemSoftwareCollectionProvider.c index b4bc12f..7a840b9 100644 --- a/src/software-dbus/LMI_SystemSoftwareCollectionProvider.c +++ b/src/software-dbus/LMI_SystemSoftwareCollectionProvider.c @@ -54,10 +54,10 @@ static CMPIStatus LMI_SystemSoftwareCollectionEnumInstances( const CMPIObjectPath* cop, const char** properties) { - char instance_id[INSTANCE_ID_LEN] = ""; + char instance_id[BUFLEN] = ""; - create_instance_id(SYSTEM_SW_COLLECTION_CLASS_NAME, NULL, instance_id, - INSTANCE_ID_LEN); + create_instance_id(LMI_SystemSoftwareCollection_ClassName, NULL, instance_id, + BUFLEN); LMI_SystemSoftwareCollection w; LMI_SystemSoftwareCollection_Init(&w, _cb, KNameSpace(cop)); diff --git a/src/software-dbus/sw-utils.c b/src/software-dbus/sw-utils.c index e523fd2..6b1424d 100644 --- a/src/software-dbus/sw-utils.c +++ b/src/software-dbus/sw-utils.c @@ -59,27 +59,27 @@ short create_sw_package_from_pk_pkg_id(const char *pk_pkg_id, SwPackage *sw_pkg) init_sw_package(sw_pkg); if (!pk_pkg_id || !*pk_pkg_id) { - warn("Empty package ID!"); + lmi_warn("Empty package ID!"); goto done; } id = pk_pkg_id; split_id = pk_package_id_split(id); if (!split_id) { - warn("Invalid package ID: %s!", id); + lmi_warn("Invalid package ID: %s!", id); goto done; } if (!(name = split_id[PK_PACKAGE_ID_NAME])) { - warn("Package with ID: %s doesn't have name!", id); + lmi_warn("Package with ID: %s doesn't have name!", id); goto done; } if (!(ver = split_id[PK_PACKAGE_ID_VERSION])) { - warn("Package with ID: %s doesn't have version!", id); + lmi_warn("Package with ID: %s doesn't have version!", id); goto done; } if (!(arch = split_id[PK_PACKAGE_ID_ARCH])) { - warn("Package with ID: %s doesn't have architecture!", id); + lmi_warn("Package with ID: %s doesn't have architecture!", id); goto done; } @@ -99,13 +99,13 @@ short create_sw_package_from_pk_pkg_id(const char *pk_pkg_id, SwPackage *sw_pkg) } else { sw_pkg->version = strdup(ver); sw_pkg->release = strdup("0"); - warn("Package with ID: %s doesn't have release number! Using '0' instead.", + lmi_warn("Package with ID: %s doesn't have release number! Using '0' instead.", id); } if (!sw_pkg->name || !sw_pkg->arch || !sw_pkg->epoch || !sw_pkg->version || !sw_pkg->release || !sw_pkg->pk_version) { - warn("Memory allocation failed."); + lmi_warn("Memory allocation failed."); goto done; } @@ -132,24 +132,24 @@ short create_sw_package_from_elem_name(const char *elem_name, SwPackage *sw_pkg) init_sw_package(sw_pkg); if (!elem_name || !*elem_name) { - warn("Empty element name."); + lmi_warn("Empty element name."); goto done; } if (!(en = strdup(elem_name))) { - warn("Memory allocation failed."); + lmi_warn("Memory allocation failed."); goto done; } if (!(delim = strrchr(en, '.'))) { - warn("Invalid element name of the package: %s", elem_name); + lmi_warn("Invalid element name of the package: %s", elem_name); goto done; } sw_pkg->arch = strdup(delim + 1); delim[0] = '\0'; if (!(delim = strrchr(en, '-'))) { - warn("Invalid element name of the package: %s", elem_name); + lmi_warn("Invalid element name of the package: %s", elem_name); goto done; } sw_pkg->release = strdup(delim + 1); @@ -160,14 +160,14 @@ short create_sw_package_from_elem_name(const char *elem_name, SwPackage *sw_pkg) delim[0] = '\0'; if (!(delim = strrchr(en, '-'))) { - warn("Invalid element name of the package: %s", elem_name); + lmi_warn("Invalid element name of the package: %s", elem_name); goto done; } sw_pkg->epoch = strdup(delim + 1); delim[0] = '\0'; } else { if (!(delim = strrchr(en, '-'))) { - warn("Invalid element name of the package: %s", elem_name); + lmi_warn("Invalid element name of the package: %s", elem_name); goto done; } sw_pkg->version = strdup(delim + 1); @@ -180,20 +180,20 @@ short create_sw_package_from_elem_name(const char *elem_name, SwPackage *sw_pkg) if (!sw_pkg->name || !sw_pkg->arch || !sw_pkg->epoch || !sw_pkg->version || !sw_pkg->release) { - warn("Memory allocation failed."); + lmi_warn("Memory allocation failed."); goto done; } if (strcmp(sw_pkg->epoch, "0") == 0) { if (asprintf(&sw_pkg->pk_version, "%s-%s", sw_pkg->version, sw_pkg->release) < 0) { - warn("Memory allocation failed."); + lmi_warn("Memory allocation failed."); goto done; } } else { if (asprintf(&sw_pkg->pk_version, "%s:%s-%s", sw_pkg->epoch, sw_pkg->version, sw_pkg->release) < 0) { - warn("Memory allocation failed."); + lmi_warn("Memory allocation failed."); goto done; } } @@ -238,7 +238,7 @@ void get_pk_pkg_from_sw_pkg(const SwPackage *sw_pkg, PkBitfield filters, GError *gerror = NULL; gchar **values = NULL; unsigned i; - char error_msg[ERROR_MSG_LEN] = ""; + char error_msg[BUFLEN] = ""; task = pk_task_new(); @@ -247,8 +247,8 @@ void get_pk_pkg_from_sw_pkg(const SwPackage *sw_pkg, PkBitfield filters, results = pk_task_search_names_sync(task, filters, values, NULL, NULL, NULL, &gerror); if (check_and_create_error_msg(results, gerror, "Resolving package failed", - error_msg, ERROR_MSG_LEN)) { - warn(error_msg); + error_msg, BUFLEN)) { + lmi_warn(error_msg); goto done; } @@ -319,19 +319,19 @@ void create_instance_from_pkgkit_data(PkPackage *pk_pkg, PkDetails *pk_det, LMI_SoftwareIdentity *w) { const gchar *summary, *desc = NULL; - char elem_name[ELEM_NAME_LEN] = "", ver_str[VER_STR_LEN] = "", - instance_id[INSTANCE_ID_LEN] = ""; + char elem_name[BUFLEN] = "", ver_str[BUFLEN] = "", + instance_id[BUFLEN] = ""; summary = pk_package_get_summary(pk_pkg); if (pk_det) { desc = pk_details_get_description(pk_det); } - sw_pkg_get_element_name(sw_pkg, elem_name, ELEM_NAME_LEN); - sw_pkg_get_version_str(sw_pkg, ver_str, VER_STR_LEN); + sw_pkg_get_element_name(sw_pkg, elem_name, BUFLEN); + sw_pkg_get_version_str(sw_pkg, ver_str, BUFLEN); - create_instance_id(SW_IDENTITY_CLASS_NAME, elem_name, instance_id, - INSTANCE_ID_LEN); + create_instance_id(LMI_SoftwareIdentity_ClassName, elem_name, instance_id, + BUFLEN); LMI_SoftwareIdentity_Init(w, cb, ns); LMI_SoftwareIdentity_Set_InstanceID(w, instance_id); @@ -401,7 +401,7 @@ done: return; } -void get_pk_det_from_array(const char **values_p, GPtrArray **garray, +void get_pk_det_from_array(char **values_p, GPtrArray **garray, PkTask *task_p) { PkTask *task = NULL; @@ -410,10 +410,10 @@ void get_pk_det_from_array(const char **values_p, GPtrArray **garray, GError *gerror = NULL; gchar **values = NULL; unsigned i, j, values_p_count = 0; - char error_msg[ERROR_MSG_LEN] = ""; + char error_msg[BUFLEN] = ""; if (!values_p || !*values_p) { - warn("No package IDs given."); + lmi_warn("No package IDs given."); goto done; } @@ -444,8 +444,8 @@ void get_pk_det_from_array(const char **values_p, GPtrArray **garray, results = pk_task_get_details_sync(task, values, NULL, NULL, NULL, &gerror); if (check_and_create_error_msg(results, gerror, - "Getting package details failed", error_msg, ERROR_MSG_LEN)) { - warn(error_msg); + "Getting package details failed", error_msg, BUFLEN)) { + lmi_warn(error_msg); goto done; } @@ -491,7 +491,7 @@ void k_return_sw_identity_op_from_pkg_id(const char *pkg_id, const CMPIBroker *cb, const char *ns, const CMPIResult* cr) { SwPackage sw_pkg; - char elem_name[ELEM_NAME_LEN] = "", instance_id[INSTANCE_ID_LEN] = ""; + char elem_name[BUFLEN] = "", instance_id[BUFLEN] = ""; init_sw_package(&sw_pkg); @@ -499,10 +499,10 @@ void k_return_sw_identity_op_from_pkg_id(const char *pkg_id, goto done; } - sw_pkg_get_element_name(&sw_pkg, elem_name, ELEM_NAME_LEN); + sw_pkg_get_element_name(&sw_pkg, elem_name, BUFLEN); - create_instance_id(SW_IDENTITY_CLASS_NAME, elem_name, instance_id, - INSTANCE_ID_LEN); + create_instance_id(LMI_SoftwareIdentity_ClassName, elem_name, instance_id, + BUFLEN); LMI_SoftwareIdentityRef w; LMI_SoftwareIdentityRef_Init(&w, cb, ns); @@ -623,7 +623,7 @@ void get_pk_repo(const char *repo_id_p, PkRepoDetail **repo_p, char *error_msg, get_pk_repos(&array, error_msg, error_msg_len); if (!array) { - warn(error_msg); + lmi_warn(error_msg); goto done; } @@ -710,7 +710,7 @@ void get_repo_id_from_sw_pkg(const SwPackage *sw_pkg, gchar **repo_id_p, repo_id_pkg = pk_package_get_data(pk_pkg); if (!repo_id_pkg) { - warn("Invalid PackageKit package."); + lmi_warn("Invalid PackageKit package."); goto done; } @@ -748,7 +748,7 @@ void get_repo_id_from_sw_pkg(const SwPackage *sw_pkg, gchar **repo_id_p, continue; } if (!(*repo_id_p = g_strdup(pkg_id_parts[PK_PACKAGE_ID_DATA]))) { - warn("Memory allocation failed."); + lmi_warn("Memory allocation failed."); } goto done; } @@ -854,7 +854,7 @@ void gc_gobject_ptr_array_append(GPtrArray **a, const GPtrArray *b) guint i; if (!a || !b) { - warn("Received empty parameter."); + lmi_warn("Received empty parameter."); return; } @@ -874,18 +874,18 @@ void gc_gobject_ptr_array_append(GPtrArray **a, const GPtrArray *b) const char *get_elem_name_from_instance_id(const char *instance_id) { if (!instance_id || !*instance_id) { - warn("Empty InstanceID."); + lmi_warn("Empty InstanceID."); return ""; } if (strlen(instance_id) <= SW_IDENTITY_INSTANCE_ID_PREFIX_LEN) { - warn("Invalid InstanceID: %s", instance_id); + lmi_warn("Invalid InstanceID: %s", instance_id); return ""; } if (strncasecmp(instance_id, SW_IDENTITY_INSTANCE_ID_PREFIX, SW_IDENTITY_INSTANCE_ID_PREFIX_LEN) != 0) { - warn("Invalid InstanceID: %s", instance_id); + lmi_warn("Invalid InstanceID: %s", instance_id); return ""; } @@ -896,45 +896,8 @@ void create_instance_id(const char *class_name, const char *id, char *instance_id, const unsigned instance_id_len) { if (id) { - snprintf(instance_id, instance_id_len, ORGID ":" ORGID "_%s:%s", - class_name, id); + snprintf(instance_id, instance_id_len, LMI_ORGID ":%s:%s", class_name, id); } else { - snprintf(instance_id, instance_id_len, ORGID ":" ORGID "_%s", - class_name); + snprintf(instance_id, instance_id_len, LMI_ORGID ":%s", class_name); } } - -const char *get_str_property_from_op(const CMPIObjectPath *o, const char *prop) -{ - CMPIData d; - d = CMGetKey(o, prop, NULL); - return KChars(d.value.string); -} - -short cm_class_is_a(const CMPIBroker *cb, const char *ns, const char *cm_class, - const char *type) -{ - CMPIStatus st; - CMPIObjectPath *o = NULL; - short ret = 0; - - o = CMNewObjectPath(cb, ns, cm_class, &st); - if (!o) { - goto done; - } else if (st.rc != CMPI_RC_OK) { - goto done; - } - - if (type && !CMClassPathIsA(cb, o, type, &st)) { - goto done; - } - - ret = 1; - -done: - if (o) { - CMRelease(o); - } - - return ret; -} diff --git a/src/software-dbus/sw-utils.h b/src/software-dbus/sw-utils.h index a8a6565..d3475a8 100644 --- a/src/software-dbus/sw-utils.h +++ b/src/software-dbus/sw-utils.h @@ -26,41 +26,21 @@ #include #include #include -#include #include -#include "globals.h" +#include "openlmi.h" #include "LMI_SoftwareIdentity.h" -#define VER_STR_LEN 256 -#define ELEM_NAME_LEN 256 -#define INSTANCE_ID_LEN 282 -#define ERROR_MSG_LEN 512 - #define PK_DETAILS_LIMIT 4999 #define EST_OF_INSTD_PKGS 1000 -#define SW_IDENTITY_CLASS_NAME "SoftwareIdentity" -#define SYSTEM_SW_COLLECTION_CLASS_NAME "SystemSoftwareCollection" -#define SW_IDENTITY_RESOURCE_CLASS_NAME "SoftwareIdentityResource" -#define MEM_SW_COLL_CLASS_NAME "MemberOfSoftwareCollection" -#define INST_SW_IDENTITY_CLASS_NAME "InstalledSoftwareIdentity" -#define RESOURCE_FOR_SW_IDENTITY_CLASS_NAME "ResourceForSoftwareIdentity" - -#define COLLECTION_ATTR "Collection" -#define MEMBER_ATTR "Member" -#define SYSTEM_ATTR "System" -#define INST_SW_ATTR "InstalledSoftware" -#define AVAIL_SAP_ATTR "AvailableSAP" -#define MNGD_ELEM_ATTR "ManagedElement" - -#define SW_IDENTITY_INSTANCE_ID_PREFIX ORGID ":" ORGID "_" SW_IDENTITY_CLASS_NAME ":" +#define SW_IDENTITY_INSTANCE_ID_PREFIX LMI_ORGID ":" LMI_SoftwareIdentity_ClassName ":" #define SW_IDENTITY_INSTANCE_ID_PREFIX_LEN 25 #define get_sw_pkg_from_sw_identity_op(cop, sw_pkg) \ create_sw_package_from_elem_name(get_elem_name_from_instance_id(\ - get_str_property_from_op(cop, "InstanceID")), sw_pkg) + lmi_get_string_property_from_objectpath(cop, "InstanceID")), sw_pkg) const char *provider_name; const ConfigEntry *provider_config_defaults; @@ -190,7 +170,7 @@ void get_pk_packages(PkBitfield filters, GPtrArray **garray, char *error_msg, * @param task_p if supplied, this task will be used when querying PackageKit; * performance optimization, can be NULL */ -void get_pk_det_from_array(const char **values_p, GPtrArray **garray, +void get_pk_det_from_array(char **values_p, GPtrArray **garray, PkTask *task_p); /* @@ -339,23 +319,4 @@ const char *get_elem_name_from_instance_id(const char *instance_id); void create_instance_id(const char *class_name, const char *id, char *instance_id, const unsigned instance_id_len); -/* - * Get string property from Object Path. - * @param o Object Path - * @param prop property - * @return string value of property - */ -const char *get_str_property_from_op(const CMPIObjectPath *o, const char *prop); - -/* - * Check whether cm_class is type of type. Takes inheritance into account. - * @param cb CMPI Broker - * @param ns namespace - * @param cm_class - * @param type; can be NULL, in which case the comparison will succeed - * @return 1 if cm_class is type of type, 0 otherwise - */ -short cm_class_is_a(const CMPIBroker *cb, const char *ns, const char *cm_class, - const char *type); - #endif /* SW_UTILS_H_ */ -- cgit