[Libvirt-cim] [PATCH 3 of 3] [CU] classname_from_inst

Jay Gagnon grendel at linux.vnet.ibm.com
Mon Feb 25 20:54:31 UTC 2008


# HG changeset patch
# User Jay Gagnon <grendel at linux.vnet.ibm.com>
# Date 1203959116 18000
# Node ID d424467c183864fcf2c308ebe02e81f2f208e9b5
# Parent  ad33899f5782b926070a0290ec8622fe164b5a27
[CU] 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.

Signed-off-by: Jay Gagnon <grendel at linux.vnet.ibm.com>

diff -r ad33899f5782 -r d424467c1838 instance_util.c
--- a/instance_util.c	Mon Feb 25 12:05:15 2008 -0500
+++ b/instance_util.c	Mon Feb 25 12:05:16 2008 -0500
@@ -251,6 +251,21 @@ CMPIInstance *cu_dup_instance(const CMPI
 
  out:
         return dest;
+}
+
+const char *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 ad33899f5782 -r d424467c1838 libcmpiutil.h
--- a/libcmpiutil.h	Mon Feb 25 12:05:15 2008 -0500
+++ b/libcmpiutil.h	Mon Feb 25 12:05:16 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 *classname_from_inst(CMPIInstance *inst);
 
 #define DEFAULT_EIN(pn)                                                 \
         static CMPIStatus pn##EnumInstanceNames(CMPIInstanceMI *self,   \




More information about the Libvirt-cim mailing list