
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1201194986 28800 # Node ID b0b9833dfa219a3e9a7898c0b6f5bab7afaf460a # Parent adf18661f7948a0287a4586d97572793e8e03826 Add ref class/prefix compare to misc_util Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r adf18661f794 -r b0b9833dfa21 libxkutil/misc_util.c --- a/libxkutil/misc_util.c Thu Jan 24 12:56:45 2008 +0100 +++ b/libxkutil/misc_util.c Thu Jan 24 09:16:26 2008 -0800 @@ -435,6 +435,60 @@ bool libvirt_cim_init(void) return virInitialize == 0; } +bool check_refs_pfx_match(const CMPIObjectPath *refa, + const CMPIObjectPath *refb) +{ + bool result = false; + const char *refa_cn; + const char *refb_cn; + const char *ccn; + char *refa_pfx = NULL; + char *refb_pfx = NULL; + + refa_cn = CLASSNAME(refa); + refb_cn = CLASSNAME(refb); + + if ((refa_cn == NULL) || (refb_cn == NULL)) { + CU_DEBUG("Error getting ref classes %s:%s", + refa_cn, refb_cn); + goto out; + } + + refa_pfx = class_prefix_name(refa_cn); + refb_pfx = class_prefix_name(refb_cn); + + if ((refa_pfx == NULL) || (refb_pfx == NULL)) { + CU_DEBUG("Error getting ref prefixes %s:%s %s:%s", + refa_pfx, refb_pfx, + refa_cn, refb_cn); + goto out; + } + + if (!STREQC(refa_pfx, refb_pfx)) { + CU_DEBUG("Ref mismatch: %s != %s", + refa_pfx, + refb_pfx); + goto out; + } + + if (cu_get_str_path(refb, "CreationClassName", &ccn) == CMPI_RC_OK) { + if (!STREQC(ccn, refb_cn)) { + CU_DEBUG("ClassName(%s) != CreationClassName(%s)", + refb_cn, + ccn); + goto out; + } + } + + result = true; + + out: + free(refa_pfx); + free(refb_pfx); + + return result; +} + /* * Local Variables: * mode: C diff -r adf18661f794 -r b0b9833dfa21 libxkutil/misc_util.h --- a/libxkutil/misc_util.h Thu Jan 24 12:56:45 2008 +0100 +++ b/libxkutil/misc_util.h Thu Jan 24 09:16:26 2008 -0800 @@ -115,6 +115,8 @@ CMPIInstance *make_reference(const CMPIB struct std_assoc_info *info, struct std_assoc *assoc); +bool check_refs_pfx_match(const CMPIObjectPath *refa, + const CMPIObjectPath *refb); #define LIBVIRT_CIM_DEFAULT_MAKEREF() \ static CMPIInstance* make_ref(const CMPIObjectPath *source_ref, \