
# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # Date 1204056957 18000 # Node ID 0840762ff38237d40ca56973d3455a1b54f154b7 # Parent af61b6c75b143067444f4eefe694d1e9709d2ccb [CU] (#2) classname_from_inst Function that pulls a classname out of an instance. Nothing fancy, just saves a few lines whenever this is needed. This is used by the new std_indication stuff. Changes from 1 to 2: cu_ prefix on function name Signed-off-by: Jay Gagnon <grendel@linux.vnet.ibm.com> diff -r af61b6c75b14 -r 0840762ff382 instance_util.c --- a/instance_util.c Wed Feb 13 08:26:56 2008 -0800 +++ b/instance_util.c Tue Feb 26 15:15:57 2008 -0500 @@ -251,6 +251,21 @@ CMPIInstance *cu_dup_instance(const CMPI out: return dest; +} + +const char *cu_classname_from_inst(CMPIInstance *inst) +{ + char *ret = NULL; + + CMPIObjectPath *ref; + ref = CMGetObjectPath(inst, NULL); + if (CMIsNullObject(ref)) + goto out; + + ret = CLASSNAME(ref); + + out: + return ret; } /* diff -r af61b6c75b14 -r 0840762ff382 libcmpiutil.h --- a/libcmpiutil.h Wed Feb 13 08:26:56 2008 -0800 +++ b/libcmpiutil.h Tue Feb 26 15:15:57 2008 -0500 @@ -414,6 +414,15 @@ CMPIStatus cu_validate_ref(const CMPIBro CMPIStatus cu_validate_ref(const CMPIBroker *broker, const CMPIObjectPath *ref, const CMPIInstance *inst); + +/** + * Returns the classname from an instance without forcing user to get + * ObjectPath first. + * + * @param inst Instance to examine + * @returns Classname of instance , NULL on failure + */ +const char *cu_classname_from_inst(CMPIInstance *inst); #define DEFAULT_EIN(pn) \ static CMPIStatus pn##EnumInstanceNames(CMPIInstanceMI *self, \